跳转到主要内容

metasyntactic - 主题化元语法的变量名

项目描述

版本:
1.0.14

摘要

这是一个由Phillipe (BooK) Bruhat编写的优秀Perl模块Acme::MetaSyntactic的端口。

实际上它是从Acme::MetaSynctacic自动生成的。这个特定版本是从版本0.99生成的。

原始CONTRIBUTORS文件包含在这个发行版中。

使用方法

通用

获取所有主题列表

>>> import metasyntactic
>>> metasyntactic.all_themes
set(...)

获取随机主题

>>> metasyntactic.random()
<module 'metasyntactic.themes.stars' from 'metasyntactic/themes/stars.py'>

从随机主题获取随机元变量

>>> metasyntactic.random().random()
['Barbouille']

从随机主题获取4个随机元变量

>>> metasyntactic.random().random(4)
['eve', 'irene', 'frank', 'ellen']

从4个随机主题获取随机元变量

>>> [theme.random() for theme in metasyntactic.random(4)]
['Barbouille', 'Fragarach', 'Grumpy', 'the_Lord_of_the_Rings']

从4个随机主题获取2个随机元变量

>>> [theme.random(2) for theme in metasyntactic.random(4)]
[['Lupa', 'Civetta'],
 ['spigot', 'physique'],
 ['Patrice_Petit', 'Yvette_Chauvire'],
 ['GiNG_GiNG', 'DOINK_DOINK_DOINK_DOINK']]

主题

# Get theme by theme name
>>> foo = metasyntactic.get("foo")
>>> foo
<module 'metasyntactic.themes.foo' from 'metasyntactic/themes/foo.py'>

# Get random name
>>> foo.random()
'fubar'

# Get several random names.
>>> foo.random(8)
['bar', 'xyzzy', 'foobar', 'thud', 'foo', 'fred', 'garply', 'quux']

# Get all names
>>> foo.all()
set(....)

分类

# Get random name in specific category
>>> foo.random(8, category="fr")
['truc', 'test1', 'machin', 'titi', 'tutu', 'pipo', 'test2', 'tata']

# get default category
>>> foo.default()
'en'

# get all available categories
>>> foo.categories()
set(['en', 'fr', 'nl'])

# get all names in specific category
>>> foo.all(category="fr")
set(...)

>>> yapc = metasyntactic.get("yapc")

>>> yapc.random(4, section="america north")
['Buffalo', 'Pittsburgh', 'Boca_Raton', 'Saint_Louis']

>>> yapc.sections()
set(['america north',
     'america south',
     'asia',
     'australia',
     'brazil',
     'canada',
     'europe',
     'israel',
     'taipei'])

安装

您可以通过Python包索引(PyPI)或源代码安装metasyntactic

要使用pip安装,

$ pip install metasyntactic

要使用easy_install安装,

$ easy_install metasyntactic

如果您已经下载了源代码包,您可以按照以下步骤安装,

$ python setup.py build
# python setup.py install # as root

错误跟踪器

如果您有任何建议、错误报告或困扰,请向我们的问题跟踪器报告,网址为 http://github.com/ask/metasyntactic/issues/

许可证

本软件遵循 艺术许可证。我不会为这项工作保留任何版权,因为所有的辛勤工作都应该归功于原始作者。

项目详情


下载文件

下载您平台对应的文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。

源代码分发

metasyntactic-1.0.14.tar.gz (336.9 kB 查看哈希值)

上传时间 源代码

构建分发

metasyntactic-1.0.14-py3-none-any.whl (421.6 kB 查看哈希值)

上传时间 Python 3

支持