def _xml_to_log_message(self, output): """ author - string - the name of the author who committed the revision date - float time - the date of the commit message - string - the text of the log message for the commit revision - pysvn.Revision - the revision of the commit changed_paths - list of dictionaries. Each dictionary contains: path - string - the path in the repository action - string copyfrom_path - string - if copied, the original path, else None copyfrom_revision - pysvn.Revision - if copied, the revision of the original, else None """ doc = ET.fromstring(output) entries = [] for logentry in doc: entry = dict( revision = CommandLineRevision(logentry.get('revision')), author = logentry.findtext("author"), date = self._xmldate_to_timestamp(logentry.findtext("date")), message = logentry.findtext("msg"), ) entry['changed_paths'] = [] paths = logentry.find("paths") if paths: for path in paths: cp = CommandLineChangedPath() cp.kind = path.get('kind') cp.action = path.get('action') cp.path = path.text entry['changed_paths'].append(cp) entries.append(entry) return entries
def _xml_to_log_message(self, output): """ author - string - the name of the author who committed the revision date - float time - the date of the commit message - string - the text of the log message for the commit revision - pysvn.Revision - the revision of the commit changed_paths - list of dictionaries. Each dictionary contains: path - string - the path in the repository action - string copyfrom_path - string - if copied, the original path, else None copyfrom_revision - pysvn.Revision - if copied, the revision of the original, else None """ doc = ET.fromstring(output) entries = [] for logentry in doc: entry = dict( revision=CommandLineRevision(logentry.get('revision')), author=logentry.findtext("author"), date=self._xmldate_to_timestamp(logentry.findtext("date")), message=logentry.findtext("msg"), ) entry['changed_paths'] = [] paths = logentry.find("paths") if paths: for path in paths: cp = CommandLineChangedPath() cp.kind = path.get('kind') cp.action = path.get('action') cp.path = path.text entry['changed_paths'].append(cp) entries.append(entry) return entries
def remote_latest(self, service, user): if service['api'] == 'twitter': # Twitter ommits retweets in the JSON and XML results: statuses = generic_webservice( '%sstatuses/user_timeline/%s.atom' % (service['endpoint'], user.encode('utf-8')), {'count': 1}) tree = ElementTree.fromstring(statuses) latest = tree.find('{http://www.w3.org/2005/Atom}entry') if latest is None: raise self.NoTweetsException(user) return { 'text': latest.findtext('{http://www.w3.org/2005/Atom}content').split( ': ', 1)[1], 'ago': ago(datetime.utcnow() - parse_timestamp( latest.findtext('{http://www.w3.org/2005/Atom}published')) ), 'url': [ x for x in latest.getiterator( '{http://www.w3.org/2005/Atom}link') if x.get('type') == 'text/html' ][0].get('href'), } elif service['api'] == 'laconica': statuses = json_webservice( '%sstatuses/user_timeline/%s.json' % (service['endpoint'], user.encode('utf-8')), {'count': 1}) if not statuses: raise self.NoTweetsException(user) latest = statuses[0] url = '%s/notice/%i' % (service['endpoint'].split( '/api/', 1)[0], latest['id']) return { 'text': decode_htmlentities(latest['text']), 'ago': ago(datetime.utcnow() - parse_timestamp(latest['created_at'])), 'url': url, }
def remote_latest(self, service, user): if service['api'] == 'twitter': # Twitter ommits retweets in the JSON and XML results: statuses = generic_webservice( '%sstatuses/user_timeline.rss' % service['endpoint'], { 'screen_name': user, 'count': 1 }) tree = ElementTree.fromstring(statuses) latest = tree.find('.//item') if latest is None: if tree.find('.//error'): log.info('Twitter user_latest returned: %s', tree.findtext('.//error')) raise self.NoTweetsException(user) return { 'text': latest.findtext('description').split(': ', 1)[1], 'ago': ago(datetime.utcnow() - parse_timestamp(latest.findtext('pubDate'))), 'url': latest.findtext('guid'), } elif service['api'] == 'laconica': statuses = json_webservice( '%sstatuses/user_timeline/%s.json' % (service['endpoint'], user.encode('utf-8')), {'count': 1}) if not statuses: raise self.NoTweetsException(user) latest = statuses[0] url = '%s/notice/%i' % (service['endpoint'].split( '/api/', 1)[0], latest['id']) return { 'text': decode_htmlentities(latest['text']), 'ago': ago(datetime.utcnow() - parse_timestamp(latest['created_at'])), 'url': url, }
def remote_latest(self, service, user): if service['api'] == 'twitter': # Twitter ommits retweets in the JSON and XML results: statuses = generic_webservice('%sstatuses/user_timeline.rss' % service['endpoint'], { 'screen_name': user, 'count': 1 }) tree = ElementTree.fromstring(statuses) latest = tree.find('.//item') if latest is None: if tree.find('.//error'): log.info('Twitter user_latest returned: %s', tree.findtext('.//error')) raise self.NoTweetsException(user) return { 'text': latest.findtext('description') .split(': ', 1)[1], 'ago': ago(datetime.utcnow() - parse_timestamp( latest.findtext('pubDate'))), 'url': latest.findtext('guid'), } elif service['api'] == 'laconica': statuses = json_webservice('%sstatuses/user_timeline/%s.json' % (service['endpoint'], user.encode('utf-8')), {'count': 1}) if not statuses: raise self.NoTweetsException(user) latest = statuses[0] url = '%s/notice/%i' % (service['endpoint'].split('/api/', 1)[0], latest['id']) return { 'text': decode_htmlentities(latest['text']), 'ago': ago(datetime.utcnow() - parse_timestamp(latest['created_at'])), 'url': url, }
def remote_latest(self, service, user): if service['api'] == 'twitter': # Twitter ommits retweets in the JSON and XML results: statuses = generic_webservice('%sstatuses/user_timeline/%s.atom' % (service['endpoint'], user.encode('utf-8')), {'count': 1}) tree = ElementTree.fromstring(statuses) latest = tree.find('{http://www.w3.org/2005/Atom}entry') if latest is None: raise self.NoTweetsException(user) return { 'text': latest.findtext('{http://www.w3.org/2005/Atom}content') .split(': ', 1)[1], 'ago': ago(datetime.utcnow() - parse_timestamp( latest.findtext('{http://www.w3.org/2005/Atom}published'))), 'url': [x for x in latest.getiterator('{http://www.w3.org/2005/Atom}link') if x.get('type') == 'text/html' ][0].get('href'), } elif service['api'] == 'laconica': statuses = json_webservice('%sstatuses/user_timeline/%s.json' % (service['endpoint'], user.encode('utf-8')), {'count': 1}) if not statuses: raise self.NoTweetsException(user) latest = statuses[0] url = '%s/notice/%i' % (service['endpoint'].split('/api/', 1)[0], latest['id']) return { 'text': decode_htmlentities(latest['text']), 'ago': ago(datetime.utcnow() - parse_timestamp(latest['created_at'])), 'url': url, }