Added logic to initialize Meeting object from yaml. Implemented crude display function to test correctness, by showing the initialized values of the Meeting.

This commit is contained in:
Josh Tan 2014-03-07 14:22:13 -06:00
parent 2747e0cc94
commit 7fbe7fb43a
2 changed files with 41 additions and 30 deletions

View File

@ -3,23 +3,31 @@ import icalendar
import pprint
import sys
import os
from meeting import Meeting
class MeetingJobs:
"""Executes post, gate, and check jobs."""
# make this a singleton?
def __init__(self, publish_url):
self.publish_url = publish_url
yaml_dir = '../meetings'
publish_url = '127.0.0.1'
def execute_check():
def execute_check(self):
meetings = self.create_meetings(self.yaml_dir)
meetings_display = "\n".join([m.display() for m in meetings])
print(meetings_display) # testing purpose
# now convert meetings to a list of ical
def execute_gate(self):
pass
def execute_gate():
def execute_post(self):
pass
def execute_post():
pass
def create_meetings(self, yaml_dir):
os.chdir(yaml_dir)
meetings_yaml = [yaml.load(open(f, 'r')) for f in os.listdir() if os.path.isfile(f) and ".yaml" in f]
meetings = [Meeting(y) for y in meetings_yaml]
return meetings
def pprint_yaml():
"""For now, this is a simple script to import all the yaml files and pretty print it."""
@ -33,6 +41,7 @@ def pprint_yaml():
for m in meetings:
print(yaml.dump(m))
# main
pprint_yaml()
# entry point
#pprint_yaml()
jobs = MeetingJobs()
jobs.execute_check()

View File

@ -1,29 +1,31 @@
import pprint
class Meeting:
"""An OpenStack meeting."""
def __init__(self, yaml_file):
def __init__(self, yaml):
# create yaml object from yaml file. use it initialize following fields.
self.proj_name = yaml.name
self.uuid = yaml.uuid
self.chair = yaml.chair
self.descript = yaml.descript
self.agenda = yaml.agenda # this is a list of topics
self.project = yaml['project']
self.chair = yaml['chair']
self.description = yaml['description']
self.agenda = pprint.pformat(yaml['agenda']) # this is a list of topics
# create schedule object
self.schedule = newly_created_schedule_object
schedule = yaml['schedule'][0]
self.schedule = Schedule(schedule['time'], schedule['day'], schedule['irc'], schedule['period'])
# create checksum from something, perhaps entire object (this would
# be an easy way to check is anything has changed that needs to be
# published)
self.checksum = generated_checksum
def display(self):
return "project:\t%s\nchair:\t%s\ndescription:\t%s\nagenda:\t%s\nschedule:\t%s" % (self.project, self.chair, self.description, self.agenda, self.schedule.display())
class Schedule:
"""A meeting schedule."""
class Schedule:
"""A meeting schedule."""
def __init__(self, time, day, irc, period):
self.time = time
self.day = day
self.irc = irc
self.period = period
def __init__(self, time, day, irc, period):
self.time = time
self.day = day
self.irc = irc
self.period = period
def display(self):
return "Schedule:\n\ttime:\t%s\n\tday:\t%s\n\tirc:\t%s\n\tperiod:\t%s\n" % (self.time, self.day, self.irc, self.period)