Merge "Add functionality to batch the meetings list"

This commit is contained in:
Jenkins 2016-02-05 02:07:41 +00:00 committed by Gerrit Code Review
commit b14b2fb3cf
2 changed files with 18 additions and 0 deletions

View File

@ -10,6 +10,8 @@
# License for the specific language governing permissions and limitations
# under the License.
from __future__ import division
import datetime
import jinja2
import logging
@ -17,6 +19,20 @@ import os
import os.path
def batch_meetings(meetings, batch_size):
col_length = len(meetings) // batch_size
new_meetings = [None] * len(meetings)
src = 0
for row in range(batch_size):
for col in range(col_length):
dest = col * batch_size + row
new_meetings[dest] = meetings[src]
src += 1
return new_meetings
def convert_meetings_to_index(meetings, template, output_file):
"""Creates index file from list of meetings.
@ -30,6 +46,7 @@ def convert_meetings_to_index(meetings, template, output_file):
loader = jinja2.FileSystemLoader(template_dir)
env = jinja2.environment.Environment(trim_blocks=True, loader=loader)
template = env.get_template(template_file)
template.globals['batch_meetings'] = batch_meetings
with open(output_file, "w") as out:
out.write(template.render(meetings=meetings,

View File

@ -214,6 +214,7 @@ def load_meetings(yaml_source):
raise ValueError("No .yaml file, directory containing .yaml files, "
"or YAML data found.")
else:
meetings.sort(key=lambda x: x.project)
return meetings