def __init__ (self, checkout, **kw): self.checkout = checkout self.id = utils.utf8dec (kw.get ('id')) self.datetime = kw.get ('datetime') self.author_id = utils.utf8dec (kw.get ('author_id')) self.author_email = utils.utf8dec (kw.get ('author_email')) self.author_name = utils.utf8dec (kw.get ('author_name')) self.comment = utils.utf8dec (kw.get ('comment')) self.files = kw.get ('files', [])
def process(data): headers = [] for name in data.next(): headers.append(MAP.get(name, name)) for line in data: bugtracker = 'bugzilla.gnome.org' this = dict(zip(headers, line)) this['datetime'] = datetime.datetime.strptime(this['changeddate'], '%Y-%m-%d %H:%M:%S') timestamp = time.mktime(this['datetime'].timetuple()) issue_ident = u'issue/%s/%s/%i' % (bugtracker, this['bug_id'], timestamp) issue = pulse.db.Issue.get_or_create (issue_ident) for key, value in this.items(): converter = {'bug_id': int, 'datetime': lambda x: x} value = converter.get(key, utf8dec)(value) if hasattr(issue.__class__, key): setattr(issue, key, value) # component comp_ident = u'comp/%s/%s/%s' % (bugtracker, this['product'], this['component']) issue.comp = pulse.db.Component.get_or_create (comp_ident) issue.comp.name = utf8dec(this['component'])