| License | Version | ||
| Github Actions | Coverage | ||
| Supported versions | Wheel | ||
| Status | Downloads |
DocCron
Schedule with Docstrings
Installation
pip install DocCron
Description
Cron-based scheduler inspired by doctest
Example
Cron jobs can be embedded into docstrings by using a literal block (::). Literal blocks should start with /etc/crontab.
Standard/Extended Format
Run hello() at every 2nd minute and 3rd minute:
import time
def hello():
"""
Print "hello world" at every 2nd minute and 3rd minute:
/etc/crontab::
*/2 * * * *
*/3 * * * *
"""
print(time.strftime('%Y-%m-%d %H:%M:%S'), "hello world")
if __name__ == '__main__':
import doccron
doccron.run_jobs()
Quartz Format
Run hello() at every 2nd second and 3rd second:
import time
def hello():
"""
Print "hello world" every 2nd second and 3rd second:
/etc/crontab::
*/2 * * * * *
*/3 * * * * *
"""
print(time.strftime('%Y-%m-%d %H:%M:%S'), "hello world")
if __name__ == '__main__':
import doccron
doccron.run_jobs(quartz=True)
Timezone-Awareness (CRON_TZ)
DocCron now support CRON_TZ. The value of CRON_TZ only applies to succeeding cron jobs.
DocCron supports multiple CRON_TZ in a cron table. The default timezone value is the local/system timezone, if not specified.
import time
def hello():
"""
Print "hello world" at every 2nd minute and 3rd minute:
/etc/crontab::
CRON_TZ=UTC
*/2 * * * *
*/3 * * * *
"""
print(time.strftime('%Y-%m-%d %H:%M:%S%z'), "hello world")
if __name__ == '__main__':
import doccron
doccron.run_jobs()
Features
- Standard and extended cron formats (see CRON Expression)
- Nonstandard predefined scheduling definitions
- Non-standard characters
- Quartz format
- Works with documentation tools like Sphinx
- Timezone-awareness (CRON_TZ)
- Interval (e.g.,
@every 1h2m3s)
TODO
- Human-readable date/time strings
References
Author
Metadata
Release files for doccron 1.6.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| doccron-1.6.2.tar.gz | 9.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| doccron-1.6.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.0 kB
Release files / doccron-1.6.2.tar.gz
| Download URL | doccron-1.6.2.tar.gz |
|---|---|
| Size | 9.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2eab323ce775ba9715b2d5bb8ec64fce69d4f8a747e1cb287c843eb5e6dbac75
|
|
BLAKE2b-256 checksum How to use checksums |
7bd091c81c393d3008e03403df73d27a9ac7c6f769b855adbefab3eac2be2a4e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.10.2 Linux/5.11.0-1028-azure
|
Release files / doccron-1.6.2-py3-none-any.whl
| Download URL | doccron-1.6.2-py3-none-any.whl |
|---|---|
| Size | 9.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5bc7fa2997f642ae1aa131172c41434fa19fae20e43fc63520245ed1e0f73e8b
|
|
BLAKE2b-256 checksum How to use checksums |
5312305dac523c9c7563b7d017f2ffdb55b1c700407ac6b5fca3ff0b8f61e71b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.10.2 Linux/5.11.0-1028-azure
|