Skip to main content

Python version of old BSD Unix fortune program

Project description

# Introduction

fortune is a stripped-down implementation of the classic BSD Unix fortune command. It combines the capabilities of the strfile command (which produces the fortune index file) and the fortune command (which displays a random fortune). It reads the traditional fortune program’s text file format.

# Usage

Usage:

fortune [OPTIONS] /path/to/fortunes

OPTIONS

-h, --help

Show usage and exit.

-u, --update

Update the index file.

-q, --quiet

When updating the index file, do so quietly.

-V, --version

Show version and exit.

If you omit the path, fortune looks at the FORTUNE_FILE environment variable. If that environment variable isn’t set, fortune aborts.

# Fortune Cookie File Format

A fortune cookie file is a text file full of quotes. The format is simple: The file consists of paragraphs separated by lines containing a single ‘%’ character. For example:

A little caution outflanks a large cavalry.
    -- Bismarck
%
A little retrospection shows that although many fine, useful software
systems have been designed by committees and built as part of multipart
projects, those software systems that have excited passionate fans are
those that are the products of one or a few designing minds, great
designers. Consider Unix, APL, Pascal, Modula, the Smalltalk interface,
even Fortran; and contrast them with Cobol, PL/I, Algol, MVS/370, and
MS-DOS.
    -- Fred Brooks, Jr.
%
A man is not old until regrets take the place of dreams.
    -- John Barrymore

# Generating a Random Fortune

Just run:

fortune /path/to/fortunes

If your FORTUNE_FILE environment variable is set, you can run it as

fortune

# Differences

This version of fortune does not provide some of the more advanced capabilities of the original BSD program. For instance, it lacks:

  • the ability to mark offensive and inoffensive fortunes

  • the ability to separate long and short quotes

  • the ability to print all fortunes matching a regular expression

It does, however, provide the most important function: The ability to display a random quote from a set of quotes.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fortune-1.1.1.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

fortune-1.1.1-py2.py3-none-any.whl (9.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file fortune-1.1.1.tar.gz.

File metadata

  • Download URL: fortune-1.1.1.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for fortune-1.1.1.tar.gz
Algorithm Hash digest
SHA256 7c59a7442f6b1e0e7abe5d524fc23ede8c60478967d95b629bcde38ba7773e1c
MD5 5500c445e6a27c2a9068f721be9d962b
BLAKE2b-256 5fcba634b313615961012775d8b4ab03e0bac853396c976c3e77ded8e0404af4

See more details on using hashes here.

File details

Details for the file fortune-1.1.1-py2.py3-none-any.whl.

File metadata

  • Download URL: fortune-1.1.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for fortune-1.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 67cf3dae7bc9685af98dfb4476878018598664e65ffe1aad0d359ec0dc92d058
MD5 fa8d4079282689806c5f6f709c8ce9a3
BLAKE2b-256 ad489e4b4bba762eb059601fbfece3cc0cfef87d2688d1dddb91d0c361ad682f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page