gwsumm.tabs.core module

This module defines the core Tab object.

The basic Tab allows for simple embedding of arbitrary text inside a standardised HTML interface. Most real-world applications will use a sub-class of Tab to create more complex HTML output.

The Tab class comes in three flavours:

  • ‘static’, no specific GPS time reference

  • ‘interval’, displaying data in a given GPS [start, stop) interval

  • ‘event’, displaying data around a specific central GPS time

The flavour is dynamically set when each instance is created based on the mode keyword, or the presence of span, start and `end, or gpstime keyword arguments.

class gwsumm.tabs.core.BaseTab(name, index=None, shortname=None, parent=None, children=[], group=None, notes=None, overlay=None, path='.', mode=None, hidden=False)[source]

Bases: object

The core Tab object, defining basic functionality

add_child(tab)[source]

Add a child to this SummaryTab

Parameters:
tabSummaryTab

child tab to record

property children

List of child tabs for this Tab

If this tab is given children, it cannot also have a parent, as it will define its own dropdown menu in the HTML navigation bar, linking to itself and its children.

Type:

list of tabs <Tab>

classmethod from_ini(cp, section, *args, **kwargs)[source]

Define a new tab from a ~gwsumm.config.GWConfigParser

Parameters:
cp~gwsumm.config.GWConfigParser

customised configuration parser containing given section

sectionstr

name of section to parse

*args, **kwargs

other positional and keyword arguments to pass to the class constructor (__init__)

Returns:
tabTab

a new tab defined from the configuration

Notes

This method parses the following configuration options

name

Full name for this Tab

shortname

Short name for this tab

parent

Short name of the parent page for this Tab

group

Dropdown group for this Tab in the navigation bar

notes

Release notes for this Tab

overlay

Boolean switch to enable plot overlay for this Tab

index

The HTML path (relative to the ~Tab.path) for this tab

Sub-classes should parse their own configuration values and then pass these as *args and **kwargs to this method via super:

class MyTab(Tab):
    [...]
    def from_ini(cls, cp, section)
        """Define a new `MyTab`.
        """
        foo = cp.get(section, 'foo')
        bar = cp.get(section, 'bar')
        return super(MyTab, cls).from_ini(cp, section, foo, bar=bar)
get_child(name)[source]

Find a child tab of this SummaryTab by name

Parameters:
namestr

string identifier of child tab to use in search

Returns:
childSummaryTab

the child tab found by name

Raises:
RuntimeError

if no child tab can be found matching the given name

property group

Dropdown group for this Tab in the navigation bar

Type:

str

property href

HTML href (relative to the ~Tab.path) for this tab

This attribute is just a convenience to clean-up the ~Tab.index for a given tab, by removing index.htmls. hierarchy.

Type:

str

html_banner(title=None, subtitle=None)[source]

Build the HTML headline banner for this tab.

Parameters:
titlestr

title for this page

subtitlestr

sub-title for this page

Returns:
banner~MarkupPy.markup.page

formatter markup page for the banner

static html_content(content)[source]

Build the #main div for this tab.

Parameters:
contentstr, ~MarkupPy.markup.page

HTML content to be wrapped

Returns:
#main~MarkupPy.markup.page

A new page with the input content wrapped as

html_navbar(help_=None, calendar=[], tabs=[], ifo=None, ifomap={}, **kwargs)[source]

Build the navigation bar for this tab.

Parameters:
help_str, ~MarkupPy.markup.page

content to place on the upper-right side of the navbar

calendarlist, optional

datepicker calendar objects for navigation

tabslist, optional

list of parent tabs (each with a list of children) to include in the navigation bar.

ifostr, optional

prefix for this IFO.

ifomapdict, optional

dict of (ifo, {base url}) pairs to map to summary pages for other IFOs.

**kwargs

other keyword arguments to pass to :meth:`gwsumm.html.navbar`

Returns:
page~MarkupPy.markup.page

a markup page containing the navigation bar.

property index

The HTML path (relative to the ~Tab.path) for this tab

property mode

The date-time mode of this tab.

Type:

int

See also

:obj:`gwsumm.mode`

for details on the modes

property name

Full name for this Tab

Type:

str

property notes

Release notes for this Tab

property overlay

Boolean switch to enable plot overlay for this Tab

property parent

Short name of the parent page for this Tab

A given tab can either be a parent for a set of child tabs, or can have a parent, it cannot be both. In this system, the parent attribute defines the heading under which this tab will be linked in the HTML navigation bar.

Type:

str

set_parent(p)[source]

Set the parent Tab for this tab

Parameters:
pTab

the parent tab for this one

property shortname

Short name for this tab

This will be displayed in the navigation bar.

Type:

str

property shorttitle

Page title for this tab

property title

Page title for this tab

write_html(maincontent, title=None, subtitle=None, tabs=[], ifo=None, ifomap={}, help_=None, base=None, css=None, js=None, about=None, footer=None, issues=True, **inargs)[source]

Write the HTML page for this Tab.

Parameters:
maincontentstr, ~MarkupPy.markup.page

simple string content, or a structured page of markup to embed as the content of the #main div.

titlestr, optional, default: {parent.name}

level 1 heading for this Tab.

subtitlestr, optional, default: {self.name}

level 2 heading for this Tab.

tabs: `list`, optional

list of top-level tabs (with children) to populate navbar

ifostr, optional

prefix for this IFO.

ifomapdict, optional

dict of (ifo, {base url}) pairs to map to summary pages for other IFOs.

help_str, ~MarkupPy.markup.page, optional

non-menu content for navigation bar

csslist, optional

list of resolvable URLs for CSS files. See gwsumm.html.CSS for the default list.

jslist, optional

list of resolvable URLs for javascript files. See gwumm.html.JS for the default list.

aboutstr, optional

href for the ‘About’ page

footerstr, ~MarkupPy.markup.page

external link, if applicable (linked from an icon in the footer)

issuesbool or str, default: True

print link to github.com issue tracker for this package

**inargs

other keyword arguments to pass to the :meth:`~Tab.build_inner_html` method

class gwsumm.tabs.core.Tab(*args, **kwargs)[source]

Bases: BaseTab

A Simple HTML tab.

This class provides a mechanism to generate a full-formatted HTML page including banner, navigation-bar, content, and a footer, without the user worrying too much about the details.

For example:

>>> # import Tab and make a new one with a given title and HTML file
>>> from gwsumm.tabs import Tab
>>> tab = Tab('My new tab', 'mytab.html')
>>> # write the Tab to disk with some simple content
>>> tab.write_html('This is my content', brand='Brand name')
Parameters:
namestr

name of this tab (required)

indexstr

HTML file in which to write. By default each tab is written to an index.html file in its own directory. Use ~Tab.index to find out the default index, if not given.

shortnamestr

shorter name for this tab to use in the navigation bar. By default the regular name is used

parent~gwsumm.tabs.Tab

parent of this tab. This is used to position this tab in the navigation bar.

childrenlist

list of child Tabs <~gwsumm.tabs.Tab> of this one. This is used to position this tab in the navigation bar.

groupstr

name of containing group for this tab in the navigation bar dropdown menu. This is only relevant if this tab has a parent.

pathstr

base output directory for this tab (should be the same directory for all tabs in this run)

Notes

A Tab cannot have both a ~Tab.parent and ~tab.Children. This is a limitation imposed by the twitter bootstrap navigation bar implementation, which does not allow nested dropdown menus. In order to collect child tabs in a given place, assign them all the same ~Tab.group.

type = 'basic'
class gwsumm.tabs.core.TabList(entries=[])[source]

Bases: list

Custom list of Tab objects with sorting and parsing

classmethod from_ini(config, tag='tab[_-]', match=[], path='.', plotdir='plots')[source]
get_hierarchy()[source]
sort(key=None, reverse=False)[source]

Sort this TabList in place