Refactor schedule class into its own module
Previously, the schedule class was in the meeting module with the meeting class. This change pulls schedule into its own module. This will be easier for unit testing and will make it is easier for us to change in the future if we want to incorporate the schedule class purpose into the meeting object. Change-Id: I3f03c2167997b39fadd362bd66a35cae570503ef
This commit is contained in:
parent
edd18b7bf6
commit
7dd6117659
@ -23,7 +23,8 @@ import icalendar
|
||||
import pytz
|
||||
import yaml
|
||||
|
||||
import const
|
||||
from arbiter import const
|
||||
from arbiter import schedule
|
||||
|
||||
|
||||
class Meeting:
|
||||
@ -41,7 +42,10 @@ class Meeting:
|
||||
self.agenda = yaml['agenda'] # this is a list of list of topics
|
||||
|
||||
# create schedule objects
|
||||
self.schedules = [Schedule(schedule) for schedule in yaml['schedule']]
|
||||
self.schedules = []
|
||||
for sch in yaml['schedule']:
|
||||
s = schedule.Schedule(sch)
|
||||
self.schedules.append(s)
|
||||
|
||||
def write_ical(self, ical_dir):
|
||||
"""Write this meeting to disk using the iCal format."""
|
||||
@ -129,18 +133,6 @@ class Meeting:
|
||||
return meetings
|
||||
|
||||
|
||||
class Schedule:
|
||||
"""A meeting schedule."""
|
||||
|
||||
def __init__(self, sched_yaml):
|
||||
"""Initialize schedule from yaml."""
|
||||
|
||||
self.time = datetime.datetime.strptime(sched_yaml['time'], '%H%M')
|
||||
self.day = sched_yaml['day']
|
||||
self.irc = sched_yaml['irc']
|
||||
self.freq = sched_yaml['frequency']
|
||||
|
||||
|
||||
def next_weekday(ref_date, weekday):
|
||||
"""Return the date of the next weekday after ref_date."""
|
||||
|
||||
|
30
arbiter/schedule.py
Normal file
30
arbiter/schedule.py
Normal file
@ -0,0 +1,30 @@
|
||||
#! /usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright 2014 OpenStack Foundation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import datetime
|
||||
|
||||
|
||||
class Schedule:
|
||||
"""A meeting schedule."""
|
||||
|
||||
def __init__(self, sched_yaml):
|
||||
"""Initialize schedule from yaml."""
|
||||
|
||||
self.time = datetime.datetime.strptime(sched_yaml['time'], '%H%M')
|
||||
self.day = sched_yaml['day']
|
||||
self.irc = sched_yaml['irc']
|
||||
self.freq = sched_yaml['frequency']
|
Loading…
x
Reference in New Issue
Block a user