def add_timestamped_entry(self, worksheet_name): feed, worksheet_key = self.get_feed_for_worksheet(worksheet_name) main_entry = feed.entry[0] new_entry = ListEntry() new_entry.from_dict(main_entry.to_dict()) new_entry.set_value('timestamp', format_date_for_gdata(datetime.datetime.utcnow())) self.spr_client.add_list_entry(new_entry, self.spreadsheet_key, worksheet_key)
def add_row(self, spreadsheet_key=None, worksheet_id=None, values={}): spreadsheet_key = spreadsheet_key or self.default_spreadsheet_key if spreadsheet_key is None: raise Exception('spreadsheet_key is not given') worksheet_id = worksheet_id or self.default_worksheet_id if worksheet_id is None: raise Exception('sheet_id is not given') if len(values) == 0: return list_entry = ListEntry() list_entry.from_dict( {key: _convert(value) for key, value in values.iteritems()}) self.client.add_list_entry(list_entry, spreadsheet_key, worksheet_id)
def update_sheet(self, lpdata): feed, sheet_key = self.get_feed_for_worksheet('Raw data') seen_bugs = set() for row in feed.entry: d = row.to_dict() bug_id = d['id'] seen_bugs.add(bug_id) if bug_id in lpdata and lpdata[bug_id] != d: print 'difference!' print 'row.to_dict: %r' % (d,) print 'lpdata[bug_id]: %r' % (lpdata[bug_id],) for key in lpdata[bug_id]: row.set_value(key, lpdata[bug_id][key]) self.spr_client.update(row) missing_bugs = set(lpdata.keys()) - seen_bugs for bug_id in missing_bugs: print 'Adding new bug: %s' % (bug_id,) row = ListEntry() for key in lpdata[bug_id]: row.set_value(key, lpdata[bug_id][key]) self.spr_client.add_list_entry(row, self.spreadsheet_key, sheet_key)
def writeRow(rowDict, client, sheetKey, sheetID='od6'): fixedRow = convertRow(rowDict) listEntry = ListEntry() listEntry.from_dict(fixedRow) client.add_list_entry(listEntry, sheetKey, sheetID)