diff options
author | CoprDistGit <infra@openeuler.org> | 2023-04-12 06:20:58 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2023-04-12 06:20:58 +0000 |
commit | dea273a04ee52255659ae64a0e2c799c09227c60 (patch) | |
tree | ba92010bd2f35d4e66301a3f8891a49461c95cb6 | |
parent | f3a7588d621c04a2d1ba10689df72dbe3a252066 (diff) |
automatic import of python-cron-validator
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | python-cron-validator.spec | 455 | ||||
-rw-r--r-- | sources | 1 |
3 files changed, 457 insertions, 0 deletions
@@ -0,0 +1 @@ +/cron-validator-1.0.6.tar.gz diff --git a/python-cron-validator.spec b/python-cron-validator.spec new file mode 100644 index 0000000..3302242 --- /dev/null +++ b/python-cron-validator.spec @@ -0,0 +1,455 @@ +%global _empty_manifest_terminate_build 0 +Name: python-cron-validator +Version: 1.0.6 +Release: 1 +Summary: Unix cron implementation by Python +License: MIT +URL: https://github.com/vcoder4c/cron-validator +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/e1/ab/ecbfcb9f42312fe87e3cb46514b7c3b1fc63f4d8d2529a7006a49792b059/cron-validator-1.0.6.tar.gz +BuildArch: noarch + +Requires: python3-dateutil +Requires: python3-pytz + +%description +# Cron Validator + +[](https://travis-ci.org/vcoder4c/cron-validator) +[](https://coveralls.io/github/vcoder4c/cron-validator?branch=master) + +### **Features** + +- Validate unix cron expression +- Match unit cron expression with specific datetime +- Generate match datetime between two datetime +- Schedule tasks + +### **Install** + +```shell script +pip install cron-validator +``` + +### **Run Tests** + +**1. Install test requirements** + +```shell script +pip install -r requirements/test.txt +``` + +**2. Run tests (with coverage if wished)** + +```shell script +pytest --cov=. test/ +``` + +### Sample + +**1. Validate unix cron expression** + +```python +from cron_validator import CronValidator + +assert CronValidator.parse('* * * * *') is not None # valid +assert CronValidator.parse('*/3 * * * *') is not None # valid +assert CronValidator.parse('*/61 * * * *') is None # invalid +``` + +**2. Match unit cron expression with specific datetime** + +```python +from cron_validator import CronValidator +from cron_validator.util import str_to_datetime + +dt_str = '2019-04-23 1:00' +dt = str_to_datetime(dt_str) + +assert CronValidator.match_datetime("* * * * *", dt) +assert CronValidator.match_datetime("* * * 4 *", dt) +assert CronValidator.match_datetime("* * * 5 *", dt) is False +assert CronValidator.match_datetime("* * * 1-5 *", dt) +assert CronValidator.match_datetime("* * * 1-3 *", dt) is False +assert CronValidator.match_datetime("* * * 1/5 *", dt) is False +assert CronValidator.match_datetime("* * * * *", dt) +assert CronValidator.match_datetime("0 * * * *", dt) +assert CronValidator.match_datetime("0-30 * * * *", dt) +assert CronValidator.match_datetime("0/30 * * * *", dt) +``` + +**3. Generate match datetime between two datetime** + +```python +from cron_validator import CronValidator +from cron_validator.util import str_to_datetime + + +from_str = '2019-04-22 00:00' +to_str = '2019-04-23 23:59' + +for dt in CronValidator.get_execution_time("0 0 * * *", +from_dt=str_to_datetime(from_str), to_dt=str_to_datetime(to_str)): + print(dt) + +# Output: +# 2019-04-22 00:00:00+00:00 +# 2019-04-23 00:00:00+00:00 +``` + +**4. Use scheduler for repetitive task** + +```python +from cron_validator import CronScheduler + +cron_string = "*/1 * * * *" +scheduler = CronScheduler(cron_string) + +while True: + if scheduler.time_for_execution(): + # Get's called every full minute (excluding first iteration) + print("Now is the next scheduled time.") +``` + +**5. Use extended cron rules based on AWS EventBridge rules** (from v1.0.6) + +The cron validator supports partially extended rules based on the Amazon EvenBridge rule set. [More info.](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-create-rule-schedule.html#eb-cron-expressions) + +Currently we support: +- 'L' for day of the month and day of the week +- 'W' for day of the week. + +```python +from cron_validator import CronValidator +from cron_validator.util import str_to_datetime +from cron_validator.regexes import Version + +dt_str = '2023-04-28 1:00' +dt = str_to_datetime(dt_str) + +assert CronValidator.match_datetime("* * * * 30W", dt, version=Version.EB) +assert CronValidator.match_datetime("* * * * 5L", dt, version=Version.EB) + +dt_str = "2022-02-28 1:00" +dt = str_to_datetime(dt_str) +assert CronValidator.match_datetime("* * L * *", dt, version=Version.EB) +``` + +### License + +This project is licensed under the MIT License - see the [LICENSE.txt](LICENSE.txt) file for details + + + + +%package -n python3-cron-validator +Summary: Unix cron implementation by Python +Provides: python-cron-validator +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-cron-validator +# Cron Validator + +[](https://travis-ci.org/vcoder4c/cron-validator) +[](https://coveralls.io/github/vcoder4c/cron-validator?branch=master) + +### **Features** + +- Validate unix cron expression +- Match unit cron expression with specific datetime +- Generate match datetime between two datetime +- Schedule tasks + +### **Install** + +```shell script +pip install cron-validator +``` + +### **Run Tests** + +**1. Install test requirements** + +```shell script +pip install -r requirements/test.txt +``` + +**2. Run tests (with coverage if wished)** + +```shell script +pytest --cov=. test/ +``` + +### Sample + +**1. Validate unix cron expression** + +```python +from cron_validator import CronValidator + +assert CronValidator.parse('* * * * *') is not None # valid +assert CronValidator.parse('*/3 * * * *') is not None # valid +assert CronValidator.parse('*/61 * * * *') is None # invalid +``` + +**2. Match unit cron expression with specific datetime** + +```python +from cron_validator import CronValidator +from cron_validator.util import str_to_datetime + +dt_str = '2019-04-23 1:00' +dt = str_to_datetime(dt_str) + +assert CronValidator.match_datetime("* * * * *", dt) +assert CronValidator.match_datetime("* * * 4 *", dt) +assert CronValidator.match_datetime("* * * 5 *", dt) is False +assert CronValidator.match_datetime("* * * 1-5 *", dt) +assert CronValidator.match_datetime("* * * 1-3 *", dt) is False +assert CronValidator.match_datetime("* * * 1/5 *", dt) is False +assert CronValidator.match_datetime("* * * * *", dt) +assert CronValidator.match_datetime("0 * * * *", dt) +assert CronValidator.match_datetime("0-30 * * * *", dt) +assert CronValidator.match_datetime("0/30 * * * *", dt) +``` + +**3. Generate match datetime between two datetime** + +```python +from cron_validator import CronValidator +from cron_validator.util import str_to_datetime + + +from_str = '2019-04-22 00:00' +to_str = '2019-04-23 23:59' + +for dt in CronValidator.get_execution_time("0 0 * * *", +from_dt=str_to_datetime(from_str), to_dt=str_to_datetime(to_str)): + print(dt) + +# Output: +# 2019-04-22 00:00:00+00:00 +# 2019-04-23 00:00:00+00:00 +``` + +**4. Use scheduler for repetitive task** + +```python +from cron_validator import CronScheduler + +cron_string = "*/1 * * * *" +scheduler = CronScheduler(cron_string) + +while True: + if scheduler.time_for_execution(): + # Get's called every full minute (excluding first iteration) + print("Now is the next scheduled time.") +``` + +**5. Use extended cron rules based on AWS EventBridge rules** (from v1.0.6) + +The cron validator supports partially extended rules based on the Amazon EvenBridge rule set. [More info.](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-create-rule-schedule.html#eb-cron-expressions) + +Currently we support: +- 'L' for day of the month and day of the week +- 'W' for day of the week. + +```python +from cron_validator import CronValidator +from cron_validator.util import str_to_datetime +from cron_validator.regexes import Version + +dt_str = '2023-04-28 1:00' +dt = str_to_datetime(dt_str) + +assert CronValidator.match_datetime("* * * * 30W", dt, version=Version.EB) +assert CronValidator.match_datetime("* * * * 5L", dt, version=Version.EB) + +dt_str = "2022-02-28 1:00" +dt = str_to_datetime(dt_str) +assert CronValidator.match_datetime("* * L * *", dt, version=Version.EB) +``` + +### License + +This project is licensed under the MIT License - see the [LICENSE.txt](LICENSE.txt) file for details + + + + +%package help +Summary: Development documents and examples for cron-validator +Provides: python3-cron-validator-doc +%description help +# Cron Validator + +[](https://travis-ci.org/vcoder4c/cron-validator) +[](https://coveralls.io/github/vcoder4c/cron-validator?branch=master) + +### **Features** + +- Validate unix cron expression +- Match unit cron expression with specific datetime +- Generate match datetime between two datetime +- Schedule tasks + +### **Install** + +```shell script +pip install cron-validator +``` + +### **Run Tests** + +**1. Install test requirements** + +```shell script +pip install -r requirements/test.txt +``` + +**2. Run tests (with coverage if wished)** + +```shell script +pytest --cov=. test/ +``` + +### Sample + +**1. Validate unix cron expression** + +```python +from cron_validator import CronValidator + +assert CronValidator.parse('* * * * *') is not None # valid +assert CronValidator.parse('*/3 * * * *') is not None # valid +assert CronValidator.parse('*/61 * * * *') is None # invalid +``` + +**2. Match unit cron expression with specific datetime** + +```python +from cron_validator import CronValidator +from cron_validator.util import str_to_datetime + +dt_str = '2019-04-23 1:00' +dt = str_to_datetime(dt_str) + +assert CronValidator.match_datetime("* * * * *", dt) +assert CronValidator.match_datetime("* * * 4 *", dt) +assert CronValidator.match_datetime("* * * 5 *", dt) is False +assert CronValidator.match_datetime("* * * 1-5 *", dt) +assert CronValidator.match_datetime("* * * 1-3 *", dt) is False +assert CronValidator.match_datetime("* * * 1/5 *", dt) is False +assert CronValidator.match_datetime("* * * * *", dt) +assert CronValidator.match_datetime("0 * * * *", dt) +assert CronValidator.match_datetime("0-30 * * * *", dt) +assert CronValidator.match_datetime("0/30 * * * *", dt) +``` + +**3. Generate match datetime between two datetime** + +```python +from cron_validator import CronValidator +from cron_validator.util import str_to_datetime + + +from_str = '2019-04-22 00:00' +to_str = '2019-04-23 23:59' + +for dt in CronValidator.get_execution_time("0 0 * * *", +from_dt=str_to_datetime(from_str), to_dt=str_to_datetime(to_str)): + print(dt) + +# Output: +# 2019-04-22 00:00:00+00:00 +# 2019-04-23 00:00:00+00:00 +``` + +**4. Use scheduler for repetitive task** + +```python +from cron_validator import CronScheduler + +cron_string = "*/1 * * * *" +scheduler = CronScheduler(cron_string) + +while True: + if scheduler.time_for_execution(): + # Get's called every full minute (excluding first iteration) + print("Now is the next scheduled time.") +``` + +**5. Use extended cron rules based on AWS EventBridge rules** (from v1.0.6) + +The cron validator supports partially extended rules based on the Amazon EvenBridge rule set. [More info.](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-create-rule-schedule.html#eb-cron-expressions) + +Currently we support: +- 'L' for day of the month and day of the week +- 'W' for day of the week. + +```python +from cron_validator import CronValidator +from cron_validator.util import str_to_datetime +from cron_validator.regexes import Version + +dt_str = '2023-04-28 1:00' +dt = str_to_datetime(dt_str) + +assert CronValidator.match_datetime("* * * * 30W", dt, version=Version.EB) +assert CronValidator.match_datetime("* * * * 5L", dt, version=Version.EB) + +dt_str = "2022-02-28 1:00" +dt = str_to_datetime(dt_str) +assert CronValidator.match_datetime("* * L * *", dt, version=Version.EB) +``` + +### License + +This project is licensed under the MIT License - see the [LICENSE.txt](LICENSE.txt) file for details + + + + +%prep +%autosetup -n cron-validator-1.0.6 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-cron-validator -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Wed Apr 12 2023 Python_Bot <Python_Bot@openeuler.org> - 1.0.6-1 +- Package Spec generated @@ -0,0 +1 @@ +75fb22c18291a163b2c8cb16a5d9b007 cron-validator-1.0.6.tar.gz |