一个将 cron 表达式转换为人类可读字符串的 Python 库。
项目描述
定时描述符
一个将 cron 表达式转换为人类可读字符串的 Python 库。从https://github.com/bradyholt/cron-expression-descriptor移植到 Python 。
作者:Adam Schubert ( https://www.salamek.cz )
原始作者和信用:Brady Holt ( http://www.geekytidbits.com )
许可证:麻省理工学院
特征
- 支持所有 cron 表达式特殊字符,包括 * / , - ? 长,#
- 支持 5、6(含秒或年)或 7(含秒和年)部分 cron 表达式
- 提供大小写选项(Sentence、Title、Lower 等)
- 支持 14 种语言的本地化
- 支持 Python 2.7 - 3.7
安装
使用画中画
pip install cron-descriptor
使用示例
# Simple
from cron_descriptor import get_description, ExpressionDescriptor
print(get_description("* 2 3 * *"))
#OR
print(str(ExpressionDescriptor("* 2 3 * *")))
# Advanced
# Consult Options.py/CasingTypeEnum.py/DescriptionTypeEnum.py for more info
from cron_descriptor import Options, CasingTypeEnum, DescriptionTypeEnum, ExpressionDescriptor
descripter = ExpressionDescriptor(
expression = "*/10 * * * *",
throw_exception_on_parse_error = True,
casing_type = CasingTypeEnum.Sentence,
use_24hour_time_format = True
)
# GetDescription uses DescriptionTypeEnum.FULL by default:
print(descripter.get_description())
print("{}".format(descripter))
#or passing Options class as second argument:
options = Options()
options.throw_exception_on_parse_error = True
options.casing_type = CasingTypeEnum.Sentence
options.use_24hour_time_format = True
descripter = ExpressionDescriptor("*/10 * * * *", options)
print(descripter.get_description(DescriptionTypeEnum.FULL))
可用语言
| 语 | 语言环境代码 | 贡献者 |
|---|---|---|
| 英语 | zh | 布雷迪霍尔特 |
| 巴西人 | pt_PT | 雷纳托·利马 |
| 简体中文 | zh_CN | 彭星 |
| 西班牙语 | es_ES | 伊万桑托斯 |
| 挪威 | nb_NO | 夏尔海伊·哈利普斯基 |
| 土耳其 | tr_TR | 穆斯塔法·萨德迪尔 |
| 荷兰语 | nl_NL | 总锤 |
| 俄语 | ru_RU | LBISS |
| 法语 | fr_FR | 阿诺·塔梅隆 |
| 德语 | de_DE | 迈克尔·舒勒 |
| 乌克兰 | uk_UA | 塔拉斯 |
| 意大利语 | it_IT | 里纳尔迪诺 |
| 捷克语 | cs_CZ | 亚当舒伯特 |
| 瑞典 | sv_SE | 奥克·恩格尔布雷克森 |
原始来源
端口
- Java - https://github.com/RedHogs/cron-parser
- 红宝石 - https://github.com/alpinweis/cronex
- Golang - https://github.com/jsuar/go-cron-descriptor
运行单元测试
python setup.py test
翻译
cron-descriptor 使用Gettext进行翻译。
要创建新翻译或编辑现有翻译,我建议使用Poedit。
您可以复制/重命名和翻译locale目录中的任何文件:
cp ./cron_descriptor/locale/de_DE.po ./cron_descriptor/locale/YOUR_LOCALE_CODE.po
poedit ./cron_descriptor/locale/YOUR_LOCALE_CODE.po
或者您可以通过在目录中运行从源代码生成新的未翻译 *.po 文件cron_descriptor:
cd cron_descriptor
xgettext *.py -o locale/YOUR_LOCALE_CODE.po
从 *.po 文件生成 *.mo 文件。在根目录运行命令:
msgfmt -o cron_descriptor/locale/YOUR_LOCALE_CODE.mo cron_descriptor/locale/YOUR_LOCALE_CODE.po
发展
欢迎所有建议和公关
只需克隆此存储库并通过运行注册预提交挂钩:
ln -s ../../pre-commit.sh .git/hooks/pre-commit
然后安装开发要求:
pip install pep8
pip install flake8
pip install pep8-naming
项目详情
下载文件
下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。
源分布
cron_descriptor_ko-1.2.24.tar.gz
(23.9 kB
查看哈希)
内置分布
关
cron_descriptor_ko -1.2.24.tar.gz 的哈希值
| 算法 | 哈希摘要 | |
|---|---|---|
| SHA256 | 9d6720fa2620d9b617af2bd32d8267ca322bbdbfc72a3a808d6734c953aa3984 |
|
| MD5 | 2b144c32e4c2db47650c29fa84f9a7d1 |
|
| 布莱克2-256 | c2932702562a3290741de9ff71499ea396612651b91ee5dac19175e783c4ae2c |
关
cron_descriptor_ko -1.2.24-py3-none-any.whl 的哈希值
| 算法 | 哈希摘要 | |
|---|---|---|
| SHA256 | 610cd94f51f02870212e7f6d98399cff13a689960fbca70005b71ad7aec9d4f2 |
|
| MD5 | 169c9ebe5dddf337a3ac86b2aebfa293 |
|
| 布莱克2-256 | 141996dc921271bc138a7f12eabfd59badfbf8be606f1a361231b73a86c7baff |