diff --git a/piker/brokers/config.py b/piker/brokers/config.py index 9a8f6360..3805f9c8 100644 --- a/piker/brokers/config.py +++ b/piker/brokers/config.py @@ -20,6 +20,7 @@ Broker configuration mgmt. import os from os.path import dirname import shutil +from typing import Optional import toml import click @@ -101,3 +102,20 @@ def write( log.debug(f"Writing config file {path}") with open(path, 'w') as cf: return toml.dump(config, cf) + + +def load_accounts() -> dict[str, Optional[str]]: + + # our default paper engine entry + accounts: dict[str, Optional[str]] = {'paper': None} + + conf, path = load() + section = conf.get('accounts') + if section is None: + log.warning('No accounts config found?') + + for brokername, account_labels in section.items(): + for name, value in account_labels.items(): + accounts[f'{brokername}.{name}'] = value + + return accounts