Skip to main content

A Python library that converts cron expressions into human readable strings.

Project description

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 ~31 languages
  • Supports Python 3.9 - 3.13

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 * * * *",
    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))

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
Turkish tr_TR Mustafa SADEDİL
Tamil ta_IN Sankar Hari
Ukrainian uk_UA Taras
Greek el_GR hardra1n
Kazakh kk_KZ hardra1n

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 ../../code-check.sh .git/hooks/pre-commit

Then install dev requirements:

pip install .[dev,test]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cron_descriptor-2.1.0.tar.gz (50.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cron_descriptor-2.1.0-py3-none-any.whl (74.7 kB view details)

Uploaded Python 3

File details

Details for the file cron_descriptor-2.1.0.tar.gz.

File metadata

  • Download URL: cron_descriptor-2.1.0.tar.gz
  • Upload date:
  • Size: 50.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for cron_descriptor-2.1.0.tar.gz
Algorithm Hash digest
SHA256 ecddb8b2f6c5286398949aaefe185364666af74f33b01877c61378e1fd4e38e6
MD5 ffd3f52e4571a34c90589cdb0e529802
BLAKE2b-256 9175b44b05ae7d1e49b59a27a917c44e04ce9aa4cebdd05dac42ba7df06a91b4

See more details on using hashes here.

File details

Details for the file cron_descriptor-2.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for cron_descriptor-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e280efae0e375e2cbc62846f833888f12c7921d2d11ab0dca598f94c51af8639
MD5 42dfe0980cf9ca665edb99b853206d5c
BLAKE2b-256 0d41c476c41cb88dbbba83e0685dd331b9d32599f1e4a94ca223b02437a3d83b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page