1
0
Keep track of your piggy bank.
Go to file
2020-06-07 04:47:15 +04:00
piggybank Final rewrite of CLI arguments form. Now program has single entry point that serves everything. README to be updated. 2020-06-07 04:47:15 +04:00
.gitignore Performed some refactoring on an existing code base before further work. 2020-03-27 20:14:22 +04:00
COPYING Initial commit adding everything that consists the project. 2019-12-25 23:08:20 +04:00
Makefile Nah, I don't want to remove distributions. 2020-06-05 04:23:32 +04:00
pyproject.toml --user flag added in Makefile. Added a pyproject.toml file. setup.cfg fixed. 2020-06-05 03:50:21 +04:00
README.md Added possibility to add missing currencies through config. 2020-06-06 03:00:36 +04:00
setup.cfg Final rewrite of CLI arguments form. Now program has single entry point that serves everything. README to be updated. 2020-06-07 04:47:15 +04:00
setup.py Initial commit adding everything that consists the project. 2019-12-25 23:08:20 +04:00

Keep track of your piggy bank.

Every time you put coins in or take them out of your piggy bank, write here down how much did you put or take. So you won't have to spend time counting them when you decide to take them all out.

Yes, only coins, no banknots. Well, you actually can easily add support for banknots, but table will become indeed wide.

Backstory

Many years ago I wrote a little script to store info on how much coins I have in my piggy bank. It used SQLite 3 database for it and was hardcoded to rubles. Why had I use whole SQL database? That was the first time I tried SQLite in Python.

Once I came up with an idea that it would be good to learn on how to make packages for Python. And with no better ideas I took my piggy bank script to be rewritten to support any currency. Database was thrown away and its place was took by a simple text format.

Usage

This is a CLI program that is broken down to three separate programs:

  • piggybank-put — puts coins in a piggy bank and create a new one if there is no such file;
  • piggybank-take — takes coins from an existsing piggy bank file;
  • piggybank-show — shows summarised information on a piggy bank and, optionally, print a list of transactions.

Common flags

piggybank-* [(-h | --help) | (-v | --version) | (-L | --list-currencies)
	| --set-default-currency]

These flags are used with every sub-program.

--help to show help.

--version to show version of program.

--list-currencies to show what currencies supported and which one is default.

--set-default-currency to set a currency of your choice as default one.

How to put coins in

piggybank-put [-r | --reverse] COINS in FILE of CURRENCY

--reverse flag reverses the order of coins. By default they come from least significant face value to the most significant one and as stated above being complemented from left so a set shorter than number of coins in a currency, e.g. 5 8 4 will be interpreted as 0 0 0 5 8 4. And this flag will make it to be interpreted as 5 8 4 0 0 0. It is convenient if you want to add only coins of low face value (e.g. cents).

COINS is a set of coins' counts separated with space or comma character. For example: 0 5 0 4 6 7. By default trailing zeroes will be added from the left. So if you wrote something like 6 0 5 12 then it will be complemented to 0 0 6 0 5 12 if currency has 6 coins.

FILE is a name of a piggy bank file wich may not have a .pb extension at the end, it will be added automatically.

CURRENCY specifies the currency of a new piggy bank. It will not change currency of an existing piggy bank. ISO standard is used, e.g. EUR. Case-insensitive.

Examples:

piggybank-put 7 4 3 0 5 in example.pb  of EUR
piggybank-put -r 0 4 6 in example

How to take coins out

piggybank-take [-r | --reverse] COINS in FILE

All the parameters are explained above.

Examples:

piggybank-take -r 0 0 4 from example.pb

How to see what you have in there

piggybank-show FILE [ with (t | transactions)]

It will print a summary table of what is stored in a piggy bank.

with t(ransactions) will print also a table of all transactions stored in a file.

Examples:

piggybank-show example.pb with t

Configuration

Configuration file piggybank.conf is stored in directory specified by $XDG_CONFIG_HOME environment variable or, if it isn't set, in $HOME/.config on Linux and in %APPDATA% on Windows.

By default it has following content:

default-currency = SRUB

Aside from default-currency there is also a currency.* parameter. * is a currency's ISO code, e.g. currency.RUB, currency.USD, currency.EUR etc. This parameter allows you to add a currency needed for you, but not presented in program.

Currency is defined following way:

currency.ISO = ISO;NAME;DESCRIPTION;COINS_COUNT;COINS_NAME;FACE_VALUES

That is best described with an example. Here it is:

currency.SRUB = SRUB;Russian ruble (shortened);Russian Federation. Excluding coins of 1 and 5 kopek;6;10к.,50к.,1₽,2₽,5₽,10₽;10,50,100,200,500,1000

Yes, long and clunky way... May be I'll come up with something better.