Fix single emtpy .ics file issue

The function responsible for determining the file
name for the .ics files was not handling paths properly,
resulting in a single .ics file being generated. This
fixes the issue and also tweaks the INFO output a bit.

Change-Id: Ib620cf5d683f74b3d5066e6e6ce75e1b7e36ed1d
This commit is contained in:
Mathew Odden 2014-05-30 20:58:03 -05:00
parent edd18b7bf6
commit a753e41ee7
2 changed files with 7 additions and 5 deletions

View File

@ -98,18 +98,21 @@ class Meeting:
# add event to calendar
cal.add_component(event)
# write ical files to disk
ical_filename = self.filename.split('.')[0] + '.ics'
# determine file name from source file
ical_filename = os.path.basename(self.filename).split('.')[0] + '.ics'
ical_filename = os.path.join(ical_dir, ical_filename)
if not os.path.exists(ical_dir):
os.makedirs(ical_dir)
# write ical files to disk
with open(ical_filename, 'wb') as ics:
ics.write(cal.to_ical())
num_events = len(cal.subcomponents)
logging.info('\'%s\' processed. [%d event(s)]' % (ical_filename,
num_events))
logging.info("Wrote %(num_events)d event(s) to file '%(ical_file)s'" %
{'ical_file': ical_filename,
'num_events': num_events})
def get_schedule_tuple(self):
"""returns a list of meeting tuples consisting meeting name, meeting

View File

@ -45,7 +45,6 @@ def load_meetings(yaml_dir, meeting_list=None):
continue
meetings_yaml.append(yaml_file)
print meetings_yaml
meetings = [Meeting(yaml.load(open(f, 'r')), f)
for f in meetings_yaml]