Skip to content

Instantly share code, notes, and snippets.

Created September 27, 2013 14:17
Show Gist options
  • Save anonymous/6729275 to your computer and use it in GitHub Desktop.
Save anonymous/6729275 to your computer and use it in GitHub Desktop.
Hey tripit, tell me what dates I have accommodation booked so I know the trip's covered
# Hey tripit, tell me what dates I have accommodation booked so I know the trip's covered
from pytripit import tripit
consumer_key = '---'
consumer_secret = '---'
authorized_token_key = '---'
authorized_token_secret = '---'
oauth_credential = tripit.OAuthConsumerCredential(consumer_key, consumer_secret, authorized_token_key, authorized_token_secret)
t = tripit.TripIt(oauth_credential)
import memcache
mc = memcache.Client(['127.0.0.1:11211'], debug=0)
result = mc.get('trip')
if not result:
t.list_object({'trip_id':'---'})
result = t.response
mc.set('trip', result, 600)
from lxml import etree
root = etree.fromstring(result)
lodging = root.findall('LodgingObject')
print sorted([(l.findall('StartDateTime/date')[0].text, l.findall('EndDateTime/date')[0].text) for l in lodging if l.findall('StartDateTime')])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment