RSC On This Day in Chemistry

Displays Royal Society of Chemistry “On This Day” facts.

Docs

Documentation Build Status Docs Check Status

Tests

Linux Test Status Windows Test Status macOS Test Status Coverage

PyPI

PyPI - Package Version PyPI - Supported Python Versions PyPI - Supported Implementations PyPI - Wheel

Activity

GitHub last commit GitHub commits since tagged version Maintenance PyPI - Downloads

QA

CodeFactor Grade Flake8 Status mypy status

Other

License GitHub top language Requirements Status

Installation

python3 -m pip install rsc_on_this_day --user

Once installed, rsc_on_this_day can be run by typing:

rsc_on_this_day

If rsc_on_this_day is not installed in a directory in $PATH, you may need to add ~/.local/bin/ to your $PATH.

Contents

Usage

rsc-on-this-day

Display the Royal Society of Chemistry “On This Day In Chemistry” fact for the given day.

If no date is given the current date is used.

rsc-on-this-day [OPTIONS] [MONTH] [DAY]

Options

--version

Show the version and exit.

--clear-cache

Clear any cached data and exit.

-w, --width <width>

The number of characters per line of the output. Set to -1 to disable wrapping.

Default

80

Arguments

MONTH

Optional argument. Default None

DAY

Optional argument. Default None

Examples

rsc_on_this_day
  • Display the “On This Day In Chemistry” fact for today.

rsc_on_this_day Apr 1
  • Display the “On This Day In Chemistry” fact for April 1st.

rsc_on_this_day 12 25
  • Display the “On This Day In Chemistry” fact for 25 December.

rsc_on_this_day --clear-cache
  • Clear any cached data.

rsc_on_this_day October 13 --width 80
  • Display the “On This Day In Chemistry” fact for October 13th, with at most 80 characters per line.

Adding to ~/.bashrc

rsc-on-this-day can be run every time you open a terminal by adding rsc-on-this-day to your ~/.bashrc file. For example:

echo "rsc-on-this-day" >> ~/.bashrc

API Reference

Displays Royal Society of Chemistry “On This Day In Chemistry” facts in your terminal.

Functions:

clear_cache()

Clear any cached responses.

get_fact([month, day])

Returns the fact for the given date.

clear_cache()[source]

Clear any cached responses.

Return type

int

get_fact(month=None, day=None)[source]

Returns the fact for the given date.

Parameters
  • month (Union[str, int, None]) – The month, either its short name (e.g. 'Oct'), its full name (e.g. 'October') or its number (e.g. 10). Default None.

  • day (Union[str, int, None]) – The day of the month. Default None.

If month and day are both left as None (the default) the current date is used.

Return type

Tuple[str, str]

Contributing

rsc_on_this_day uses tox to automate testing and packaging, and pre-commit to maintain code quality.

Install pre-commit with pip and install the git hook:

python -m pip install pre-commit
pre-commit install

Coding style

formate is used for code formatting.

It can be run manually via pre-commit:

pre-commit run formate -a

Or, to run the complete autoformatting suite:

pre-commit run -a

Automated tests

Tests are run with tox and pytest. To run tests for a specific Python version, such as Python 3.6:

tox -e py36

To run tests for all Python versions, simply run:

tox

Type Annotations

Type annotations are checked using mypy. Run mypy using tox:

tox -e mypy

Build documentation locally

The documentation is powered by Sphinx. A local copy of the documentation can be built with tox:

tox -e docs

Downloading source code

The rsc_on_this_day source code is available on GitHub, and can be accessed from the following URL: https://github.com/domdfcoding/rsc-on-this-day

If you have git installed, you can clone the repository with the following command:

git clone https://github.com/domdfcoding/rsc-on-this-day
Cloning into 'rsc-on-this-day'...
remote: Enumerating objects: 47, done.
remote: Counting objects: 100% (47/47), done.
remote: Compressing objects: 100% (41/41), done.
remote: Total 173 (delta 16), reused 17 (delta 6), pack-reused 126
Receiving objects: 100% (173/173), 126.56 KiB | 678.00 KiB/s, done.
Resolving deltas: 100% (66/66), done.
Alternatively, the code can be downloaded in a ‘zip’ file by clicking:
Clone or download –> Download Zip
Downloading a 'zip' file of the source code.

Downloading a ‘zip’ file of the source code

Building from source

The recommended way to build rsc_on_this_day is to use tox:

tox -e build

The source and wheel distributions will be in the directory dist.

If you wish, you may also use pep517.build or another PEP 517-compatible build tool.

View the Function Index or browse the Source Code.

Browse the GitHub Repository