From f2c1988536948a7d148b2d615a7df8dd71e5ec30 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Fri, 16 Jun 2023 21:06:28 -0400 Subject: [PATCH] Better empty account console msg styling --- piker/accounting/_mktinfo.py | 2 +- piker/accounting/cli.py | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/piker/accounting/_mktinfo.py b/piker/accounting/_mktinfo.py index 046195ca..2d2ebccd 100644 --- a/piker/accounting/_mktinfo.py +++ b/piker/accounting/_mktinfo.py @@ -121,7 +121,7 @@ class Asset(Struct, frozen=True): # NOTE: additional info optionally packed in by the backend, but # should not be explicitly required in our generic API. - info: dict = {} # make it frozen? + info: dict | None = None # TODO? # _to_dict_skip = {'info'} diff --git a/piker/accounting/cli.py b/piker/accounting/cli.py index c655d8b5..0b18a3eb 100644 --- a/piker/accounting/cli.py +++ b/piker/accounting/cli.py @@ -34,6 +34,7 @@ from ..service import ( open_piker_runtime, ) from ..clearing._messages import BrokerdPosition +from ..config import load_ledger from ..calc import humanize @@ -169,14 +170,18 @@ def sync( ): try: assert len(accounts) == 1 - if ( - not pp_msg_table - and account == 'paper' - ): + if not pp_msg_table: + ld, fpath = load_ledger(brokername, account) + assert not ld, f'WTF did we fail to parse ledger:\n{ld}' + console.print( - '[yellow underline]' - f'No pps found for `{brokername}.paper` account!\n' - 'Do you even have any paper ledger files?' + '[yellow]' + 'No pps found for ' + f'`{brokername}.{account}` ' + 'account!\n\n' + '[/][underline]' + 'None of the following ledger files exist:\n\n[/]' + f'{fpath.as_uri()}\n' ) return