Bugzilla的客户端库
bugzilla的Python项目详细描述
简单的Bugzilla接口
为什么?
因为我发现的其他库有有限的api支持(比如没有附件支持),复杂的实现,而且似乎不太受支持/接受 减贫战略:)
例如,使用1000sloc库可以完成的大部分工作都是在这个使用100sloc的库中完成的。
用法
在用户首选项中,您可以而且应该使用bugzilla帐户从bugzilla获取到实例的api密钥。 一切基本上都是一个docdict(dict()可以像对象一样寻址,即dict['x']也是dict.x)。 dotdict的内容反映了api的确切输出,即api发送的任何json都是 多迪克特。任何需要发送到api的数据也使用相同的名称。 请参阅http://bugzilla.readthedocs.org/en/latest/api/core/v1/或/上的完整文档,并查看示例的输出。
示例
importbugzillab=bugzilla.Bugzilla(url="https://bugzilla-dev.allizom.org/rest/",api_key="your api key")#Just getting a bugbug=b.get_bug(1001)print(bug.id,bug.status)#All attributes - it's just a dot dict.print(bug)#Making a bugbug=bugzilla.DotDict()bug.product='My product'bug.component='My component'bug.summary='A test bug'bug.whiteboard'my_flag'print(b.post_bug(bug))#Adding an attachmentattachment=bugzilla.DotDict()attachment.file_name='clowns.txt'attachment.summary='Test attachement'attachment.data='some ASCII content'print(b.post_attachment(1001,attachment))#Search for stuffterms=[{'product':'MyProduct'},{'product':'MyOtherProduct'},{'status':'NEW'}]print(b.search_bugs(terms))#Or more easilyprint(b.quick_search('test bug'))
待办事项
- 目前,如果没有api密钥,它就无法工作。
- 目前只支持字符串形式的ascii附件。
- 一些更晦涩的api方法没有实现,比如classifieds。