Changed frequency into a dataclass
For more compact and pythonic code
This commit is contained in:
parent
1f2b75282b
commit
b6b2381163
@ -11,15 +11,12 @@ class Options:
|
|||||||
closest: str = 'before' # after
|
closest: str = 'before' # after
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass(frozen=True)
|
||||||
class Frequency:
|
class Frequency:
|
||||||
def __init__(self, name, interval_type, interval_value, interval_days_value):
|
name: str
|
||||||
self.name = name
|
freq_type: str
|
||||||
self.type = interval_type
|
value: int
|
||||||
self.value = interval_value
|
days: int
|
||||||
self.days = interval_days_value
|
|
||||||
|
|
||||||
def __repr__(self):
|
|
||||||
return f"Frequency({self.name}, {self.type}, {self.value}, {self.days})"
|
|
||||||
|
|
||||||
|
|
||||||
class AllFrequencies:
|
class AllFrequencies:
|
||||||
@ -43,7 +40,7 @@ def create_date_series(
|
|||||||
dates = []
|
dates = []
|
||||||
|
|
||||||
for i in range(0, int(datediff)):
|
for i in range(0, int(datediff)):
|
||||||
diff = {frequency.type: frequency.value*i}
|
diff = {frequency.freq_type: frequency.value*i}
|
||||||
dates.append(start_date + relativedelta(**diff))
|
dates.append(start_date + relativedelta(**diff))
|
||||||
|
|
||||||
return dates
|
return dates
|
||||||
|
Loading…
Reference in New Issue
Block a user