From 2a641ab8b48dd723e4d535b9c37d4f543af8ea0a Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Fri, 10 Jun 2022 17:39:17 -0400 Subject: [PATCH] Call it `pps.toml`, allows toml passthrough kwargs --- piker/config.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/piker/config.py b/piker/config.py index 706ada5e..72ff8a41 100644 --- a/piker/config.py +++ b/piker/config.py @@ -113,7 +113,7 @@ if _parent_user: _conf_names: set[str] = { 'brokers', - 'pp', + 'pps', 'trades', 'watchlists', } @@ -240,6 +240,7 @@ def load( ''' path = path or get_conf_path(conf_name) + if not os.path.isfile(path): fn = _conf_fn_w_ext(conf_name) @@ -252,6 +253,9 @@ def load( # if one exists. if os.path.isfile(template): shutil.copyfile(template, path) + else: + with open(path, 'w'): + pass # touch config = toml.load(path) log.debug(f"Read config file {path}") @@ -262,6 +266,7 @@ def write( config: dict, # toml config as dict name: str = 'brokers', path: str = None, + **toml_kwargs, ) -> None: '''' @@ -285,7 +290,11 @@ def write( f"{path}" ) with open(path, 'w') as cf: - return toml.dump(config, cf) + return toml.dump( + config, + cf, + **toml_kwargs, + ) def load_accounts(