Update hacking version
yaml2ical was using a very old version that started to break with newer Python, so it's time to upgrade. This requires a few adjustments to quiet new warnings. Change-Id: Ib081dcfeca7c40f877059793dab58d00a7b0d53e
This commit is contained in:
parent
90ddef2d8c
commit
b413607a97
@ -1,4 +1,4 @@
|
|||||||
hacking>=0.11.0,<0.12 # Apache-2.0
|
hacking>=3.2.0 # Apache-2.0
|
||||||
|
|
||||||
coverage>=3.6 # Apache-2.0
|
coverage>=3.6 # Apache-2.0
|
||||||
fixtures>=3.0.0 # Apache-2.0/BSD
|
fixtures>=3.0.0 # Apache-2.0/BSD
|
||||||
|
@ -38,92 +38,92 @@ class Yaml2IcalCalendar(icalendar.Calendar):
|
|||||||
self.add_schedule(meeting, sch)
|
self.add_schedule(meeting, sch)
|
||||||
|
|
||||||
def add_schedule(self, meeting, sch, exdate=None):
|
def add_schedule(self, meeting, sch, exdate=None):
|
||||||
event = icalendar.Event()
|
event = icalendar.Event()
|
||||||
|
|
||||||
# NOTE(jotan): I think the summary field needs to be unique per
|
# NOTE(jotan): I think the summary field needs to be unique per
|
||||||
# event in an ical file (at least, for it to work with
|
# event in an ical file (at least, for it to work with
|
||||||
# Google Calendar)
|
# Google Calendar)
|
||||||
|
|
||||||
summary = meeting.project
|
summary = meeting.project
|
||||||
# NOTE(tonyb): If we're adding an a place holder event for a
|
# NOTE(tonyb): If we're adding an a place holder event for a
|
||||||
# cancelled meeting make that as obvious as possible in the
|
# cancelled meeting make that as obvious as possible in the
|
||||||
# summary.
|
# summary.
|
||||||
if exdate:
|
if exdate:
|
||||||
# NOTE(tonyb): Because some iCal consumers require that the
|
# NOTE(tonyb): Because some iCal consumers require that the
|
||||||
# summary be unique, and adding multiple "CANCELLED: $x"
|
# summary be unique, and adding multiple "CANCELLED: $x"
|
||||||
# entries would violate that rule, append the (UTC)
|
# entries would violate that rule, append the (UTC)
|
||||||
# timestamp for the cancelled meeting.
|
# timestamp for the cancelled meeting.
|
||||||
suffix = exdate.date_str
|
suffix = exdate.date_str
|
||||||
summary = 'CANCELLED: %s (%s)' % (summary, suffix)
|
summary = 'CANCELLED: %s (%s)' % (summary, suffix)
|
||||||
event.add('summary', summary)
|
event.add('summary', summary)
|
||||||
event.add('location', '#' + sch.irc)
|
event.add('location', '#' + sch.irc)
|
||||||
|
|
||||||
# add ical description
|
# add ical description
|
||||||
project_descript = "Project: %s" % (meeting.project)
|
project_descript = "Project: %s" % (meeting.project)
|
||||||
chair_descript = "Chair: %s" % (meeting.chair)
|
chair_descript = "Chair: %s" % (meeting.chair)
|
||||||
descript_descript = "Description: %s" % (meeting.description)
|
descript_descript = "Description: %s" % (meeting.description)
|
||||||
ical_descript = "\n".join((project_descript,
|
ical_descript = "\n".join((project_descript,
|
||||||
chair_descript,
|
chair_descript,
|
||||||
descript_descript))
|
descript_descript))
|
||||||
# Add URLs, if present, to the description
|
# Add URLs, if present, to the description
|
||||||
if 'agenda_url' in meeting.extras:
|
if 'agenda_url' in meeting.extras:
|
||||||
ical_descript = "\n".join((ical_descript,
|
ical_descript = "\n".join((ical_descript,
|
||||||
"Agenda URL: %s" %
|
"Agenda URL: %s" %
|
||||||
(meeting.extras['agenda_url'])))
|
(meeting.extras['agenda_url'])))
|
||||||
if 'project_url' in meeting.extras:
|
if 'project_url' in meeting.extras:
|
||||||
ical_descript = "\n".join((ical_descript,
|
ical_descript = "\n".join((ical_descript,
|
||||||
"Project URL: %s" %
|
"Project URL: %s" %
|
||||||
(meeting.extras['project_url'])))
|
(meeting.extras['project_url'])))
|
||||||
|
|
||||||
# NOTE(tonyb): If we're adding an a place holder event for a
|
# NOTE(tonyb): If we're adding an a place holder event for a
|
||||||
# cancelled meeting do not add an rrule and set dtstart to the
|
# cancelled meeting do not add an rrule and set dtstart to the
|
||||||
# skipped date.
|
# skipped date.
|
||||||
if not exdate:
|
if not exdate:
|
||||||
# get starting date
|
# get starting date
|
||||||
next_meeting = sch.recurrence.next_occurence(sch.start_date,
|
next_meeting = sch.recurrence.next_occurence(sch.start_date,
|
||||||
sch.day)
|
sch.day)
|
||||||
# NOTE(aschultz): to handle adhoc meetings, we check to make
|
# NOTE(aschultz): to handle adhoc meetings, we check to make
|
||||||
# sure there is a next meeting before trying to add it to the
|
# sure there is a next meeting before trying to add it to the
|
||||||
# the calendar
|
# the calendar
|
||||||
if next_meeting is None:
|
if next_meeting is None:
|
||||||
return
|
return
|
||||||
next_meeting_date = datetime.datetime(next_meeting.year,
|
next_meeting_date = datetime.datetime(next_meeting.year,
|
||||||
next_meeting.month,
|
next_meeting.month,
|
||||||
next_meeting.day,
|
next_meeting.day,
|
||||||
sch.time.hour,
|
sch.time.hour,
|
||||||
sch.time.minute,
|
sch.time.minute,
|
||||||
tzinfo=pytz.utc)
|
tzinfo=pytz.utc)
|
||||||
event.add('dtstart', next_meeting_date)
|
event.add('dtstart', next_meeting_date)
|
||||||
|
|
||||||
# add recurrence rule
|
# add recurrence rule
|
||||||
event.add('rrule', sch.recurrence.rrule())
|
event.add('rrule', sch.recurrence.rrule())
|
||||||
event.add('description', ical_descript)
|
event.add('description', ical_descript)
|
||||||
else:
|
else:
|
||||||
event.add('dtstart', exdate.date)
|
event.add('dtstart', exdate.date)
|
||||||
event.add('description', exdate.reason)
|
event.add('description', exdate.reason)
|
||||||
|
|
||||||
event.add('duration', datetime.timedelta(minutes=sch.duration))
|
event.add('duration', datetime.timedelta(minutes=sch.duration))
|
||||||
|
|
||||||
# Add exdate (exclude date) if present
|
# Add exdate (exclude date) if present
|
||||||
if not exdate and hasattr(sch, 'skip_dates'):
|
if not exdate and hasattr(sch, 'skip_dates'):
|
||||||
for skip_date in sch.skip_dates:
|
for skip_date in sch.skip_dates:
|
||||||
event.add('exdate', skip_date.date)
|
event.add('exdate', skip_date.date)
|
||||||
# NOTE(tonyb): If this is a skipped meeting add a
|
# NOTE(tonyb): If this is a skipped meeting add a
|
||||||
# non-recurring event with an obvious summary.
|
# non-recurring event with an obvious summary.
|
||||||
self.add_schedule(meeting, sch, exdate=skip_date)
|
self.add_schedule(meeting, sch, exdate=skip_date)
|
||||||
|
|
||||||
# Add update timestamp and unique ID for the event.
|
# Add update timestamp and unique ID for the event.
|
||||||
# Note: we need a way to uniquely identify the meeting, even if its
|
# Note: we need a way to uniquely identify the meeting, even if its
|
||||||
# details are modified. We don't really have much to go on to do
|
# details are modified. We don't really have much to go on to do
|
||||||
# that, so best effort just use the project name and date.
|
# that, so best effort just use the project name and date.
|
||||||
event.add('dtstamp', meeting.last_update)
|
event.add('dtstamp', meeting.last_update)
|
||||||
start_date = exdate.date if exdate else next_meeting_date
|
start_date = exdate.date if exdate else next_meeting_date
|
||||||
event.add('uid', '%s-%s' % (
|
event.add('uid', '%s-%s' % (
|
||||||
meeting.project.replace(' ', '').lower(),
|
meeting.project.replace(' ', '').lower(),
|
||||||
datetime.datetime.strftime(start_date, '%Y%m%d')))
|
datetime.datetime.strftime(start_date, '%Y%m%d')))
|
||||||
|
|
||||||
# add event to calendar
|
# add event to calendar
|
||||||
self.add_component(event)
|
self.add_component(event)
|
||||||
|
|
||||||
def write_to_disk(self, filename):
|
def write_to_disk(self, filename):
|
||||||
# write ical files to disk
|
# write ical files to disk
|
||||||
|
@ -183,15 +183,15 @@ class MeetingTestCase(unittest.TestCase):
|
|||||||
summary = 'OpenStack Subteam 8 Meeting'
|
summary = 'OpenStack Subteam 8 Meeting'
|
||||||
patterns = []
|
patterns = []
|
||||||
# The "main" meeting should have an exdate
|
# The "main" meeting should have an exdate
|
||||||
patterns.append(re.compile('.*exdate:\s*20150810T120000', re.I))
|
patterns.append(re.compile(r'.*exdate:\s*20150810T120000', re.I))
|
||||||
# The "main" meeting should start on 2015-08-13
|
# The "main" meeting should start on 2015-08-13
|
||||||
patterns.append(re.compile('.*dtstart;.*:20150803T120000Z', re.I))
|
patterns.append(re.compile(r'.*dtstart;.*:20150803T120000Z', re.I))
|
||||||
# The "main" meeting should have a simple summary
|
# The "main" meeting should have a simple summary
|
||||||
patterns.append(re.compile('.*summary:\s*%s' % summary, re.I))
|
patterns.append(re.compile(r'.*summary:\s*%s' % summary, re.I))
|
||||||
# The "skipped" meeting should start on 20150806
|
# The "skipped" meeting should start on 20150806
|
||||||
patterns.append(re.compile('.*dtstart;.*:20150810T120000Z', re.I))
|
patterns.append(re.compile(r'.*dtstart;.*:20150810T120000Z', re.I))
|
||||||
# The "skipped" meeting should say include 'CANCELLED' and the datetime
|
# The "skipped" meeting should say include 'CANCELLED' and the datetime
|
||||||
patterns.append(re.compile('.*summary:\s*CANCELLED.*20150810T120000Z',
|
patterns.append(re.compile(r'.*summary:\s*CANCELLED.*20150810T120000Z',
|
||||||
re.I))
|
re.I))
|
||||||
m = meeting.load_meetings(meeting_yaml)[0]
|
m = meeting.load_meetings(meeting_yaml)[0]
|
||||||
cal = ical.Yaml2IcalCalendar()
|
cal = ical.Yaml2IcalCalendar()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user