Python Fortune Program
|
Download
To obtain my PGP/GnuPG key, see these instructions. DocumentationBack to software page. |
Introductionfortune 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. Usagefortune [OPTIONS] /path/to/fortunes Fortune Cookie File FormatA 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:
The Index FileFor efficiency and speed, fortune uses an index file to store the offsets and lengths of every fortune in the text fortune file. So, before you can use fortune to read a random fortune, you have to generate the data file. With the traditional BSD fortune program, you used the strfile(8) command to generate the index. With this fortune program, however, you simply pass a special argument to the fortune command: fortune -u /path/to/fortunes That command will generate a binary /path/to/fortunes.dat file that contains the index. You should run fortune -u whenever you change the text fortune file. Generating a Random FortuneOnce you have an index file, you can generate a random fortune simply by running the fortune utility with the path to your text fortunes file: fortune /path/to/fortunes DifferencesThis version of fortune does not provide some of the more advanced capabilities of the original BSD program. For instance, it lacks:
It does, however, provide the most important function: The ability to display a random quote from a set of quotes. InstallationThe usual:
easy_install fortune AuthorBrian M. Clapper, <bmc @ clapper . org> Copyright© 2008 Brian M. Clapper LicenseBSD-style license. See accompanying LICENSE file. $Id: index.html,v 1.7 2005/05/20 14:37:58 bmc Exp $
|