diff --git a/dj/scripts/addeps.py b/dj/scripts/addeps.py index 4547613..8c564d2 100755 --- a/dj/scripts/addeps.py +++ b/dj/scripts/addeps.py @@ -2,6 +2,7 @@ # adds episodes from an external source, like a csv +import datetime from csv import DictReader from datetime import timedelta from dateutil.parser import parse @@ -10,6 +11,10 @@ from process import process from main.models import Client, Show, Location, Episode + +DJANGOCON_START_DATE = datetime.date(2009, 9, 8) + + def fnify(text): """ file_name_ify - make a file name out of text, like a talk title. @@ -27,6 +32,8 @@ class process_csv(process): def one_show(self, show): seq=0 + current_date = DJANGOCON_START_DATE + last_start = None for row in DictReader(open(self.csv_pathname)): seq+=1 print row @@ -41,14 +48,18 @@ class process_csv(process): # Remove #N from the start of PhOhio talk titles: # if name.startswith('#'): name = ' '.join(name.split()[1:]) + start = datetime.time(*map(int, row['Startime'].split(':'))) + end = datetime.time(*map(int, row['Endtime'].split(':'))) + + if last_start and start > last_start: + current_date = current_date + datetime.timedelta(days=1) + + last_start = start - # dt = row['date']+' '+ row['time'] - talkdate='2009-09-08' - start=row['Starttime'] - start=parse(row['Starttime']) - # minutes = int(row['min']) - # end=start+timedelta(minutes=minutes) - end = row['Endtime'] + start_date = datetime.datetime( + *current_date.timetuple()[:3] + start.timetuple()) + end_date = datetime.datetime( + *current_date.timetuple()[:3] + end.timetuple()) ep = Episode( sequence=seq, @@ -57,9 +68,8 @@ class process_csv(process): slug=fnify(name), primary=row['id'], authors=row['presenters'], - start=start, end=end, - state=self.state_done - ) + start=start_date, end=end_date, + state=self.state_done) # ep.save() def add_more_options(self, parser):