GithubHelp home page GithubHelp logo

adamchainz / cron-descriptor Goto Github PK

View Code? Open in Web Editor NEW

This project forked from salamek/cron-descriptor

0.0 3.0 0.0 156 KB

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

License: MIT License

Shell 2.31% Python 97.69%

cron-descriptor's Introduction

Cron Descriptor

Master: Master Build Status All: Build Status 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 14 languages
  • Supports Python 2.7 - 3.5

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("*/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

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

cron-descriptor's People

Contributors

agutierrezdapda avatar bradymholt avatar eson57 avatar guysoft avatar pengwk avatar salamek avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.