• Stars
    star
    155
  • Rank 240,864 (Top 5 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 9 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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 * * * *",
    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.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 ruff

More Repositories

1

huawei-lte-api

API For huawei LAN/WAN LTE Modems
Python
362
star
2

gitlab-tools

Web application providing tools not avaiable in GitLab CE (Gitlab push/pull mirror and more)
Python
99
star
3

huawei-lte-api-ts

API For huawei LAN/WAN LTE Modems written in TypeScript
TypeScript
48
star
4

chromium-kiosk

Chromium kiosk is simple package turning your Archlinux or Debian (and alike) based PC/Raspberry into simple web kiosk using chromium.
Python
48
star
5

PplMyApi

Professional Parcel Logistic MyApi PHP client implementation with PDF and ZPL label generator
PHP
26
star
6

instagram-basic-display-python

A simple Python library for accessing the Instagram Basic Display API
Python
21
star
7

blacklist

Czech web blacklist info page (periodicaly downloads and parses MFCR pdfs and exposes data in REST API and web UI)
Python
15
star
8

picpro

PIC K150 programmer software written in Python 3
Python
10
star
9

javascript-de-obfuscator

Javascript DE-Obfuscator used to deobfuscate JS generated by javascriptobfuscator.com
PHP
10
star
10

zasilkovna

Zasilkovna.cz PHP library supporting SOAP and REST API + custom Label generator
PHP
9
star
11

netkeeper

Netkeeper keeps your huawei router connected
Python
7
star
12

qiosk

Kiosk web browser written in QT
C++
6
star
13

git-deploy

Server side and client side Git deployement tool
Python
5
star
14

pohoda

Pohoda XML implementation in Python
Python
5
star
15

raven-nette

[ABANDONED] This is nette implementation of sentry raven-php as logger service for tracy.
PHP
5
star
16

czech-post-api

Czech post API (Unofficial, parsing podani online)
PHP
4
star
17

doctrine-daterange

PHP
4
star
18

ddrescue-ffile

Tool for identifying corrupted files in image created by ddrescue
Python
3
star
19

servis24.cz

API for servis24.cz using servis24.cz as source of data (parsing loaded HTML).
PHP
2
star
20

php-daterange

PHP
2
star
21

packagebot

Packagebot for maitaining Czech Post, PPL and zasilkovna packages and printing labels
PHP
2
star
22

http-request

Simple class to perform requests to web apps acting as browser, storing cookies between redirects and so
PHP
2
star
23

reader

Old project in python 2, Library + GUI for work with ACR122l NFC card reader. Working under Linux and Windows.
Python
1
star
24

hocr-translate

Simple hocr file translator using google translate API
Python
1
star
25

xscreensaver-appearing-picture

Simple appearing picture screensaver for xscreensaver.
Python
1
star
26

sensu-go-load-check

This plugin provides native load instrumentation including load health and per-core metrics
Go
1
star
27

version

Do you know that boring step before pushing new relese ? Yes changing version strings all over the place ☹ Well this tool solves that for you!
Python
1
star
28

file-thumbnailer

File thumbnailer for images, pdfs and more
Python
1
star
29

gettexttranslator

Gettext Translator is tool that enables simple and user friendly translation of your texts via panel in debug bar.
PHP
1
star