Add config account loader
parent
b09d0d7129
commit
15fc66f0a9
|
@ -20,6 +20,7 @@ Broker configuration mgmt.
|
||||||
import os
|
import os
|
||||||
from os.path import dirname
|
from os.path import dirname
|
||||||
import shutil
|
import shutil
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
import toml
|
import toml
|
||||||
import click
|
import click
|
||||||
|
@ -101,3 +102,20 @@ def write(
|
||||||
log.debug(f"Writing config file {path}")
|
log.debug(f"Writing config file {path}")
|
||||||
with open(path, 'w') as cf:
|
with open(path, 'w') as cf:
|
||||||
return toml.dump(config, 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
|
||||||
|
|
Loading…
Reference in New Issue