def make_page(environment, country_1, country_2, the_date): '''Create page showing temperature ratios.''' data_1 = get_temps(country_1) data_2 = get_temps(country_2) years = data_1.keys() years.sort() template = environment.get_template(INDIVIDUAL_PAGE) result = template.render(country_1=country_1, data_1=data_1, country_2=country_2, data_2=data_2, years=years, the_date=the_date) return result
def make_page(template_filename, country_1, country_2): '''Create page showing temperature ratios.''' data_1 = get_temps(country_1) data_2 = get_temps(country_2) years = data_1.keys() years.sort() the_date = date.isoformat(date.today()) loader = jinja2.FileSystemLoader(['.']) environment = jinja2.Environment(loader=loader) template = environment.get_template(template_filename) result = template.render(country_1=country_1, data_1=data_1, country_2=country_2, data_2=data_2, years=years, the_date=the_date) return result
def make_page(output, first_country, second_country): '''Create page showing temperature ratios.''' first_data = get_temps(first_country) second_data = get_temps(second_country) the_date = date.isoformat(date.today()) html = ET.Element('html') head = ET.SubElement(html, 'head') revised = ET.SubElement(head, 'meta', {'name' : 'revised', 'content' : the_date}) body = ET.SubElement(html, 'body') h1 = ET.SubElement(body, 'h1') h1.text = 'Ratio of Average Annual Temperatures for %s and %s' % \ (first_country, second_country) make_table(body, first_data, second_data) output.write(ET.tostring(html))