diff --git a/doc/source/_exts/candidates.py b/doc/source/_exts/candidates.py index 1707a5e9..9796a9e5 100644 --- a/doc/source/_exts/candidates.py +++ b/doc/source/_exts/candidates.py @@ -14,6 +14,7 @@ """ import os +import subprocess from jinja2 import FileSystemLoader from jinja2.environment import Environment @@ -22,6 +23,13 @@ BASE_URL = "http://git.openstack.org/cgit/openstack/election" PATH_PREFIX = 'candidates' +def get_fullname(filepath, exceptions): + if filepath in exceptions: + return exceptions[filepath] + return subprocess.Popen(["git", "log", "--format=%aN", filepath], + stdout=subprocess.PIPE).stdout.readlines()[-1][:-1] + + def render_template(template, data, **kwargs): template_dir = kwargs.get('template_dir', os.getcwd()) loader = FileSystemLoader(template_dir) @@ -33,17 +41,30 @@ def render_template(template, data, **kwargs): def build_candidates_list(election): project_list = os.listdir(os.path.join(PATH_PREFIX, election)) project_list.sort() + exceptions = {} + for e in open("exceptions.txt").readlines(): + if e[0] == "#" or ":" not in e: + continue + exceptions[e.split(':')[0]] = " ".join(e.split(':')[1:])[:-1].strip() candidates_lists = {} for project in project_list: project_prefix = os.path.join(PATH_PREFIX, election, project) - candidates_list = filter( + file_list = filter( lambda x: x.endswith(".txt"), os.listdir(unicode(project_prefix)), ) - candidates_list = [os.path.join(project_prefix, c) - for c in candidates_list] - candidates_list.sort() + candidates_list = [] + for candidate_file in file_list: + filepath = os.path.join(project_prefix, candidate_file) + candidates_list.append( + { + 'path': filepath, + 'ircname': os.path.basename(filepath)[:-4], + 'fullname': get_fullname(filepath, exceptions) + }) + + candidates_list.sort(key=lambda x: x['fullname']) candidates_lists[project] = candidates_list return {'election': election, diff --git a/doc/source/_exts/ptl.jinja b/doc/source/_exts/ptl.jinja index daddda52..fb69b0db 100644 --- a/doc/source/_exts/ptl.jinja +++ b/doc/source/_exts/ptl.jinja @@ -4,7 +4,7 @@ * {{ project.replace('_', ' ') }} {% for candidate in candidates[project] %} - * `{{ candidate.split('/')[-1][:-4].replace('_', ' ').title() }} `_ + * `{{ candidate['fullname'] }} ({{ candidate['ircname'] }}) `_ {% endfor %} {% endif %}{% endfor %} diff --git a/doc/source/_exts/tc.jinja b/doc/source/_exts/tc.jinja index 3a95d476..e87ef01d 100644 --- a/doc/source/_exts/tc.jinja +++ b/doc/source/_exts/tc.jinja @@ -2,5 +2,5 @@ ====================== {% for candidate in candidates['TC'] %} - * `{{ candidate.split('/')[-1][:-4].replace('_', ' ').title() }} `_ + * `{{ candidate['fullname'] }} ({{ candidate['ircname'] }}) `_ {% endfor %} diff --git a/doc/source/index.rst b/doc/source/index.rst index 5d4db009..796533e5 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -10,13 +10,15 @@ OpenStack Election .. include:: ./candidates/events.rst -See `Election system`_ `PTL details`_ and `TC details`_. +See `Election system`_, `PTL details`_ and `TC details`_. Below is the official list of candidates for the current round. .. TODO: Change from ptl.rst to tc.rst when TC rounds starts .. include:: ./candidates/ptl.rst +.. TODO: Adds TC Results and a link to `TC Candidates list`_ when TC candidacies are over +.. TODO: Adds PTL Results and a link to `PTL Candidates list`_ when PTL candidacies are over Election Officials ================== @@ -144,6 +146,10 @@ candidates//TC/.txt. The candidacy is then confirmed by elections officials through gerrit vote. See above `How to submit a candidacy`_ documentation. + +.. TODO: add PTL Candidates list when PTL elections are over +.. TODO: add TC Candidates list when TC elections are over + .. seealso:: See the `Election Officiating Guidelines`_ page in the wiki for details on the diff --git a/exceptions.txt b/exceptions.txt new file mode 100644 index 00000000..397ac3ee --- /dev/null +++ b/exceptions.txt @@ -0,0 +1,2 @@ +# This file contains exception for manually verified candidates +# :