cron-descriptor


Namecron-descriptor JSON
Version 1.4.3 PyPI version JSON
download
home_pagehttps://github.com/Salamek/cron-descriptor
SummaryA Python library that converts cron expressions into human readable strings.
upload_time2024-01-29 22:11:33
maintainer
docs_urlNone
authorAdam Schubert
requires_python
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Cron Descriptor

[![Python tests](https://github.com/Salamek/cron-descriptor/actions/workflows/python-test.yml/badge.svg)](https://github.com/Salamek/cron-descriptor/actions/workflows/python-test.yml)
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.me/salamek)

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](http://opensource.org/licenses/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
```bash
pip install cron-descriptor
```

## Usage example

### Simple
```python
from cron_descriptor import get_description, ExpressionDescriptor

print(get_description("* 2 3 * *"))

#OR

print(str(ExpressionDescriptor("* 2 3 * *")))
```

### Advanced
```python
# 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](https://github.com/bradyholt)|
|Brazilian |pt_PT|[Renato Lima](https://github.com/natenho)|
|Chinese Simplified | zh_CN |[Star Peng](https://github.com/starpeng)|
|Spanish |es_ES|[Ivan Santos](https://github.com/ivansg)|
|Norwegian |nb_NO|[Siarhei Khalipski](https://github.com/KhalipskiSiarhei)|
|Turkish |tr_TR|[Mustafa SADEDİL](https://github.com/sadedil)|
|Dutch |nl_NL|[TotalMace](https://github.com/TotalMace)|
|Russian |ru_RU|[LbISS](https://github.com/LbISS)|
|French |fr_FR|[Arnaud TAMAILLON](https://github.com/Greybird)|
|German |de_DE|[Michael Schuler](https://github.com/mschuler)|
|Ukrainian |uk_UA|[Taras](https://github.com/tbudurovych)|
|Italian |it_IT|[rinaldihno](https://github.com/rinaldihno)|
|Czech |cs_CZ|[Adam Schubert](https://github.com/salamek)|
|Swedish |sv_SE|[Åke Engelbrektson](https://github.com/eson57)|
|Tamil |ta_IN|[Sankar Hari](https://github.com/sankarhari)|
|Persian|fa_IR|[M. Yas. Davoodeh](https://github.com/Davoodeh)|
|Korean|ko_KR|[KyuJoo Han](https://github.com/hanqyu)|
|Japanese |ja_JP|[Tho Nguyen](https://github.com/tho-asterist)|

<!-- SOON
## Demo



## Download

-->

## Original Source
 - .NET - [https://github.com/bradyholt/cron-expression-descriptor](https://github.com/bradyholt/cron-expression-descriptor)

## Ports
 - Java     - [https://github.com/RedHogs/cron-parser](https://github.com/RedHogs/cron-parser)
 - Ruby     - [https://github.com/alpinweis/cronex](https://github.com/alpinweis/cronex)
 - Golang   - [https://github.com/jsuar/go-cron-descriptor](https://github.com/jsuar/go-cron-descriptor)

## Running Unit Tests

```bash
python setup.py test
```

## Translating
cron-descriptor is using [Gettext](https://www.gnu.org/software/gettext/) for translations.

> To create new translation or edit existing one, i suggest using [Poedit](https://poedit.net/).

You can copy/rename and translate any file from `locale` directory:
```bash
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:
```bash
cd cron_descriptor
xgettext *.py -o locale/YOUR_LOCALE_CODE.po
```

Generating *.mo file from *.po file. In root directory run command:
```bash
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:

```bash
ln -s ../../pre-commit.sh .git/hooks/pre-commit
```

Then install dev requirements:

```bash
pip install ruff
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Salamek/cron-descriptor",
    "name": "cron-descriptor",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Adam Schubert",
    "author_email": "adam.schubert@sg1-game.net",
    "download_url": "https://files.pythonhosted.org/packages/28/be/bb2c93b445fdd341ec057e0920c5b2b35c910db6f0d76dca8ea123504107/cron_descriptor-1.4.3.tar.gz",
    "platform": null,
    "description": "# Cron Descriptor\n\n[![Python tests](https://github.com/Salamek/cron-descriptor/actions/workflows/python-test.yml/badge.svg)](https://github.com/Salamek/cron-descriptor/actions/workflows/python-test.yml)\n[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.me/salamek)\n\nA Python library that converts cron expressions into human readable strings. Ported to Python from https://github.com/bradyholt/cron-expression-descriptor.\n\n**Author**: Adam Schubert (https://www.salamek.cz)  \n**Original Author & Credit**: Brady Holt (http://www.geekytidbits.com)  \n**License**: [MIT](http://opensource.org/licenses/MIT)\n\n## Features         \n * Supports all cron expression special characters including * / , - ? L W, #\n * Supports 5, 6 (w/ seconds or year), or 7 (w/ seconds and year) part cron expressions\n * Provides casing options (Sentence, Title, Lower, etc.)\n * Localization with support for 17 languages\n * Supports Python 2.7 - 3.10\n\n## Installation\nUsing PIP\n```bash\npip install cron-descriptor\n```\n\n## Usage example\n\n### Simple\n```python\nfrom cron_descriptor import get_description, ExpressionDescriptor\n\nprint(get_description(\"* 2 3 * *\"))\n\n#OR\n\nprint(str(ExpressionDescriptor(\"* 2 3 * *\")))\n```\n\n### Advanced\n```python\n# Consult Options.py/CasingTypeEnum.py/DescriptionTypeEnum.py for more info\nfrom cron_descriptor import Options, CasingTypeEnum, DescriptionTypeEnum, ExpressionDescriptor\n\ndescriptor = ExpressionDescriptor(\n    expression = \"*/10 * * * *\",\n    casing_type = CasingTypeEnum.Sentence,\n    use_24hour_time_format = True\n)\n\n# GetDescription uses DescriptionTypeEnum.FULL by default:\nprint(descriptor.get_description())\nprint(\"{}\".format(descriptor))\n\n# Or passing Options class as second argument:\n\noptions = Options()\noptions.casing_type = CasingTypeEnum.Sentence\noptions.use_24hour_time_format = True\ndescriptor = ExpressionDescriptor(\"*/10 * * * *\", options)\nprint(descriptor.get_description(DescriptionTypeEnum.FULL))\n```\n\n## Languages Available\n\n|Language| Locale Code | Contributor |\n|--------|-------------|-------------|\n|English |en|[Brady Holt](https://github.com/bradyholt)|\n|Brazilian |pt_PT|[Renato Lima](https://github.com/natenho)|\n|Chinese Simplified | zh_CN |[Star Peng](https://github.com/starpeng)|\n|Spanish |es_ES|[Ivan Santos](https://github.com/ivansg)|\n|Norwegian |nb_NO|[Siarhei Khalipski](https://github.com/KhalipskiSiarhei)|\n|Turkish |tr_TR|[Mustafa SADED\u0130L](https://github.com/sadedil)|\n|Dutch |nl_NL|[TotalMace](https://github.com/TotalMace)|\n|Russian |ru_RU|[LbISS](https://github.com/LbISS)|\n|French |fr_FR|[Arnaud TAMAILLON](https://github.com/Greybird)|\n|German |de_DE|[Michael Schuler](https://github.com/mschuler)|\n|Ukrainian |uk_UA|[Taras](https://github.com/tbudurovych)|\n|Italian |it_IT|[rinaldihno](https://github.com/rinaldihno)|\n|Czech |cs_CZ|[Adam Schubert](https://github.com/salamek)|\n|Swedish |sv_SE|[\u00c5ke Engelbrektson](https://github.com/eson57)|\n|Tamil |ta_IN|[Sankar Hari](https://github.com/sankarhari)|\n|Persian|fa_IR|[M. Yas. Davoodeh](https://github.com/Davoodeh)|\n|Korean|ko_KR|[KyuJoo Han](https://github.com/hanqyu)|\n|Japanese |ja_JP|[Tho Nguyen](https://github.com/tho-asterist)|\n\n<!-- SOON\n## Demo\n\n\n\n## Download\n\n-->\n\n## Original Source\n - .NET - [https://github.com/bradyholt/cron-expression-descriptor](https://github.com/bradyholt/cron-expression-descriptor)\n\n## Ports\n - Java     - [https://github.com/RedHogs/cron-parser](https://github.com/RedHogs/cron-parser)\n - Ruby     - [https://github.com/alpinweis/cronex](https://github.com/alpinweis/cronex)\n - Golang   - [https://github.com/jsuar/go-cron-descriptor](https://github.com/jsuar/go-cron-descriptor)\n\n## Running Unit Tests\n\n```bash\npython setup.py test\n```\n\n## Translating\ncron-descriptor is using [Gettext](https://www.gnu.org/software/gettext/) for translations.\n\n> To create new translation or edit existing one, i suggest using [Poedit](https://poedit.net/).\n\nYou can copy/rename and translate any file from `locale` directory:\n```bash\ncp ./cron_descriptor/locale/de_DE.po ./cron_descriptor/locale/YOUR_LOCALE_CODE.po\npoedit ./cron_descriptor/locale/YOUR_LOCALE_CODE.po\n```\nor you can generate new untranslated *.po file from sources by running in `cron_descriptor` directory:\n```bash\ncd cron_descriptor\nxgettext *.py -o locale/YOUR_LOCALE_CODE.po\n```\n\nGenerating *.mo file from *.po file. In root directory run command:\n```bash\nmsgfmt -o cron_descriptor/locale/YOUR_LOCALE_CODE.mo cron_descriptor/locale/YOUR_LOCALE_CODE.po\n```\n\n## Developing\n\nAll suggestions and PR's are welcomed\n\nJust clone this repository and register pre-commit hook by running:\n\n```bash\nln -s ../../pre-commit.sh .git/hooks/pre-commit\n```\n\nThen install dev requirements:\n\n```bash\npip install ruff\n```\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A Python library that converts cron expressions into human readable strings.",
    "version": "1.4.3",
    "project_urls": {
        "Homepage": "https://github.com/Salamek/cron-descriptor"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e018136b0073305038d1317f3442f614a698ce686830a2810bbe7e875311e09f",
                "md5": "2e3af75244b27c6750765645647bab6e",
                "sha256": "a67ba21804983b1427ed7f3e1ec27ee77bf24c652b0430239c268c5ddfbf9dc0"
            },
            "downloads": -1,
            "filename": "cron_descriptor-1.4.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2e3af75244b27c6750765645647bab6e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 49799,
            "upload_time": "2024-01-29T22:11:31",
            "upload_time_iso_8601": "2024-01-29T22:11:31.662809Z",
            "url": "https://files.pythonhosted.org/packages/e0/18/136b0073305038d1317f3442f614a698ce686830a2810bbe7e875311e09f/cron_descriptor-1.4.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "28bebb2c93b445fdd341ec057e0920c5b2b35c910db6f0d76dca8ea123504107",
                "md5": "d870b2b0cb24b68fd19dc20f68701555",
                "sha256": "7b1a00d7d25d6ae6896c0da4457e790b98cba778398a3d48e341e5e0d33f0488"
            },
            "downloads": -1,
            "filename": "cron_descriptor-1.4.3.tar.gz",
            "has_sig": false,
            "md5_digest": "d870b2b0cb24b68fd19dc20f68701555",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 30289,
            "upload_time": "2024-01-29T22:11:33",
            "upload_time_iso_8601": "2024-01-29T22:11:33.985786Z",
            "url": "https://files.pythonhosted.org/packages/28/be/bb2c93b445fdd341ec057e0920c5b2b35c910db6f0d76dca8ea123504107/cron_descriptor-1.4.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-29 22:11:33",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Salamek",
    "github_project": "cron-descriptor",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "cron-descriptor"
}
        
Elapsed time: 0.23100s