From 15025d6047ede75e640d490998b168578eb333ea Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Mon, 6 Sep 2021 21:26:28 -0400 Subject: [PATCH] Move config module to top level --- piker/brokers/ib.py | 2 +- piker/brokers/questrade.py | 2 +- piker/cli/__init__.py | 3 ++- piker/{brokers => }/config.py | 2 +- piker/ui/_forms.py | 14 +++++++------- 5 files changed, 12 insertions(+), 11 deletions(-) rename piker/{brokers => }/config.py (99%) diff --git a/piker/brokers/ib.py b/piker/brokers/ib.py index 121ad428..cf646f07 100644 --- a/piker/brokers/ib.py +++ b/piker/brokers/ib.py @@ -53,7 +53,7 @@ from ib_insync.client import Client as ib_Client from fuzzywuzzy import process as fuzzy import numpy as np -from . import config +from .. import config from ..log import get_logger, get_console_log from .._daemon import maybe_spawn_brokerd from ..data._source import from_df diff --git a/piker/brokers/questrade.py b/piker/brokers/questrade.py index 7a06ce76..30ba049e 100644 --- a/piker/brokers/questrade.py +++ b/piker/brokers/questrade.py @@ -43,7 +43,7 @@ import asks from ..calc import humanize, percent_change from .._cacheables import open_cached_client, async_lifo_cache -from . import config +from .. import config from ._util import resproc, BrokerError, SymbolNotFound from ..log import get_logger, colorize_json, get_console_log from . import get_brokermod diff --git a/piker/cli/__init__.py b/piker/cli/__init__.py index e5e9a2d1..22022e84 100644 --- a/piker/cli/__init__.py +++ b/piker/cli/__init__.py @@ -8,8 +8,9 @@ import trio import tractor from ..log import get_console_log, get_logger, colorize_json -from ..brokers import get_brokermod, config +from ..brokers import get_brokermod from .._daemon import _tractor_kwargs +from .. import config log = get_logger('cli') diff --git a/piker/brokers/config.py b/piker/config.py similarity index 99% rename from piker/brokers/config.py rename to piker/config.py index 1fbd8ce1..e979a354 100644 --- a/piker/brokers/config.py +++ b/piker/config.py @@ -25,7 +25,7 @@ from typing import Optional import toml import click -from ..log import get_logger +from .log import get_logger log = get_logger('broker-config') diff --git a/piker/ui/_forms.py b/piker/ui/_forms.py index b504a408..966192e6 100644 --- a/piker/ui/_forms.py +++ b/piker/ui/_forms.py @@ -47,7 +47,7 @@ from PyQt5.QtWidgets import ( from ._event import open_handlers from ._style import hcolor, _font, _font_small, DpiAwareFont from ._label import FormatLabel -from .. import brokers +from .. import config class FontAndChartAwareLineEdit(QLineEdit): @@ -382,21 +382,21 @@ def mk_form( form._font_size = font_size or _font_small.px_size # generate sub-components from schema dict - for key, config in fields_schema.items(): - wtype = config['type'] - label = str(config.get('label', key)) + for key, conf in fields_schema.items(): + wtype = conf['type'] + label = str(conf.get('label', key)) # plain (line) edit field if wtype == 'edit': w = form.add_edit_field( key, label, - config['default_value'] + conf['default_value'] ) # drop-down selection elif wtype == 'select': - values = list(config['default_value']) + values = list(conf['default_value']) w = form.add_select_field( key, label, @@ -635,7 +635,7 @@ def mk_order_pane_layout( # font_size: int = _font_small.px_size - 2 font_size: int = _font.px_size - 2 - accounts = brokers.config.load_accounts() + accounts = config.load_accounts() # TODO: maybe just allocate the whole fields form here # and expect an async ctx entry?