clockwork 0.3.5__tar.gz → 0.4.0__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.3.5
3
+ Version: 0.4.0
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
@@ -16,7 +16,7 @@ Classifier: Programming Language :: Python :: 3.11
16
16
  Classifier: Programming Language :: Python :: 3.12
17
17
  Requires-Dist: holidays
18
18
  Requires-Dist: numpy
19
- Requires-Dist: oddments (>=0.3.1)
19
+ Requires-Dist: oddments (>=0.4.0)
20
20
  Requires-Dist: pandas
21
21
  Requires-Dist: schedule
22
22
  Project-URL: Repository, https://github.com/zteinck/clockwork
@@ -8,5 +8,5 @@ from .utils import (
8
8
  temporal_format_to_regex,
9
9
  )
10
10
 
11
- __version__ = '0.3.5'
11
+ __version__ = '0.4.0'
12
12
  __author__ = 'Zachary Einck <zacharyeinck@gmail.com>'
@@ -1,5 +1,5 @@
1
1
  from functools import wraps
2
- from oddments import add_border
2
+ import oddments as odd
3
3
  import time
4
4
 
5
5
  from .utils import format_elapsed_seconds
@@ -11,11 +11,11 @@ def action_timer(func):
11
11
  def wrapper(*args, **kwargs):
12
12
  start_time = time.time()
13
13
  action = func.__name__
14
- header = add_border(action, width=75, fixed_width=True)
14
+ header = odd.add_border(action, width=75, fixed_width=True)
15
15
  print(header + '\n')
16
16
  out = func(*args, **kwargs)
17
17
  duration = format_elapsed_seconds(time.time() - start_time)
18
- trailer = add_border(f'{action} complete in {duration}.')
18
+ trailer = odd.add_border(f'{action} complete in {duration}.')
19
19
  print(trailer + '\n')
20
20
  return out
21
21
 
@@ -96,17 +96,17 @@ class MonthEnd(Timestamp):
96
96
 
97
97
  @property
98
98
  def long_label(self):
99
- return self.str('%Y-%m-%d')
99
+ return self.to_string('%Y-%m-%d')
100
100
 
101
101
 
102
102
  @property
103
103
  def compact_label(self):
104
- return self.str('%Y-%m')
104
+ return self.to_string('%Y-%m')
105
105
 
106
106
 
107
107
  @property
108
108
  def short_label(self):
109
- return self.str('%b')
109
+ return self.to_string('%b')
110
110
 
111
111
 
112
112
  @property
@@ -145,7 +145,7 @@ class MonthEnd(Timestamp):
145
145
  ''' offsets instance by desired number of periods '''
146
146
  odd.validate_value(
147
147
  value=periods,
148
- attr='periods',
148
+ name='periods',
149
149
  types=int
150
150
  )
151
151
 
@@ -96,7 +96,7 @@ class QuarterEnd(MonthEnd):
96
96
 
97
97
  @property
98
98
  def compact_label(self):
99
- return f'{self.qtr}Q' + self.str('%y')
99
+ return f'{self.qtr}Q' + self.to_string('%y')
100
100
 
101
101
 
102
102
  @property
@@ -150,7 +150,7 @@ class QuarterEnd(MonthEnd):
150
150
 
151
151
  odd.validate_value(
152
152
  value=value,
153
- attr='scheme',
153
+ name='scheme',
154
154
  types=tuple
155
155
  )
156
156
 
@@ -140,8 +140,8 @@ class TaskMaster(object):
140
140
  will be set to 'second' and 1, respectively, so that the job will
141
141
  run ASAP once the 'start' criteria has been met (if applicable).
142
142
  at : str | iter
143
- time_string argument passed to schedule.Job.at(time_string). Times may be
144
- passed in '%I:%M%p' format (e.g ['06:15 AM', '12:15 PM']).
143
+ time_string argument passed to schedule.Job.at(time_string). Times
144
+ may be passed in '%I:%M%p' format (e.g ['06:15 AM', '12:15 PM']).
145
145
  If argument is an iterable then the job will be scheduled at each
146
146
  constituent time.
147
147
  interval : int
@@ -182,7 +182,7 @@ class TaskMaster(object):
182
182
  else:
183
183
  raise Exception("'every' argument cannot be None")
184
184
 
185
- for at in odd.to_iter(at):
185
+ for at in odd.ensure_list(at):
186
186
  job = getattr(cls.scheduler.every(interval), every)
187
187
  if at is not None:
188
188
  try:
@@ -173,7 +173,7 @@ class Timestamp(object):
173
173
  shifted : Timestamp
174
174
  Timestamp instance
175
175
  '''
176
- odd.validate_value(value=arg, attr='arg', types=str)
176
+ odd.validate_value(value=arg, name='arg', types=str)
177
177
  kind = func.__name__
178
178
 
179
179
  # try weekday
@@ -262,8 +262,8 @@ class Timestamp(object):
262
262
  self._dt = value
263
263
  else:
264
264
  raise TypeError(
265
- f"Value must be of type <datetime.datetime> when set directly, "
266
- f"got: {value!r} of type <{type(value).__name__}>."
265
+ f'Value must be of type <datetime.datetime> when set '
266
+ f'directly, got: {value!r} of type <{type(value).__name__}>.'
267
267
  )
268
268
 
269
269
 
@@ -286,9 +286,9 @@ class Timestamp(object):
286
286
 
287
287
 
288
288
  @property
289
- def pandas(self):
290
- ''' to_pandas() alias '''
291
- return self.to_pandas()
289
+ def pd(self):
290
+ ''' to_pandas_timestamp() alias '''
291
+ return self.to_pandas_timestamp()
292
292
 
293
293
 
294
294
  @property
@@ -564,19 +564,24 @@ class Timestamp(object):
564
564
  return self.__class__(dt)
565
565
 
566
566
 
567
+ def to_base(self):
568
+ ''' return a base-class version of this instance '''
569
+ return self._make_base(self)
570
+
571
+
567
572
  def to_datetime(self):
568
573
  ''' returns a copy of the underlying datetime.datetime object '''
569
574
  return deepcopy(self.dt)
570
575
 
571
576
 
572
- def to_pandas(self):
577
+ def to_pandas_timestamp(self):
573
578
  ''' return as a pd.Timestamp object '''
574
579
  return pd.to_datetime(self.dt)
575
580
 
576
581
 
577
582
  def to_timestamp(self):
578
583
  ''' returns timestamp expressed in seconds '''
579
- return self.to_pandas().timestamp()
584
+ return self.pd.timestamp()
580
585
 
581
586
 
582
587
  def to_date(self):
@@ -1,4 +1,4 @@
1
- from oddments import validate_value
1
+ import oddments as odd
2
2
  import re
3
3
 
4
4
 
@@ -74,8 +74,8 @@ def temporal_format_to_regex(format, encase=False):
74
74
  pattern : str
75
75
  regex pattern
76
76
  '''
77
- validate_value(value=format, attr='format', types=str)
78
- validate_value(value=encase, attr='encase', types=bool)
77
+ odd.validate_value(value=format, name='format', types=str)
78
+ odd.validate_value(value=encase, name='encase', types=bool)
79
79
 
80
80
  digit_pattern = lambda x: r'\d{%d}' % x
81
81
  mapping = {}
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "clockwork"
3
- version = "0.3.5"
3
+ version = "0.4.0"
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"
@@ -14,7 +14,7 @@ pandas = "*"
14
14
  numpy = "*"
15
15
  schedule = "*"
16
16
  holidays = "*"
17
- oddments = ">=0.3.1"
17
+ oddments = ">=0.4.0"
18
18
 
19
19
  [build-system]
20
20
  requires = ["poetry-core"]
File without changes
File without changes