sluyspy.html module
HTML functions for the sluyspy package.
- sluyspy.html.close_html_file(fd, sc_id=None, sc_secr=None, sc_name=None)[source]
Close an html file by writing StatCounter code if desired, and closing <body>, <html> and the file.
- Parameters:
fd (io) – File descriptor.
sc_id (int) – StatCounter project ID.
sc_secr (str) – StatCounter security secret.
sc_name (str) – Name for the StatCounter code block.
- sluyspy.html.last_update(fd, indent, size='65%', seconds=False, tz=False)[source]
Add a ‘Last update’ line to an html file with the current system date and time.
- Parameters:
fd (io) – File descriptor.
indent (int) – Number of spaces for indentation.
size (str) – String with font size, e.g. ‘100%’.
seconds (bool) – Print seconds in timestamp.
tz (bool) – Print time zone in timestamp.
- sluyspy.html.start_html_file(file_name='index.html', lang='en', title='Page title', icon=None, css=None, author='Marc van der Sluys', copyr_start=None, refresh=None, meta_prop=None)[source]
Create an html file, write the head section and start the body.
- Parameters:
file_name (str) – Name/path of the html file.
lang (str) – Language.
title (str) – Page title.
icon (str) – Path to an icon file.
css (str) – Path to a css file.
author (str) – Author name.
copyr_start (int) – Starting year of copyright.
refresh (int) – Refresh period in minutes.
meta_prop (dict) – Dict of meta data with the keys containing properties and the values their content.
- Returns:
File descriptor.
- Return type:
(io)
- sluyspy.html.table_td_tr(indent, td_width, td_extra_width)[source]
Define trtd, tdtd and tdtr elements for an html table.
- Parameters:
indent (int) – Number of spaces for indentation.
td_width (str) – Width of empty column between columns (e.g. ‘1%’).
td_extra_width (str) – Width of extra-wide empty column between columns (e.g. ‘10%’).
- Returns:
tuple containing trtd, tdtd, tdtdw, tdtr:
trtd (str): the <tr><td> element.
tdtd (str): the default </td><td> element.
tdtdw (str): the extra-wide </td><td> element.
tdbrtd (str): an empty </td><td> element for an empty row (<br>).
tdtr (str): the </td></tr> element.
- Return type:
(tuple)