PEP8 cleanups

pull/4/merge
Erik Johnston 10 years ago
parent 8fa3cc37f9
commit d260a42ca2
  1. 1
      synapse/api/events/room.py
  2. 13
      synapse/handlers/room.py
  3. 6
      synapse/storage/__init__.py
  4. 3
      synapse/storage/_base.py
  5. 15
      synapse/storage/room.py
  6. 1
      synapse/storage/roommember.py
  7. 2
      synapse/storage/stream.py

@ -20,6 +20,7 @@ class GenericEvent(SynapseEvent):
def get_content_template(self):
return {}
class RoomTopicEvent(SynapseEvent):
TYPE = "m.room.topic"

@ -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
@ -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,

@ -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)

@ -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):

@ -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
]

@ -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.

@ -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])

Loading…
Cancel
Save