Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Run isort on synapse, tests, and scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkowl committed Jun 28, 2018
1 parent 5f8bb08 commit 10da6dc
Show file tree
Hide file tree
Showing 345 changed files with 1,686 additions and 1,608 deletions.
10 changes: 5 additions & 5 deletions scripts-dev/check_auth.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from synapse.events import FrozenEvent
from synapse.api.auth import Auth

from mock import Mock

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)
Expand Down
10 changes: 5 additions & 5 deletions scripts-dev/check_event_hash.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from synapse.crypto.event_signing import *
from unpaddedbase64 import encode_base64

import argparse
import hashlib
import sys
import json
import sys

from unpaddedbase64 import encode_base64

from synapse.crypto.event_signing import *


class dictobj(dict):
Expand Down Expand Up @@ -47,4 +48,3 @@ def main():

if __name__=="__main__":
main()

18 changes: 9 additions & 9 deletions scripts-dev/check_signature.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@

from signedjson.sign import verify_signed_json
from signedjson.key import decode_verify_key_bytes, write_signing_keys
from unpaddedbase64 import decode_base64

import urllib2
import argparse
import json
import logging
import pprint
import sys
import urllib2

import dns.resolver
import pprint
import argparse
import logging
from signedjson.key import decode_verify_key_bytes, write_signing_keys
from signedjson.sign import verify_signed_json
from unpaddedbase64 import decode_base64


def get_targets(server_name):
if ":" in server_name:
Expand Down Expand Up @@ -68,4 +69,3 @@ def main():

if __name__ == '__main__':
main()

13 changes: 7 additions & 6 deletions scripts-dev/convert_server_keys.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import psycopg2
import yaml
import sys
import hashlib
import json
import sys
import time
import hashlib
from unpaddedbase64 import encode_base64

import psycopg2
import yaml
from canonicaljson import encode_canonical_json
from signedjson.key import read_signing_keys
from signedjson.sign import sign_json
from canonicaljson import encode_canonical_json
from unpaddedbase64 import encode_base64


def select_v1_keys(connection):
Expand Down
2 changes: 2 additions & 0 deletions scripts-dev/definitions.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#! /usr/bin/python

import ast

import yaml


class DefinitionVisitor(ast.NodeVisitor):
def __init__(self):
super(DefinitionVisitor, self).__init__()
Expand Down
3 changes: 2 additions & 1 deletion scripts-dev/dump_macaroon.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/env python2

import pymacaroons
import sys

import pymacaroons

if len(sys.argv) == 1:
sys.stderr.write("usage: %s macaroon [key]\n" % (sys.argv[0],))
sys.exit(1)
Expand Down
9 changes: 4 additions & 5 deletions scripts-dev/federation_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,16 @@
from __future__ import print_function

import argparse
import base64
import json
import sys
from urlparse import urlparse, urlunparse

import nacl.signing
import json
import base64
import requests
import sys

from requests.adapters import HTTPAdapter
import srvlookup
import yaml
from requests.adapters import HTTPAdapter

# uncomment the following to enable debug logging of http requests
#from httplib import HTTPConnection
Expand Down
24 changes: 14 additions & 10 deletions scripts-dev/hash_history.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
from synapse.storage.pdu import PduStore
from synapse.storage.signatures import SignatureStore
from synapse.storage._base import SQLBaseStore
from synapse.federation.units import Pdu
from synapse.crypto.event_signing import (
add_event_pdu_content_hash, compute_pdu_event_reference_hash
)
from synapse.api.events.utils import prune_pdu
from unpaddedbase64 import encode_base64, decode_base64
from canonicaljson import encode_canonical_json
import sqlite3
import sys

from canonicaljson import encode_canonical_json
from unpaddedbase64 import decode_base64, encode_base64

from synapse.api.events.utils import prune_pdu
from synapse.crypto.event_signing import (
add_event_pdu_content_hash,
compute_pdu_event_reference_hash,
)
from synapse.federation.units import Pdu
from synapse.storage._base import SQLBaseStore
from synapse.storage.pdu import PduStore
from synapse.storage.signatures import SignatureStore


class Store(object):
_get_pdu_tuples = PduStore.__dict__["_get_pdu_tuples"]
_get_pdu_content_hashes_txn = SignatureStore.__dict__["_get_pdu_content_hashes_txn"]
Expand Down
3 changes: 2 additions & 1 deletion scripts-dev/list_url_patterns.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#! /usr/bin/python

import ast
import argparse
import ast
import os
import sys

import yaml

PATTERNS_V1 = []
Expand Down
5 changes: 3 additions & 2 deletions scripts-dev/tail-synapse.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import requests
import collections
import json
import sys
import time
import json

import requests

Entry = collections.namedtuple("Entry", "name position rows")

Expand Down
5 changes: 1 addition & 4 deletions scripts/hash_password
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#!/usr/bin/env python

import argparse

import getpass
import sys

import bcrypt
import getpass

import yaml

bcrypt_rounds=12
Expand Down Expand Up @@ -52,4 +50,3 @@ if __name__ == "__main__":
password = prompt_for_pass()

print bcrypt.hashpw(password + password_pepper, bcrypt.gensalt(bcrypt_rounds))

5 changes: 1 addition & 4 deletions scripts/move_remote_media_to_new_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,9 @@

import argparse
import logging

import sys

import os

import shutil
import sys

from synapse.rest.media.v1.filepath import MediaFilePaths

Expand Down
1 change: 1 addition & 0 deletions scripts/register_new_matrix_user
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import hmac
import json
import sys
import urllib2

import yaml


Expand Down
16 changes: 8 additions & 8 deletions scripts/synapse_port_db
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from twisted.internet import defer, reactor
from twisted.enterprise import adbapi

from synapse.storage._base import LoggingTransaction, SQLBaseStore
from synapse.storage.engines import create_engine
from synapse.storage.prepare_database import prepare_database

import argparse
import curses
import logging
import sys
import time
import traceback
import yaml

from six import string_types

import yaml

from twisted.enterprise import adbapi
from twisted.internet import defer, reactor

from synapse.storage._base import LoggingTransaction, SQLBaseStore
from synapse.storage.engines import create_engine
from synapse.storage.prepare_database import prepare_database

logger = logging.getLogger("synapse_port_db")

Expand Down
5 changes: 3 additions & 2 deletions synapse/api/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@
from six import itervalues

import pymacaroons

from twisted.internet import defer

import synapse.types
from synapse import event_auth
from synapse.api.constants import EventTypes, Membership, JoinRules
from synapse.api.constants import EventTypes, JoinRules, Membership
from synapse.api.errors import AuthError, Codes
from synapse.types import UserID
from synapse.util.caches import register_cache, CACHE_SIZE_FACTOR
from synapse.util.caches import CACHE_SIZE_FACTOR, register_cache
from synapse.util.caches.lrucache import LruCache
from synapse.util.metrics import Measure

Expand Down
4 changes: 2 additions & 2 deletions synapse/api/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@

import logging

from canonicaljson import json

from six import iteritems
from six.moves import http_client

from canonicaljson import json

logger = logging.getLogger(__name__)


Expand Down
14 changes: 7 additions & 7 deletions synapse/api/filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from synapse.api.errors import SynapseError
from synapse.storage.presence import UserPresenceState
from synapse.types import UserID, RoomID
from twisted.internet import defer

from canonicaljson import json

import jsonschema
from canonicaljson import json
from jsonschema import FormatChecker

from twisted.internet import defer

from synapse.api.errors import SynapseError
from synapse.storage.presence import UserPresenceState
from synapse.types import RoomID, UserID

FILTER_SCHEMA = {
"additionalProperties": False,
"type": "object",
Expand Down
2 changes: 1 addition & 1 deletion synapse/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
# limitations under the License.

"""Contains the URL paths to prefix various aspects of the server with. """
from hashlib import sha256
import hmac
from hashlib import sha256

from six.moves.urllib.parse import urlencode

Expand Down
4 changes: 3 additions & 1 deletion synapse/app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
# limitations under the License.

import sys

from synapse import python_dependencies # noqa: E402

sys.dont_write_bytecode = True

from synapse import python_dependencies # noqa: E402

try:
python_dependencies.check_requirements()
Expand Down
11 changes: 7 additions & 4 deletions synapse/app/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,18 @@
import logging
import sys

from daemonize import Daemonize

from twisted.internet import error, reactor

from synapse.util import PreserveLoggingContext
from synapse.util.rlimit import change_resource_limit

try:
import affinity
except Exception:
affinity = None

from daemonize import Daemonize
from synapse.util import PreserveLoggingContext
from synapse.util.rlimit import change_resource_limit
from twisted.internet import error, reactor

logger = logging.getLogger(__name__)

Expand Down
5 changes: 3 additions & 2 deletions synapse/app/appservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
import logging
import sys

from twisted.internet import defer, reactor
from twisted.web.resource import NoResource

import synapse
from synapse import events
from synapse.app import _base
Expand All @@ -36,8 +39,6 @@
from synapse.util.logcontext import LoggingContext, run_in_background
from synapse.util.manhole import manhole
from synapse.util.versionstring import get_version_string
from twisted.internet import reactor, defer
from twisted.web.resource import NoResource

logger = logging.getLogger("synapse.app.appservice")

Expand Down
Loading

0 comments on commit 10da6dc

Please sign in to comment.