当前位置: 首页>>代码示例>>Python>>正文


Python html.td函数代码示例

本文整理汇总了Python中py.xml.html.td函数的典型用法代码示例。如果您正苦于以下问题:Python td函数的具体用法?Python td怎么用?Python td使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了td函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: version_get

    def version_get(self, user, index, name, version):
        stage = self.getstage(user, index)
        name = ensure_unicode(name)
        version = ensure_unicode(version)
        metadata = stage.get_projectconfig(name)
        if not metadata:
            abort(404, "project %r does not exist" % name)
        verdata = metadata.get(version, None)
        if not verdata:
            abort(404, "version %r does not exist" % version)
        if json_preferred():
            apireturn(200, type="versiondata", result=verdata)

        # if html show description and metadata
        rows = []
        for key, value in sorted(verdata.items()):
            if key == "description":
                continue
            if isinstance(value, list):
                value = html.ul([html.li(x) for x in value])
            rows.append(html.tr(html.td(key), html.td(value)))
        title = "%s/: %s-%s metadata and description" % (
                stage.name, name, version)

        content = stage.get_description(name, version)
        #css = "https://pypi.python.org/styles/styles.css"
        return simple_html_body(title,
            [html.table(*rows), py.xml.raw(content)],
            extrahead=
            [html.link(media="screen", type="text/css",
                rel="stylesheet", title="text",
                href="https://pypi.python.org/styles/styles.css")]
        ).unicode(indent=2)
开发者ID:kenatbasis,项目名称:devpi,代码行数:33,代码来源:views.py

示例2: add_row

 def add_row(self, lineno, text):
     if text == ['']:
         text = [raw(' ')]
     else:
         text = prepare_line(text, self.tokenizer, self.encoding)
     self.tbody.append(html.tr(html.td(str(lineno), class_='lineno'),
                               html.td(class_='code', *text)))
开发者ID:mickg10,项目名称:DARLAB,代码行数:7,代码来源:html.py

示例3: make_test_name

 def make_test_name(self, test, test_data, index):
     pos_cls = "even" if index % 2 else "odd"
     test_name = self.test_string(test)
     if len(test_data) == 1 and None in test_data.keys():
         return [html.td(test_name, colspan=2, class_="parent_test %s" % pos_cls)], False
     else:
         return [html.td(test_name, rowspan=len(test_data), class_="parent_test %s" % pos_cls)], True
开发者ID:Mozilla-TWQA,项目名称:fxos-certsuite,代码行数:7,代码来源:subsuite.py

示例4: make_table_rows

    def make_table_rows(self):
        regressions = self.results.regressions

        rv = []
        tests = sorted(regressions.keys())
        for i, test in enumerate(tests):
            test_data = regressions[test]
            cells, needs_subtest = self.make_test_name(test, test_data, i)
            for subtest in sorted(test_data.keys()):
                if needs_subtest:
                    cells.append(html.td(subtest))
                subtest_data = test_data[subtest]
                cells.extend([
                    html.td(subtest_data["expected"].title(),
                            class_="condition %s" % subtest_data["expected"]),
                    html.td(subtest_data["status"].title(),
                            class_="condition %s" % subtest_data["status"]),
                    html.td(subtest_data.get("message", ""),
                            class_="message")
                ])
                tr = html.tr(cells)
                rv.append(tr)
                cells = []
                needs_subtest = True
        return rv
开发者ID:Mozilla-TWQA,项目名称:fxos-certsuite,代码行数:25,代码来源:subsuite.py

示例5: _appendrow

    def _appendrow(self, result_name, report):
        time = getattr(report, 'duration', 0.0)

        additional_html = []
        links_html = []

        for extra in getattr(report, 'extra', []):
            self.append_extra_html(extra, additional_html, links_html)

        self.append_log_html(report, additional_html)

        test_id = report.nodeid
        if report.when != 'call':
            test_id = '::'.join([report.nodeid, report.when])

        rows_table = html.tr([
            html.td(result_name, class_='col-result'),
            html.td(test_id, class_='col-name'),
            html.td('{0:.2f}'.format(time), class_='col-duration'),
            html.td(links_html, class_='col-links')])

        rows_extra = html.tr(html.td(additional_html,
                             class_='extra', colspan='5'))

        self.test_logs.append(html.tbody(rows_table, rows_extra,
                                         class_=result_name.lower() +
                                         ' results-table-row'))
开发者ID:redixin,项目名称:pytest-html,代码行数:27,代码来源:plugin.py

示例6: make_result_html

    def make_result_html(self, data):
        tc_time = (data["time"] - self.start_times.pop(data["test"])) / 1000.
        additional_html = []
        debug = data.get("extra", {})
        links_html = []

        status = status_name = data["status"]
        expected = data.get("expected", status)

        if status != expected:
            status_name = "UNEXPECTED_" + status
        elif status != "PASS":
            status_name = "EXPECTED_" + status

        self.test_count[status_name] += 1

        if status in ['SKIP', 'FAIL', 'ERROR']:
            if debug.get('screenshot'):
                screenshot = 'data:image/png;base64,%s' % debug['screenshot']
                additional_html.append(html.div(
                    html.a(html.img(src=screenshot), href="#"),
                    class_='screenshot'))
            for name, content in debug.items():
                if 'screenshot' in name:
                    href = '#'
                else:
                    # use base64 to avoid that some browser (such as Firefox, Opera)
                    # treats '#' as the start of another link if the data URL contains.
                    # use 'charset=utf-8' to show special characters like Chinese.
                    href = 'data:text/plain;charset=utf-8;base64,%s' % base64.b64encode(content.encode('utf-8'))
                links_html.append(html.a(
                    name.title(),
                    class_=name,
                    href=href,
                    target='_blank'))
                links_html.append(' ')

            log = html.div(class_='log')
            output = data.get('stack', '').splitlines()
            output.extend(data.get('message', '').splitlines())
            for line in output:
                separator = line.startswith(' ' * 10)
                if separator:
                    log.append(line[:80])
                else:
                    if line.lower().find("error") != -1 or line.lower().find("exception") != -1:
                        log.append(html.span(raw(cgi.escape(line)), class_='error'))
                    else:
                        log.append(raw(cgi.escape(line)))
                log.append(html.br())
            additional_html.append(log)

        self.result_rows.append(
            html.tr([html.td(status_name, class_='col-result'),
                     html.td(data['test'], class_='col-name'),
                     html.td('%.2f' % tc_time, class_='col-duration'),
                     html.td(links_html, class_='col-links'),
                     html.td(additional_html, class_='debug')],
                    class_=status_name.lower() + ' results-table-row'))
开发者ID:Andrel322,项目名称:gecko-dev,代码行数:59,代码来源:html.py

示例7: _appendrow

    def _appendrow(self, result, report):
        time = getattr(report, 'duration', 0.0)

        additional_html = []
        links_html = []

        for extra in getattr(report, 'extra', []):
            href = None
            if extra.get('format') == extras.FORMAT_IMAGE:
                href = '#'
                image = 'data:image/png;base64,%s' % extra.get('content')
                additional_html.append(html.div(
                    html.a(html.img(src=image), href="#"),
                    class_='image'))
            elif extra.get('format') == extras.FORMAT_HTML:
                additional_html.append(extra.get('content'))
            elif extra.get('format') == extras.FORMAT_JSON:
                href = data_uri(json.dumps(extra.get('content')),
                                mime_type='application/json')
            elif extra.get('format') == extras.FORMAT_TEXT:
                href = data_uri(extra.get('content'))
            elif extra.get('format') == extras.FORMAT_URL:
                href = extra.get('content')

            if href is not None:
                links_html.append(html.a(
                    extra.get('name'),
                    class_=extra.get('format'),
                    href=href,
                    target='_blank'))
                links_html.append(' ')

        if 'Passed' not in result:

            if report.longrepr:
                log = html.div(class_='log')
                for line in str(report.longrepr).splitlines():
                    if not PY3:
                        line = line.decode('utf-8')
                    separator = line.startswith('_ ' * 10)
                    if separator:
                        log.append(line[:80])
                    else:
                        exception = line.startswith("E   ")
                        if exception:
                            log.append(html.span(raw(escape(line)),
                                                 class_='error'))
                        else:
                            log.append(raw(escape(line)))
                    log.append(html.br())
                additional_html.append(log)

        self.test_logs.append(html.tr([
            html.td(result, class_='col-result'),
            html.td(report.nodeid, class_='col-name'),
            html.td('%.2f' % time, class_='col-duration'),
            html.td(links_html, class_='col-links'),
            html.td(additional_html, class_='extra')],
            class_=result.lower() + ' results-table-row'))
开发者ID:jharrowmortelliti,项目名称:pytest-html,代码行数:59,代码来源:plugin.py

示例8: make_errors_table

 def make_errors_table(self, errors):
     rows = []
     for error in errors:
         rows.append(html.tr(
             html.td(error["level"],
                     class_="log_%s" % error["level"]),
             html.td(error.get("message", ""))
         ))
     return html.table(rows, id_="errors")
开发者ID:Mozilla-TWQA,项目名称:fxos-certsuite,代码行数:9,代码来源:subsuite.py

示例9: _appendrow

    def _appendrow(self, result, report):
        time = getattr(report, 'duration', 0.0)

        additional_html = []
        links_html = []

        if 'Passed' not in result:

            for extra in getattr(report, 'extra', []):
                href = None
                if type(extra) is Image:
                    href = '#'
                    image = 'data:image/png;base64,%s' % extra.content
                    additional_html.append(html.div(
                        html.a(html.img(src=image), href="#"),
                        class_='image'))
                elif type(extra) is HTML:
                    additional_html.append(extra.content)
                elif type(extra) is Text:
                    href = 'data:text/plain;charset=utf-8;base64,%s' % \
                        b64encode(extra.content)
                elif type(extra) is URL:
                    href = extra.content

                if href is not None:
                    links_html.append(html.a(
                        extra.name,
                        class_=extra.__class__.__name__.lower(),
                        href=href,
                        target='_blank'))
                    links_html.append(' ')

            if report.longrepr:
                log = html.div(class_='log')
                for line in str(report.longrepr).splitlines():
                    line = line.decode('utf-8')
                    separator = line.startswith('_ ' * 10)
                    if separator:
                        log.append(line[:80])
                    else:
                        exception = line.startswith("E   ")
                        if exception:
                            log.append(html.span(raw(cgi.escape(line)),
                                                 class_='error'))
                        else:
                            log.append(raw(cgi.escape(line)))
                    log.append(html.br())
                additional_html.append(log)

        self.test_logs.append(html.tr([
            html.td(result, class_='col-result'),
            html.td(report.nodeid, class_='col-name'),
            html.td('%.2f' % time, class_='col-duration'),
            html.td(links_html, class_='col-links'),
            html.td(additional_html, class_='extra')],
            class_=result.lower() + ' results-table-row'))
开发者ID:justinpotts,项目名称:pytest-html,代码行数:56,代码来源:pytest_html.py

示例10: _create_overview

    def _create_overview(self):
        for node, results in self.tempDict.iteritems():
            table = [html.td(node, class_="col-name")]

            res = [
                html.td(result.capitalize(), class_="%s col-%s" % (result.lower(), when))
                for when, result in results.iteritems()
            ]
            table.extend(res)
            self.test_overview.append(html.tr(table))
开发者ID:dhoomakethu,项目名称:pytest-html,代码行数:10,代码来源:plugin.py

示例11: tabelize

 def tabelize(value):
     try:
         rows = []
         for key in value.keys():
             rows.append(html.tr(html.td(html.pre(key)), html.td(tabelize(value[key]))))
         return html.table(rows)
     except AttributeError:
         if type(value) == type([]):
             return html.table(map(tabelize, value))
         else:
             return html.pre(value)
开发者ID:Mozilla-TWQA,项目名称:fxos-certsuite,代码行数:11,代码来源:cert.py

示例12: make_body

    def make_body(self):
        body_parts = [html.div(
             html.script(raw(pkg_resources.resource_string(
                rcname, os.path.sep.join(['resources', 'htmlreport', 
                    'jquery.js']))),
                type='text/javascript'),
            html.script(raw(pkg_resources.resource_string(
                rcname, os.path.sep.join(['resources', 'htmlreport', 
                    'main.js']))),
                type='text/javascript'),
            html.h1("FirefoxOS Certification Suite Report"),
            html.p("Run at %s" % self.time.strftime("%Y-%m-%d %H:%M:%S"))
            )]
        if self.logs:
            device_profile_object = None
            with open(self.logs[-1]) as f:
                device_profile_object = json.load(f)['result']['contact']
            device_profile = [html.h2('Device Information')]
            device_table = html.table()
            for key in device_profile_object:
                device_table.append(
                    html.tr(
                        html.td(key),
                        html.td(device_profile_object[key])
                    )
                )
                #device_profile.append(html.p("%s, %s"% (key, device_profile_object[key])))
            device_profile.append(device_table)
            body_parts.extend(device_profile);

        if self.summary_results.has_errors:
            body_parts.append(html.h2("Errors During Run"))
            body_parts.append(self.make_errors_table(self.summary_results.errors))
        body_parts.append(html.h2("Test Results"))
        body_parts.append(self.make_result_table())

        if self.logs:
            ulbody = [];
            for log_path in self.logs:
                details_log = ''
                with open(log_path, 'r') as f:
                    details_log = f.read()
                href = 'data:text/plain;charset=utf-8;base64,%s' % base64.b64encode(details_log)
                ulbody.append(html.li(html.a(os.path.basename(log_path), href=href, target='_blank')))
            device_profile_object = None
            body_parts.append(html.h2("Details log information"))
            body_parts.append(html.ul(ulbody))
        return html.body(body_parts)
开发者ID:JJTC-PX,项目名称:fxos-certsuite,代码行数:48,代码来源:summary.py

示例13: create_dir_html

def create_dir_html(path, href_prefix=''):
    h = html.html(
        html.head(
            html.title('directory listing of %s' % (path,)),
            style,
        ),
    )
    body = html.body(
        html.h1('directory listing of %s' % (path,)),
    )
    h.append(body)
    table = html.table()
    body.append(table)
    tbody = html.tbody()
    table.append(tbody)
    items = list(path.listdir())
    items.sort(key=lambda p: p.basename)
    items.sort(key=lambda p: not p.check(dir=True))
    for fpath in items:
        tr = html.tr()
        tbody.append(tr)
        td1 = html.td(fpath.check(dir=True) and 'D' or 'F', class_='type')
        tr.append(td1)
        href = fpath.basename
        if href_prefix:
            href = '%s%s' % (href_prefix, href)
        if fpath.check(dir=True):
            href += '/'
        td2 = html.td(html.a(fpath.basename, href=href), class_='name')
        tr.append(td2)
        td3 = html.td(time.strftime('%Y-%m-%d %H:%M:%S',
                      time.gmtime(fpath.mtime())), class_='mtime')
        tr.append(td3)
        if fpath.check(dir=True):
            size = ''
            unit = ''
        else:
            size = fpath.size()
            unit = 'B'
            for u in ['kB', 'MB', 'GB', 'TB']:
                if size > 1024:
                    size = round(size / 1024.0, 2)
                    unit = u
        td4 = html.td('%s %s' % (size, unit), class_='size')
        tr.append(td4)
    return unicode(h)
开发者ID:mickg10,项目名称:DARLAB,代码行数:46,代码来源:html.py

示例14: make_table_rows

    def make_table_rows(self, results):
        rv = []
        for result in results:
            details_link = "%s/report.html" % result.name
            cells = [html.td(result.name)]
            if result.has_errors:
                cells.append(html.td(
                    len(result.errors),
                    class_="condition FAIL",
                ))
            else:
                cells.append(html.td("0",
                                     class_="condition PASS"))
            if result.has_regressions:
                num_regressions = sum(len(item) for item in result.regressions.itervalues())
                cells.append(html.td(num_regressions, class_="condition FAIL"))
            else:
                cells.append(html.td("0", class_="condition PASS"))

            if result.is_pass:
                cells.append(html.td())
            else:
                cells.append(html.td(
                    html.a("details",
                           href=details_link),
                    class_="details"
                ))
            rv.append(html.tr(cells))

        return rv
开发者ID:Mozilla-TWQA,项目名称:fxos-certsuite,代码行数:30,代码来源:summary.py

示例15: make_errors_table

 def make_errors_table(self, errors):
     rows = []
     for error in errors:
         error_message = error.get("message", "")
         log = html.div(class_='log')
         for line in error_message.splitlines():
             separator = line.startswith(' ' * 10)
             if separator:
                 log.append(line[:80])
             else:
                 if line.lower().find("error") != -1 or line.lower().find("exception") != -1:
                     log.append(html.span(raw(cgi.escape(line)), class_='error'))
                 else:
                     log.append(raw(cgi.escape(line)))
             log.append(html.br())
         rows.append(html.tr(
             html.td(error["level"],
                     class_="log_%s" % error["level"]),
             html.td(log, class_='log')
         ))
     return html.table(rows, id_="errors")
开发者ID:JJTC-PX,项目名称:fxos-certsuite,代码行数:21,代码来源:summary.py


注:本文中的py.xml.html.td函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。