用于与fogbugz api交互的python库
fogbugz的Python项目详细描述
python fogbugz api包装器
这个python api只是fogbugz api的一个包装器,在leonard richardson的beautifulsoup(http://www.crummy.com/software/BeautifulSoup/)和python的魔术getattr()的帮助下。
开始:
要使用fogbugz api,请下载源代码并运行
$ python setup.py install
或者使用pip
$ pip install fogbugz
一个简单的例子:
>>> from fogbugz import FogBugz >>> fb = FogBugz("http://example.fogbugz.com/") # URL is to your FogBugz install >>> fb.logon("logon@example.com", "password") >>> resp = fb.search(q="assignedto:tyler") # All calls take named parameters, per the API >>> resp # Responses are BeautifulSoup objects of the response XML. <response><cases count="2"><case ixbug="1" operations="edit,assign,resolve,email,remind"></case><case ixbug="2" operations="edit,spam,assign,resolve,reply,forward,remind"></case></cases></response> >>> # You shouldn't need to know too much about BeautifulSoup, but the documentation can be found here: >>> # http://www.crummy.com/software/BeautifulSoup/documentation.html >>> for case in resp.cases.childGenerator(): # One way to access the cases ... print case['ixbug'] ... 1 2 >>> for case in resp.findAll('case'): # Another way to access the cases ... print case['operations'] ... edit,assign,resolve,email,remind edit,spam,assign,resolve,reply,forward,remind >>> resp = fb.edit(ixbug=1, sEvent="Edit from the API") # Note the named parameters >>> resp <response><case ixbug="1" operations="edit,assign,resolve,email,remind"></case></response>
请注意,根据ApiV5.0,标记之间的所有数据(如标记)现在都包装在CData中。beautifulsoup对cdata的实现通常允许将其视为字符串,但有一个重要的情况除外:cdata.\uu str_uuu()(也称为str(cdata))返回全文,包括cdata包装器(例如“<;)![CData[foo]]>;“).为了避免意外包含cdata tage,请使用cdata.encode('utf-8')
其他详细信息:
如果脚本需要特定版本的fogbugz api,请确保将其作为参数传递给构造函数。如果我们进行向后不兼容的更改,这将保护您不受意外差异的影响。
>>> from fogbugz import FogBugz >>> fb = FogBugz("http://example.fogbugz.com", api_version=5)
有关API的更多信息: http://help.fogcreek.com/the-fogbugz-api
很多api都没有经过彻底的测试。请向customer-service@fogcreek.com报告错误
fogbugz_bis是支持python 3和 美化组4。您应该只安装/需要fogbugz或 fogbugz_bis,因为它们都实现同一个模块。