Schedule with Docstrings
Project description
| 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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file doccron-1.6.2.tar.gz.
File metadata
- Download URL: doccron-1.6.2.tar.gz
- Upload date:
- Size: 9.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.10.2 Linux/5.11.0-1028-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2eab323ce775ba9715b2d5bb8ec64fce69d4f8a747e1cb287c843eb5e6dbac75
|
|
| MD5 |
21fc9af762ff62f25964888cc134abd4
|
|
| BLAKE2b-256 |
7bd091c81c393d3008e03403df73d27a9ac7c6f769b855adbefab3eac2be2a4e
|
File details
Details for the file doccron-1.6.2-py3-none-any.whl.
File metadata
- Download URL: doccron-1.6.2-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.10.2 Linux/5.11.0-1028-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5bc7fa2997f642ae1aa131172c41434fa19fae20e43fc63520245ed1e0f73e8b
|
|
| MD5 |
140889ac114b4feaff58e6938d21107c
|
|
| BLAKE2b-256 |
5312305dac523c9c7563b7d017f2ffdb55b1c700407ac6b5fca3ff0b8f61e71b
|