Return accounts in `bidict`
parent
063788499a
commit
0d2cddec9a
|
@ -22,6 +22,7 @@ from os.path import dirname
|
|||
import shutil
|
||||
from typing import Optional
|
||||
|
||||
from bidict import bidict
|
||||
import toml
|
||||
import click
|
||||
|
||||
|
@ -104,10 +105,13 @@ def write(
|
|||
return toml.dump(config, cf)
|
||||
|
||||
|
||||
def load_accounts() -> dict[str, Optional[str]]:
|
||||
def load_accounts(
|
||||
provider: Optional[str] = None
|
||||
|
||||
) -> bidict[str, Optional[str]]:
|
||||
|
||||
# our default paper engine entry
|
||||
accounts: dict[str, Optional[str]] = {'paper': None}
|
||||
accounts = bidict({'paper': None})
|
||||
|
||||
conf, path = load()
|
||||
section = conf.get('accounts')
|
||||
|
@ -116,6 +120,10 @@ def load_accounts() -> dict[str, Optional[str]]:
|
|||
|
||||
else:
|
||||
for brokername, account_labels in section.items():
|
||||
if (
|
||||
provider is None or
|
||||
provider and brokername == provider
|
||||
):
|
||||
for name, value in account_labels.items():
|
||||
accounts[f'{brokername}.{name}'] = value
|
||||
|
||||
|
|
Loading…
Reference in New Issue