gwdetchar.io.html module¶
Utilties for HTML output
- class gwdetchar.io.html.FancyPlot(img, caption=None)[source]¶
Bases:
object
A helpful class of objects that coalesce image links and caption text for fancybox figures.
- Parameters:
- __dict__ = mappingproxy({'__module__': 'gwdetchar.io.html', '__doc__': "A helpful class of objects that coalesce image links and caption text\n for fancybox figures.\n\n Parameters\n ----------\n img : `str` or `FancyPlot`\n either a filename (including relative or absolute path) or another\n FancyPlot instance\n\n caption : `str`\n the text to be displayed in a fancybox as this figure's caption\n ", '__init__': <function FancyPlot.__init__>, '__str__': <function FancyPlot.__str__>, '__dict__': <attribute '__dict__' of 'FancyPlot' objects>, '__weakref__': <attribute '__weakref__' of 'FancyPlot' objects>, '__annotations__': {}})¶
- __doc__ = "A helpful class of objects that coalesce image links and caption text\n for fancybox figures.\n\n Parameters\n ----------\n img : `str` or `FancyPlot`\n either a filename (including relative or absolute path) or another\n FancyPlot instance\n\n caption : `str`\n the text to be displayed in a fancybox as this figure's caption\n "¶
- __module__ = 'gwdetchar.io.html'¶
- __weakref__¶
list of weak references to the object (if defined)
- gwdetchar.io.html._get_card_header(context)[source]¶
Return the correct bootstrap-4 card-header class for the given context
- gwdetchar.io.html.about_this_page(config, packagelist=True, prog=None)[source]¶
Write a blurb documenting how a page was generated, including the command-line arguments and configuration files used
- Parameters:
- config
str
,list
, optional the absolute path(s) to one or a number of INI files used in this process
- packagelist
bool
, optional boolean switch to include (
True
) or exclude (False
) a comprehensive list of system packages- prog
str
, optional name of the program which produced this page, defaults to the script run on the command-line
- config
- Returns:
- page
page
the HTML page to be inserted into the #main <div>.
- page
- gwdetchar.io.html.alert(text, context='info', dismiss=True)[source]¶
Enclose text within a bootstrap dialog box
- Parameters:
- Returns:
- page
page
the rendered dialog box object
- page
- gwdetchar.io.html.cis_link(channel, **params)[source]¶
Write a channel name as a link to the Channel Information System
- gwdetchar.io.html.close_page(page, target, **kwargs)[source]¶
Close an HTML document with markup then write to disk
This method writes the closing markup to complement the opening written by
init_page
, something like:</div> <footer> <!-- some stuff --> </footer> </body> </html>
- Parameters:
- page
markup.page
the markup object to close
- target
str
the output filename for HTML
- page
- gwdetchar.io.html.download_btn(content, label='Download summary', btndiv='dropdown float-right d-none d-lg-block', btnclass='btn btn-outline-secondary dropdown-toggle')[source]¶
Toggle download options with a Bootstrap button
- Parameters:
- content
list
oftuple
ofstr
collection of
(title, link)
pairs to list- label
str
, optional text appearing inside the button, default:
Download summary
- id_
str
, optional unique HTML identifier for this button
- btndiv
str
, optional class name of the enclosing
<div>
, default:dropdown float-right d-none d-lg-block
- btnclass
str
, optional class name of the Bootstrap button object, default:
btn btn-secondary dropdown-toggle
- content
- Returns:
- page
page
fully rendered download button
- page
- gwdetchar.io.html.dropdown(text, links, active=None, class_='nav-link dropdown-toggle')[source]¶
Construct a dropdown menu in bootstrap format
- Parameters:
- Returns:
- page
page
HTML element with the following grammar:
<a>text</a> <ul> <li>link</li> <li>link</li> </ul>
- page
- gwdetchar.io.html.dropdown_link(page, link, active=False, class_='')[source]¶
Format links within a dropdown menu
- gwdetchar.io.html.fancybox_img(img, linkparams={}, lazy=False, **params)[source]¶
Return the markup to embed an <img> in HTML
- Parameters:
- Returns:
- page
page
the markup object containing fancyplot HTML
- page
- gwdetchar.io.html.finalize_static_urls(static, base, cssfiles, jsfiles)[source]¶
Finalise the necessary CSS and javascript files as URLS.
The method parses the lists of files given, copying any local files into
static
as necessary to create resolvable URLs to include in the HTML<head>
.- Parameters:
- Returns:
- gwdetchar.io.html.get_brand(ifo, name, gps, about=None)[source]¶
Return a brand for navigation bar formatting
- Parameters:
- Returns:
- brand
page
the navbar brand
page
object- class_
str
object class of the navbar
- brand
- gwdetchar.io.html.get_command_line(language='bash', about=True, prog=None)[source]¶
Render the command-line invocation used to generate a page
- Parameters:
- Returns:
- page
page
fully rendered command-line arguments
- page
Construct a navigation bar in bootstrap format
- Parameters:
- links
list
list of either (text, URL) tuples or
page
objects. Tuples will be written in<a>
tags whilepages
will be copied directly. Both will be enclosed in a <li> element inside the navbar- class_
str
, optional navbar object class, default:
'navbar navbar-expand-md fixed-top'
- brand
str
,page
, orlist
, optional branding for the navigation bar, default: None
- collapse
bool
, optional whether to toggle all dropdown menus, default: True
- links
- Returns:
- page
page
navbar HTML
page
object
- page
- gwdetchar.io.html.new_bootstrap_page(base='.', path='.', lang='en', refresh=False, topbtn=True, navbar=None, **kwargs)[source]¶
Create a new
page
with custom twitter bootstrap CSS and JS headers- Parameters:
- base
str
, optional relative path to the base directory, default:
- path
str
, optional path to directory where the page is located, default:
- lang
str
, optional language of the page, default: en
- refresh
bool
, optional boolean switch to enable periodic page refresh, default: False
- topbtn
bool
, optional boolean switch to include or exclude a floating button that scrolls to the top of the page, default: True
- navbar
str
, optional HTML enconding of a floating navbar, will be ignored if not given, default: None
- base
- Returns:
- page
page
a populated HTML page object, which can be appended to as desired
- page
- gwdetchar.io.html.package_table(h2='Environment', class_='table table-sm table-hover table-responsive', caption='Table of packages installed in the production environment', id_='package-table')[source]¶
Write a table listing packages installed in the current environment
- gwdetchar.io.html.parameter_table(content=[], start=None, end=None, flag=None, id_='parameters', tableclass='table table-sm table-hover')[source]¶
Render an informative section with run parameters in HTML
- Parameters:
- content: `list` of `tuple` of `str`
collection of parameters to list
- start
float
GPS start time of the analysis
- end
float
GPS end time of the analysis
- flag
str
, optional name of a data-quality state flag required for this analysis
- section
str
, optional text to label the section header (
<h2>
), default:Parameters
- id_
str
, optional unique HTML identifier for this section, default:
parameters
- tableclass
str
, optional the
class
for the summary<table>
, defaults to a responsive Bootstrap table
- Returns:
- page
page
fully rendered table of parameters
- page
- gwdetchar.io.html.render_code(code, language)[source]¶
Render a block of code with syntax highlighting
- gwdetchar.io.html.scaffold_omega_scans(times, channel, plot_durations=[1, 4, 16], scandir='.')[source]¶
Preview a batch of omega scans in HTML
- Parameters:
- Returns:
- page
page
rendered scaffold of omega scan plots
- page
- gwdetchar.io.html.scaffold_plots(plots, nperrow=3, lazy=True)[source]¶
Embed a
list
of images in a bootstrap scaffold
- gwdetchar.io.html.table(headers, data, caption=None, separator='', id=None, **class_)[source]¶
Write a <table> with one row of headers and many rows of data
- Parameters:
- headers
list
list of column header names
- data
list
oflists
list of column data lists, for
m
rows andn
columns, this should have dimensionsm x n
- caption
str
, optional content for this table’s
<caption>
- **class_
class attribute declarations for each tag used in the table, any of
table
,thead
,tbody
,tr
,th
,td
,caption
- headers
- Returns:
- table
page
a formatted HTML page object containing the
<table>
- table
- gwdetchar.io.html.write_flag_html(flag, span=None, id=0, parent='accordion', context='warning', title=None, plotdir=None, plot_func=<function plot_segments>, **kwargs)[source]¶
Write HTML for data-quality flags
- Parameters:
- flag
DataQualityFlag
the flag object to represent
- span
Segment
, optional GPS start and stop time of flag duration
- id
int
, optional unique identifier for the flag, default: 0
- parent
str
, optional HTML identifier of the parent object, default:
accordion
- context
str
, optional Bootstrap context type, default:
warning
- title
str
, optional title of the flag, defaults to
flag.name
- plotdir
str
, optional path to directory containing plots, required if plotting segments
- plot_func
func
, optional function used to plot segments, default:
plot_segments
- **kwargs
dict
, optional additional keyword arguments to
plot_func
- flag
- Returns:
- page
page
fully rendered HTML with a card object for the flag
- page
Write a <footer> for a bootstrap page
- Parameters:
- Returns:
- page
page
the markup object containing the footer HTML
- page