Merge "Add configuration.yaml"

This commit is contained in:
Jenkins 2016-09-16 00:04:27 +00:00 committed by Gerrit Code Review
commit 7ddc80621c
5 changed files with 15 additions and 19 deletions

9
configuration.yaml Normal file
View File

@ -0,0 +1,9 @@
timelines:
- {'date': '2016-09-12T00:00', 'name': 'PTL nomination starts'}
- {'date': '2016-09-18T23:45', 'name': 'PTL nomination ends'}
- {'date': '2016-09-19T00:00', 'name': 'PTL elections begins'}
- {'date': '2016-09-25T23:45', 'name': 'PTL elections ends'}
- {'date': '2016-09-26T00:00', 'name': 'TC nomination starts'}
- {'date': '2016-10-01T23:45', 'name': 'TC nomination ends'}
- {'date': '2016-10-03T00:00', 'name': 'TC elections begins'}
- {'date': '2016-10-08T23:45', 'name': 'TC elections ends'}

View File

@ -14,23 +14,21 @@
""" """
import os import os
import yaml
import calendar import calendar
import time import time
from jinja2 import FileSystemLoader from jinja2 import FileSystemLoader
from jinja2.environment import Environment from jinja2.environment import Environment
PATH_PREFIX = 'candidates' from openstack_election import utils
def build_timer(app): def build_timer(app):
app.add_javascript("event_timer.js") app.add_javascript("event_timer.js")
data = yaml.load(open("events.yaml").read())
# add better text for tabulatted planning # add better text for tabulatted planning
now = time.time() now = time.time()
outdated = '*' outdated = '*'
for ev in data: for ev in utils.conf['timelines']:
d, h = ev['date'].split('T') d, h = ev['date'].split('T')
epoch_time = calendar.timegm( epoch_time = calendar.timegm(
time.strptime(ev['date'], "%Y-%m-%dT%H:%M")) time.strptime(ev['date'], "%Y-%m-%dT%H:%M"))
@ -45,18 +43,15 @@ def build_timer(app):
outdated = '' outdated = ''
ev['date_str'] = "%s%s, %s UTC%s" % (outdated, d, h, outdated) ev['date_str'] = "%s%s, %s UTC%s" % (outdated, d, h, outdated)
ev['name_str'] = "%s%s%s" % (outdated, ev['name'], outdated) ev['name_str'] = "%s%s%s" % (outdated, ev['name'], outdated)
output_file = os.path.join(PATH_PREFIX, "events.rst") output_file = os.path.join(utils.CANDIDATE_PATH, "events.rst")
with open(output_file, "w") as out: with open(output_file, "w") as out:
template_dir = os.path.join(".", "doc", "source", "_exts") template_dir = os.path.join(".", "doc", "source", "_exts")
loader = FileSystemLoader(template_dir) loader = FileSystemLoader(template_dir)
env = Environment(trim_blocks=True, loader=loader) env = Environment(trim_blocks=True, loader=loader)
template = env.get_template("events.jinja") template = env.get_template("events.jinja")
out.write(template.render({'events': data})) out.write(template.render({'events': utils.conf['timelines']}))
def setup(app): def setup(app):
if not os.path.isfile("events.yaml"):
app.info('No events.yaml found, not loading events_timer extension')
return
app.info('loading events_timer extension') app.info('loading events_timer extension')
app.connect('builder-inited', build_timer) app.connect('builder-inited', build_timer)

View File

@ -1,9 +0,0 @@
---
- {'date': '2016-09-12T00:00', 'name': 'PTL nomination starts'}
- {'date': '2016-09-18T23:45', 'name': 'PTL nomination ends'}
- {'date': '2016-09-19T00:00', 'name': 'PTL elections begins'}
- {'date': '2016-09-25T23:45', 'name': 'PTL elections ends'}
- {'date': '2016-09-26T00:00', 'name': 'TC nomination starts'}
- {'date': '2016-10-01T23:45', 'name': 'TC nomination ends'}
- {'date': '2016-10-03T00:00', 'name': 'TC elections begins'}
- {'date': '2016-10-08T23:45', 'name': 'TC elections ends'}

View File

@ -43,6 +43,7 @@ CGIT_URL = 'https://git.openstack.org/cgit'
PROJECTS_URL = ('%s/openstack/governance/plain/reference/projects.yaml' % PROJECTS_URL = ('%s/openstack/governance/plain/reference/projects.yaml' %
(CGIT_URL)) (CGIT_URL))
conf = yaml.load(open('configuration.yaml'))
exceptions = None exceptions = None

View File

@ -15,7 +15,7 @@ deps = -r{toxinidir}/requirements.txt
commands = python setup.py testr --slowest --testr-args="{posargs}" commands = python setup.py testr --slowest --testr-args="{posargs}"
[testenv:linters] [testenv:linters]
commands = yamllint events.yaml commands = yamllint configuration.yaml
flake8 flake8
[testenv:venv] [testenv:venv]