lfortune


Namelfortune JSON
Version 0.3.2 PyPI version JSON
download
home_pagehttps://github.com/lbacik/fortune
SummaryGood old fortunes!
upload_time2022-12-18 10:54:47
maintainer
docs_urlNone
authorŁukasz Bacik
requires_python
licenseGPLv3
keywords
VCS
bugtrack_url
requirements simple_value_object
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Fortune

![Python application](https://github.com/lbacik/fortune/workflows/Python%20application/badge.svg)
[![codecov](https://codecov.io/gh/lbacik/fortune/branch/master/graph/badge.svg?token=W8LPOUVRSX)](https://codecov.io/gh/lbacik/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](https://salsa.debian.org/search?utf8=✓&search=fortune&group_id=&project_id=&snippets=false&repository_ref=&nav_source=navbar) 

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



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/lbacik/fortune",
    "name": "lfortune",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "\u0141ukasz Bacik",
    "author_email": "mail@luka.sh",
    "download_url": "https://files.pythonhosted.org/packages/78/1a/d9e37a7d3d4a05ecfd85d45c6edcb522c8377842ed39e3b941aaaddd5c06/lfortune-0.3.2.tar.gz",
    "platform": null,
    "description": "# Fortune\n\n![Python application](https://github.com/lbacik/fortune/workflows/Python%20application/badge.svg)\n[![codecov](https://codecov.io/gh/lbacik/fortune/branch/master/graph/badge.svg?token=W8LPOUVRSX)](https://codecov.io/gh/lbacik/fortune)\n\nProgram allows to play with fortunes files in a very similar way to the original \"fortune\" app \n(https://en.wikipedia.org/wiki/Fortune_(Unix)); however, a few new features are planned!\n\nI have used \"l\" as a prefix for the console program version as the \"fortune\" name is already taken on PyPI.\n\n## Installation\n\n### PyPI\n\nhttps://pypi.org/project/lfortune/\n\nFor python3:\n\n    pip install lfortune\n    \nor (when the python2 is also installed):\n\n    pip3 install lfortune\n\nYou will need to separately install the fortunes file(s) and appropriately configure the app (see below) - to point \nwhere it can find these file(s).\n\n### Docker image\n\nhttps://hub.docker.com/r/lbacik/fortune\n\nThere is set an automated build on dockerhub for the project's master branch. This build includes the debian's fortunes \npackage (stable release).\n\n    docker run --rm lbacik/fortune \n\n### Build the docker image locally\n\n    git clone git@github.com:lbacik/fortune.git\n    git checkout BRANCH\n    docker build -t fortune:local . \n\n## Usage\n \n### docker\n\nIf you are using docker image - it already contains the fortune package, however, there is still a few packages/sets \nwhich you can add/try - check the `apt search fortune` ;).\n\nTo get to bash prompt in docker image say:\n\n    docker run --rm -ti --entrypoint=/bin/bash lbacik/fortune\n\n### macOS\n\nYou can install the original fortune's data files with `brew` (of course it also contains the \"fortune\" program):\n\n    brew install fortune \n\nNext see the \"configuration\" section (below).\n\n### other \n\nYou can just clone the fortune data files from any of its repositories, \ne.g: [debian salsa repos](https://salsa.debian.org/search?utf8=\u2713&search=fortune&group_id=&project_id=&snippets=false&repository_ref=&nav_source=navbar) \n\n## help\n\nTo get help:\n\n**1. when using docker image:**\n\n    docker run --rm lbacik/fortune --help\n    \n**2. when installed locally:**\n\n    $ lfortune --help         \n    usage: lfortune [-h] [-p [PATH]] [-c [CONFIG]] [--copy-config [COPY_CONFIG]] [--show-config] [--show-fortunes] \n                    [db ...]\n    \n    positional arguments:\n      db                    fortunes db(s) - file(s)/directory(ies) (without root_path), optionally prepended with a\n                            percentage chance of a hit, e.g: lfortune 50% computers art 40% tao (in this example art\n                            will have 10%)\n    \n    optional arguments:\n      -h, --help            show this help message and exit\n      -p [PATH], --path [PATH]\n                            file/directory to get random fortune from (overrides the root_path, it can be also set as\n                            FORTUNES environment variable)\n      -c [CONFIG], --config [CONFIG]\n                            config file to use\n      --copy-config [COPY_CONFIG]\n                            copy config file. You can provide the dest, the default is ~/.config/lfortune/config.ini\n      --show-config         show settings and exit\n      --show-fortunes       show fortunes (only the first positional argument is used)\n    \n    2020 \u0141ukasz Bacik <mail@luka.sh> https://github.com/lbacik/fortune\n\n## Configuration\n\nThe `lfortune` app (installed locally) will have to know where it can find the fortunes data files. \nThis information can be pass to the app on various ways:\n\n**1. by the** `-p` **argument** \n\nLet assume we are using macOS, and you have installed the fortune files by the `brew` command (`brew install fortune`).\nYou can check where they had been copied by:\n\n    $ brew list fortune\n    /usr/local/Cellar/fortune/9708/bin/fortune\n    /usr/local/Cellar/fortune/9708/bin/strfile\n    /usr/local/Cellar/fortune/9708/bin/unstr\n    /usr/local/Cellar/fortune/9708/share/games/ (70 files)\n    /usr/local/Cellar/fortune/9708/share/man/ (3 files)\n\n    $ ls /usr/local/Cellar/fortune/9708/share/games/                                   \n    fortunes\n    \n    $ ls /usr/local/Cellar/fortune/9708/share/games/fortunes  \n    ... a lot of files...\n     \n So, the fortune's data files can be found at `/usr/local/Cellar/fortune/9708/share/games/fortunes`, \n in such a case you can get the random fortune by: \n \n    $ lfortune -p /usr/local/Cellar/fortune/9708/share/games/fortunes       \n \n**2. by the environment variable**\n \n The env variable which the fortune app is looking for is `FORTUNES`:\n \n    $ export FORTUNES=/usr/local/Cellar/fortune/9708/share/games/fortunes\n    $ lfortune\n    \n**3. by the config file**\n \n To copy the config file to your home directory you can use:\n \n    $ lfortune --copy-config\n    \nThen the file is available at `~/.config/lfortune/config.ini` - you can set the fortune's data dir by setting \nthe `root` parameter.    \n \n## Examples\n\n`lfortune` can be always replaced by the `docker run --rm lbacik/fortune`\n\n\n    $ lfortune --show-config                                             \n    ConfigValues(root_path=/usr/local/Cellar/fortune/9708/share/games/fortunes)\n\n---\n\n    $ lfortune --show-fortunes \n    PATH: /usr/local/Cellar/fortune/9708/share/games/fortunes\n    computers\n    riddles\n    men-women\n    literature\n    love\n    magic\n    linuxcookie\n    ...    \n\n---\n\n    $ lfortune --show-fortunes computers | tail\n    %\n    Your mode of life will be changed to ASCII.\n    %\n    Your mode of life will be changed to EBCDIC.\n    %\n    Your password is pitifully obvious.\n    %\n    Your program is sick!  Shoot it and put it out of its memory.\n    %\n\n---\n\nRandom generation from all the files in the `root` directory (and its subdirectories, what probably should be fixed):\n    \n    $ lfortune\n\n---\n    \nRandom generation from the file:\n\n    $ lfortune magic\n    \"The first rule of magic is simple.  Don't waste your time waving your\n    hands and hoping when a rock or a club will do.\"\n                    -- McCloctnik the Lucid\n\n---\n\nSetting the percentage probability (linuxcookie will have had assigned the probability of 60%):\n\n    $ lfortune 20% computers 20% magic linuxcookie\n    \"I once witnessed a long-winded, month-long flamewar over the use of\n    mice vs. trackballs...It was very silly.\"\n    (By Matt Welsh)\n\n\n",
    "bugtrack_url": null,
    "license": "GPLv3",
    "summary": "Good old fortunes!",
    "version": "0.3.2",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "021c324278eb769d85895341971cb5dc",
                "sha256": "3252ae8c9a9b79136f5374072de92048ab27c98ab123540282af9f879fb80002"
            },
            "downloads": -1,
            "filename": "lfortune-0.3.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "021c324278eb769d85895341971cb5dc",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 31278,
            "upload_time": "2022-12-18T10:54:44",
            "upload_time_iso_8601": "2022-12-18T10:54:44.928867Z",
            "url": "https://files.pythonhosted.org/packages/bd/f6/aaef8d3e5fae3cea68b1e4ab0ed2766c70b471f8d49a2139a433580f0374/lfortune-0.3.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "2d0a945c62963f44effe6ac07fe7d716",
                "sha256": "61ee14fddfe72d7b14c42870d2af7c34e7b7d486ba554de54bfea68105d11790"
            },
            "downloads": -1,
            "filename": "lfortune-0.3.2.tar.gz",
            "has_sig": false,
            "md5_digest": "2d0a945c62963f44effe6ac07fe7d716",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 25795,
            "upload_time": "2022-12-18T10:54:47",
            "upload_time_iso_8601": "2022-12-18T10:54:47.932728Z",
            "url": "https://files.pythonhosted.org/packages/78/1a/d9e37a7d3d4a05ecfd85d45c6edcb522c8377842ed39e3b941aaaddd5c06/lfortune-0.3.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-18 10:54:47",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "lbacik",
    "github_project": "fortune",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "simple_value_object",
            "specs": [
                [
                    "==",
                    "1.5"
                ]
            ]
        }
    ],
    "lcname": "lfortune"
}
        
Elapsed time: 0.01808s