diff sat/tools/common/data_objects.py @ 2624:56f94936df1e

code style reformatting using black
author Goffi <goffi@goffi.org>
date Wed, 27 Jun 2018 20:14:46 +0200
parents 26edcf3a30eb
children 93a421de0e3d
line wrap: on
line diff
--- a/sat/tools/common/data_objects.py	Wed Jun 27 07:51:29 2018 +0200
+++ b/sat/tools/common/data_objects.py	Wed Jun 27 20:14:46 2018 +0200
@@ -20,6 +20,7 @@
 """Objects handling bridge data, with jinja2 safe markup handling"""
 
 from sat.tools.common import data_format
+
 try:
     from jinja2 import Markup as safe
 except ImportError:
@@ -28,11 +29,10 @@
 from sat.tools.common import uri as xmpp_uri
 import urllib
 
-q = lambda value: urllib.quote(value.encode('utf-8'), safe='@')
+q = lambda value: urllib.quote(value.encode("utf-8"), safe="@")
 
 
 class BlogItem(object):
-
     def __init__(self, mb_data, parent):
         self.mb_data = mb_data
         self.parent = parent
@@ -43,97 +43,97 @@
 
     @property
     def id(self):
-        return self.mb_data.get(u'id')
+        return self.mb_data.get(u"id")
 
     @property
     def atom_id(self):
-        return self.mb_data.get(u'atom_id')
+        return self.mb_data.get(u"atom_id")
 
     @property
     def uri(self):
         node = self.parent.node
         service = self.parent.service
-        return xmpp_uri.buildXMPPUri(u'pubsub',
-                                     subtype=u'microblog',
-                                     path=service,
-                                     node=node,
-                                     item=self.id)
+        return xmpp_uri.buildXMPPUri(
+            u"pubsub", subtype=u"microblog", path=service, node=node, item=self.id
+        )
 
     @property
     def published(self):
-        return self.mb_data.get(u'published')
+        return self.mb_data.get(u"published")
 
     @property
     def updated(self):
-        return self.mb_data.get(u'updated')
+        return self.mb_data.get(u"updated")
 
     @property
     def language(self):
-        return self.mb_data.get(u'language')
+        return self.mb_data.get(u"language")
 
     @property
     def author(self):
-        return self.mb_data.get(u'author')
+        return self.mb_data.get(u"author")
 
     @property
     def author_jid(self):
-        return self.mb_data.get(u'author_jid')
+        return self.mb_data.get(u"author_jid")
 
     @property
     def author_jid_verified(self):
-        return self.mb_data.get(u'author_jid_verified')
+        return self.mb_data.get(u"author_jid_verified")
 
     @property
     def author_email(self):
-        return self.mb_data.get(u'author_email')
+        return self.mb_data.get(u"author_email")
 
     @property
     def tags(self):
         if self._tags is None:
-            self._tags = list(data_format.dict2iter('tag', self.mb_data))
+            self._tags = list(data_format.dict2iter("tag", self.mb_data))
         return self._tags
 
     @property
     def groups(self):
         if self._groups is None:
-            self._groups = list(data_format.dict2iter('group', self.mb_data))
+            self._groups = list(data_format.dict2iter("group", self.mb_data))
         return self._groups
 
     @property
     def title(self):
-        return self.mb_data.get(u'title')
+        return self.mb_data.get(u"title")
 
     @property
     def title_xhtml(self):
         try:
-            return safe(self.mb_data[u'title_xhtml'])
+            return safe(self.mb_data[u"title_xhtml"])
         except KeyError:
             return None
 
     @property
     def content(self):
-        return self.mb_data.get(u'content')
+        return self.mb_data.get(u"content")
 
     @property
     def content_xhtml(self):
         try:
-            return safe(self.mb_data[u'content_xhtml'])
+            return safe(self.mb_data[u"content_xhtml"])
         except KeyError:
             return None
 
     @property
     def comments(self):
         if self._comments is None:
-            self._comments = data_format.dict2iterdict(u'comments', self.mb_data, (u'node', u'service'))
+            self._comments = data_format.dict2iterdict(
+                u"comments", self.mb_data, (u"node", u"service")
+            )
         return self._comments
 
     @property
     def comments_service(self):
-        return self.mb_data.get(u'comments_service')
+        return self.mb_data.get(u"comments_service")
 
     @property
     def comments_node(self):
-        return self.mb_data.get(u'comments_node')
+        return self.mb_data.get(u"comments_node")
 
     @property
     def comments_items_list(self):
@@ -147,22 +147,21 @@
 
 
 class BlogItems(object):
-
     def __init__(self, mb_data):
         self.items = [BlogItem(i, self) for i in mb_data[0]]
         self.metadata = mb_data[1]
 
     @property
     def service(self):
-        return self.metadata[u'service']
+        return self.metadata[u"service"]
 
     @property
     def node(self):
-        return self.metadata[u'node']
+        return self.metadata[u"node"]
 
     @property
     def uri(self):
-        return self.metadata[u'uri']
+        return self.metadata[u"uri"]
 
     def __len__(self):
         return self.items.__len__()
@@ -184,7 +183,6 @@
 
 
 class Message(object):
-
     def __init__(self, msg_data):
         self._uid = msg_data[0]
         self._timestamp = msg_data[1]
@@ -194,7 +192,7 @@
         self._subject_data = msg_data[5]
         self._type = msg_data[6]
         self._extra = msg_data[7]
-        self._html = dict(data_format.getSubDict('xhtml', self._extra))
+        self._html = dict(data_format.getSubDict("xhtml", self._extra))
 
     @property
     def id(self):
@@ -211,14 +209,14 @@
     @property
     def text(self):
         try:
-            return self._message_data['']
+            return self._message_data[""]
         except KeyError:
             return next(self._message_data.itervalues())
 
     @property
     def subject(self):
         try:
-            return self._subject_data['']
+            return self._subject_data[""]
         except KeyError:
             return next(self._subject_data.itervalues())
 
@@ -228,36 +226,35 @@
 
     @property
     def thread(self):
-        return self._extra.get('thread')
+        return self._extra.get("thread")
 
     @property
     def thread_parent(self):
-        return self._extra.get('thread_parent')
+        return self._extra.get("thread_parent")
 
     @property
     def received(self):
-        return self._extra.get('received_timestamp', self._timestamp)
+        return self._extra.get("received_timestamp", self._timestamp)
 
     @property
     def delay_sender(self):
-        return self._extra.get('delay_sender')
+        return self._extra.get("delay_sender")
 
     @property
     def info_type(self):
-        return self._extra.get('info_type')
+        return self._extra.get("info_type")
 
     @property
     def html(self):
         if not self._html:
             return None
         try:
-            return safe(self._html[''])
+            return safe(self._html[""])
         except KeyError:
             return safe(next(self._html.itervalues()))
 
 
 class Messages(object):
-
     def __init__(self, msgs_data):
         self.messages = [Message(m) for m in msgs_data]
 
@@ -279,8 +276,8 @@
     def __contains__(self, item):
         return self.messages.__contains__(item)
 
+
 class Room(object):
-
     def __init__(self, jid, name=None, url=None):
         self.jid = jid
         self.name = name or jid
@@ -289,7 +286,6 @@
 
 
 class Identity(object):
-
     def __init__(self, jid_str, data=None):
         self.jid_str = jid_str
         self.data = data if data is not None else {}
@@ -305,7 +301,6 @@
 
 
 class Identities(object):
-
     def __init__(self):
         self.identities = {}
 
@@ -352,5 +347,6 @@
 
         values will be quoted before being used
         """
-        return self.url.format(*[q(a) for a in args],
-            **{k: ObjectQuoter(v) for k,v in kwargs.iteritems()})
+        return self.url.format(
+            *[q(a) for a in args], **{k: ObjectQuoter(v) for k, v in kwargs.iteritems()}
+        )