From ca5d2157c8b1ff4803e64ba90a996f0e51dfe271 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Sun, 29 Dec 2019 18:26:37 +0400 Subject: [PATCH] A little edit of strings and docstrings. Sorted imports ascendingly. Added replacement of letter T that separates data and time in a timestamp. So timestamps now are looking prettier. --- piggybank/cli/put.py | 6 +++--- piggybank/cli/show.py | 13 ++++++++----- piggybank/cli/take.py | 6 +++--- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/piggybank/cli/put.py b/piggybank/cli/put.py index 78f974b..4463d5c 100644 --- a/piggybank/cli/put.py +++ b/piggybank/cli/put.py @@ -5,10 +5,10 @@ from os.path import exists from sys import exit, stderr from piggybank import print_program_version -from piggybank.piggybank import PiggyBank from piggybank.cli import EPILOGUE from piggybank.currencies import CURRENCIES, DEFAULT_CURRENCY, \ BaseCurrencyError, print_supported_currencies +from piggybank.piggybank import PiggyBank from piggybank.util import add_common_arguments_to_parser, \ complement_array_of_coins @@ -24,8 +24,8 @@ def main() -> None: help="a piggy bank file name. Missing .pb extension" "will be added") parser.add_argument("coins", type=int, nargs="+", metavar="COIN", - help="a set of coins to add to a piggy bank. A new file" - "will be created if it doesn't exist") + help="a set of coins to add. A new file will be" + "created if it doesn't exist") parser.add_argument("-c", "--currency", type=str, default=DEFAULT_CURRENCY, help="set currency of a piggy bank. Not applicable to" diff --git a/piggybank/cli/show.py b/piggybank/cli/show.py index bc1406d..1393105 100644 --- a/piggybank/cli/show.py +++ b/piggybank/cli/show.py @@ -5,10 +5,10 @@ from os.path import exists from sys import exit, stderr from piggybank import print_program_version, PIGGYBANK_FILE_EXTENSION -from piggybank.piggybank import PiggyBank from piggybank.cli import EPILOGUE from piggybank.currencies import CURRENCIES, DEFAULT_CURRENCY, \ BaseCurrencyError, print_supported_currencies +from piggybank.piggybank import PiggyBank from piggybank.util import add_common_arguments_to_parser __all__ = ["main"] @@ -18,7 +18,10 @@ DEFAULT_COIN_CENTERING: int = 10 def print_summary(piggybank: PiggyBank, centering: int = DEFAULT_COIN_CENTERING) -> None: - """Print summarised info on a piggy bank.""" + """Print summarised information on a piggy bank. + Prints a table with totals of how much coins of which face value are in a + piggy bank; A total sum converted to its currency for each face value and + overall total sum in a currency of a piggy bank.""" def print_separator(left="┣", lmiddle="╋", rmiddle="╋", right="┫"): line = rmiddle.join('━' * centering for _ in @@ -56,14 +59,14 @@ def print_transactions(piggybank, centering=DEFAULT_COIN_CENTERING): cline = "┃".join([f'{l:^{centering}}' for l in CURRENCIES[piggybank.currency]["names"]]) -# cline_len = len(cline) print_separator() print(f"┃{'Timestamp':^21}┃ I/O ┃{cline}┃") print_separator("┣", "╋", "┫") for tr in piggybank.transactions: coin_line = "┃".join([f'{c:^{centering}}' for c in tr.coins]) - print(f"┃ {tr.timestamp} ┃{tr.direction:^5}┃{coin_line}┃") + ts = tr.timestamp.replace("T", " ") + print(f"┃ {ts} ┃{tr.direction:^5}┃{coin_line}┃") print_separator("┗", "┻", "┛") @@ -83,7 +86,7 @@ def main(): parser.add_argument("-m", "--merge", action="append", type=str, metavar="FILE", help="merge multiple files to show how much do you" - "have across them. They all should have same currency") + "have across them. They all should be of same currency") add_common_arguments_to_parser(parser, include_reverse_flag=False) diff --git a/piggybank/cli/take.py b/piggybank/cli/take.py index b2d7571..0e12432 100644 --- a/piggybank/cli/take.py +++ b/piggybank/cli/take.py @@ -4,10 +4,10 @@ from argparse import ArgumentParser from sys import exit, stderr from piggybank import print_program_version -from piggybank.piggybank import PiggyBank from piggybank.cli import EPILOGUE from piggybank.currencies import CURRENCIES, DEFAULT_CURRENCY, \ BaseCurrencyError, print_supported_currencies +from piggybank.piggybank import PiggyBank from piggybank.transaction import TYPE_OUTCOME from piggybank.util import add_common_arguments_to_parser, \ complement_array_of_coins @@ -24,8 +24,8 @@ def main(): help="a coin box file name. Missing .cb extension will" "be added") parser.add_argument("coins", type=int, nargs="+", metavar="COIN", - help="add a set of coins to a coin box. A new file" - "will be created if it doesn't exist") + help="add a set of coins. A new file will be created" + "if it doesn't exist") add_common_arguments_to_parser(parser)