旧bsd unix fortune程序的python版本
fortune的Python项目详细描述
#简介
《财富》杂志是经典bsd unix的精简实现 《财富》杂志它结合了strfile命令的功能 (它生成财富索引文件)和fortune命令(它 显示随机财富)。它读取传统的 文本文件格式。
#用法
用法:
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.
如果省略路径,fortune查看fortune\u文件环境 变量。如果未设置该环境变量,fortune将中止。
#Fortune Cookie文件格式
Fortune Cookie文件是一个包含引号的文本文件。格式很简单: 文件由包含单个“%”的行分隔的段落组成 性格。例如:
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
#产生随机财富
只需运行:
fortune /path/to/fortunes
如果设置了fortune\u文件环境变量,则可以将其运行为
fortune
#差异
这个版本的《财富》杂志并没有提供一些更先进的 原始bsd程序的功能。例如,它缺少:
- 能够标记进攻性和非进攻性财富
- 区分长引号和短引号的能力
- 能够打印与正则表达式匹配的所有财富
不过,它确实提供了最重要的功能:显示 一组引号中的随机引号。