Fortune
Program allows to play with fortunes files in a very similar way to the original "fortune" app (https://en.wikipedia.org/wiki/Fortune_(Unix)); however, a few new features are planned!
I have used "l" as a prefix for the console program version as the "fortune" name is already taken on PyPI.
Installation
PyPI
https://pypi.org/project/lfortune/
For python3:
pip install lfortune
or (when the python2 is also installed):
pip3 install lfortune
You will need to separately install the fortunes file(s) and appropriately configure the app (see below) - to point where it can find these file(s).
Docker image
https://hub.docker.com/r/lbacik/fortune
There is set an automated build on dockerhub for the project's master branch. This build includes the debian's fortunes package (stable release).
docker run --rm lbacik/fortune
Build the docker image locally
git clone git@github.com:lbacik/fortune.git
git checkout BRANCH
docker build -t fortune:local .
Usage
docker
If you are using docker image - it already contains the fortune package, however, there is still a few packages/sets
which you can add/try - check the apt search fortune ;).
To get to bash prompt in docker image say:
docker run --rm -ti --entrypoint=/bin/bash lbacik/fortune
macOS
You can install the original fortune's data files with brew (of course it also contains the "fortune" program):
brew install fortune
Next see the "configuration" section (below).
other
You can just clone the fortune data files from any of its repositories, e.g: debian salsa repos
help
To get help:
1. when using docker image:
docker run --rm lbacik/fortune --help
2. when installed locally:
$ lfortune --help
usage: lfortune [-h] [-p [PATH]] [-c [CONFIG]] [--copy-config [COPY_CONFIG]] [--show-config] [--show-fortunes]
[db ...]
positional arguments:
db fortunes db(s) - file(s)/directory(ies) (without root_path), optionally prepended with a
percentage chance of a hit, e.g: lfortune 50% computers art 40% tao (in this example art
will have 10%)
optional arguments:
-h, --help show this help message and exit
-p [PATH], --path [PATH]
file/directory to get random fortune from (overrides the root_path, it can be also set as
FORTUNES environment variable)
-c [CONFIG], --config [CONFIG]
config file to use
--copy-config [COPY_CONFIG]
copy config file. You can provide the dest, the default is ~/.config/lfortune/config.ini
--show-config show settings and exit
--show-fortunes show fortunes (only the first positional argument is used)
2020 Łukasz Bacik <mail@luka.sh> https://github.com/lbacik/fortune
Configuration
The lfortune app (installed locally) will have to know where it can find the fortunes data files.
This information can be pass to the app on various ways:
1. by the -p argument
Let assume we are using macOS, and you have installed the fortune files by the brew command (brew install fortune).
You can check where they had been copied by:
$ brew list fortune
/usr/local/Cellar/fortune/9708/bin/fortune
/usr/local/Cellar/fortune/9708/bin/strfile
/usr/local/Cellar/fortune/9708/bin/unstr
/usr/local/Cellar/fortune/9708/share/games/ (70 files)
/usr/local/Cellar/fortune/9708/share/man/ (3 files)
$ ls /usr/local/Cellar/fortune/9708/share/games/
fortunes
$ ls /usr/local/Cellar/fortune/9708/share/games/fortunes
... a lot of files...
So, the fortune's data files can be found at /usr/local/Cellar/fortune/9708/share/games/fortunes,
in such a case you can get the random fortune by:
$ lfortune -p /usr/local/Cellar/fortune/9708/share/games/fortunes
2. by the environment variable
The env variable which the fortune app is looking for is FORTUNES:
$ export FORTUNES=/usr/local/Cellar/fortune/9708/share/games/fortunes
$ lfortune
3. by the config file
To copy the config file to your home directory you can use:
$ lfortune --copy-config
Then the file is available at ~/.config/lfortune/config.ini - you can set the fortune's data dir by setting
the root parameter.
Examples
lfortune can be always replaced by the docker run --rm lbacik/fortune
$ lfortune --show-config
ConfigValues(root_path=/usr/local/Cellar/fortune/9708/share/games/fortunes)
$ lfortune --show-fortunes
PATH: /usr/local/Cellar/fortune/9708/share/games/fortunes
computers
riddles
men-women
literature
love
magic
linuxcookie
...
$ lfortune --show-fortunes computers | tail
%
Your mode of life will be changed to ASCII.
%
Your mode of life will be changed to EBCDIC.
%
Your password is pitifully obvious.
%
Your program is sick! Shoot it and put it out of its memory.
%
Random generation from all the files in the root directory (and its subdirectories, what probably should be fixed):
$ lfortune
Random generation from the file:
$ lfortune magic
"The first rule of magic is simple. Don't waste your time waving your
hands and hoping when a rock or a club will do."
-- McCloctnik the Lucid
Setting the percentage probability (linuxcookie will have had assigned the probability of 60%):
$ lfortune 20% computers 20% magic linuxcookie
"I once witnessed a long-winded, month-long flamewar over the use of
mice vs. trackballs...It was very silly."
(By Matt Welsh)
Metadata
Release files for lfortune 0.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| lfortune-0.3.2.tar.gz | 25.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| lfortune-0.3.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 57.1 kB
Release files / lfortune-0.3.2.tar.gz
| Download URL | lfortune-0.3.2.tar.gz |
|---|---|
| Size | 25.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
61ee14fddfe72d7b14c42870d2af7c34e7b7d486ba554de54bfea68105d11790
|
|
BLAKE2b-256 checksum How to use checksums |
781ad9e37a7d3d4a05ecfd85d45c6edcb522c8377842ed39e3b941aaaddd5c06
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.3
|
Release files / lfortune-0.3.2-py3-none-any.whl
| Download URL | lfortune-0.3.2-py3-none-any.whl |
|---|---|
| Size | 31.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3252ae8c9a9b79136f5374072de92048ab27c98ab123540282af9f879fb80002
|
|
BLAKE2b-256 checksum How to use checksums |
bdf6aaef8d3e5fae3cea68b1e4ab0ed2766c70b471f8d49a2139a433580f0374
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.3
|
Security for lfortune 0.3.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.