Skip to main content

一个将 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 奥克·恩格尔布雷克森

原始来源

端口

运行单元测试

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 查看哈希

已上传 source

内置分布

cron_descriptor_ko-1.2.24-py3-none-any.whl (39.3 kB 查看哈希

已上传 py3