Write a separate `pps.<brokername>.<accountname>.toml` file per account
parent
7b3d724908
commit
4494acbc01
|
@ -26,10 +26,10 @@ from contextlib import contextmanager as cm
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from math import copysign
|
from math import copysign
|
||||||
from pprint import pformat
|
from pprint import pformat
|
||||||
|
from pathlib import Path
|
||||||
from typing import (
|
from typing import (
|
||||||
Any,
|
Any,
|
||||||
Iterator,
|
Iterator,
|
||||||
Optional,
|
|
||||||
Union,
|
Union,
|
||||||
Generator
|
Generator
|
||||||
)
|
)
|
||||||
|
@ -88,7 +88,7 @@ class Position(Struct):
|
||||||
] = {}
|
] = {}
|
||||||
first_clear_dt: datetime | None = None
|
first_clear_dt: datetime | None = None
|
||||||
|
|
||||||
expiry: Optional[datetime] = None
|
expiry: datetime | None = None
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
return pformat(self.to_dict())
|
return pformat(self.to_dict())
|
||||||
|
@ -497,7 +497,8 @@ class PpTable(Struct):
|
||||||
brokername: str
|
brokername: str
|
||||||
acctid: str
|
acctid: str
|
||||||
pps: dict[str, Position]
|
pps: dict[str, Position]
|
||||||
conf: Optional[dict] = {}
|
conf_path: Path
|
||||||
|
conf: dict | None = {}
|
||||||
|
|
||||||
def update_from_trans(
|
def update_from_trans(
|
||||||
self,
|
self,
|
||||||
|
@ -683,8 +684,8 @@ class PpTable(Struct):
|
||||||
] = enc.dump_inline_table
|
] = enc.dump_inline_table
|
||||||
|
|
||||||
config.write(
|
config.write(
|
||||||
self.conf,
|
config=self.conf,
|
||||||
'pps',
|
path=self.conf_path,
|
||||||
encoder=enc,
|
encoder=enc,
|
||||||
fail_empty=False
|
fail_empty=False
|
||||||
)
|
)
|
||||||
|
@ -696,7 +697,7 @@ def load_pps_from_ledger(
|
||||||
acctname: str,
|
acctname: str,
|
||||||
|
|
||||||
# post normalization filter on ledger entries to be processed
|
# post normalization filter on ledger entries to be processed
|
||||||
filter_by: Optional[list[dict]] = None,
|
filter_by: list[dict] | None = None,
|
||||||
|
|
||||||
) -> tuple[
|
) -> tuple[
|
||||||
dict[str, Transaction],
|
dict[str, Transaction],
|
||||||
|
@ -746,7 +747,11 @@ def open_pps(
|
||||||
incremental update file: ``pps.toml``.
|
incremental update file: ``pps.toml``.
|
||||||
|
|
||||||
'''
|
'''
|
||||||
conf, path = config.load('pps')
|
conf: dict
|
||||||
|
conf_path: Path
|
||||||
|
conf, conf_path = config.load(
|
||||||
|
f'pps.{brokername}.{acctid}',
|
||||||
|
)
|
||||||
brokersection = conf.setdefault(brokername, {})
|
brokersection = conf.setdefault(brokername, {})
|
||||||
pps = brokersection.setdefault(acctid, {})
|
pps = brokersection.setdefault(acctid, {})
|
||||||
|
|
||||||
|
@ -765,6 +770,7 @@ def open_pps(
|
||||||
brokername,
|
brokername,
|
||||||
acctid,
|
acctid,
|
||||||
pp_objs,
|
pp_objs,
|
||||||
|
conf_path,
|
||||||
conf=conf,
|
conf=conf,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue