Cron Descriptor
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 14 languages
- Supports Python 2.7 - 3.7
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
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))
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 |
Original Source
Ports
- Java - https://github.com/RedHogs/cron-parser
- Ruby - https://github.com/alpinweis/cronex
- Golang - https://github.com/jsuar/go-cron-descriptor
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 suggescions 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
Metadata
Release files for cron-descriptor-ko 1.2.24
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| cron_descriptor_ko-1.2.24.tar.gz | 23.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cron_descriptor_ko-1.2.24-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 63.2 kB
Release files / cron_descriptor_ko-1.2.24.tar.gz
| Download URL | cron_descriptor_ko-1.2.24.tar.gz |
|---|---|
| Size | 23.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9d6720fa2620d9b617af2bd32d8267ca322bbdbfc72a3a808d6734c953aa3984
|
|
BLAKE2b-256 checksum How to use checksums |
c2932702562a3290741de9ff71499ea396612651b91ee5dac19175e783c4ae2c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.8.6
|
Release files / cron_descriptor_ko-1.2.24-py3-none-any.whl
| Download URL | cron_descriptor_ko-1.2.24-py3-none-any.whl |
|---|---|
| Size | 39.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
610cd94f51f02870212e7f6d98399cff13a689960fbca70005b71ad7aec9d4f2
|
|
BLAKE2b-256 checksum How to use checksums |
141996dc921271bc138a7f12eabfd59badfbf8be606f1a361231b73a86c7baff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.8.6
|