noc.lib.app.simplereport

Module Contents

noc.lib.app.simplereport.INDENT =
class noc.lib.app.simplereport.ReportNode(name=None)

Bases: object

Abstract Report Node

tag
quote(self, s)

Return XML-quoted value

format_opening_xml_tag(self, **kwargs)

Return opening XML tag

format_closing_xml_tag(self)

Return closing XML tag

indent(self, s, n=1)

Indent block of code

to_xml(self)

Return XML presentation of Node

to_html(self)

Return HTML presentation of Node

to_csv(self, delimiter=', ')

Return CSV presentation of Node

class noc.lib.app.simplereport.Report(name=None)

Bases: noc.lib.app.simplereport.ReportNode

Report root node

tag = report
append_section(self, s)
to_xml(self)

Return XML code for report :return:

to_html(self)

Return HTML code for report :return:

to_csv(self, delimiter=', ')

Return CSV for report :return:

class noc.lib.app.simplereport.ReportSection

Bases: noc.lib.app.simplereport.ReportNode

Abstract class for report sections

class noc.lib.app.simplereport.TextSection(name=None, title=None, text=None)

Bases: noc.lib.app.simplereport.ReportSection

Section containing text. Consists of title and text text bay be string or list of paragraphs. Skipped in CSV mode

tag = text
paragraphs

Returns a list of paragraphs

to_xml(self)

Return XML presentation of text section

to_html(self)

Return HTML presentation of text section

noc.lib.app.simplereport.SIZE_DATA = []
noc.lib.app.simplereport.dec
class noc.lib.app.simplereport.SafeString

Bases: unicode

Do not perform HTML quoting

class noc.lib.app.simplereport.TableColumn(name, title=None, align=None, format=None, total=None, total_label=None)

Bases: noc.lib.app.simplereport.ReportNode

Table column. Contains rules for formatting the cells

tag = column
ALIGN_LEFT = 1
ALIGN_RIGHT = 2
ALIGN_CENTER = 3
H_ALIGN_MASK = 3
has_total

Check column has total :return:

start_section(self)

Reset sub-totals :return:

contribute_data(self, s)

Contribute data to totals :param s: :return:

format_data(self, s)

Return formatted cell :param s: :return:

to_xml(self)

Return XML representation of column :return:

html_td_attrs(self)

Return quoted HTML TD attributes :return:

format_html(self, s)

Render single cell :param s: :return:

format_html_total(self)

Render totals :return:

format_html_subtotal(self, d)

Render subtotals :param d: :return:

f_date(self, f)

Display date according to settings :param f: :return:

f_time(self, f)

Display time according to settings :param f: :return:

f_datetime(self, f)

Display date and time according to settings :param f: :return:

f_size(self, f)

Display pretty size :param f: :return:

f_numeric(self, f)

Display pretty numeric :param f: :return:

f_bool(self, f)

Display boolean field

f_url(self, url)

Display url field

f_integer(self, f)

Display pretty-formatted integer

f_percent(self, f)

Display numeric with % sign

f_pprint(self, l)

Returns a pretty-printed object

f_tags(self, f)

Display and object’s tags

ft_sum(self, l)

Returns a sum of not-null elements

ft_count(self, l)

Returns a count of not-null elements

class noc.lib.app.simplereport.SectionRow(name, title=None, subtotal=True)

Bases: object

Delimiter row

contribute_data(self, column, d)
class noc.lib.app.simplereport.TableSection(name=None, columns=[], enumerate=False, data=[])

Bases: noc.lib.app.simplereport.ReportSection

tag = table
to_xml(self)

Return XML representation of table

to_html(self)

Return HTML representation of table :return:

to_csv(self, delimiter=', ')

Return CSV representation of table :return:

to_ssv2(self, delimiter=';', mrf='center', date=None)

Return CSV representation of table :return:

class noc.lib.app.simplereport.MatrixSection(name, data=None, enumerate=False)

Bases: noc.lib.app.simplereport.ReportSection

Data is a list of (row, column, data)

to_html(self)
class noc.lib.app.simplereport.SimpleReport

Bases: noc.lib.app.reportapplication.ReportApplication

predefined_reports
get_data(self, request, **kwargs)

Returns Report object

report_html(self, **kwargs)

Render HTML

report_csv(self, **kwargs)

Render CSV

from_dataset(self, title, columns, data, enumerate=False)

Shortcut to generate Report from dataset

from_query(self, title, columns, query, params=[], enumerate=False)

Shortcut to generate Report from SQL query

get_predefined_args(self, variant)
class noc.lib.app.simplereport.PredefinedReport(title=None, args=None)

Bases: object