@@ -224,10 +224,19 @@ class croniter(object):
224
224
130
225
225
)
226
226
227
- def __init__ (self , expr_format , start_time = None , ret_type = float ,
228
- day_or = True , max_years_between_matches = None , is_prev = False ,
229
- hash_id = None , implement_cron_bug = False , second_at_beginning = None ,
230
- expand_from_start_time = False ):
227
+ def __init__ (
228
+ self ,
229
+ expr_format ,
230
+ start_time = None ,
231
+ ret_type = float ,
232
+ day_or = True ,
233
+ max_years_between_matches = None ,
234
+ is_prev = False ,
235
+ hash_id = None ,
236
+ implement_cron_bug = False ,
237
+ second_at_beginning = None ,
238
+ expand_from_start_time = False ,
239
+ ):
231
240
self ._ret_type = ret_type
232
241
self ._day_or = day_or
233
242
self ._implement_cron_bug = implement_cron_bug
@@ -337,7 +346,13 @@ def _timedelta_to_seconds(td):
337
346
"""
338
347
return timedelta_to_seconds (td )
339
348
340
- def _get_next (self , ret_type = None , start_time = None , is_prev = None , update_current = None ):
349
+ def _get_next (
350
+ self ,
351
+ ret_type = None ,
352
+ start_time = None ,
353
+ is_prev = None ,
354
+ update_current = None ,
355
+ ):
341
356
if update_current is None :
342
357
update_current = True
343
358
self .set_current (start_time , force = True )
@@ -800,7 +815,13 @@ def value_alias(cls, val, field_index, len_expressions=UNIX_CRON_LEN):
800
815
return val
801
816
802
817
@classmethod
803
- def _expand (cls , expr_format , hash_id = None , second_at_beginning = False , from_timestamp = None ):
818
+ def _expand (
819
+ cls ,
820
+ expr_format ,
821
+ hash_id = None ,
822
+ second_at_beginning = False ,
823
+ from_timestamp = None ,
824
+ ):
804
825
# Split the expression in components, and normalize L -> l, MON -> mon,
805
826
# etc. Keep expr_format untouched so we can use it in the exception
806
827
# messages.
@@ -1019,7 +1040,13 @@ def _expand(cls, expr_format, hash_id=None, second_at_beginning=False, from_time
1019
1040
return expanded , nth_weekday_of_month
1020
1041
1021
1042
@classmethod
1022
- def expand (cls , expr_format , hash_id = None , second_at_beginning = False , from_timestamp = None ):
1043
+ def expand (
1044
+ cls ,
1045
+ expr_format ,
1046
+ hash_id = None ,
1047
+ second_at_beginning = False ,
1048
+ from_timestamp = None ,
1049
+ ):
1023
1050
"""
1024
1051
Expand a cron expression format into a noramlized format of
1025
1052
list[list[int | 'l' | '*']]. The first list representing each element
@@ -1088,8 +1115,13 @@ def _get_low_from_current_date_number(cls, field_index, step, from_timestamp):
1088
1115
raise ValueError ("Can't get current date number for index larger than 4" )
1089
1116
1090
1117
@classmethod
1091
- def is_valid (cls , expression , hash_id = None , encoding = "UTF-8" ,
1092
- second_at_beginning = False ):
1118
+ def is_valid (
1119
+ cls ,
1120
+ expression ,
1121
+ hash_id = None ,
1122
+ encoding = "UTF-8" ,
1123
+ second_at_beginning = False ,
1124
+ ):
1093
1125
if hash_id :
1094
1126
if not isinstance (hash_id , (bytes , str )):
1095
1127
raise TypeError ("hash_id must be bytes or UTF-8 string" )
@@ -1108,8 +1140,14 @@ def match(cls, cron_expression, testdate, day_or=True, second_at_beginning=False
1108
1140
return cls .match_range (cron_expression , testdate , testdate , day_or , second_at_beginning )
1109
1141
1110
1142
@classmethod
1111
- def match_range (cls , cron_expression , from_datetime , to_datetime ,
1112
- day_or = True , second_at_beginning = False ):
1143
+ def match_range (
1144
+ cls ,
1145
+ cron_expression ,
1146
+ from_datetime ,
1147
+ to_datetime ,
1148
+ day_or = True ,
1149
+ second_at_beginning = False ,
1150
+ ):
1113
1151
cron = cls (cron_expression , to_datetime , ret_type = datetime .datetime ,
1114
1152
day_or = day_or , second_at_beginning = second_at_beginning )
1115
1153
tdp = cron .get_current (datetime .datetime )
@@ -1125,10 +1163,17 @@ def match_range(cls, cron_expression, from_datetime, to_datetime,
1125
1163
return (max (tdp , tdt ) - min (tdp , tdt )).total_seconds () < duration_in_second
1126
1164
1127
1165
1128
- def croniter_range (start , stop , expr_format , ret_type = None , day_or = True , exclude_ends = False ,
1129
- _croniter = None ,
1130
- second_at_beginning = False ,
1131
- expand_from_start_time = False ):
1166
+ def croniter_range (
1167
+ start ,
1168
+ stop ,
1169
+ expr_format ,
1170
+ ret_type = None ,
1171
+ day_or = True ,
1172
+ exclude_ends = False ,
1173
+ _croniter = None ,
1174
+ second_at_beginning = False ,
1175
+ expand_from_start_time = False ,
1176
+ ):
1132
1177
"""
1133
1178
Generator that provides all times from start to stop matching the given cron expression.
1134
1179
If the cron expression matches either 'start' and/or 'stop', those times will be returned as
0 commit comments