旧bsd unix fortune程序的python版本

fortunate的Python项目详细描述


财富

简介

fortunate是经典bsd unix的精简实现 fortune命令。它结合了strfile命令的功能 (它生成财富索引文件)和fortunate命令(它 显示随机财富)。它读取传统程序的 文本文件格式。

此存储库包含一个fortune cookie数据库。它包含超过 布莱恩M克拉珀从1990年左右开始收集了2800条引文。

用法

用作命令行工具时:

Usage: fortunate [OPTIONS] [fortune_files ...]

Options:
-h, --help     show this help message and exit
-v, --verbose  when updating the index file, emit verbose messages
-u, --update   update the index file, instead of printing a fortune.
-V, --version  show version and exit.
-n NUM         number of fortune cookies to show

如果省略fortune文件/路径,fortunate将查看FORTUNE_FILE 环境变量。如果未设置该环境变量,fortunate/usr/local/share/games/fortunes中查找,否则将中止。

用作python库时:

fromfortunateimportFortunategenerator=Fortunate('/path/to/fortunes')print(generator())

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

索引文件

为了提高效率和速度,fortunate使用索引文件存储偏移量 以及财富文本文件中每个财富的长度。所以,在你使用之前 fortunate要读取随机财富,必须生成数据文件。与 在传统的bsd fortunate程序中,您使用了strfile(8)命令 生成索引。然而,使用thisfortune程序,您可以 在用户的主目录中,~/.fortunate内自动生成。

每当您更改文本财富文件时,应该运行fortunate -u, 因此可以生成一个新的索引。

产生随机财富

您可以通过运行fortunate实用程序生成随机财富 使用文本财富文件的路径:

fortunate /path/to/fortunes

差异

此版本的fortunate不提供一些更高级的 原始bsd程序的功能。例如,它缺少:

  • 能够标记进攻性和非进攻性财富
  • 区分长引号和短引号的能力
  • 能够打印与正则表达式匹配的所有财富

不过,它确实提供了最重要的功能:显示 一组引号中的随机引号。

许可证和版权信息

这是一款免费软件,根据以下类似BSD的许可证发布:

Copyright (c) 2018 German Mendez Bravo (Kronuz)
Copyright (c) 2008 Brian M. Clapper

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

- Redistributions of source code must retain the above copyright notice,
    this list of conditions and the following disclaimer.

- The end-user documentation included with the redistribution, if any,
    must include the following acknowlegement:

    This product includes software developed by Brian M. Clapper
    (bmc@clapper.org, http://www.clapper.org/bmc/). That software is
    copyright (c) 2008 Brian M. Clapper.

    Alternately, this acknowlegement may appear in the software itself, if
    and wherever such third-party acknowlegements normally appear.

THIS SOFTWARE IS PROVIDED AS IS AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BRIAN M.
CLAPPER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

此财富文件数据库在Creative Commons属性下提供 4.0国际许可证。详情请参阅 http://creativecommons.org/licenses/by/4.0/legalcode

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
box api如何使用box Java SDK从图像文件中获取特定大小的缩略图?   java无法从JNA使用python cffi调用DLL中定义的函数   java在linux中通过Jar文件发送电子邮件   使用lucene+hibernate的java查询时间连接   java在带有循环的arrayList中设置值   java为什么ImageReader返回错误的BuffereImage?   c#TCP数据有时接收顺序错误且不完整   java如果发生IOException,该InputStream是否会正确关闭?   tcp在Java中,如果不使用IP,如何获取MAC地址?   java从批处理方法调用中收集结果   java Android Studio RecyclerView在滚动图像时严重滞后   java如何使用OOP进行retrofti调用?   记录FileAppender在Java中如何工作   与S3连接期间收到java异常   java找不到JNDI资源Tomcat 7