Development of an internal social media platform with personalised dashboards for students
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

METADATA 8.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. Metadata-Version: 2.1
  2. Name: croniter
  3. Version: 0.3.25
  4. Summary: croniter provides iteration for datetime object with cron like format
  5. Home-page: http://github.com/kiorky/croniter
  6. Author: Matsumoto Taichi, kiorky
  7. Author-email: taichino@gmail.com, kiorky@cryptelium.net
  8. License: MIT License
  9. Keywords: datetime,iterator,cron
  10. Platform: UNKNOWN
  11. Classifier: Development Status :: 4 - Beta
  12. Classifier: Intended Audience :: Developers
  13. Classifier: License :: OSI Approved :: MIT License
  14. Classifier: Operating System :: POSIX
  15. Classifier: Programming Language :: Python
  16. Classifier: Programming Language :: Python :: 2
  17. Classifier: Programming Language :: Python :: 2.6
  18. Classifier: Programming Language :: Python :: 2.7
  19. Classifier: Programming Language :: Python :: 3
  20. Classifier: Programming Language :: Python :: 3.4
  21. Classifier: Programming Language :: Python :: 3.5
  22. Classifier: Topic :: Software Development :: Libraries :: Python Modules
  23. Requires-Python: >=2.6, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*
  24. Requires-Dist: python-dateutil
  25. Introduction
  26. ============
  27. .. contents::
  28. croniter provides iteration for the datetime object with a cron like format.
  29. ::
  30. _ _
  31. ___ _ __ ___ _ __ (_) |_ ___ _ __
  32. / __| '__/ _ \| '_ \| | __/ _ \ '__|
  33. | (__| | | (_) | | | | | || __/ |
  34. \___|_| \___/|_| |_|_|\__\___|_|
  35. Website: https://github.com/kiorky/croniter
  36. Travis badge
  37. =============
  38. .. image:: https://travis-ci.org/kiorky/croniter.svg?branch=master
  39. :target: https://travis-ci.org/kiorky/croniter
  40. Usage
  41. ============
  42. A simple example::
  43. >>> from croniter import croniter
  44. >>> from datetime import datetime
  45. >>> base = datetime(2010, 1, 25, 4, 46)
  46. >>> iter = croniter('*/5 * * * *', base) # every 5 minutes
  47. >>> print(iter.get_next(datetime)) # 2010-01-25 04:50:00
  48. >>> print(iter.get_next(datetime)) # 2010-01-25 04:55:00
  49. >>> print(iter.get_next(datetime)) # 2010-01-25 05:00:00
  50. >>>
  51. >>> iter = croniter('2 4 * * mon,fri', base) # 04:02 on every Monday and Friday
  52. >>> print(iter.get_next(datetime)) # 2010-01-26 04:02:00
  53. >>> print(iter.get_next(datetime)) # 2010-01-30 04:02:00
  54. >>> print(iter.get_next(datetime)) # 2010-02-02 04:02:00
  55. >>>
  56. >>> iter = croniter('2 4 1 * wed', base) # 04:02 on every Wednesday OR on 1st day of month
  57. >>> print(iter.get_next(datetime)) # 2010-01-27 04:02:00
  58. >>> print(iter.get_next(datetime)) # 2010-02-01 04:02:00
  59. >>> print(iter.get_next(datetime)) # 2010-02-03 04:02:00
  60. >>>
  61. >>> iter = croniter('2 4 1 * wed', base, day_or=False) # 04:02 on every 1st day of the month if it is a Wednesday
  62. >>> print(iter.get_next(datetime)) # 2010-09-01 04:02:00
  63. >>> print(iter.get_next(datetime)) # 2010-12-01 04:02:00
  64. >>> print(iter.get_next(datetime)) # 2011-06-01 04:02:00
  65. >>> iter = croniter('0 0 * * sat#1,sun#2', base)
  66. >>> print(iter.get_next(datetime)) # datetime.datetime(2010, 2, 6, 0, 0)
  67. All you need to know is how to use the constructor and the ``get_next``
  68. method, the signature of these methods are listed below::
  69. >>> def __init__(self, cron_format, start_time=time.time(), day_or=True)
  70. croniter iterates along with ``cron_format`` from ``start_time``.
  71. ``cron_format`` is **min hour day month day_of_week**, you can refer to
  72. http://en.wikipedia.org/wiki/Cron for more details. The ``day_or``
  73. switch is used to control how croniter handles **day** and **day_of_week**
  74. entries. Default option is the cron behaviour, which connects those
  75. values using **OR**. If the switch is set to False, the values are connected
  76. using **AND**. This behaves like fcron and enables you to e.g. define a job that
  77. executes each 2nd friday of a month by setting the days of month and the
  78. weekday.
  79. ::
  80. >>> def get_next(self, ret_type=float)
  81. get_next calculates the next value according to the cron expression and
  82. returns an object of type ``ret_type``. ``ret_type`` should be a ``float`` or a
  83. ``datetime`` object.
  84. Supported added for ``get_prev`` method. (>= 0.2.0)::
  85. >>> base = datetime(2010, 8, 25)
  86. >>> itr = croniter('0 0 1 * *', base)
  87. >>> print(itr.get_prev(datetime)) # 2010-08-01 00:00:00
  88. >>> print(itr.get_prev(datetime)) # 2010-07-01 00:00:00
  89. >>> print(itr.get_prev(datetime)) # 2010-06-01 00:00:00
  90. You can validate your crons using ``is_valid`` class method. (>= 0.3.18)::
  91. >>> croniter.is_valid('0 0 1 * *') # True
  92. >>> croniter.is_valid('0 wrong_value 1 * *') # False
  93. About DST
  94. =========
  95. Be sure to init your croniter instance with a TZ aware datetime for this to work !::
  96. >>> local_date = tz.localize(datetime(2017, 3, 26))
  97. >>> val = croniter('0 0 * * *', local_date).get_next(datetime)
  98. Develop this package
  99. ====================
  100. ::
  101. git clone https://github.com/kiorky/croniter.git
  102. cd croniter
  103. virtualenv --no-site-packages venv
  104. . venv/bin/activate
  105. pip install --upgrade -r requirements/test.txt
  106. py.test src
  107. Make a new release
  108. ====================
  109. We use zest.fullreleaser, a great release infrastructure.
  110. Do and follow these instructions
  111. ::
  112. . venv/bin/activate
  113. pip install --upgrade -r requirements/release.txt
  114. fullrelease
  115. Contributors
  116. ===============
  117. Thanks to all who have contributed to this project!
  118. If you have contributed and your name is not listed below please let me know.
  119. - mrmachine
  120. - Hinnack
  121. - shazow
  122. - kiorky
  123. - jlsandell
  124. - mag009
  125. - djmitche
  126. - GreatCombinator
  127. - chris-baynes
  128. - ipartola
  129. - yuzawa-san
  130. Changelog
  131. ==============
  132. 0.3.25 (2018-08-07)
  133. -------------------
  134. - Pypî hygiene
  135. [hugovk]
  136. 0.3.24 (2018-06-20)
  137. -------------------
  138. - fix `#107 <https://github.com/taichino/croniter/issues/107>`_: microsecond threshold
  139. [kiorky]
  140. 0.3.23 (2018-05-23)
  141. -------------------
  142. - fix `get_next` while perserving the fix of `get_prev` in 7661c2aaa
  143. [Avikam Agur <avikam@pagaya-inv.com>]
  144. 0.3.22 (2018-05-16)
  145. -------------------
  146. - Don't count previous minute if now is dynamic
  147. If the code is triggered from 5-asterisk based cron
  148. `get_prev` based on `datetime.now()` is expected to return
  149. current cron iteration and not previous execution.
  150. [Igor Khrol <igor.khrol@toptal.com>]
  151. 0.3.20 (2017-11-06)
  152. -------------------
  153. - More DST fixes
  154. [Kevin Rose <kbrose@github>]
  155. 0.3.19 (2017-08-31)
  156. -------------------
  157. - fix #87: backward dst changes
  158. [kiorky]
  159. 0.3.18 (2017-08-31)
  160. -------------------
  161. - Add is valid method, refactor errors
  162. [otherpirate, Mauro Murari <mauro_murari@hotmail.com>]
  163. 0.3.17 (2017-05-22)
  164. -------------------
  165. - DOW occurence sharp style support.
  166. [kiorky, Kengo Seki <sekikn@apache.org>]
  167. 0.3.16 (2017-03-15)
  168. -------------------
  169. - Better test suite [mrcrilly@github]
  170. - DST support [kiorky]
  171. 0.3.15 (2017-02-16)
  172. -------------------
  173. - fix bug around multiple conditions and range_val in
  174. _get_prev_nearest_diff.
  175. [abeja-yuki@github]
  176. 0.3.14 (2017-01-25)
  177. -------------------
  178. - issue #69: added day_or option to change behavior when day-of-month and
  179. day-of-week is given
  180. [Andreas Vogl <a.vogl@hackner-security.com>]
  181. 0.3.13 (2016-11-01)
  182. -------------------
  183. - `Real fix for #34 <https://github.com/taichino/croniter/pull/73>`_
  184. [kiorky@github]
  185. - `Modernize test infra <https://github.com/taichino/croniter/pull/72>`_
  186. [kiorky@github]
  187. - `Release as a universal wheel <https://github.com/kiorky/croniter/pull/16>`_
  188. [adamchainz@github]
  189. - `Raise ValueError on negative numbers <https://github.com/taichino/croniter/pull/63>`_
  190. [josegonzalez@github]
  191. - `Compare types using "issubclass" instead of exact match <https://github.com/taichino/croniter/pull/70>`_
  192. [darkk@github]
  193. - `Implement step cron with a variable base <https://github.com/taichino/croniter/pull/60>`_
  194. [josegonzalez@github]
  195. 0.3.12 (2016-03-10)
  196. -------------------
  197. - support setting ret_type in __init__ [Brent Tubbs <brent.tubbs@gmail.com>]
  198. 0.3.11 (2016-01-13)
  199. -------------------
  200. - Bug fix: The get_prev API crashed when last day of month token was used. Some
  201. essential logic was missing.
  202. [Iddo Aviram <iddo.aviram@similarweb.com>]
  203. 0.3.10 (2015-11-29)
  204. -------------------
  205. - The fuctionality of 'l' as day of month was broken, since the month variable
  206. was not properly updated
  207. [Iddo Aviram <iddo.aviram@similarweb.com>]
  208. 0.3.9 (2015-11-19)
  209. ------------------
  210. - Don't use datetime functions python 2.6 doesn't support
  211. [petervtzand]
  212. 0.3.8 (2015-06-23)
  213. ------------------
  214. - Truncate microseconds by setting to 0
  215. [Corey Wright]
  216. 0.3.7 (2015-06-01)
  217. ------------------
  218. - converting sun in range sun-thu transforms to int 0 which is
  219. recognized as empty string; the solution was to convert sun to string "0"
  220. 0.3.6 (2015-05-29)
  221. ------------------
  222. - Fix default behavior when no start_time given
  223. Default value for `start_time` parameter is calculated at module init time rather than call time.
  224. - Fix timezone support and stop depending on the system time zone
  225. 0.3.5 (2014-08-01)
  226. ------------------
  227. - support for 'l' (last day of month)
  228. 0.3.4 (2014-01-30)
  229. ------------------
  230. - Python 3 compat
  231. - QA Relase
  232. 0.3.3 (2012-09-29)
  233. ------------------
  234. - proper packaging