Changeset - 7f7f325f7344
[Not reviewed]
0 1 0
Ben Sturmfels (bsturmfels) - 17 months ago 2023-01-11 08:36:42
ben@sturm.com.au
reconcile.helper: Appease code linter
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
conservancy_beancount/reconcile/helper.py
Show inline comments
...
 
@@ -38,49 +38,49 @@ def end_of_month(date: datetime.date) -> datetime.date:
 

	
 
def format_record_for_grep(row: typing.List, homedir: str) -> typing.List:
 
    """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, '~')
 
    return [f'{file}:{row[1]}:'] + row[2:]
 

	
 

	
 
def max_column_widths(rows: List) -> List[int]:
 
    """Return the max width for each column in a table of data."""
 
    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
 

	
 

	
 
def tabulate(rows: List, headers: List=None) -> str:
 
def tabulate(rows: List, headers: List = None) -> str:
 
    """Format a table of data as a string.
 

	
 
    Implemented here to avoid adding dependency on "tabulate" package.
 
    """
 
    output = io.StringIO()
 
    if headers:
 
        rows = [headers] + rows
 
    widths = max_column_widths(rows)
 
    for row in rows:
 
        for i, col in enumerate(row):
 
            width = widths[i]
 
            if col is None:
 
                print(' ' * width, end=' ', file=output)
 
            elif isinstance(col, str):
 
                print((str(col)).ljust(width), end=' ', file=output)
 
            else:
 
                print((str(col)).rjust(width), end=' ', file=output)
 
        print('', file=output)
 
    return output.getvalue().strip()
 

	
 

	
 
def reconciliation_report(account, end_date, bank_account_balance, uncleared, prev_end_date, our_account_balance, prev_uncleared):
 
    *_, account_name = account.rpartition(':')
 
    # end_date_iso = end_date.isoformat()
0 comments (0 inline, 0 general)