コード例 #1
0
    def _add_cell(self,
                  title="",
                  text="",
                  css=None,
                  help_txt=None,
                  colspan=None,
                  sortable=True,
                  escape_text=False):
        if escape_text:
            text = html.permissive_attrencode(text)
        else:
            if isinstance(text, HTML):
                text = "%s" % text
            if not isinstance(text, unicode):
                text = str(text)

        htmlcode = text + html.drain()

        if self.options["collect_headers"] is True:
            # small helper to make sorting introducion easier. Cells which contain
            # buttons are never sortable
            if css and 'buttons' in css and sortable:
                sortable = False
            self.headers.append((title, css, help_txt, sortable))

        self.rows[-1][0].append((htmlcode, css, colspan))
コード例 #2
0
ファイル: forms.py プロジェクト: KNGP14/checkmk
def section(title=None,
            checkbox=None,
            section_id=None,
            simple=False,
            hide=False,
            legend=True,
            css=None):
    global g_section_open
    if g_section_open:
        html.close_td()
        html.close_tr()
    html.open_tr(id_=section_id,
                 class_=[css],
                 style="display:none;" if hide else None)

    if legend:
        html.open_td(class_=["legend", "simple" if simple else None])
        if title:
            html.open_div(
                class_=["title", "withcheckbox" if checkbox else None],
                title=html.strip_tags(title))
            html.write(html.permissive_attrencode(title))
            html.span('.' * 100, class_="dots")
            html.close_div()
        if checkbox:
            html.open_div(class_="checkbox")
            if isinstance(checkbox, six.string_types + (HTML, )):
                html.write(checkbox)
            else:
                name, active, attrname = checkbox
                html.checkbox(
                    name,
                    active,
                    onclick='cmk.wato.toggle_attribute(this, \'%s\')' %
                    attrname)
            html.close_div()
        html.close_td()
    html.open_td(class_=["content", "simple" if simple else None])
    g_section_open = True
コード例 #3
0
def test_htmllib_integration(register_builtin_html):
    assert type(html.escaper) == htmllib.Escaper

    assert html.attrencode("") == ""
    assert html.permissive_attrencode("") == ""
コード例 #4
0
def test_htmllib_integration(register_builtin_html):
    assert isinstance(html.escaper, htmllib.Escaper)

    assert html.attrencode("") == ""
    assert html.permissive_attrencode("") == ""