一个用于与Trello API工作的Python库。
项目描述
认识Trollop
Trollop是一个用于与Trello API工作的Python库。
快速入门
使用您的API密钥和一个用户的oauth令牌实例化Trello连接
In [1]: from trollop import TrelloConnection In [2]: conn = TrelloConnection(<your developer key>, <user's oauth token>)
连接对象将自动附加一个Member对象,代表使用oauth令牌连接的用户
In [3]: conn.me Out[3]: <Member: me> In [4]: conn.me.username Out[4]: u'btubbs'
在之前的示例中,直到命令4(访问conn.me.username)之前没有发出HTTP请求。Trollop对象是惰性的。
连接对象具有通过ID获取对象的方法
In [5]: card = conn.get_card('4f2e454cefab2bbd4ea71b02') In [6]: card.name Out[6]: u'Build a Python Trello Library' In [7]: card.desc Out[7]: u'And call it Trollop.'
您可以使用常规Python内省技术来查看可用的属性。它们的名称将与从Trello返回的JSON中的名称完全相同
In [13]: dir(card) Out[13]: ['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattr__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_conn', '_id', '_path', '_prefix', 'badges', 'board', 'checkItemStates', 'close', 'closed', 'desc', 'labels', 'list', 'members', 'name', 'url']
从trello.com返回的确切解析JSON可用作所有Trello对象上的_data属性
In [7]: card._data Out[7]: {u'badges': {u'attachments': 0, u'checkItems': 0, u'checkItemsChecked': 0, u'comments': 1, u'description': True, u'due': None, u'fogbugz': u'', u'votes': 0}, u'checkItemStates': [], u'closed': True, u'desc': u'And call it Trollop.', u'id': u'4f2e454cefab2bbd4ea71b02', u'idBoard': u'4e8df268f14f2517a7a342fa', u'idList': u'4f17cb04d5c817032301c179', u'idMembers': [], u'idShort': 130, u'labels': [], u'name': u'Build a Python Trello Library', u'url': u'https://trello.com/card/build-a-python-trello-library/4e8df268f14f2517a7a342fa/130'}
Trello对象具有智能字段,可以自动查找相关对象
In [9]: lst = card.list In [10]: lst Out[10]: <List: Icebox> In [11]: lst.name Out[11]: u'Icebox' In [12]: lst._id Out[12]: u'4f17cb04d5c817032301c179' In [13]: len(lst.cards) Out[13]: 20 In [14]: lst.cards[-1].name Out[14]: u'Build a Python Trello Library'
需要帮助
创建/更新对象的覆盖率仍然非常薄。如果您想加入完成整个API的覆盖,请发送带有更改的pull request。
许可证
Trollop在MIT许可证下发布。
项目详情
关闭
trollop-0.0.17.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | d3a347b79d1510565d3ec80c1706ed745c15e0799d353a4ed4a138f59f637869 |
|
MD5 | cfa709c065d588a4702965de6937ce3c |
|
BLAKE2b-256 | 86efd030452d31a2185913786fadb9e30da5c13c916f7c26af0b1302e1fb976f |