This app calculates your monthly newspaper bill. Requires SQLite>=3.35 (and Python>=3.9 if you intend to develop anything, instead of just using the executables).
- Each newspaper has a certain cost per day of the week
- Each newspaper may or may not be delivered on a given day
- Each newspaper has a name, and a number called a key
- You may register any dates when you didn't receive a paper in advance using the
addudl
command - Once you calculate, the results are displayed and logged.
-
From the latest release, download the "updater" file for your operating system in any folder, and make it executable.
Recommended locations, where the CLI will always download.
OS Location Linux ~/bin/npbc/npbc
macOS ~/Applications/npbc/npbc
Windows ~\.npbc\bin\npbc.exe
-
Run the following command:
/path/to/updater update
-
You can now run
path/to/updater init
to begin.
Alternatively, just run these scripts. You'll need to have wget installed.
For Linux systems, run:
mkdir -p ~/bin/npbc
wget https://github.com/eccentricOrange/npbc/releases/latest/download/npbc_updater-linux-x64 -O ~/bin/npbc/npbc
chmod +x ~/bin/npbc/npbc
~/bin/npbc/npbc init
echo "alias npbc=\"~/bin/npbc/npbc\"" >> ~/.bashrc
exec "$SHELL"
For macOS systems, run:
mkdir -p ~/Applications/npbc
wget https://github.com/eccentricOrange/npbc/releases/latest/download/npbc_updater-macos-x64 -O ~/Applications/npbc/npbc
chmod +x ~/Applications/npbc/npbc
~/bin/Applications/npbc init
echo "alias npbc=\"~/Applications/npbc/npbc\"" >> ~/.bashrc
exec "$SHELL"
For Windows systems, run the following from PowerShell and add ~\.npbc\bin
to PATH:
mkdir -p "~\.npbc\bin";
wget https://github.com/eccentricOrange/npbc/releases/latest/download/npbc_updater-windows-x64.exe -O "~\.npbc\bin\npbc.exe";
& "~\.npbc\bin\npbc.exe" init;
This application helps you calculate monthly newspaper bills. The goal is to generate a message that I can paste into WhatsApp and send to my newspaper vendor. The end result here is a CLI tool that will be later used as a back-end to build GUIs (hence learn about: C#, HTML/CSS/JS, Flutter). In its current form, everything will be "compiled" by PyInstaller into one-file stand-alone executables for the end-user using GitHub Actions.
The other important goal was to be a testbed for learning a bunch of new tools: more Python libraries, SQL connectors, GitHub Actions (CI/CD, if I understand correctly), unit tests, CLI libraries, type-hinting, regex. I had earlier built this on a different platform, so I now have a solid idea of how this application is used.
(ignoring conventional ones like README
and requirements.txt
)
File | Purpose/Description |
---|---|
npbc_core.py |
Provide the core functionality: the calculation, parsing and validation of user input, interaction with the DB etc. Later on, some functionality from this will be extracted to create server-side code that can service more users, but I have to learn a lot more before getting there. |
npbc_regex.py |
Contains all the regex statements used to validate and parse user input. |
npbc_exceptions.py |
Defines classes for all the custom exceptions used by the core and the CLI. |
npbc_cli.py |
Import functionality from npbc_core.py and wrap a CLI layer on it using argparse . Also provide some additional validation. |
npbc_updater.py |
Provide a utility to update the application on the user's end. |
test_core.py |
Test the functionality of the core file (pytest), except anything to do with the database. |
test_db.py |
Test the functionality of the core file (pytest), for anything to do with the database. |
test_regex.py |
Test the functionality of the regex statements. |
data/schema.sql |
Database schema. In my local environment, the data folder also has a test database file (but I don't want to upload this online). |
data/test.sql |
SQL statements to generate test data for test_db.py . |
test.dockerfile |
Provide an environment for the PyTest to run, because the project needs SQLite>=3.35, which does not ship with most stable Debian Bullseye or Ubuntu 20 systems. This is available as built image from Docker Hub as eccentricorange/npbc:test . |