Making flickr client setup func more sane, adding convenience func for futzing in the repl
This commit is contained in:
parent
ab492e70d0
commit
7addaa6552
@ -1,11 +1,20 @@
|
||||
import json
|
||||
from os.path import expanduser
|
||||
|
||||
import flickrapi
|
||||
|
||||
|
||||
def setup_flickr(self, api_key, api_secret):
|
||||
self.flickr = flickrapi.FlickrAPI(api_key, api_secret)
|
||||
def setup_flickr(api_key, api_secret):
|
||||
flickr = flickrapi.FlickrAPI(api_key, api_secret)
|
||||
|
||||
token, frob = self.flickr.get_token_part_one(perms='write')
|
||||
token, frob = flickr.get_token_part_one(perms='write')
|
||||
if not token:
|
||||
raw_input("Press ENTER after you authorized this program")
|
||||
|
||||
self.flickr.get_token_part_two((token, frob))
|
||||
flickr.get_token_part_two((token, frob))
|
||||
return flickr
|
||||
|
||||
|
||||
def get_flickr_from_rc_file(rc_file=expanduser('~/.flickrscripts.json')):
|
||||
rc_conf = json.load(open(rc_file))
|
||||
return setup_flickr(rc_conf['APIKEY'], rc_conf['APISECRET'])
|
||||
|
@ -13,7 +13,7 @@ class TimeWarper(object):
|
||||
_base_query_args = dict(user_id='me', page=1)
|
||||
|
||||
def __init__(self, api_key, api_secret):
|
||||
setup_flickr(self, api_key, api_secret)
|
||||
self.flickr = setup_flickr(api_key, api_secret)
|
||||
self.log = logging.getLogger(self.__class__.__name__)
|
||||
self.log.level = logging.INFO
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user