Mercurial > libervia-backend
comparison src/plugins/plugin_xep_0277.py @ 854:762b191e1e1e
plugin XEP-0277: added missing docstring
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 23 Feb 2014 23:30:35 +0100 |
parents | a8260ee88708 |
children | 03addfe98b64 |
comparison
equal
deleted
inserted
replaced
853:c2f6ada7858f | 854:762b191e1e1e |
---|---|
69 method=self.setMicroblogAccess, | 69 method=self.setMicroblogAccess, |
70 async=True, | 70 async=True, |
71 doc={}) | 71 doc={}) |
72 | 72 |
73 def parseCommentUrl(self, node_url): | 73 def parseCommentUrl(self, node_url): |
74 """Determine the fields comments_service and comments_node of a microblog data | |
75 from the href attribute of an entry's link element. For example this input: | |
76 xmpp:sat-pubsub.libervia.org?node=urn%3Axmpp%3Acomments%3A_c5c4a142-2279-4b2a-ba4c-1bc33aa87634__urn%3Axmpp%3Agroupblog%3Asouliane%libervia.org | |
77 will return (JID(u'sat-pubsub.libervia.org'), 'urn:xmpp:comments:_c5c4a142-2279-4b2a-ba4c-1bc33aa87634__urn:xmpp:groupblog:souliane%libervia.org') | |
78 @return: a tuple (JID, str) | |
79 """ | |
74 parsed_url = urlparse.urlparse(node_url, 'xmpp') | 80 parsed_url = urlparse.urlparse(node_url, 'xmpp') |
75 service = jid.JID(parsed_url.path) | 81 service = jid.JID(parsed_url.path) |
76 queries = parsed_url.query.split(';') | 82 queries = parsed_url.query.split(';') |
77 parsed_queries = dict() | 83 parsed_queries = dict() |
78 for query in queries: | 84 for query in queries: |
152 service, node = self.parseCommentUrl(microblog_data["comments"]) | 158 service, node = self.parseCommentUrl(microblog_data["comments"]) |
153 microblog_data['comments_service'] = service.full() | 159 microblog_data['comments_service'] = service.full() |
154 microblog_data['comments_node'] = node | 160 microblog_data['comments_node'] = node |
155 break | 161 break |
156 except (KeyError, exceptions.DataError, RuntimeError): | 162 except (KeyError, exceptions.DataError, RuntimeError): |
157 warning("Can't parse link") | 163 warning(_("Can't parse the link element of pubsub entry %s") % item['id']) |
158 continue | 164 continue |
159 except (AttributeError, KeyError): | 165 except (AttributeError, KeyError): |
160 error(_('Error while parsing atom entry for microblogging event')) | 166 error(_('Error while parsing atom entry for microblogging event')) |
161 raise exceptions.DataError | 167 raise exceptions.DataError |
162 | 168 |