From f3d6affcbd8414c2d69405559535a34e01b1b04b Mon Sep 17 00:00:00 2001 From: Johannes Löthberg Date: Thu, 12 Jan 2017 21:21:49 +0000 Subject: Set the stop name in the generated html MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Johannes Löthberg --- real.py | 16 ++++++++-------- templates/layout.html | 1 + 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/real.py b/real.py index bf3eb0a..d19b7e1 100644 --- a/real.py +++ b/real.py @@ -21,16 +21,16 @@ def write_data(data, site_id): f.write(data) -def write_html(data, site_id): +def write_html(data, site_id, stop_name, path): template = env.get_template('layout.html') - with open('{}.html'.format(site_id), 'w+') as f: - f.write(template.render(data=data)) + with open('{}/{}.html'.format(path, site_id), 'w+') as f: + f.write(template.render(data=data, stop_name=stop_name)) -def write_txt(data, site_id): +def write_txt(data, site_id, stop_name, path): template = env.get_template('layout.txt') - with open('{}.txt'.format(site_id), 'w+') as f: - f.write(template.render(data=data)) + with open('{}/{}.txt'.format(path, site_id), 'w+') as f: + f.write(template.render(data=data, stop_name=stop_name)) if __name__ == '__main__': @@ -53,5 +53,5 @@ if __name__ == '__main__': else: data = get_data(config['key'], config['site_id']) - write_html(data, config['site_id']) - write_txt(data, config['site_id']) + write_html(data, config['site_id'], config['stop_name'], config['output_path']) + write_txt(data, config['site_id'], config['stop_name'], config['output_path']) diff --git a/templates/layout.html b/templates/layout.html index aead13f..937a12a 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -23,6 +23,7 @@ p {
+

{{ stop_name }}

Last updated: {{ data['ResponseData']['LatestUpdate'] }}

    -- cgit v1.2.3-70-g09d2