Changeset - dbe8d02b7807
[Not reviewed]
0 1 0
Ben Sturmfels (bsturmfels) - 2 years ago 2022-01-27 23:11:48
ben@sturm.com.au
reconcile: Update helper to show N/A when no results, similar to Perl.

Also clarified that a full account name should be passed. This aligns with the
Perl behaviour.
1 file changed with 19 insertions and 8 deletions:
0 comments (0 inline, 0 general)
conservancy_beancount/reconcile/helper.py
Show inline comments
...
 
@@ -35,2 +35,7 @@ def end_of_month(date):
 
def format_record_for_grep(row, homedir):
 
    """Return a line in a grep-style.
 

	
 
    This is so the line can be fed into Emacs grep-mode for quickly jumping to
 
    the relevant lines in the books.
 
    """
 
    file = row[0].replace(homedir, '~')
...
 
@@ -41,8 +46,11 @@ def max_column_widths(rows):
 
    """Return the max width for each column in a table of data."""
 
    maxes = [0] * len(rows[0])
 
    for row in rows:
 
        for i, val in enumerate(row):
 
            length = len(str(val))
 
            maxes[i] = max(maxes[i], length)
 
    return maxes
 
    if not rows:
 
        return []
 
    else:
 
        maxes = [0] * len(rows[0])
 
        for row in rows:
 
            for i, val in enumerate(row):
 
                length = len(str(val))
 
                maxes[i] = max(maxes[i], length)
 
        return maxes
 

	
...
 
@@ -70,2 +78,3 @@ def tabulate(rows, headers=None):
 

	
 

	
 
# Parse all the arguments
...
 
@@ -73,3 +82,3 @@ parser = argparse.ArgumentParser(description='Reconciliation helper')
 
parser.add_argument('--beancount-file', required=True)
 
parser.add_argument('--account', help='Account regexp', required=True)
 
parser.add_argument('--account', help='Full account name, e.g. "Liabilities:CreditCard:AMEX"', required=True)
 
parser.add_argument('--prev-end-date', type=datetime.date.fromisoformat)
...
 
@@ -158,3 +167,5 @@ for desc, query in QUERIES.items():
 
    rtypes, rrows = run_query(entries, options, query, numberify=True)
 
    if desc.startswith('04'):
 
    if not rrows:
 
        print(f'{desc:<55} N/A')
 
    elif desc.startswith('04'):
 
        homedir = os.getenv('HOME')
0 comments (0 inline, 0 general)