All Projects → Salamek → cron-descriptor

Salamek / cron-descriptor

Licence: MIT license
A Python library that converts cron expressions into human readable strings.

Programming Languages

python
139335 projects - #7 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to cron-descriptor

point-vue-cron
vue component: cron expression generator
Stars: ✭ 21 (-81.42%)
Mutual labels:  cron-expression
cron-validate
A cron-expression validator for TypeScript/JavaScript projects.
Stars: ✭ 40 (-64.6%)
Mutual labels:  cron-expression
angular-cron-gen
A basic way to for users to graphically build a cron expression using Angular.
Stars: ✭ 36 (-68.14%)
Mutual labels:  cron-expression
croncpp
A C++11/14/17 header-only cross-platform library for handling CRON expressions
Stars: ✭ 162 (+43.36%)
Mutual labels:  cron-expression
one-cron
a time scheduling component based cron expressions
Stars: ✭ 14 (-87.61%)
Mutual labels:  cron-expression
cron-schedule
A zero-dependency cron parser and scheduler for Node.js, Deno and the browser.
Stars: ✭ 28 (-75.22%)
Mutual labels:  cron-expression
php-cron-expr
Ultra lightweight, Dependency free and Super Fast Cron Expression parser for PHP
Stars: ✭ 42 (-62.83%)
Mutual labels:  cron-expression
gronx
Lightweight, fast and dependency-free Cron expression parser (due checker), task scheduler and/or daemon for Golang (tested on v1.13 and above) and standalone usage
Stars: ✭ 206 (+82.3%)
Mutual labels:  cron-expression
crontab
cron expression parser and executor for dotnet core.
Stars: ✭ 13 (-88.5%)
Mutual labels:  cron-expression
cron-time
Javascript Cron Time Expressions
Stars: ✭ 58 (-48.67%)
Mutual labels:  cron-expression

Cron Descriptor

Python tests Donate

A Python library that converts cron expressions into human readable strings. Ported to Python from https://github.com/bradyholt/cron-expression-descriptor.

Author: Adam Schubert (https://www.salamek.cz)
Original Author & Credit: Brady Holt (http://www.geekytidbits.com)
License: MIT

Features

  • Supports all cron expression special characters including * / , - ? L W, #
  • Supports 5, 6 (w/ seconds or year), or 7 (w/ seconds and year) part cron expressions
  • Provides casing options (Sentence, Title, Lower, etc.)
  • Localization with support for 17 languages
  • Supports Python 2.7 - 3.10

Installation

Using PIP

pip install cron-descriptor

Usage example

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

descriptor = 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(descriptor.get_description())
print("{}".format(descriptor))

# 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
descriptor = ExpressionDescriptor("*/10 * * * *", options)
print(descriptor.get_description(DescriptionTypeEnum.FULL))

Languages Available

Language Locale Code Contributor
English en Brady Holt
Brazilian pt_PT Renato Lima
Chinese Simplified zh_CN Star Peng
Spanish es_ES Ivan Santos
Norwegian nb_NO Siarhei Khalipski
Turkish tr_TR Mustafa SADEDİL
Dutch nl_NL TotalMace
Russian ru_RU LbISS
French fr_FR Arnaud TAMAILLON
German de_DE Michael Schuler
Ukrainian uk_UA Taras
Italian it_IT rinaldihno
Czech cs_CZ Adam Schubert
Swedish sv_SE Åke Engelbrektson
Tamil ta_IN Sankar Hari
Persian fa_IR M. Yas. Davoodeh
Korean ko_KR KyuJoo Han
Japanese ja_JP Tho Nguyen

Original Source

Ports

Running Unit Tests

python setup.py test

Translating

cron-descriptor is using Gettext for translations.

To create new translation or edit existing one, i suggest using Poedit.

You can copy/rename and translate any file from locale directory:

cp ./cron_descriptor/locale/de_DE.po ./cron_descriptor/locale/YOUR_LOCALE_CODE.po
poedit ./cron_descriptor/locale/YOUR_LOCALE_CODE.po

or you can generate new untranslated *.po file from sources by running in cron_descriptor directory:

cd cron_descriptor
xgettext *.py -o locale/YOUR_LOCALE_CODE.po

Generating *.mo file from *.po file. In root directory run command:

msgfmt -o cron_descriptor/locale/YOUR_LOCALE_CODE.mo cron_descriptor/locale/YOUR_LOCALE_CODE.po

Developing

All suggestions and PR's are welcomed

Just clone this repository and register pre-commit hook by running:

ln -s ../../pre-commit.sh .git/hooks/pre-commit

Then install dev requirements:

pip install pep8
pip install flake8
pip install pep8-naming
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].