Skip to content

Commit b52172a

Browse files
authored
Merge pull request #1 from dapper91/dev
first version implemented
2 parents 89c7456 + 600ec18 commit b52172a

File tree

15 files changed

+1365
-19
lines changed

15 files changed

+1365
-19
lines changed

.flake8

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[flake8]
2+
max-line-length = 130
3+
per-file-ignores =
4+
crontools/*__init__.py: F401

.github/workflows/release.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: release
2+
3+
on:
4+
release:
5+
types:
6+
- released
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
- name: Set up Python ${{ matrix.python-version }}
14+
uses: actions/setup-python@v2
15+
with:
16+
python-version: '3.x'
17+
- name: Install dependencies
18+
run: |
19+
python -m pip install --upgrade pip
20+
pip install setuptools wheel twine
21+
- name: Build and publish
22+
env:
23+
TWINE_USERNAME: __token__
24+
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
25+
run: |
26+
python setup.py sdist
27+
twine upload dist/*

.github/workflows/test.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: release
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- dev
7+
- master
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: [3.7, 3.8, 3.9]
15+
steps:
16+
- uses: actions/checkout@v2
17+
- name: Set up Python ${{ matrix.python-version }}
18+
uses: actions/setup-python@v2
19+
with:
20+
python-version: ${{ matrix.python-version }}
21+
- name: Install dependencies
22+
run: |
23+
python -m pip install --upgrade pip
24+
pip install pipenv --upgrade
25+
pipenv install --python ${{ matrix.python-version }} --dev
26+
- name: Run linter
27+
run: pipenv run flake8 .
28+
- name: Run tests
29+
run: PYTHONPATH="$(pwd):$PYTHONPATH" pipenv run py.test --cov=crontools tests

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,7 @@ dmypy.json
127127

128128
# Pyre type checker
129129
.pyre/
130+
131+
.idea/
132+
133+
Pipfile.lock

.pre-commit-config.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v3.4.0
4+
hooks:
5+
- id: check-docstring-first
6+
stages:
7+
- commit
8+
- push
9+
- id: check-merge-conflict
10+
stages:
11+
- push
12+
- id: trailing-whitespace
13+
stages:
14+
- commit
15+
- push
16+
- id: end-of-file-fixer
17+
stages:
18+
- commit
19+
- push
20+
- id: mixed-line-ending
21+
stages:
22+
- commit
23+
- push
24+
args:
25+
- --fix=lf
26+
- id: no-commit-to-branch
27+
stages:
28+
- commit
29+
- repo: https://github.com/pre-commit/mirrors-autopep8
30+
rev: v1.5.5
31+
hooks:
32+
- id: autopep8
33+
stages:
34+
- commit
35+
- push
36+
args:
37+
- --max-line-length=130
38+
- --diff
39+
- repo: https://github.com/asottile/add-trailing-comma
40+
rev: v2.1.0
41+
hooks:
42+
- id: add-trailing-comma
43+
stages:
44+
- commit
45+
- push
46+
- repo: https://gitlab.com/pycqa/flake8
47+
rev: 3.9.0
48+
hooks:
49+
- id: flake8
50+
stages:
51+
- commit
52+
- push

CHANGELOG.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Changelog
2+
=========
3+
4+
5+
0.1.0 (2021-03-15)
6+
------------------
7+
8+
- Initial release

LICENSE

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
1-
MIT License
1+
This is free and unencumbered software released into the public domain.
22

3-
Copyright (c) 2021 Dmitry Pershin
3+
Anyone is free to copy, modify, publish, use, compile, sell, or
4+
distribute this software, either in source code form or as a compiled
5+
binary, for any purpose, commercial or non-commercial, and by any
6+
means.
47

5-
Permission is hereby granted, free of charge, to any person obtaining a copy
6-
of this software and associated documentation files (the "Software"), to deal
7-
in the Software without restriction, including without limitation the rights
8-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
copies of the Software, and to permit persons to whom the Software is
10-
furnished to do so, subject to the following conditions:
8+
In jurisdictions that recognize copyright laws, the author or authors
9+
of this software dedicate any and all copyright interest in the
10+
software to the public domain. We make this dedication for the benefit
11+
of the public at large and to the detriment of our heirs and
12+
successors. We intend this dedication to be an overt act of
13+
relinquishment in perpetuity of all present and future rights to this
14+
software under copyright law.
1115

12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22+
OTHER DEALINGS IN THE SOFTWARE.
1423

15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
24+
For more information, please refer to <http://unlicense.org>

Pipfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[[source]]
2+
name = "pypi"
3+
url = "https://pypi.org/simple"
4+
verify_ssl = true
5+
6+
[dev-packages]
7+
pytest = "~=6.0"
8+
pytest-cov = "~=2.0"
9+
freezegun = "~=0.0"
10+
flake8 = "~=3.0"
11+
12+
[packages]
13+
tzlocal = "~=2.0"

README.md

Lines changed: 0 additions & 2 deletions
This file was deleted.

README.rst

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
=========
2+
crontools
3+
=========
4+
5+
Features:
6+
7+
- crontab expression parser
8+
- optional seconds field support
9+
- optional year field support
10+
- crontab fire time sequential iteration support
11+
12+
Installation
13+
------------
14+
15+
You can install crontools with pip:
16+
17+
.. code-block:: console
18+
19+
$ pip install crontools
20+
21+
22+
Quickstart
23+
----------
24+
25+
On the server side everything is also pretty straightforward:
26+
27+
.. code-block:: python
28+
29+
import datetime as dt
30+
import crontools as ct
31+
32+
tz = dt.timezone.utc
33+
now = dt.datetime.fromisoformat('2021-02-01 00:00:00+00:00')
34+
ct = ct.Crontab.parse(
35+
'30 30 12-16/2 1,2 JAN SAT,SUN *',
36+
seconds_ext=True,
37+
years_ext=True,
38+
tz=tz,
39+
)
40+
41+
cron_iter = ct.iter(start_from=now)
42+
for n, fire_datetime in zip(range(1, 31), cron_iter):
43+
print("{n:2}: {dt}".format(n=n, dt=fire_datetime))
44+
45+
output:
46+
47+
1: 2022-01-01 12:30:30+00:00
48+
2: 2022-01-01 14:30:30+00:00
49+
3: 2022-01-01 16:30:30+00:00
50+
4: 2022-01-02 12:30:30+00:00
51+
5: 2022-01-02 14:30:30+00:00
52+
6: 2022-01-02 16:30:30+00:00
53+
7: 2022-01-08 12:30:30+00:00
54+
8: 2022-01-08 14:30:30+00:00
55+
9: 2022-01-08 16:30:30+00:00
56+
10: 2022-01-09 12:30:30+00:00
57+
11: 2022-01-09 14:30:30+00:00
58+
12: 2022-01-09 16:30:30+00:00
59+
13: 2022-01-15 12:30:30+00:00
60+
14: 2022-01-15 14:30:30+00:00
61+
15: 2022-01-15 16:30:30+00:00
62+
16: 2022-01-16 12:30:30+00:00
63+
17: 2022-01-16 14:30:30+00:00
64+
18: 2022-01-16 16:30:30+00:00
65+
19: 2022-01-22 12:30:30+00:00
66+
20: 2022-01-22 14:30:30+00:00
67+
21: 2022-01-22 16:30:30+00:00
68+
22: 2022-01-23 12:30:30+00:00
69+
23: 2022-01-23 14:30:30+00:00
70+
24: 2022-01-23 16:30:30+00:00
71+
25: 2023-01-01 12:30:30+00:00
72+
26: 2023-01-01 14:30:30+00:00
73+
27: 2023-01-01 16:30:30+00:00
74+
28: 2023-01-02 12:30:30+00:00
75+
29: 2023-01-02 14:30:30+00:00
76+
30: 2023-01-02 16:30:30+00:00

0 commit comments

Comments
 (0)