use template_name and improve structure

This commit is contained in:
Thor77 2015-07-13 21:02:48 +02:00
parent 18f952dbdb
commit dd7732a757
1 changed files with 3 additions and 3 deletions

View File

@ -190,9 +190,7 @@ def parse_logs(log_path, ident_map={}, file_log=False):
def render_template(clients, output, template_name='template.html', title='TeamspeakStats', debug=False): def render_template(clients, output, template_name='template.html', title='TeamspeakStats', debug=False):
# render template # prepare clients
template = Environment(loader=FileSystemLoader(abspath)).get_template('template.html')
clients_onlinetime_ = _get_sorted(clients.clients_by_id, 'onlinetime') clients_onlinetime_ = _get_sorted(clients.clients_by_id, 'onlinetime')
clients_onlinetime = [(client, _format_seconds(onlinetime)) for client, onlinetime in clients_onlinetime_] clients_onlinetime = [(client, _format_seconds(onlinetime)) for client, onlinetime in clients_onlinetime_]
@ -204,6 +202,8 @@ def render_template(clients, output, template_name='template.html', title='Teams
('passive Kicks', clients_pkicks), ('passive Kicks', clients_pkicks),
('Bans', clients_bans), ('passive Bans', clients_pbans)] # (headline, list) ('Bans', clients_bans), ('passive Bans', clients_pbans)] # (headline, list)
# render
template = Environment(loader=FileSystemLoader(abspath)).get_template(template_name)
with open(output, 'w') as f: with open(output, 'w') as f:
f.write(template.render(title=title, objs=objs, debug=debug)) f.write(template.render(title=title, objs=objs, debug=debug))