Add template_path-kwarg to tsstats.template.render_template

This commit is contained in:
Thor77 2016-08-10 22:47:19 +02:00
parent 604fefe286
commit bbd2ff7a46
1 changed files with 5 additions and 2 deletions

View File

@ -11,7 +11,8 @@ from tsstats.utils import seconds_to_text, sort_clients
logger = logging.getLogger('tsstats')
def render_template(clients, output, title='TeamspeakStats'):
def render_template(clients, output, title='TeamspeakStats',
template_path='template.html'):
'''
render template with `clients`
@ -19,11 +20,13 @@ def render_template(clients, output, title='TeamspeakStats'):
:param output: path to output-file
:param template_name: path to template-file
:param title: title of the resulting html-document
:param template_path: path to template-file
:type clients: tsstats.client.Clients
:type output: str
:type template_name: str
:type title: str
:type template_path: str
'''
# prepare clients
clients_onlinetime_ = sort_clients(
@ -54,7 +57,7 @@ def render_template(clients, output, title='TeamspeakStats'):
return ''
return timestamp.strftime('%x %X %Z')
template_env.filters['frmttime'] = frmttime
template = template_env.get_template('template.html')
template = template_env.get_template(template_path)
with open(output, 'w') as f:
f.write(template.render(title=title, objs=objs,
debug=logger.level <= logging.DEBUG,