summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2014-08-15 16:17:36 +0100
committerErik Johnston <erik@matrix.org>2014-08-15 16:17:36 +0100
commitd260a42ca279fbca46f85b2c96bddc4f814ecef3 (patch)
tree41a27d45cdd901555b3e877d45b757848d199f7f /synapse
parentComment. (diff)
downloadsynapse-d260a42ca279fbca46f85b2c96bddc4f814ecef3.tar.xz
PEP8 cleanups
Diffstat (limited to '')
-rw-r--r--synapse/api/events/room.py1
-rw-r--r--synapse/handlers/room.py17
-rw-r--r--synapse/storage/__init__.py6
-rw-r--r--synapse/storage/_base.py3
-rw-r--r--synapse/storage/room.py15
-rw-r--r--synapse/storage/roommember.py1
-rw-r--r--synapse/storage/stream.py2
7 files changed, 29 insertions, 16 deletions
diff --git a/synapse/api/events/room.py b/synapse/api/events/room.py
index d9b3d572fa..dbf537fb88 100644
--- a/synapse/api/events/room.py
+++ b/synapse/api/events/room.py
@@ -20,6 +20,7 @@ class GenericEvent(SynapseEvent):
     def get_content_template(self):
         return {}
 
+
 class RoomTopicEvent(SynapseEvent):
     TYPE = "m.room.topic"
 
diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py
index b0b2441b9f..4ecfb278be 100644
--- a/synapse/handlers/room.py
+++ b/synapse/handlers/room.py
@@ -114,8 +114,9 @@ class MessageHandler(BaseHandler):
         """
         yield self.auth.check_joined_room(room_id, user_id)
 
-        data_source = [EventsStreamData(self.hs, room_id=room_id,
-                                          feedback=feedback)]
+        data_source = [
+            EventsStreamData(self.hs, room_id=room_id, feedback=feedback)
+        ]
         event_stream = EventStream(user_id, data_source)
         pagin_config = yield event_stream.fix_tokens(pagin_config)
         data_chunk = yield event_stream.get_chunk(config=pagin_config)
@@ -196,7 +197,9 @@ class MessageHandler(BaseHandler):
                 raise RoomError(
                     403, "Member does not meet private room rules.")
 
-        data = yield self.store.get_current_state(room_id, event_type, state_key)
+        data = yield self.store.get_current_state(
+            room_id, event_type, state_key
+        )
         defer.returnValue(data)
 
     @defer.inlineCallbacks
@@ -496,7 +499,7 @@ class RoomMemberHandler(BaseHandler):
             SynapseError if there was a problem changing the membership.
         """
 
-        #broadcast_msg = False
+        # broadcast_msg = False
 
         prev_state = yield self.store.get_room_member(
             event.target_user_id, event.room_id
@@ -570,7 +573,8 @@ class RoomMemberHandler(BaseHandler):
         defer.returnValue({"room_id": room_id})
 
     @defer.inlineCallbacks
-    def _do_join(self, event, room_host=None, do_auth=True, broadcast_msg=True):
+    def _do_join(self, event, room_host=None, do_auth=True,
+                 broadcast_msg=True):
         joinee = self.hs.parse_userid(event.target_user_id)
         # room_id = RoomID.from_string(event.room_id, self.hs)
         room_id = event.room_id
@@ -621,7 +625,6 @@ class RoomMemberHandler(BaseHandler):
                 broadcast_msg=broadcast_msg,
             )
 
-
         if should_do_dance:
             yield self._do_invite_join_dance(
                 room_id=room_id,
@@ -755,7 +758,7 @@ class RoomMemberHandler(BaseHandler):
             room_id, "", is_public=False
         )
 
-        #yield self.state_handler.handle_new_event(event)
+        # yield self.state_handler.handle_new_event(event)
         yield federation.handle_new_event(new_event)
         yield federation.get_state_for_room(
             target_host, room_id
diff --git a/synapse/storage/__init__.py b/synapse/storage/__init__.py
index 750e86040e..ad36d14a36 100644
--- a/synapse/storage/__init__.py
+++ b/synapse/storage/__init__.py
@@ -87,7 +87,11 @@ class DataStore(RoomMemberStore, RoomStore,
             "content": json.dumps(event.content),
         }
 
-        unrec = {k: v for k, v in event.get_full_dict().items() if k not in vals.keys()}
+        unrec = {
+            k: v
+            for k, v in event.get_full_dict().items()
+            if k not in vals.keys()
+        }
         vals["unrecognized_keys"] = json.dumps(unrec)
 
         yield self._simple_insert("events", vals)
diff --git a/synapse/storage/_base.py b/synapse/storage/_base.py
index 413838f798..36cc57c1b8 100644
--- a/synapse/storage/_base.py
+++ b/synapse/storage/_base.py
@@ -60,7 +60,8 @@ class SQLBaseStore(object):
             The result of decoder(results)
         """
         logger.debug(
-            "[SQL] %s  Args=%s Func=%s", query, args, decoder.__name__ if decoder else None
+            "[SQL] %s  Args=%s Func=%s",
+            query, args, decoder.__name__ if decoder else None
         )
 
         def interaction(txn):
diff --git a/synapse/storage/room.py b/synapse/storage/room.py
index 8f44b67d8c..22f2dcca45 100644
--- a/synapse/storage/room.py
+++ b/synapse/storage/room.py
@@ -87,19 +87,26 @@ class RoomStore(SQLBaseStore):
         """
 
         topic_subquery = (
-            "SELECT topics.event_id as event_id, topics.room_id as room_id, topic FROM topics "
+            "SELECT topics.event_id as event_id, "
+            "topics.room_id as room_id, topic "
+            "FROM topics "
             "INNER JOIN current_state_events as c "
             "ON c.event_id = topics.event_id "
         )
 
         name_subquery = (
-            "SELECT room_names.event_id as event_id, room_names.room_id as room_id, name FROM room_names "
+            "SELECT room_names.event_id as event_id, "
+            "room_names.room_id as room_id, name "
+            "FROM room_names "
             "INNER JOIN current_state_events as c "
             "ON c.event_id = room_names.event_id "
         )
 
+        # We use non printing ascii character US () as a seperator
         sql = (
-            "SELECT r.room_id, n.name, t.topic, group_concat(a.room_alias) FROM rooms AS r "
+            "SELECT r.room_id, n.name, t.topic, "
+            "group_concat(a.room_alias, '') "
+            "FROM rooms AS r "
             "LEFT JOIN (%(topic)s) AS t ON t.room_id = r.room_id "
             "LEFT JOIN (%(name)s) AS n ON n.room_id = r.room_id "
             "INNER JOIN room_aliases AS a ON a.room_id = r.room_id "
@@ -117,7 +124,7 @@ class RoomStore(SQLBaseStore):
                 "room_id": r[0],
                 "name": r[1],
                 "topic": r[2],
-                "aliases": r[3].split(","),
+                "aliases": r[3].split(""),
             }
             for r in rows
         ]
diff --git a/synapse/storage/roommember.py b/synapse/storage/roommember.py
index a0620677b9..89c87290cf 100644
--- a/synapse/storage/roommember.py
+++ b/synapse/storage/roommember.py
@@ -62,7 +62,6 @@ class RoomMemberStore(SQLBaseStore):
 
             yield self._execute(None, sql, event.room_id, domain)
 
-
     @defer.inlineCallbacks
     def get_room_member(self, user_id, room_id):
         """Retrieve the current state of a room member.
diff --git a/synapse/storage/stream.py b/synapse/storage/stream.py
index 7c2c45e0ff..cf4b1682b6 100644
--- a/synapse/storage/stream.py
+++ b/synapse/storage/stream.py
@@ -61,7 +61,6 @@ class StreamStore(SQLBaseStore):
             defer.returnValue(([], to_key))
             return
 
-
         sql = (
             "SELECT * FROM events as e WHERE "
             "((room_id IN (%(current)s)) OR "
@@ -90,7 +89,6 @@ class StreamStore(SQLBaseStore):
 
         ret = [self._parse_event_from_row(r) for r in rows]
 
-
         if rows:
             if from_key < to_key:
                 key = max([r["ordering"] for r in rows])