Created
September 27, 2013 14:17
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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