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 ~31 languages
- Supports Python 3.10 - 3.13
Installation
Using PIP
pip install cron-descriptor
Babel is installed automatically. The selected locale_code controls sentence
translations and weekday/month names without changing the process locale.
Missing message catalogs fall back to English. Custom catalogs with a locale
identifier unknown to Babel retain their messages and use English calendar names.
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 * * * *",
casing_type = CasingTypeEnum.Sentence,
use_24hour_time_format = True
)
# GetDescription uses DescriptionTypeEnum.FULL by default:
print(descriptor.get_description())
print(f"{descriptor = }")
# Or passing Options class as second argument:
options = Options()
options.casing_type = CasingTypeEnum.Sentence
options.use_24hour_time_format = True
descriptor = ExpressionDescriptor("*/10 * * * *", options)
print(descriptor.get_description(DescriptionTypeEnum.FULL))
Expressions with six fields
Set six_field_expression_has_seconds to select the format:
None(default): Use the existing automatic format detection.True: Read the fields as seconds, minutes, hours, day of month, month, and day of week.False: Read the fields as minutes, hours, day of month, month, day of week, and year.
This option applies only to expressions with six fields.
from cron_descriptor import ExpressionDescriptor, Options, get_description
options = Options(locale_code="en_US", six_field_expression_has_seconds=False)
print(get_description("* * * * * *", options)) # Every minute
# Set the option with an ExpressionDescriptor keyword argument.
descriptor = ExpressionDescriptor(
"* * * * * *",
locale_code="en_US",
six_field_expression_has_seconds=False,
)
print(descriptor.get_description()) # Every minute
Languages Available
| Language | Locale Code | Contributor |
|---|---|---|
| English | en | Brady Holt |
| Chinese Simplified | zh_CN | Star Peng |
| Chinese Traditional | zh_TW | Ricky Chiang |
| Czech | cs_CZ | Adam Schubert |
| Danish | da_DK | Rasmus Melchior Jacobsen |
| Dutch | nl_NL | TotalMace |
| Finnish | fi_FI | Mikael Rosenberg |
| French | fr_FR | Arnaud TAMAILLON |
| German | de_DE | Michael Schuler |
| Hebrew | he_IL | Ariel Deil |
| Hungarian | hu_HU | Varga Miklós |
| Italian | it_IT | rinaldihno |
| Japanese | ja_JP | Tho Nguyen |
| Korean | ko_KR | KyuJoo Han |
| Norwegian | nb_NO | Siarhei Khalipski |
| Persian | fa_IR | A. Bahrami |
| Polish | pl_PL | foka |
| Portuguese | pt_PT | Renato Lima |
| Portuguese (Brazil) | pt_BR | Renato Lima |
| Romanian | ro_RO | Illegitimis |
| Russian | ru_RU | LbISS |
| Slovenian | sl_SI | Jani Bevk |
| Spanish | es_ES | Ivan Santos |
| Spanish (Mexico) | es_MX | Ion Mincu |
| Swedish | sv_SE | Åke Engelbrektson |
| Vietnamese | vi_VN | Nguyen Duc Son |
| Tamil | ta_IN | Sankar Hari |
| Thai | th_TH | Michael Lyons |
| Turkish | tr_TR | Mustafa SADEDİL |
| Ukrainian | uk_UA | Taras |
| Greek | el_GR | hardra1n |
| Kazakh | kk_KZ | hardra1n |
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 suggestions and PR's are welcomed
Just clone this repository and register pre-commit hook by running:
ln -s ../../code-check.sh .git/hooks/pre-commit
Then install dev requirements:
pip install .[dev,test]
Metadata
Release files for cron-descriptor 2.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cron_descriptor-2.3.1.tar.gz | 59.5 kB | Without provenance | Details for cron_descriptor-2.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cron_descriptor-2.3.1-py3-none-any.whl | Python 3 | none | any | Details for cron_descriptor-2.3.1-py3-none-any.whl |
Total release size: 138.1 kB
Release files / cron_descriptor-2.3.1.tar.gz
| Download URL | cron_descriptor-2.3.1.tar.gz |
|---|---|
| Size | 59.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
edb8030b338c0be798c15e71906fe76eb7f1b135fd18d5e43a70351d93532387
|
|
BLAKE2b-256 checksum How to use checksums |
b2da9adbf896058bc8b74533aedd628ab6e6cb2c573014f9622097f1e125b75c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.5
|
Release files / cron_descriptor-2.3.1-py3-none-any.whl
| Download URL | cron_descriptor-2.3.1-py3-none-any.whl |
|---|---|
| Size | 78.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7112f8f682c14e0fd17377c0e0e514764ac9b64eae8c1df7e1c52d702b39ea40
|
|
BLAKE2b-256 checksum How to use checksums |
0ffcc791468f5e7ba9ac690ebfd8b91d4fdf7d43826538e28de75eb816809a9a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.5
|
Security for cron-descriptor 2.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.