rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
album_path + base_album_path + '-%i' % album_concat | album_path = base_album_path + '-%i' % album_concat | def DownloadAlbum(self, base_path, user='default', title=None): """Download an album to the client. Keyword arguments: base_path -- the path on the filesystem to copy albums to. Each album will be stored in base_path/<album title>. If base_path does not exist, it and each non-existent parent directory will be created.... |
photo_path = os.path.join(album_path, photo.title.text) | photo_name = os.path.split(photo.title.text)[1] photo_path = os.path.join(album_path, photo_name) | def DownloadAlbum(self, base_path, user='default', title=None): """Download an album to the client. Keyword arguments: base_path -- the path on the filesystem to copy albums to. Each album will be stored in base_path/<album title>. If base_path does not exist, it and each non-existent parent directory will be created.... |
urllib.urlretrieve(photo.content.src, photo_path) | url = photo.content.src high_res_url = url[:url.rfind('/')+1]+'d'+url[url.rfind('/'):] urllib.urlretrieve(high_res_url, photo_path) | def DownloadAlbum(self, base_path, user='default', title=None): """Download an album to the client. Keyword arguments: base_path -- the path on the filesystem to copy albums to. Each album will be stored in base_path/<album title>. If base_path does not exist, it and each non-existent parent directory will be created.... |
self.client.InsertPhotoSimple(album_url, file, '', file, | self.client.InsertPhotoSimple(album_url, title=os.path.split(file)[1], summary='', filename_or_handle=file, | def InsertPhotos(self, album, photo_list, tags=''): """Insert photos into an album. Keyword arguments: album -- The album entry of the album getting the photos. photo_list -- a list of paths, each path a picture on the local host. tags -- Text of the tags to be added to each photo, e.g. 'Islands, Vacation' """ album_... |
def _batch_delete_recur(self, date, event, cal_user): | def _batch_delete_recur(self, event, cal_user, start_date=None, end_date=None): | def _batch_delete_recur(self, date, event, cal_user): """Delete a subset of instances of recurring events.""" request_feed = gdata.calendar.CalendarEventFeed() single_events = self.get_events(cal_user, date=date, title=event.title.text, expand_recurrence=True) delete_events = [e for e in single_events if e.original_eve... |
single_events = self.get_events(cal_user, date=date, | single_events = self.get_events(cal_user, start_date=start_date, end_date=end_date, | def _batch_delete_recur(self, date, event, cal_user): """Delete a subset of instances of recurring events.""" request_feed = gdata.calendar.CalendarEventFeed() single_events = self.get_events(cal_user, date=date, title=event.title.text, expand_recurrence=True) delete_events = [e for e in single_events if e.original_eve... |
start_date, end_date = get_start_and_end(date) | start_date, end_date, start_date_utc, end_date_utc = get_start_and_end(date) | def delete_events(self, events, date, calendar_user): """Delete events from a calendar. Keyword arguments: events: List of non-expanded calendar events to delete. date: Date string specifying the date range of the events, as the date option. calendar_user: "User" of the calendar to delete events from. """ single_even... |
end_date, date)) | end_date, 'TWIXT')) | def delete_events(self, events, date, calendar_user): """Delete events from a calendar. Keyword arguments: events: List of non-expanded calendar events to delete. date: Date string specifying the date range of the events, as the date option. calendar_user: "User" of the calendar to delete events from. """ single_even... |
_tomorrowize(delete_date))) | 'ON')) | def delete_events(self, events, date, calendar_user): """Delete events from a calendar. Keyword arguments: events: List of non-expanded calendar events to delete. date: Date string specifying the date range of the events, as the date option. calendar_user: "User" of the calendar to delete events from. """ single_even... |
delete_date)) | 'ONAFTER')) | def delete_events(self, events, date, calendar_user): """Delete events from a calendar. Keyword arguments: events: List of non-expanded calendar events to delete. date: Date string specifying the date range of the events, as the date option. calendar_user: "User" of the calendar to delete events from. """ single_even... |
try: self._batch_delete_recur(option[1], event, calendar_user) except EventsNotFound: print 'No events found matching request!' | raise CalendarError('Got unexpected batch deletion command!') | def delete_events(self, events, date, calendar_user): """Delete events from a calendar. Keyword arguments: events: List of non-expanded calendar events to delete. date: Date string specifying the date range of the events, as the date option. calendar_user: "User" of the calendar to delete events from. """ single_even... |
def get_events(self, calendar_user, date=None, title=None, query=None, max_results=100, expand_recurrence=True): | def get_events(self, calendar_user, start_date=None, end_date=None, title=None, query=None, max_results=100, expand_recurrence=True): | def get_events(self, calendar_user, date=None, title=None, query=None, max_results=100, expand_recurrence=True): """Get events. Keyword arguments: calendar_user: "user" of the calendar to get events for. date: Date of the event(s). Sets one or both of start-min or start-max in the uri. Must follow the format 'YYYY-MM-... |
date: Date of the event(s). Sets one or both of start-min or start-max in the uri. Must follow the format 'YYYY-MM-DD' in one of three ways: '<format>' - set a start date. '<format>,<format>' - set a start and end date. ',<format>' - set an end date. Default None for only getting future events. | See get_calendar_user. start_date: Start date of the event(s). Must follow the RFC 3339 timestamp format and be in UTC. Default None. end_date: End date of the event(s). Must follow the RFC 3339 timestamp format and be in UTC. Default None. | def get_events(self, calendar_user, date=None, title=None, query=None, max_results=100, expand_recurrence=True): """Get events. Keyword arguments: calendar_user: "user" of the calendar to get events for. date: Date of the event(s). Sets one or both of start-min or start-max in the uri. Must follow the format 'YYYY-MM-... |
start_min, start_max = get_start_and_end(date) if start_min: query.start_min = start_min if start_max: query.start_max = start_max | if start_date: query.start_min = start_date if end_date: query.start_max = end_date | def get_events(self, calendar_user, date=None, title=None, query=None, max_results=100, expand_recurrence=True): """Get events. Keyword arguments: calendar_user: "user" of the calendar to get events for. date: Date of the event(s). Sets one or both of start-min or start-max in the uri. Must follow the format 'YYYY-MM-... |
except ValueError, err: if err.args[0].find('does not match format') != -1: start_time_data = time.strptime(when.start_time, '%Y-%m-%d') end_time_data = time.strptime(when.end_time, '%Y-%m-%d') | except ValueError: start_time_data = time.strptime(when.start_time, '%Y-%m-%d') end_time_data = time.strptime(when.end_time, '%Y-%m-%d') | def get_datetimes(cal_entry): """Get datetime objects for the start and end of the event specified by a calendar entry. Keyword arguments: cal_entry: A CalendarEventEntry. Returns: (start_time, end_time, freq) where start_time - datetime object of the start of the event. end_time - datetime object of the end of the e... |
will set return ('2010-06-01', '2010-06-20') | will set return ('2010-06-01', '2010-06-20', ...) | def get_start_and_end(date): """Split a string representation of a date or range of dates. Ranges should be designated via a comma. For example, '2010-06-01,2010-06-20' will set return ('2010-06-01', '2010-06-20') Returns: Tuple of (start, end) where start is either the starting date or None and end is either the end... |
Tuple of (start, end) where start is either the starting date or None and end is either the ending date or None | Tuple of (start, end, utc_start, utc_end) where start is either the starting date or None, end is either the ending date or None, utc_start is the starting date shifted into UTC, utc_end is the ending date shifted into UTC. | def get_start_and_end(date): """Split a string representation of a date or range of dates. Ranges should be designated via a comma. For example, '2010-06-01,2010-06-20' will set return ('2010-06-01', '2010-06-20') Returns: Tuple of (start, end) where start is either the starting date or None and end is either the end... |
return (start, end) | utc_timedelta = get_utc_timedelta() if start: start_time = datetime.datetime.strptime(start, googlecl.service.DATE_FORMAT) utc_start = (start_time + (utc_timedelta)).strftime(QUERY_DATE_FORMAT) else: utc_start = None if end: end_time = datetime.datetime.strptime(end, googlecl.service.DATE_FORMAT) utc_end = (end_time ... | def get_start_and_end(date): """Split a string representation of a date or range of dates. Ranges should be designated via a comma. For example, '2010-06-01,2010-06-20' will set return ('2010-06-01', '2010-06-20') Returns: Tuple of (start, end) where start is either the starting date or None and end is either the end... |
date: Date to start at, following googlecl.service.DATE_FORMAT format. Default None, for today. | date: String of date to start at, following RFC 3339 timestamp format, but does not have to include data past 'YYYY-MM-DD'. Must be in UTC. Default None, for today. | def _tomorrowize(date=None): """Return a date range from given date until tomorrow. Keyword arguments: date: Date to start at, following googlecl.service.DATE_FORMAT format. Default None, for today. Returns: A string that will be interpreted as "from <date> until <date + 1 day>" """ if not date: date_data = datetime... |
A string that will be interpreted as "from <date> until <date + 1 day>" | (start_date, end_date) where both dates are strings representing UTC time in the RFC 3339 format. end_date is exactly one day after start_date. | def _tomorrowize(date=None): """Return a date range from given date until tomorrow. Keyword arguments: date: Date to start at, following googlecl.service.DATE_FORMAT format. Default None, for today. Returns: A string that will be interpreted as "from <date> until <date + 1 day>" """ if not date: date_data = datetime... |
date_data = datetime.datetime.now() else: date_data = datetime.datetime.strptime(date, googlecl.service.DATE_FORMAT) | date_data = datetime.datetime.today() else: try: date_data = datetime.datetime.strptime(date, QUERY_DATE_FORMAT) except ValueError: date_data = datetime.datetime.strptime(date, googlecl.service.DATE_FORMAT) date_data += get_utc_timedelta() | def _tomorrowize(date=None): """Return a date range from given date until tomorrow. Keyword arguments: date: Date to start at, following googlecl.service.DATE_FORMAT format. Default None, for today. Returns: A string that will be interpreted as "from <date> until <date + 1 day>" """ if not date: date_data = datetime... |
return date_data.strftime(googlecl.service.DATE_FORMAT) + ',' + \ tomorrow_data.strftime(googlecl.service.DATE_FORMAT) | return (date_data.strftime(QUERY_DATE_FORMAT), tomorrow_data.strftime(QUERY_DATE_FORMAT)) | def _tomorrowize(date=None): """Return a date range from given date until tomorrow. Keyword arguments: date: Date to start at, following googlecl.service.DATE_FORMAT format. Default None, for today. Returns: A string that will be interpreted as "from <date> until <date + 1 day>" """ if not date: date_data = datetime... |
date=options.date, | start_date=dates[2], end_date=dates[3], | def _run_list(client, options, args): cal_user = client.get_calendar_user(options.cal) if not cal_user: print 'No calendar matches "' + options.cal + '"' return entries = client.get_events(cal_user, date=options.date, title=options.title, query=options.query) if args: style_list = args[0].split(',') else: style_list = ... |
options.date = _tomorrowize() _run_list(client, options, args) | cal_user = client.get_calendar_user(options.cal) if not cal_user: print 'No calendar matches "' + options.cal + '"' return start_date, end_date = _tomorrowize() entries = client.get_events(cal_user, start_date=start_date, end_date=end_date, title=options.title, query=options.query) if args: style_list = args[0].split('... | def _run_list_today(client, options, args): options.date = _tomorrowize() _run_list(client, options, args) |
events = client.get_events(cal_user, date=options.date, | dates = get_start_and_end(options.date) events = client.get_events(cal_user, start_date=dates[2], end_date=dates[3], | def _run_delete(client, options, args): cal_user = client.get_calendar_user(options.cal) if not cal_user: print 'No calendar matches "' + options.cal + '"' return events = client.get_events(cal_user, date=options.date, title=options.title, query=options.query, expand_recurrence=False) try: client.delete_events(events, ... |
print safe_encode('[' + str(cal) + ']') | print safe_encode('[' + unicode(cal) + ']') | def _list(client, options, date, args): cal_user_list = client.get_calendar_user_list(options.cal) if not cal_user_list: LOG.error('No calendar matches "' + options.cal + '"') return titles_list = googlecl.build_titles_list(options.title, args) for cal in cal_user_list: print '' print safe_encode('[' + str(cal) + ']') ... |
LOG.debug('(Ignoring ' + unicode(args) +')') | LOG.debug(safe_encode('(Ignoring ' + unicode(args) +')')) | def _run_delete(client, options, args): cal_user_list = client.get_calendar_user_list(options.cal) if not cal_user_list: LOG.error('No calendar matches "' + options.cal + '"') return date = googlecl.calendar.Date(options.date) if args: LOG.info('Sorry, no support for additional arguments for ' '"calendar delete" yet') ... |
LOG.info(safe_encode('For calendar ' + str(cal))) | LOG.info(safe_encode('For calendar ' + unicode(cal))) | def _run_delete(client, options, args): cal_user_list = client.get_calendar_user_list(options.cal) if not cal_user_list: LOG.error('No calendar matches "' + options.cal + '"') return date = googlecl.calendar.Date(options.date) if args: LOG.info('Sorry, no support for additional arguments for ' '"calendar delete" yet') ... |
title: Title of the album (Default None). | titles: list Titles of the albums (Default None). | def build_entry_list(self, user='default', titles=None, query=None, force_photos=False): """Build a list of entries of either photos or albums. |
if titles or not(titles or query): | if titles[0] or not(titles[0] or query): | def build_entry_list(self, user='default', titles=None, query=None, force_photos=False): """Build a list of entries of either photos or albums. |
def insert_photo_list(self, album, photo_list, tags=''): | def insert_photo_list(self, album, photo_list, tags='', user='default'): | def insert_photo_list(self, album, photo_list, tags=''): """Insert photos into an album. Keyword arguments: album: The album entry of the album getting the photos. photo_list: A list of paths, each path a picture on the local host. tags: Text of the tags to be added to each photo, e.g. 'Islands, Vacation' (Default '')... |
('default', album.gphoto_id.text)) | (user, album.gphoto_id.text)) | def insert_photo_list(self, album, photo_list, tags=''): """Insert photos into an album. Keyword arguments: album: The album entry of the album getting the photos. photo_list: A list of paths, each path a picture on the local host. tags: Text of the tags to be added to each photo, e.g. 'Islands, Vacation' (Default '')... |
entries = client.build_entry_list(user=options.user, | entries = client.build_entry_list(user=options.owner or options.user, | def _run_list(client, options, args): entries = client.build_entry_list(user=options.user, title=options.title, query=options.encoded_query, force_photos=True) if args: style_list = args[0].split(',') else: style_list = googlecl.get_config_option(SECTION_HEADER, 'list_style').split(',') for entry in entries: print goog... |
entries = client.build_entry_list(user=options.user, | entries = client.build_entry_list(user=options.owner or options.user, | def _run_list_albums(client, options, args): entries = client.build_entry_list(user=options.user, title=options.title, force_photos=False) if args: style_list = args[0].split(',') else: style_list = googlecl.get_config_option(SECTION_HEADER, 'list_style').split(',') for entry in entries: print googlecl.service.compile_... |
album = client.GetSingleAlbum(title=options.title) | album = client.GetSingleAlbum(user=options.owner or options.user, title=options.title) | def _run_post(client, options, args): if not args: LOG.error('Must provide photos to post!') return album = client.GetSingleAlbum(title=options.title) if album: client.InsertPhotoList(album, args, tags=options.tags) else: LOG.error('No albums found that match ' + options.title) |
client.InsertPhotoList(album, args, tags=options.tags) | client.InsertPhotoList(album, args, tags=options.tags, user=options.owner or options.user) | def _run_post(client, options, args): if not args: LOG.error('Must provide photos to post!') return album = client.GetSingleAlbum(title=options.title) if album: client.InsertPhotoList(album, args, tags=options.tags) else: LOG.error('No albums found that match ' + options.title) |
client.DownloadAlbum(base_path, user=options.user, title=options.title) | client.DownloadAlbum(base_path, user=options.owner or options.user, title=options.title) | def _run_get(client, options, args): if not args: LOG.error('Must provide destination of album(s)!') return base_path = args[0] client.DownloadAlbum(base_path, user=options.user, title=options.title) |
entries = client.build_entry_list(query=options.query, | entries = client.build_entry_list(user=options.owner or options.user, query=options.query, | def _run_tag(client, options, args): entries = client.build_entry_list(query=options.query, title=options.title, force_photos=True) if entries: client.TagPhotos(entries, options.tags) else: LOG.error('No matches for the title and/or query you gave.') |
required='title', optional='tags', | required='title', optional=['tags', 'owner'], | def _run_tag(client, options, args): entries = client.build_entry_list(query=options.query, title=options.title, force_photos=True) if entries: client.TagPhotos(entries, options.tags) else: LOG.error('No matches for the title and/or query you gave.') |
optional=['title', 'query']), | optional=['title', 'query', 'owner']), | def _run_tag(client, options, args): entries = client.build_entry_list(query=options.query, title=options.title, force_photos=True) if entries: client.TagPhotos(entries, options.tags) else: LOG.error('No matches for the title and/or query you gave.') |
optional=['title']), | optional=['title', 'owner']), | def _run_tag(client, options, args): entries = client.build_entry_list(query=options.query, title=options.title, force_photos=True) if entries: client.TagPhotos(entries, options.tags) else: LOG.error('No matches for the title and/or query you gave.') |
optional=['title', 'query'], | optional=['title', 'query', 'owner'], | def _run_tag(client, options, args): entries = client.build_entry_list(query=options.query, title=options.title, force_photos=True) if entries: client.TagPhotos(entries, options.tags) else: LOG.error('No matches for the title and/or query you gave.') |
required=['tags', ['title', 'query']])} | required=['tags', ['title', 'query']], optional='owner')} | def _run_tag(client, options, args): entries = client.build_entry_list(query=options.query, title=options.title, force_photos=True) if entries: client.TagPhotos(entries, options.tags) else: LOG.error('No matches for the title and/or query you gave.') |
entries = client.GetVideos(user=options.owner or options.user, | entries = client.GetVideos(user=options.owner or 'default', | def _run_list(client, options, args): entries = client.GetVideos(user=options.owner or options.user, title=options.title) if args: style_list = args[0].split(',') else: style_list = googlecl.get_config_option(SECTION_HEADER, 'list_style').split(',') for vid in entries: print googlecl.service.compile_entry_string( googl... |
photo_name=None): | photo_name=None, caption=None): | def insert_media_list(self, album, media_list, tags='', user='default', photo_name=None): """Insert photos or videos into an album. |
caption: Caption/summary to give each item. Default None for no caption. | def insert_media_list(self, album, media_list, tags='', user='default', photo_name=None): """Insert photos or videos into an album. | |
summary='', | summary=caption, | def insert_media_list(self, album, media_list, tags='', user='default', photo_name=None): """Insert photos or videos into an album. |
def tag_photos(self, photo_entries, tags): | def tag_photos(self, photo_entries, tags, caption): | def tag_photos(self, photo_entries, tags): """Add or remove tags on a list of photos. |
see googlecl.base.generate_tag_sets(). | see googlecl.base.generate_tag_sets(). Set None to leave the tags as they currently are. caption: New caption for the photo. Set None to leave the caption as it is. | def tag_photos(self, photo_entries, tags): """Add or remove tags on a list of photos. |
remove_set, add_set, replace_tags = googlecl.base.generate_tag_sets(tags) | from atom import Summary if tags is not None: remove_set, add_set, replace_tags = googlecl.base.generate_tag_sets(tags) | def tag_photos(self, photo_entries, tags): """Add or remove tags on a list of photos. |
if not photo.media: photo.media = Group() if not photo.media.keywords: photo.media.keywords = Keywords() if photo.media.keywords.text and remove_set and not replace_tags: current_tags = photo.media.keywords.text.replace(', ', ',') current_set = set(current_tags.split(',')) photo.media.keywords.text = ','.join(curren... | if tags is not None: if not photo.media: photo.media = Group() if not photo.media.keywords: photo.media.keywords = Keywords() if photo.media.keywords.text and remove_set and not replace_tags: current_tags = photo.media.keywords.text.replace(', ', ',') current_set = set(current_tags.split(',')) photo.media.keywords.te... | def tag_photos(self, photo_entries, tags): """Add or remove tags on a list of photos. |
if options.query: entry_type = 'photo' | if options.query or options.photo: entry_type = 'media' | def _run_delete(client, options, args): if options.query: entry_type = 'photo' search_string = options.query else: entry_type = 'album' search_string = options.title titles_list = googlecl.build_titles_list(options.title, args) entries = client.build_entry_list(titles=titles_list, query=options.query, photo_title=opti... |
photo_name=options.photo) | photo_name=options.photo, caption=options.summary) | def _run_post(client, options, args): media_list = options.src + args if not media_list: LOG.error('Must provide paths to media to post!') album = client.GetSingleAlbum(user=options.owner or options.user, title=options.title) if album: client.InsertMediaList(album, media_list, tags=options.tags, user=options.owner or o... |
client.TagPhotos(entries, options.tags) | client.TagPhotos(entries, options.tags, options.summary) | def _run_tag(client, options, args): titles_list = googlecl.build_titles_list(options.title, args) entries = client.build_entry_list(user=options.owner or options.user, query=options.query, titles=titles_list, force_photos=True, photo_title=options.photo) if entries: client.TagPhotos(entries, options.tags) else: LOG.er... |
optional=['tags', 'owner', 'photo']), | optional=['tags', 'owner', 'photo', 'summary']), | def _run_tag(client, options, args): titles_list = googlecl.build_titles_list(options.title, args) entries = client.build_entry_list(user=options.owner or options.user, query=options.query, titles=titles_list, force_photos=True, photo_title=options.photo) if entries: client.TagPhotos(entries, options.tags) else: LOG.er... |
'tag': googlecl.base.Task('Tag photos', callback=_run_tag, required=[['title', 'query'], 'tags'], | 'tag': googlecl.base.Task('Tag/caption photos', callback=_run_tag, required=[['title', 'query'], ['tags', 'summary']], | def _run_tag(client, options, args): titles_list = googlecl.build_titles_list(options.title, args) entries = client.build_entry_list(user=options.owner or options.user, query=options.query, titles=titles_list, force_photos=True, photo_title=options.photo) if entries: client.TagPhotos(entries, options.tags) else: LOG.er... |
photo_concat = 1 | def DownloadAlbum(self, base_path, user='default', title=None): """Download an album to the client. Keyword arguments: base_path -- the path on the filesystem to copy albums to. Each album will be stored in base_path/<album title>. If base_path does not exist, it and each non-existent parent directory will be created.... | |
request_token = self.FetchOAuthRequestToken() | request_token = self.FetchOAuthRequestToken(extra_parameters=params) | def request_access(self): """Do all the steps involved with getting an OAuth access token. Return: True if access token was succesfully retrieved and set, otherwise False. """ import ConfigParser import os import subprocess # Installed applications do not have a pre-registration and so follow # directions for unregis... |
if err.args[0]['body'].find('Token invalid') == -1: | if err.args[0]['body'].lower().find('token invalid') == -1: | def is_token_valid(self, test_uri=None): """Check that the token being used is valid. Keyword arguments: test_uri: URI to pass to self.Get(). Default None (raises error). Returns: True if Get was successful, False if Get raised an exception with the string 'Token invalid' in its body, and raises any other exceptions.... |
scopes.extend(['https://www.googleapis.com/auth/userinfo.email']) | scopes.extend(['https://www.googleapis.com/auth/userinfo | def request_access(self, domain, scopes=None): """Do all the steps involved with getting an OAuth access token. Keyword arguments: domain: Domain to request access for. (Sets the hd query parameter for the authorization step). scopes: String or list/tuple of strings describing scopes to request access to. Default None... |
password: Password used to authenticate the account given by 'email'. | password: Password used to authenticate the account given by email. | def try_login(client, email=None, password=None): """Try to log into a service via the client. Keyword arguments: client: Client for the service. email: E-mail used to log in. If '@my-mail.com' is not included, the domain is inferred. (Default None - will first check for a file containing email/password, or prompt for... |
got_creds_from_file= False | def try_login(client, email=None, password=None): """Try to log into a service via the client. Keyword arguments: client: Client for the service. email: E-mail used to log in. If '@my-mail.com' is not included, the domain is inferred. (Default None - will first check for a file containing email/password, or prompt for... | |
if os.path.exists(cred_path) and not client.logged_in: | if got_creds_from_file and not client.logged_in: | def try_login(client, email=None, password=None): """Try to log into a service via the client. Keyword arguments: client: Client for the service. email: E-mail used to log in. If '@my-mail.com' is not included, the domain is inferred. (Default None - will first check for a file containing email/password, or prompt for... |
_general = {'regex': 'True', 'delete_by_default': 'False', 'delete_prompt': 'True', 'tags_prompt': 'False', 'url_field': 'site', 'fields': 'title,url-site', 'missing_field_value': 'N/A', 'date_print_format': '%b %d %H:%M', 'cap_results': 'False', 'hostid': default_hostid} | _general = {'max_retries': '2', 'retry_delay': '0.5', 'regex': 'True', 'delete_by_default': 'False', 'delete_prompt': 'True', 'tags_prompt': 'False', 'url_field': 'site', 'fields': 'title,url-site', 'missing_field_value': 'N/A', 'date_print_format': '%b %d %H:%M', 'cap_results': 'False', 'hostid': default_hostid} | def set_options(): """Set the most basic options in the config file.""" import googlecl import getpass import socket # These may be useful to define at the module level, but for now, # keep them here. # REMEMBER: updating these means you need to update the CONFIG readme. default_hostid = getpass.getuser() + '@' + sock... |
delta = datetime.timedelta(hours=24) new_datetime = self.utc + delta else: new_datetime = self.utc | new_datetime = self.utc + datetime.timedelta(hours=24) else: new_datetime = self.utc + datetime.timedelta(minutes=1) | def to_inclusive_query(self): """Converts UTC data to query-friendly, date-inclusive string. |
format_string = '%Y-%m-%dT%H:%M' | def to_timestamp(self): """Converts UTC data to timestamp in seconds. | |
format_string)) | '%Y-%m-%dT%H:%M')) | def to_timestamp(self): """Converts UTC data to timestamp in seconds. |
try_forever = self.max_retries >= 0 | try_forever = self.max_retries <= 0 | def retry_operation(self, *args, **kwargs): """Retries an operation if certain status codes are returned. |
uri = str(urllib.quote(safe_encode(uri), '$&+,/:;=?@ | if isinstance(uri, unicode): uri = uri.encode('utf-8') | def get_entries(self, uri, titles=None, converter=None, desired_class=None): """Get a list of entries from a feed uri. |
reminder_results = [] | def _run_add(client, options, args): cal_user_list = client.get_calendar_user_list(options.cal) if not cal_user_list: LOG.error('No calendar matches "' + options.cal + '"') return reminder_in_minutes = convert_reminder_string(options.reminder) events_list = options.src + args for cal in cal_user_list: if options.date: ... | |
reminder_results = client.add_reminders(cal.user, results, reminder_in_minutes) | if reminder_in_minutes is not None: reminder_results = client.add_reminders(cal.user, results, reminder_in_minutes) | def _run_add(client, options, args): cal_user_list = client.get_calendar_user_list(options.cal) if not cal_user_list: LOG.error('No calendar matches "' + options.cal + '"') return reminder_in_minutes = convert_reminder_string(options.reminder) events_list = options.src + args for cal in cal_user_list: if options.date: ... |
request_feed.AddInsert(event, 'insert-request' + str(i)) | request_feed.AddInsert(event, 'insert-' + event_str[0:5] + str(i)) | def quick_add_event(self, quick_add_strings, calendar_user): """Add an event using the Calendar Quick Add feature. Keyword arguments: quick_add_strings: List of strings to be parsed by the Calendar service, as if it was entered via the "Quick Add" function. calendar_user: "User" of the calendar to add to. Returns: Th... |
client.quick_add_event(args, cal.user) | results = client.quick_add_event(args, cal.user) if LOG.isEnabledFor(logging.DEBUG): for entry in results: LOG.debug('ID: %s, status: %s, reason: %s', entry.batch_id.text, entry.batch_status.code, entry.batch_status.reason) if minutes: new_results = client.add_reminders(cal.user, results, minutes) if LOG.isEnabledFor(... | def _run_add(client, options, args): cal_user_list = client.get_calendar_user_list(options.cal) if not cal_user_list: LOG.error('No calendar matches "' + options.cal + '"') return for cal in cal_user_list: client.quick_add_event(args, cal.user) |
entries = [entry for entry in f.entry if re.match(title,entry.title.text)] | entries = [entry for entry in f.entry if entry.title.text and re.match(title,entry.title.text)] | def GetEntries(self, uri, title=None, converter=None): """Get a list of entries from a feed uri. Keyword arguments: uri: URI to get the feed from. title: String to use when looking for entries to return. Will be compared to entry.title.text, using regular expressions if self.use_regex. (Default None for all entries fr... |
def get_email(self, _uri=None): | def get_email(self, _uri=None, redirects_remaining=4): | def get_email(self, _uri=None): """Get the email address that has the OAuth access token. |
return BaseServiceCL.get_email(location) | return BaseServiceCL.get_email(location, redirects_remaining=redirects_remaining-1) | def get_email(self, _uri=None): """Get the email address that has the OAuth access token. |
import warnings | def get_entries(self, uri, title=None, converter=None): """Get a list of entries from a feed uri. Keyword arguments: uri: URI to get the feed from. title: String to use when looking for entries to return. Will be compared to entry.title.text, using regular expressions if self.use_regex. (Default None for all entries f... | |
return entry.content.src or href | return self.entry.content.src or href | def _url(self, substyle): if not self.entry.GetHtmlLink(): href = '' else: href = self.entry.GetHtmlLink().href |
return entry.media.description.text | value = self.entry.media.description.text | def summary(self): """Summary or description.""" try: # Try to access the "default" description return entry.media.description.text except AttributeError: # If it's not there, try the summary attribute return entry.summary.text else: if not value: # If the "default" description was there, but it was empty, # try the su... |
return entry.summary.text | value = self.entry.summary.text | def summary(self): """Summary or description.""" try: # Try to access the "default" description return entry.media.description.text except AttributeError: # If it's not there, try the summary attribute return entry.summary.text else: if not value: # If the "default" description was there, but it was empty, # try the su... |
return entry.summary.text | value = self.entry.summary.text return value | def summary(self): """Summary or description.""" try: # Try to access the "default" description return entry.media.description.text except AttributeError: # If it's not there, try the summary attribute return entry.summary.text else: if not value: # If the "default" description was there, but it was empty, # try the su... |
return entry.media.description.keywords.text | return self.entry.media.description.keywords.text | def tags(self): """Tags / keywords or labels.""" try: return entry.media.description.keywords.text except AttributeError: # Blogger uses categories. return join_string.join([c.term for c in entry.category if c.term]) |
return join_string.join([c.term for c in entry.category if c.term]) | return self.intra_property_delimiter.join( [c.term for c in self.entry.category if c.term]) | def tags(self): """Tags / keywords or labels.""" try: return entry.media.description.keywords.text except AttributeError: # Blogger uses categories. return join_string.join([c.term for c in entry.category if c.term]) |
client.Delete(entries, 'document', | client.delete(entries, 'document', | def _run_delete(client, options, args): entries = client.get_doclist(options.title) client.Delete(entries, 'document', util.config.getboolean('GENERAL', 'delete_by_default')) |
category=self.build_category(category)) | category=build_category(category)) | def post_videos(self, paths, category, title=None, desc=None, tags=None, devtags=None): """Post video(s) to YouTube. Keyword arguments: paths: List of paths to videos. category: YouTube category for the video. title: Title of the video. (Default is the filename of the video). desc: Video summary (Default None). tags: ... |
format = _get_extension(entry) | format = get_extension(entry) | def get_docs(self, base_path, entries, default_format='txt'): """Download documents. Keyword arguments: base_path: The path to download files to. This plus an entry's title plus its format-specific extension will form the complete path. entries: List of DocEntry items representing the files to download. default_format... |
path = '/tmp/googlecl/' + e.title.text + '.' + format client.export(e, path) | def _run_edit(client, options, args): import subprocess from gdata.docs.data import MIMETYPES from gdata.data import MediaSource if not os.path.exists('/tmp/googlecl'): os.mkdir('/tmp/googlecl') entries = client.get_doclist(options.title) if len(entries) > 1: print 'More than one match, only editing the first result.'... | |
try: content_type = MIMETYPES[format.upper()] except KeyError: print 'Could not find mimetype for ' + format while format not in MIMETYPES.keys(): format = raw_input('Please enter one of ' + MIMETYPES.keys() + ' for a content type to upload as.') content_type = MIMETYPES[format] mediasource = MediaSource(file_path=path... | if create_time == os.stat(path).st_mtime: print 'No modifications to file, not uploading.' return else: try: content_type = MIMETYPES[format.upper()] except KeyError: print 'Could not find mimetype for ' + format while format not in MIMETYPES.keys(): format = raw_input('Please enter one of ' + MIMETYPES.keys() + ' for ... | def _run_edit(client, options, args): import subprocess from gdata.docs.data import MIMETYPES from gdata.data import MediaSource if not os.path.exists('/tmp/googlecl'): os.mkdir('/tmp/googlecl') entries = client.get_doclist(options.title) if len(entries) > 1: print 'More than one match, only editing the first result.'... |
def upload_docs(self, paths, title=None, folder=None): | def upload_docs(self, paths, title=None, folder=None, format=None): | def upload_docs(self, paths, title=None, folder=None): """Upload a document. Keyword arguments: paths: Paths of files to upload. title: Title to give the files once uploaded. (Default None for the names of the files). folder: Folder to upload into. (Default None for no folder). |
content_type = '' try: extension = filename.split('.')[1].upper() except IndexError: print 'No extension on filename!' | if format: extension = format | def upload_docs(self, paths, title=None, folder=None): """Upload a document. Keyword arguments: paths: Paths of files to upload. title: Title to give the files once uploaded. (Default None for the names of the files). folder: Folder to upload into. (Default None for no folder). |
content_type = SUPPORTED_FILETYPES[extension] except KeyError: pass if not content_type: | extension = filename.split('.')[1] except IndexError: default_ext = 'txt' print 'No extension on filename! Treating as ' + default_ext extension = default_ext try: content_type = SUPPORTED_FILETYPES[extension.upper()] except KeyError: print 'No supported filetype found for extension ' + extension | def upload_docs(self, paths, title=None, folder=None): """Upload a document. Keyword arguments: paths: Paths of files to upload. title: Title to give the files once uploaded. (Default None for the names of the files). folder: Folder to upload into. (Default None for no folder). |
media = gdata.MediaSource(file_path=path, content_type=content_type) | try: media = gdata.MediaSource(file_path=path, content_type=content_type) except IOError, err: print err continue | def upload_docs(self, paths, title=None, folder=None): """Upload a document. Keyword arguments: paths: Paths of files to upload. title: Title to give the files once uploaded. (Default None for the names of the files). folder: Folder to upload into. (Default None for no folder). |
client.upload_docs(args, title=options.title, folder=options.folder) | client.upload_docs(args, title=options.title, folder=options.folder, format=options.format) | def _run_upload(client, options, args): if not args: print 'Need to tell me what to upload!' return client.upload_docs(args, title=options.title, folder=options.folder) |
optional=['title', 'folder', 'no-convert'], | optional=['title', 'folder', 'format'], | def _run_delete(client, options, args): entries = client.get_doclist(options.title) client.Delete(entries, 'document', googlecl.CONFIG.getboolean('GENERAL', 'delete_by_default')) |
consumer_key='aonymous', | consumer_key='anonymous', | def RequestAccess(self): """Do all the steps involved with getting an OAuth access token. Return: True if access token was succesfully retrieved and set, otherwise False. """ import gdata.auth import subprocess # Installed applications do not have a pre-registration and so follow # directions for unregistered applica... |
print e['body'].strip() + '; Request token retrieval failed!' | print e[0]['body'].strip() + '; Request token retrieval failed!' | def RequestAccess(self): """Do all the steps involved with getting an OAuth access token. Return: True if access token was succesfully retrieved and set, otherwise False. """ import gdata.auth import subprocess # Installed applications do not have a pre-registration and so follow # directions for unregistered applica... |
return 'Unexpected extension: ' + self.args[0] | return 'Unexpected extension: ' + str(self.args[0]) else: return str(self.args) class UnknownDoctype(DocsError): """Document type / label is unknown.""" def __str(self): if len(self.args) == 1: return 'Unknown document type: ' + str(self.args[0]) | def __str__(self): if len(self.args) == 1: return 'Unexpected extension: ' + self.args[0] else: return str(self.args) |
def edit_doc(self, doc_entry, editor, file_format): | def edit_doc(self, doc_entry_or_title, editor, file_format, folder_entry_or_path=None): | def edit_doc(self, doc_entry, editor, file_format): """Edit a document. Keyword arguments: doc_entry: DocEntry of the document to edit. editor: Name of the editor to use. Should be executable from the user's working directory. file_format: Suffix of the file to download. For example, "txt", "csv", "xcl". """ import s... |
doc_entry: DocEntry of the document to edit. | doc_entry_or_title: DocEntry of the existing document to edit, or title of the document to create. | def edit_doc(self, doc_entry, editor, file_format): """Edit a document. Keyword arguments: doc_entry: DocEntry of the document to edit. editor: Name of the editor to use. Should be executable from the user's working directory. file_format: Suffix of the file to download. For example, "txt", "csv", "xcl". """ import s... |
path = os.path.join(temp_dir, doc_entry.title.text + '.' + file_format) self.Export(doc_entry.content.src, path) create_time = os.stat(path).st_mtime | if new_doc and isinstance(folder_entry_or_path, basestring): folder_path = os.path.normpath(folder_entry_or_path) if os.altsep: folder_path.replace(os.altsep, os.sep) base_folder = folder_path.split(os.sep)[0] base_path = os.path.join(temp_dir, base_folder) total_basename = os.path.join(temp_dir, folder_path) os.mak... | def edit_doc(self, doc_entry, editor, file_format): """Edit a document. Keyword arguments: doc_entry: DocEntry of the document to edit. editor: Name of the editor to use. Should be executable from the user's working directory. file_format: Suffix of the file to download. For example, "txt", "csv", "xcl". """ import s... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.