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.
This commit is contained in:
parent
26777a7742
commit
ca5d2157c8
@ -5,10 +5,10 @@ from os.path import exists
|
|||||||
from sys import exit, stderr
|
from sys import exit, stderr
|
||||||
|
|
||||||
from piggybank import print_program_version
|
from piggybank import print_program_version
|
||||||
from piggybank.piggybank import PiggyBank
|
|
||||||
from piggybank.cli import EPILOGUE
|
from piggybank.cli import EPILOGUE
|
||||||
from piggybank.currencies import CURRENCIES, DEFAULT_CURRENCY, \
|
from piggybank.currencies import CURRENCIES, DEFAULT_CURRENCY, \
|
||||||
BaseCurrencyError, print_supported_currencies
|
BaseCurrencyError, print_supported_currencies
|
||||||
|
from piggybank.piggybank import PiggyBank
|
||||||
from piggybank.util import add_common_arguments_to_parser, \
|
from piggybank.util import add_common_arguments_to_parser, \
|
||||||
complement_array_of_coins
|
complement_array_of_coins
|
||||||
|
|
||||||
@ -24,8 +24,8 @@ def main() -> None:
|
|||||||
help="a piggy bank file name. Missing .pb extension"
|
help="a piggy bank file name. Missing .pb extension"
|
||||||
"will be added")
|
"will be added")
|
||||||
parser.add_argument("coins", type=int, nargs="+", metavar="COIN",
|
parser.add_argument("coins", type=int, nargs="+", metavar="COIN",
|
||||||
help="a set of coins to add to a piggy bank. A new file"
|
help="a set of coins to add. A new file will be"
|
||||||
"will be created if it doesn't exist")
|
"created if it doesn't exist")
|
||||||
|
|
||||||
parser.add_argument("-c", "--currency", type=str, default=DEFAULT_CURRENCY,
|
parser.add_argument("-c", "--currency", type=str, default=DEFAULT_CURRENCY,
|
||||||
help="set currency of a piggy bank. Not applicable to"
|
help="set currency of a piggy bank. Not applicable to"
|
||||||
|
@ -5,10 +5,10 @@ from os.path import exists
|
|||||||
from sys import exit, stderr
|
from sys import exit, stderr
|
||||||
|
|
||||||
from piggybank import print_program_version, PIGGYBANK_FILE_EXTENSION
|
from piggybank import print_program_version, PIGGYBANK_FILE_EXTENSION
|
||||||
from piggybank.piggybank import PiggyBank
|
|
||||||
from piggybank.cli import EPILOGUE
|
from piggybank.cli import EPILOGUE
|
||||||
from piggybank.currencies import CURRENCIES, DEFAULT_CURRENCY, \
|
from piggybank.currencies import CURRENCIES, DEFAULT_CURRENCY, \
|
||||||
BaseCurrencyError, print_supported_currencies
|
BaseCurrencyError, print_supported_currencies
|
||||||
|
from piggybank.piggybank import PiggyBank
|
||||||
from piggybank.util import add_common_arguments_to_parser
|
from piggybank.util import add_common_arguments_to_parser
|
||||||
|
|
||||||
__all__ = ["main"]
|
__all__ = ["main"]
|
||||||
@ -18,7 +18,10 @@ DEFAULT_COIN_CENTERING: int = 10
|
|||||||
|
|
||||||
def print_summary(piggybank: PiggyBank,
|
def print_summary(piggybank: PiggyBank,
|
||||||
centering: int = DEFAULT_COIN_CENTERING) -> None:
|
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="┫"):
|
def print_separator(left="┣", lmiddle="╋", rmiddle="╋", right="┫"):
|
||||||
line = rmiddle.join('━' * centering
|
line = rmiddle.join('━' * centering
|
||||||
for _ in
|
for _ in
|
||||||
@ -56,14 +59,14 @@ def print_transactions(piggybank, centering=DEFAULT_COIN_CENTERING):
|
|||||||
|
|
||||||
cline = "┃".join([f'{l:^{centering}}'
|
cline = "┃".join([f'{l:^{centering}}'
|
||||||
for l in CURRENCIES[piggybank.currency]["names"]])
|
for l in CURRENCIES[piggybank.currency]["names"]])
|
||||||
# cline_len = len(cline)
|
|
||||||
|
|
||||||
print_separator()
|
print_separator()
|
||||||
print(f"┃{'Timestamp':^21}┃ I/O ┃{cline}┃")
|
print(f"┃{'Timestamp':^21}┃ I/O ┃{cline}┃")
|
||||||
print_separator("┣", "╋", "┫")
|
print_separator("┣", "╋", "┫")
|
||||||
for tr in piggybank.transactions:
|
for tr in piggybank.transactions:
|
||||||
coin_line = "┃".join([f'{c:^{centering}}' for c in tr.coins])
|
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("┗", "┻", "┛")
|
print_separator("┗", "┻", "┛")
|
||||||
|
|
||||||
|
|
||||||
@ -83,7 +86,7 @@ def main():
|
|||||||
parser.add_argument("-m", "--merge", action="append",
|
parser.add_argument("-m", "--merge", action="append",
|
||||||
type=str, metavar="FILE",
|
type=str, metavar="FILE",
|
||||||
help="merge multiple files to show how much do you"
|
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)
|
add_common_arguments_to_parser(parser, include_reverse_flag=False)
|
||||||
|
|
||||||
|
@ -4,10 +4,10 @@ from argparse import ArgumentParser
|
|||||||
from sys import exit, stderr
|
from sys import exit, stderr
|
||||||
|
|
||||||
from piggybank import print_program_version
|
from piggybank import print_program_version
|
||||||
from piggybank.piggybank import PiggyBank
|
|
||||||
from piggybank.cli import EPILOGUE
|
from piggybank.cli import EPILOGUE
|
||||||
from piggybank.currencies import CURRENCIES, DEFAULT_CURRENCY, \
|
from piggybank.currencies import CURRENCIES, DEFAULT_CURRENCY, \
|
||||||
BaseCurrencyError, print_supported_currencies
|
BaseCurrencyError, print_supported_currencies
|
||||||
|
from piggybank.piggybank import PiggyBank
|
||||||
from piggybank.transaction import TYPE_OUTCOME
|
from piggybank.transaction import TYPE_OUTCOME
|
||||||
from piggybank.util import add_common_arguments_to_parser, \
|
from piggybank.util import add_common_arguments_to_parser, \
|
||||||
complement_array_of_coins
|
complement_array_of_coins
|
||||||
@ -24,8 +24,8 @@ def main():
|
|||||||
help="a coin box file name. Missing .cb extension will"
|
help="a coin box file name. Missing .cb extension will"
|
||||||
"be added")
|
"be added")
|
||||||
parser.add_argument("coins", type=int, nargs="+", metavar="COIN",
|
parser.add_argument("coins", type=int, nargs="+", metavar="COIN",
|
||||||
help="add a set of coins to a coin box. A new file"
|
help="add a set of coins. A new file will be created"
|
||||||
"will be created if it doesn't exist")
|
"if it doesn't exist")
|
||||||
|
|
||||||
add_common_arguments_to_parser(parser)
|
add_common_arguments_to_parser(parser)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user