Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/316.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用python gitlab插件在python中搜索标记?_Python_Gitlab - Fatal编程技术网

如何使用python gitlab插件在python中搜索标记?

如何使用python gitlab插件在python中搜索标记?,python,gitlab,Python,Gitlab,现在我使用PythonGitlab:1.0.0在python中执行一些gitlab操作,但我很快发现我无法使用PythonGitlab插件搜索标记 Api文档在此: 有没有办法在python中搜索gitlab标记?或者我可以使用另一个插件?到@larsks point,GitLab api不支持标记搜索。您可以搜索其他对象,例如项目,但当前不支持标记。您可以创建一个迭代来循环返回的标记,例如: import gitlab # private token authentication gl =

现在我使用PythonGitlab:1.0.0在python中执行一些gitlab操作,但我很快发现我无法使用PythonGitlab插件搜索标记

Api文档在此:


有没有办法在python中搜索gitlab标记?或者我可以使用另一个插件?

到@larsks point,GitLab api不支持标记搜索。您可以搜索其他对象,例如
项目
,但当前不支持标记。您可以创建一个迭代来循环返回的标记,例如:

import gitlab

# private token authentication
gl = gitlab.Gitlab('http://10.0.0.1', 'JVNSESs8EwWRx5yDxM5q')

# make an API request to create the gl.user object. This is mandatory if you
# use the username/password authentication.
gl.auth() 

# Get a single project by team/project name
project = gl.projects.get('myteam/myproject')

# get all tags associated with the single project returned
tags = project.tags.list()

# iterate over tags from tag list retrieved
for tag in tags:
    if tag in ('bug', 'defect', 'feature'):
         # do something here based on these tags...

希望这会有所帮助。

“搜索”标记似乎不受支持。我想你会得到所有可用标签的列表,然后自己进行筛选。事实上,我昨天已经做了,但仍然感谢你的回答:)顺便问一下,你知道如何按页面获取标签吗?我曾尝试使用
tags=project.tags.list(per_page=5,page=1)
来获取分页标签,但我仍然获取所有标签:(我目前没有用于测试的
gitlab
的活动实例,我上面的答案是通过阅读文档拼凑而成的(我以前从未真正实现过此代码).但是医生们有一个页面可以帮你找到正确的方向:这对我来说太难了