diff options
author | Amber Brown <hawkowl@atleastfornow.net> | 2018-10-20 11:16:55 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-20 11:16:55 +1100 |
commit | e1728dfcbe585edfb590bce50adeaab341a70db8 (patch) | |
tree | 0ae215c46f15ecc917bf45d75430298a003b0e27 /scripts-dev/check_auth.py | |
parent | Merge branch 'rav/fix_email_templates_4065' into develop (diff) | |
download | synapse-e1728dfcbe585edfb590bce50adeaab341a70db8.tar.xz |
Make scripts/ and scripts-dev/ pass pyflakes (and the rest of the codebase on py3) (#4068)
Diffstat (limited to 'scripts-dev/check_auth.py')
-rw-r--r-- | scripts-dev/check_auth.py | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/scripts-dev/check_auth.py b/scripts-dev/check_auth.py index 4fa8792a5f..b3d11f49ec 100644 --- a/scripts-dev/check_auth.py +++ b/scripts-dev/check_auth.py @@ -1,21 +1,20 @@ -from synapse.events import FrozenEvent -from synapse.api.auth import Auth - -from mock import Mock +from __future__ import print_function import argparse import itertools import json import sys +from mock import Mock + +from synapse.api.auth import Auth +from synapse.events import FrozenEvent + def check_auth(auth, auth_chain, events): auth_chain.sort(key=lambda e: e.depth) - auth_map = { - e.event_id: e - for e in auth_chain - } + auth_map = {e.event_id: e for e in auth_chain} create_events = {} for e in auth_chain: @@ -25,31 +24,26 @@ def check_auth(auth, auth_chain, events): for e in itertools.chain(auth_chain, events): auth_events_list = [auth_map[i] for i, _ in e.auth_events] - auth_events = { - (e.type, e.state_key): e - for e in auth_events_list - } + auth_events = {(e.type, e.state_key): e for e in auth_events_list} auth_events[("m.room.create", "")] = create_events[e.room_id] try: auth.check(e, auth_events=auth_events) except Exception as ex: - print "Failed:", e.event_id, e.type, e.state_key - print "Auth_events:", auth_events - print ex - print json.dumps(e.get_dict(), sort_keys=True, indent=4) + print("Failed:", e.event_id, e.type, e.state_key) + print("Auth_events:", auth_events) + print(ex) + print(json.dumps(e.get_dict(), sort_keys=True, indent=4)) # raise - print "Success:", e.event_id, e.type, e.state_key + print("Success:", e.event_id, e.type, e.state_key) + if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument( - 'json', - nargs='?', - type=argparse.FileType('r'), - default=sys.stdin, + 'json', nargs='?', type=argparse.FileType('r'), default=sys.stdin ) args = parser.parse_args() |