1
0

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:
Alexander "Arav" Andreev 2019-12-29 18:26:37 +04:00 committed by Alexander Arav Andreev
parent 26777a7742
commit ca5d2157c8
3 changed files with 14 additions and 11 deletions

View File

@ -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"

View File

@ -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)

View File

@ -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)