Mercurial and Git clients can push and pull from this alias URL to interact with this repository. You can change to which repository an alias points by going to the Aliases link on the project page.
pystache removed support for pystache.View in future versions. Add note about using earlier version of pystache for the time being so that we can generate the API.
import os
import re
import requests
-import pystache
+import pystache # requires pystache 0.4.1 or ealier because pystache.View has been deprecated+#to get pystache 0.4.1:+# > git clone https://github.com/defunkt/pystache.git+# > cd ./pystache+# > git checkout v0.4.1+# > python setup.py install+# TODO: change ApiClass and TrelloApi to not use pystache.Viewfrom urlparse import urljoin
from BeautifulSoup import BeautifulSoup as Soup
INDEX='https://trello.com/docs/api/index.html'METHOD_LOOKUP={'GET':'get','PUT':'update','POST':'new','DELETE':'delete',}defget_soup(url):resp=requests.get(url)resp.raise_for_status()returnSoup(resp.content)defmain():sections=get_sections()printsectionsifnotos.path.exists('trello'):os.mkdir('trello')modules=[]forsectioninsections:write_section(section)withopen(os.path.join('trello','__init__.py'),'w')asfd:trello_api=TrelloApi([module_name(section)forsectioninsections])fd.write(trello_api.render())defget_sections():sections=[]soup=get_soup(INDEX)forliinsoup.findAll('li',{'class':'toctree-l1'}):a=li.find('a',{'class':'reference internal'})sections.append(urljoin(INDEX,a['href']))returnsectionsdefget_actions(section_url):actions=[]soup=get_soup(section_url)forsectioninsoup.find('div',{'class':'section'}).findAll('div',{'class':'section'}):h2=section.find('h2')method,url,_=[s.strip()forsinh2.findAll(text=True)]ul=section.ulargs=[]forliinul.findAll('li',recursive=False):if'arguments'inli.text.lower():args_ul=li.ulifargs_ul:forarg_liinargs_ul.findAll('li',recursive=False):arg=arg_li.tt.textrequired='required'inarg_li.text.lower()args.append((arg,required))actions.append((method,url,args))returnactionsdeffunction_args(url_args,id_arg,req_args,opt_args):ifid_arg:req_args=[id_arg]+req_argsreturn', '.join(url_args+req_args+[arg+'=None'forarginopt_args])defrequest_args(request_type,req_args,opt_args):get_args=[]post_args=[]ifrequest_typein['GET','DELETE']:get_args+=req_argsget_args+=opt_argselse:post_args+=req_argspost_args+=opt_argsparams='dict(%s)'%', '.join(['key=self._apikey','token=self._token']+['%s=%s'%(arg,arg)forarginget_args])data='dict(%s)'%', '.join(['%s=%s'%(arg,arg)forarginpost_args])ifpost_argselseNonereturn'params=%s, data=%s'%(params,data)defmodule_name(section_url):returnsection_url.split('/')[-2]+'s'defwrite_section(section_url):module=module_name(section_url)withopen(os.path.join('trello','%s.py'%module),'w')asfd:fd.write(ApiClass(section_url).render())classApiClass(pystache.View):def__init__(self,section_url):super(ApiClass,self).__init__()self.module=module_name(section_url)self.actions=get_actions(section_url)defclass_name(self):returnself.module.title()defmethods(self):methods=[]foractioninself.actions:url_parts=action[1].split('/')method_parts=[part.rstrip('s')forpartinurl_parts[3:]ifnotpart.startswith('[')]method_name='_'.join([METHOD_LOOKUP[action[0]]]+method_parts)id_arg=([part.strip('[]').replace(' ','_')forpartinurl_partsifpart.startswith('[')]or[None])[0]url_args=[arg[0]forarginaction[2]if('[%s]'%arg[0]inurl_parts)]ifurl_args:method_name='%s_%s'%(method_name,'_'.join(url_args))req_args=[arg[0]forarginaction[2]ifarg[1]andarg[0]notinurl_args]opt_args=[arg[0]forarginaction[2]ifnotarg[1]]def_args=function_args(url_args,id_arg,req_args,opt_args)args=request_args(action[0].upper(),req_args,opt_args)method=action[0].lower()url='"https://trello.com%s" %% (%s)'%(re.sub(r'\[.*?\]','%s',action[1]),', '.join([id_arg]+url_argsifid_argelseurl_args))methods.append(dict(def_args=def_args,args=args,method=method,url=url,name=method_name))returnmethodsclassTrelloApi(pystache.View):def__init__(self,sections):super(TrelloApi,self).__init__()self.sections=[{'module':section,'class':section.title()}forsectioninsections]if__name__=='__main__':main()
Attach a Trello Card
Add a tag
Your session has expired
You are no longer logged in. Please log in and try your request again.
Filter RSS Feed
This RSS feed URL allows you to see the contents of your current filter using any feed reader.
This link includes a special authentication token. If you share the URL with anyone else, they can see this RSS feed's activity. You can disable these tokens when needed.
Your current filter is unsaved; changing it won't affect this RSS feed.