11import logging
22from datetime import datetime , timedelta , timezone
3- from dateutil .tz import tzlocal
4- from .messages import VolunteeringReminderNotification
53from functools import total_ordering
6- from django .core .mail import EmailMessage
7- from .models import Chore , ChoreNotification
84
95import humanize
106from croniter import croniter
7+ from dateutil .tz import tzlocal
8+ from django .core .mail import EmailMessage
9+
10+ from .messages import VolunteeringReminderNotification
11+ from .models import Chore , ChoreNotification
12+
1113logger = logging .getLogger (__name__ )
1214
1315HUMAN_DATETIME_STRING = "%H:%M:%S %d/%m/%Y"
1416local_timezone = tzlocal ()
1517
18+
1619class BaseNudge (object ):
1720 """Base class for all nudge types with common functionality."""
1821
@@ -229,7 +232,6 @@ def get_num_days_of_earliest_reminder(self):
229232 return max ([0 ] + [reminder .when ["days_before" ] for reminder in self .reminders ])
230233
231234
232-
233235class RecurrentEventGenerator (object ):
234236 def __init__ (self , starting_time , crontab , take_one_every ):
235237 self .starting_time = Time .from_datetime (
@@ -257,9 +259,6 @@ def iter_events_from_to(self, aggregator, ts_from, ts_to):
257259 yield ChoreEvent (aggregator , self .event_time )
258260
259261
260-
261-
262-
263262ALL_CHORE_TYPES = [
264263 BasicChore ,
265264]
@@ -321,6 +320,7 @@ def get_chore_type_class(chore):
321320 return chore_class
322321 raise Exception (f'Cannot find Python class for chore of type "{ chore .class_type } "' )
323322
323+
324324def build_chore_instance (chore ):
325325 chore_class = get_chore_type_class (chore )
326326 return chore_class (chore .id , chore .name , chore .description , ** chore .configuration )
@@ -339,6 +339,7 @@ def calculate_reminder_time(event, when):
339339 )
340340 return reminder_time
341341
342+
342343@total_ordering
343344class Time (object ):
344345 # Internally represents time in UTC
0 commit comments