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

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