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:
parent
2747e0cc94
commit
7fbe7fb43a
31
src/jobs.py
31
src/jobs.py
@ -3,23 +3,31 @@ import icalendar
|
|||||||
import pprint
|
import pprint
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
from meeting import Meeting
|
||||||
|
|
||||||
class MeetingJobs:
|
class MeetingJobs:
|
||||||
"""Executes post, gate, and check jobs."""
|
"""Executes post, gate, and check jobs."""
|
||||||
|
|
||||||
# make this a singleton?
|
yaml_dir = '../meetings'
|
||||||
|
publish_url = '127.0.0.1'
|
||||||
def __init__(self, publish_url):
|
|
||||||
self.publish_url = publish_url
|
|
||||||
|
|
||||||
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
|
pass
|
||||||
|
|
||||||
def execute_gate():
|
def execute_post(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def execute_post():
|
def create_meetings(self, yaml_dir):
|
||||||
pass
|
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():
|
def pprint_yaml():
|
||||||
"""For now, this is a simple script to import all the yaml files and pretty print it."""
|
"""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:
|
for m in meetings:
|
||||||
print(yaml.dump(m))
|
print(yaml.dump(m))
|
||||||
|
|
||||||
# main
|
# entry point
|
||||||
pprint_yaml()
|
#pprint_yaml()
|
||||||
|
jobs = MeetingJobs()
|
||||||
|
jobs.execute_check()
|
||||||
|
@ -1,29 +1,31 @@
|
|||||||
|
import pprint
|
||||||
|
|
||||||
class Meeting:
|
class Meeting:
|
||||||
"""An OpenStack meeting."""
|
"""An OpenStack meeting."""
|
||||||
|
|
||||||
def __init__(self, yaml_file):
|
def __init__(self, yaml):
|
||||||
|
|
||||||
# create yaml object from yaml file. use it initialize following fields.
|
# create yaml object from yaml file. use it initialize following fields.
|
||||||
|
self.project = yaml['project']
|
||||||
self.proj_name = yaml.name
|
self.chair = yaml['chair']
|
||||||
self.uuid = yaml.uuid
|
self.description = yaml['description']
|
||||||
self.chair = yaml.chair
|
self.agenda = pprint.pformat(yaml['agenda']) # this is a list of topics
|
||||||
self.descript = yaml.descript
|
|
||||||
self.agenda = yaml.agenda # this is a list of topics
|
|
||||||
|
|
||||||
# create schedule object
|
# 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
|
def display(self):
|
||||||
# be an easy way to check is anything has changed that needs to be
|
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())
|
||||||
# published)
|
|
||||||
self.checksum = generated_checksum
|
|
||||||
|
|
||||||
class Schedule:
|
class Schedule:
|
||||||
"""A meeting schedule."""
|
"""A meeting schedule."""
|
||||||
|
|
||||||
def __init__(self, time, day, irc, period):
|
def __init__(self, time, day, irc, period):
|
||||||
self.time = time
|
self.time = time
|
||||||
self.day = day
|
self.day = day
|
||||||
self.irc = irc
|
self.irc = irc
|
||||||
self.period = period
|
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)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user