clockwork 0.2.1__tar.gz → 0.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: clockwork
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: Toolkit for time-related operations including scheduling, logging, date manipulation, and more.
5
5
  Home-page: https://github.com/zteinck/clockwork
6
6
  License: MIT
@@ -15,8 +15,8 @@ Classifier: Programming Language :: Python :: 3.10
15
15
  Classifier: Programming Language :: Python :: 3.11
16
16
  Classifier: Programming Language :: Python :: 3.12
17
17
  Requires-Dist: holidays
18
- Requires-Dist: iterlab
19
18
  Requires-Dist: numpy
19
+ Requires-Dist: oddments
20
20
  Requires-Dist: pandas
21
21
  Requires-Dist: pathpilot
22
22
  Requires-Dist: schedule
@@ -0,0 +1,4 @@
1
+ from .core import *
2
+
3
+ __version__ = '0.2.2'
4
+ __author__ = 'Zachary Einck <zacharyeinck@gmail.com>'
@@ -7,7 +7,6 @@ import pandas as pd
7
7
  import numpy as np
8
8
 
9
9
 
10
-
11
10
  class DateBase(object):
12
11
  '''
13
12
  Description
@@ -1,7 +1,6 @@
1
1
  from ._base import DateBase
2
2
 
3
3
 
4
-
5
4
  class MonthEnd(DateBase):
6
5
 
7
6
  #╭-------------------------------------------------------------------------╮
@@ -1,7 +1,6 @@
1
1
  from ._month_end import MonthEnd
2
2
 
3
3
 
4
-
5
4
  class QuarterEnd(MonthEnd):
6
5
 
7
6
  #╭-------------------------------------------------------------------------╮
@@ -7,7 +7,6 @@ from ._quarter_end import QuarterEnd
7
7
  from ._month_end import MonthEnd
8
8
 
9
9
 
10
-
11
10
  def Date(arg=None, normalize=False, format=None, week_offset=0):
12
11
  '''
13
12
  Description
@@ -3,7 +3,6 @@ import time
3
3
  from .utils import elapsed_time, add_border
4
4
 
5
5
 
6
-
7
6
  def action_timer(func):
8
7
 
9
8
  def wrapper(*args, **kwargs):
@@ -0,0 +1,27 @@
1
+ import datetime
2
+ from schedule import Scheduler, CancelJob
3
+
4
+ from .utils import ContinueFailedJob
5
+
6
+
7
+ class TaskScheduler(Scheduler):
8
+
9
+ #╭-------------------------------------------------------------------------╮
10
+ #| Initialize Instance |
11
+ #╰-------------------------------------------------------------------------╯
12
+
13
+ def __init__(self, *args, **kwargs):
14
+ super().__init__(*args, **kwargs)
15
+
16
+
17
+ #╭-------------------------------------------------------------------------╮
18
+ #| Instance Methods |
19
+ #╰-------------------------------------------------------------------------╯
20
+
21
+ def _run_job(self, job):
22
+ ret = job.run()
23
+ if ret is CancelJob:
24
+ self.cancel_job(job)
25
+ elif ret is ContinueFailedJob:
26
+ job.last_run = datetime.datetime.now()
27
+ job._schedule_next_run()
@@ -8,7 +8,6 @@ from ..utils import elapsed_time
8
8
  from .utils import PrerequisiteError, ContinueFailedJob
9
9
 
10
10
 
11
-
12
11
  class Task(object):
13
12
  '''
14
13
  Description
@@ -35,7 +34,8 @@ class Task(object):
35
34
  at : str
36
35
  at time string
37
36
  expiry : Date
38
- If not None, job will be set inactive and stop running after this datetime
37
+ If not None, job will be set inactive and stop running after this
38
+ datetime
39
39
  func : func
40
40
  function to run
41
41
  args : tuple
@@ -172,7 +172,8 @@ class Task(object):
172
172
  print(f' @ {Date()} ->', end=' ')
173
173
  print('Job Cancelled')
174
174
 
175
- # cancel job if it was cancelled on cascasde or if it was set inactive after being scheduled
175
+ # cancel job if it was cancelled on cascasde or
176
+ # if it was set inactive after being scheduled
176
177
  if self.status == self.cascade_status or \
177
178
  not self.master.is_active(self.name, self.at):
178
179
  return CancelJob
@@ -1,15 +1,14 @@
1
1
  from .utils import PrerequisiteError
2
2
 
3
3
 
4
-
5
4
  class FileMonitor(object):
6
5
  '''
7
6
  Description
8
7
  --------------------
9
8
  Monitors a folder for new files and passes latest and 2nd latest file
10
- names to user-defined function. Class is intended to be used in conjunction
11
- with TaskMaster as a func argument which allows for file monitoring at regular
12
- intervals.
9
+ names to user-defined function. Class is intended to be used in
10
+ conjunction with TaskMaster as a func argument which allows for file
11
+ monitoring at regular intervals.
13
12
 
14
13
  Class Attributes
15
14
  --------------------
@@ -18,8 +17,8 @@ class FileMonitor(object):
18
17
  Instance Attributes
19
18
  --------------------
20
19
  func : func
21
- Custom function that takes the latest and second-latest file names in a
22
- folder as the first and second arguments, respectively.
20
+ Custom function that takes the latest and second-latest file names
21
+ in a folder as the first and second arguments, respectively.
23
22
  folder : Folder object
24
23
  folder to monitor for new files.
25
24
  filter_kwargs : dict
@@ -21,7 +21,6 @@ class CustomLogFormatter(logging.Formatter):
21
21
  .format('%03d' % record.msecs)
22
22
 
23
23
 
24
-
25
24
  class Logger(object):
26
25
 
27
26
  #╭-------------------------------------------------------------------------╮
@@ -1,7 +1,7 @@
1
1
  import datetime
2
2
  import time
3
3
  import uuid
4
- from iterlab import to_iter
4
+ from oddments import to_iter
5
5
  from pathpilot import Folder
6
6
 
7
7
  from ..core import Date
@@ -9,7 +9,6 @@ from ._scheduler import TaskScheduler
9
9
  from ._task import Task
10
10
 
11
11
 
12
-
13
12
  #╭-------------------------------------------------------------------------╮
14
13
  #| Classes |
15
14
  #╰-------------------------------------------------------------------------╯
@@ -2,7 +2,6 @@ import re
2
2
  from textwrap import wrap as wrap_text
3
3
 
4
4
 
5
-
6
5
  def elapsed_time(seconds):
7
6
  out = []
8
7
  for k, v in [('days', 86400), ('hours', 3600), ('minutes', 60)]:
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "clockwork"
3
- version = "0.2.1"
3
+ version = "0.2.2"
4
4
  description = "Toolkit for time-related operations including scheduling, logging, date manipulation, and more."
5
5
  authors = ["Zachary Einck <zacharyeinck@gmail.com>"]
6
6
  license = "MIT"
@@ -12,7 +12,7 @@ homepage = "https://github.com/zteinck/clockwork"
12
12
  python = "^3.8"
13
13
  pandas = "*"
14
14
  numpy = "*"
15
- iterlab = "*"
15
+ oddments = "*"
16
16
  pathpilot = "*"
17
17
  schedule = "*"
18
18
  holidays = "*"
@@ -1,4 +0,0 @@
1
- from .core import *
2
-
3
- __version__ = '0.2.1'
4
- __author__ = 'Zachary Einck <zacharyeinck@gmail.com>'
@@ -1,20 +0,0 @@
1
- import datetime
2
- from schedule import Scheduler, CancelJob
3
-
4
- from .utils import ContinueFailedJob
5
-
6
-
7
-
8
- class TaskScheduler(Scheduler):
9
-
10
- def __init__(self):
11
- super().__init__()
12
-
13
-
14
- def _run_job(self, job):
15
- ret = job.run()
16
- if ret is CancelJob:
17
- self.cancel_job(job)
18
- elif ret is ContinueFailedJob:
19
- job.last_run = datetime.datetime.now()
20
- job._schedule_next_run()
File without changes
File without changes