pantalaimon: Isort the tree.

This commit is contained in:
Damir Jelić 2019-05-14 21:50:30 +02:00
parent 22fcbff44b
commit e9d0f52a5c
8 changed files with 109 additions and 133 deletions

View File

@ -3,22 +3,17 @@ from pprint import pformat
from typing import Any, Dict, Optional
from aiohttp.client_exceptions import ClientConnectionError
from nio import (AsyncClient, ClientConfig, EncryptionError,
KeysQueryResponse, MegolmEvent,
RoomEncryptedEvent, SyncResponse,
KeyVerificationEvent, LocalProtocolError,
KeyVerificationStart, KeyVerificationKey, KeyVerificationMac)
from nio.store import SqliteStore
from nio import (AsyncClient, ClientConfig, EncryptionError, KeysQueryResponse,
KeyVerificationEvent, KeyVerificationKey, KeyVerificationMac,
KeyVerificationStart, LocalProtocolError, MegolmEvent,
RoomEncryptedEvent, SyncResponse)
from nio.crypto import Sas
from nio.store import SqliteStore
from pantalaimon.log import logger
from pantalaimon.thread_messages import (
DevicesMessage,
InviteSasSignal,
ShowSasSignal,
SasDoneSignal,
DaemonResponse
)
from pantalaimon.thread_messages import (DaemonResponse, DevicesMessage,
InviteSasSignal, SasDoneSignal,
ShowSasSignal)
class PanClient(AsyncClient):

View File

@ -1,13 +1,11 @@
import configparser
import os
from ipaddress import IPv4Address, IPv6Address, ip_address
from typing import Union
from urllib.parse import ParseResult, urlparse
from ipaddress import ip_address, IPv4Address, IPv6Address
from urllib.parse import urlparse, ParseResult
import logbook
import attr
import logbook
class PanConfigParser(configparser.ConfigParser):

View File

@ -10,24 +10,19 @@ import aiohttp
import attr
import keyring
from aiohttp import ClientSession, web
from aiohttp.client_exceptions import (ContentTypeError,
ClientConnectionError)
from aiohttp.client_exceptions import ClientConnectionError, ContentTypeError
from multidict import CIMultiDict
from nio import (EncryptionError, LoginResponse, SendRetryError)
from nio import EncryptionError, LoginResponse, SendRetryError
from pantalaimon.client import PanClient
from pantalaimon.log import logger
from pantalaimon.store import ClientInfo, PanStore
from pantalaimon.thread_messages import (
DeviceVerifyMessage,
DeviceUnverifyMessage,
ExportKeysMessage,
ImportKeysMessage,
DeviceConfirmSasMessage,
SasMessage,
AcceptSasMessage,
DaemonResponse,
)
from pantalaimon.thread_messages import (AcceptSasMessage, DaemonResponse,
DeviceConfirmSasMessage,
DeviceUnverifyMessage,
DeviceVerifyMessage,
ExportKeysMessage, ImportKeysMessage,
SasMessage)
@attr.s

View File

@ -1,23 +1,19 @@
import asyncio
import os
import signal
from typing import Optional
import click
import janus
from typing import Optional
from appdirs import user_data_dir, user_config_dir
from aiohttp import web
from appdirs import user_config_dir, user_data_dir
from logbook import StderrHandler
from aiohttp import web
from pantalaimon.ui import GlibT
from pantalaimon.thread_messages import DaemonResponse
from pantalaimon.daemon import ProxyDaemon
from pantalaimon.config import PanConfig, PanConfigError, parse_log_level
from pantalaimon.daemon import ProxyDaemon
from pantalaimon.log import logger
from pantalaimon.thread_messages import DaemonResponse
from pantalaimon.ui import GlibT
def create_dirs(data_dir, conf_dir):

View File

@ -1,22 +1,19 @@
"""Cli utility to control pantalaimon."""
import attr
import asyncio
import argparse
import asyncio
import sys
from typing import List
from itertools import zip_longest
from typing import List
from prompt_toolkit import PromptSession
from prompt_toolkit.eventloop.defaults import use_asyncio_event_loop
from prompt_toolkit.patch_stdout import patch_stdout
import attr
from gi.repository import GLib
from prompt_toolkit import HTML, PromptSession, print_formatted_text
from prompt_toolkit.completion import Completer, Completion, PathCompleter
from prompt_toolkit.document import Document
from prompt_toolkit import print_formatted_text, HTML
from prompt_toolkit.eventloop.defaults import use_asyncio_event_loop
from prompt_toolkit.patch_stdout import patch_stdout
from pydbus import SessionBus
from gi.repository import GLib
use_asyncio_event_loop()

View File

@ -1,27 +1,20 @@
import attr
from queue import Empty
import attr
from gi.repository import GLib
from nio.store import TrustState
from pydbus import SessionBus
from pydbus.generic import signal
from queue import Empty
from nio.store import TrustState
from pantalaimon.store import PanStore
from pantalaimon.thread_messages import (
DeviceVerifyMessage,
DeviceUnverifyMessage,
DevicesMessage,
AcceptSasMessage,
DeviceConfirmSasMessage,
ImportKeysMessage,
ExportKeysMessage,
ShowSasSignal,
InviteSasSignal,
SasDoneSignal,
DaemonResponse
)
from pantalaimon.log import logger
from pantalaimon.store import PanStore
from pantalaimon.thread_messages import (AcceptSasMessage, DaemonResponse,
DeviceConfirmSasMessage,
DevicesMessage, DeviceUnverifyMessage,
DeviceVerifyMessage,
ExportKeysMessage, ImportKeysMessage,
InviteSasSignal, SasDoneSignal,
ShowSasSignal)
class IdCounter:

65
tests/conftest.py Normal file
View File

@ -0,0 +1,65 @@
import shutil
import tempfile
from random import choices
from string import ascii_letters, ascii_uppercase, digits
import pytest
from faker import Faker
from faker.providers import BaseProvider
from nio.crypto import OlmAccount
from nio.store import SqliteStore
from pantalaimon.store import ClientInfo, PanStore
faker = Faker()
class Provider(BaseProvider):
def mx_id(self):
return "@{}:{}".format(faker.user_name(), faker.hostname())
def device_id(self):
return "".join(choices(ascii_uppercase, k=10))
def access_token(self):
return "MDA" + "".join(choices(digits + ascii_letters, k=272))
def client(self):
return ClientInfo(faker.mx_id(), faker.access_token())
faker.add_provider(Provider)
@pytest.fixture
def access_token():
return faker.access_token()
@pytest.fixture
def client():
return faker.client()
@pytest.fixture
def tempdir():
newpath = tempfile.mkdtemp()
yield newpath
shutil.rmtree(newpath)
@pytest.fixture
def panstore(tempdir):
for _ in range(10):
store = SqliteStore(
faker.mx_id(),
faker.device_id(),
tempdir,
"",
"pan.db"
)
account = OlmAccount()
store.save_account(account)
store = PanStore(tempdir, "pan.db")
return store

View File

@ -1,69 +1,6 @@
import pdb
import shutil
import tempfile
from random import choices
from string import ascii_letters, ascii_uppercase, digits
import pytest
from faker import Faker
from faker.providers import BaseProvider
from nio.crypto import OlmAccount
from nio.store import SqliteStore
from pantalaimon.store import ClientInfo, PanStore
faker = Faker()
class Provider(BaseProvider):
def mx_id(self):
return "@{}:{}".format(faker.user_name(), faker.hostname())
def device_id(self):
return "".join(choices(ascii_uppercase, k=10))
def access_token(self):
return "MDA" + "".join(choices(digits + ascii_letters, k=272))
def client(self):
return ClientInfo(faker.mx_id(), faker.access_token())
faker.add_provider(Provider)
@pytest.fixture
def access_token():
return faker.access_token()
@pytest.fixture
def client():
return faker.client()
@pytest.fixture
def tempdir():
newpath = tempfile.mkdtemp()
yield newpath
shutil.rmtree(newpath)
@pytest.fixture
def panstore(tempdir):
for _ in range(10):
store = SqliteStore(
faker.mx_id(),
faker.device_id(),
tempdir,
"",
"pan.db"
)
account = OlmAccount()
store.save_account(account)
store = PanStore(tempdir, "pan.db")
return store
from conftest import faker
class TestClass(object):