PEP8 cleanups

This commit is contained in:
Erik Johnston 2014-08-15 16:17:36 +01:00
parent 8fa3cc37f9
commit d260a42ca2
7 changed files with 29 additions and 16 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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