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


Python html.table函数代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: generate_html

    def generate_html(self):
        generated = datetime.utcnow()
        with open(os.path.join(base_path, "main.js")) as main_f:
            doc = html.html(
                self.head,
                html.body(
                    html.script(raw(main_f.read())),
                    html.p('Report generated on %s at %s' % (
                        generated.strftime('%d-%b-%Y'),
                        generated.strftime('%H:%M:%S'))),
                    html.h2('Environment'),
                    html.table(
                        [html.tr(html.td(k), html.td(v)) for k, v in sorted(self.env.items()) if v],
                        id='environment'),

                    html.h2('Summary'),
                    html.p('%i tests ran in %.1f seconds.' % (sum(self.test_count.itervalues()),
                                                              (self.suite_times["end"] -
                                                               self.suite_times["start"]) / 1000.),
                           html.br(),
                           html.span('%i passed' % self.test_count["PASS"], class_='pass'), ', ',
                           html.span('%i skipped' % self.test_count["SKIP"], class_='skip'), ', ',
                           html.span('%i failed' % self.test_count["UNEXPECTED_FAIL"], class_='fail'), ', ',
                           html.span('%i errors' % self.test_count["UNEXPECTED_ERROR"], class_='error'), '.',
                           html.br(),
                           html.span('%i expected failures' % self.test_count["EXPECTED_FAIL"],
                                     class_='expected_fail'), ', ',
                           html.span('%i unexpected passes' % self.test_count["UNEXPECTED_PASS"],
                                     class_='unexpected_pass'), '.'),
                    html.h2('Results'),
                    html.table([html.thead(
                        html.tr([
                            html.th('Result', class_='sortable', col='result'),
                            html.th('Test', class_='sortable', col='name'),
                            html.th('Duration', class_='sortable numeric', col='duration'),
                            html.th('Links')]), id='results-table-head'),
                        html.tbody(self.result_rows, id='results-table-body')], id='results-table')))

        return u"<!DOCTYPE html>\n" + doc.unicode(indent=2)
开发者ID:Andrel322,项目名称:gecko-dev,代码行数:39,代码来源:html.py

示例5: make_regression_table

 def make_regression_table(self):
     return html.table(
         html.thead(
             html.tr(
                 html.th("Parent Test", col='parent'),
                 html.th("Subtest", col='subtest'),
                 html.th("Expected", col='expected'),
                 html.th("Result", col='result'),
             ), id='results-table-head'
         ),
         html.tbody(*self.make_table_rows(), id='results-table-body'),
         id='results-table'
     )
开发者ID:JJTC-PX,项目名称:fxos-certsuite,代码行数:13,代码来源:subsuite.py

示例6: pytest_sessionfinish

    def pytest_sessionfinish(self, session, exitstatus):
        self._make_report_dir()
        logfile = py.std.codecs.open(self.logfile, 'w', encoding='utf-8')

        suite_stop_time = time.time()
        suite_time_delta = suite_stop_time - self.suite_start_time
        numtests = self.passed + self.failed
        generated = datetime.datetime.now()
        doc = html.html(
            html.head(
                html.meta(charset='utf-8'),
                html.title('Test Report'),
                html.link(rel='stylesheet', href='style.css'),
                html.script(src='jquery.js'),
                html.script(src='main.js')),

            html.body(
                html.p('Report generated on %s at %s ' % (
                    generated.strftime('%d-%b-%Y'),
                    generated.strftime('%H:%M:%S'),
                )),
                html.div([html.p(
                    html.span('%i tests' % numtests, class_='all clickable'),
                    ' ran in %i seconds.' % suite_time_delta,
                    html.br(),
                    html.span('%i passed' % self.passed, class_='passed clickable'), ', ',
                    html.span('%i skipped' % self.skipped, class_='skipped clickable'), ', ',
                    html.span('%i failed' % self.failed, class_='failed clickable'), ', ',
                    html.span('%i errors' % self.errors, class_='error clickable'), '.',
                    html.br(), ),
                    html.span('Hide all errors', class_='clickable hide_all_errors'), ', ',
                    html.span('Show all errors', class_='clickable show_all_errors'),
                ], id='summary-wrapper'),
                html.div(id='summary-space'),
                html.table([
                    html.thead(html.tr([
                        html.th('Result', class_='sortable', col='result'),
                        html.th('Class', class_='sortable', col='class'),
                        html.th('Name', class_='sortable', col='name'),
                        html.th('Duration', class_='sortable numeric', col='duration'),
                        # html.th('Output')]), id='results-table-head'),
                        html.th('Links')]), id='results-table-head'),
                    html.tbody(*self.test_logs, id='results-table-body')], id='results-table')))
        logfile.write(
            '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">' + doc.unicode(
                indent=2))
        logfile.close()
        self.process_screenshot_files()
        self.process_debug_event_files()
        self.process_performance_files()
开发者ID:salsita,项目名称:shishito,代码行数:50,代码来源:junithtml.py

示例7: make_result_table

 def make_result_table(self):
     return html.table(
         html.thead(
             html.tr(
                 html.th("Subsuite"),
                 html.th("Subsuite Errors"),
                 html.th("Test Regressions"),
                 html.th("Details")
             )
         ),
         html.tbody(
             self.make_table_rows(self.subsuite_results)
         )
     )
开发者ID:Mozilla-TWQA,项目名称:fxos-certsuite,代码行数:14,代码来源:summary.py

示例8: make_result_table

 def make_result_table(self):
     return html.table(
         html.thead(
             html.tr(
                 html.th("Subsuite", class_='sortable', col='subsuite'),
                 html.th("Subsuite Errors"),
                 html.th("Test Executions"),
                 html.th("Details")
             )
         ),
         html.tbody(
             self.make_table_rows(self.subsuite_results),id='results-table-body'
         ), 
         id='results-table'
     )
开发者ID:JJTC-PX,项目名称:fxos-certsuite,代码行数:15,代码来源:summary.py

示例9: make_regression_table

 def make_regression_table(self):
     return html.table(
         html.thead(
             html.tr(
                 html.th("Parent Test"),
                 html.th("Subtest"),
                 html.th("Expected"),
                 html.th("Result"),
                 html.th("Message")
             )
         ),
         html.tbody(
             *self.make_table_rows()
         )
     )
开发者ID:Mozilla-TWQA,项目名称:fxos-certsuite,代码行数:15,代码来源:subsuite.py

示例10: gen_html_table

 def gen_html_table( mtx ):
     from py.xml import html
     # print("DBG genhtmltable", mtx)
     result  = html.table(
         html.thead( html.tr( [html.th( x ) for x in mtx[0] ] ) ),  # header
         html.tbody( 
                 *[ html.tr( [html.td( x ) for x in row] )   # rows
                     for row in mtx[1:] ] 
                     ),
         class_="fixed_headers"
     ) 
     # make it fixed height scrollable # https://codepen.io/tjvantoll/pen/JEKIu
     # result = str(result) + """
     # """
     return str(result) 
开发者ID:dz0,项目名称:dummy,代码行数:15,代码来源:mytracer_render.py

示例11: 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

示例12: 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

示例13: 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

示例14: _generate_environment

    def _generate_environment(self, config):
        if not hasattr(config, '_metadata') or config._metadata is None:
            return []

        metadata = config._metadata
        environment = [html.h2('Environment')]
        rows = []

        keys = [k for k in metadata.keys() if metadata[k]]
        if not isinstance(metadata, OrderedDict):
            keys.sort()

        for key in keys:
            value = metadata[key]
            if isinstance(value, basestring) and value.startswith('http'):
                value = html.a(value, href=value, target='_blank')
            elif isinstance(value, (list, tuple, set)):
                value = ', '.join((str(i) for i in value))
            rows.append(html.tr(html.td(key), html.td(value)))

        environment.append(html.table(rows, id='environment'))
        return environment
开发者ID:davehunt,项目名称:pytest-html,代码行数:22,代码来源:plugin.py

示例15: generate_html

    def generate_html(self, results_list):

        tests = sum([results.testsRun for results in results_list])
        failures = sum([len(results.failures) for results in results_list])
        expected_failures = sum([len(results.expectedFailures) for results in results_list])
        skips = sum([len(results.skipped) for results in results_list])
        errors = sum([len(results.errors) for results in results_list])
        passes = sum([results.passed for results in results_list])
        unexpected_passes = sum([len(results.unexpectedSuccesses) for results in results_list])
        test_time = self.elapsedtime.total_seconds()
        test_logs = []

        def _extract_html(test, class_name, duration=0, text='', result='passed', debug=None):
            cls_name = class_name
            tc_name = unicode(test)
            tc_time = duration
            additional_html = []
            debug = debug or {}
            links_html = []

            if result in ['skipped', 'failure', 'expected failure', '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():
                    try:
                        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)
                        links_html.append(html.a(
                            name.title(),
                            class_=name,
                            href=href,
                            target='_blank'))
                        links_html.append(' ')
                    except:
                        pass

                log = html.div(class_='log')
                for line in text.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())
                additional_html.append(log)

            test_logs.append(html.tr([
                html.td(result.title(), class_='col-result'),
                html.td(cls_name, class_='col-class'),
                html.td(tc_name, class_='col-name'),
                html.td(tc_time, class_='col-duration'),
                html.td(links_html, class_='col-links'),
                html.td(additional_html, class_='debug')],
                class_=result.lower() + ' results-table-row'))

        for results in results_list:
            for test in results.tests_passed:
                _extract_html(test.name, test.test_class)
            for result in results.skipped:
                _extract_html(result.name, result.test_class, text='\n'.join(result.output), result='skipped')
            for result in results.failures:
                _extract_html(result.name, result.test_class, text='\n'.join(result.output), result='failure', debug=result.debug)
            for result in results.expectedFailures:
                _extract_html(result.name, result.test_class, text='\n'.join(result.output), result='expected failure', debug=result.debug)
            for test in results.unexpectedSuccesses:
                _extract_html(test.name, test.test_class, result='unexpected pass')
            for result in results.errors:
                _extract_html(result.name, result.test_class, text='\n'.join(result.output), result='error', debug=result.debug)

        generated = datetime.datetime.now()
        doc = html.html(
            html.head(
                html.meta(charset='utf-8'),
                html.title('Test Report'),
                html.style(raw(pkg_resources.resource_string(
                    __name__, os.path.sep.join(['resources', 'report', 'style.css']))),
                    type='text/css')),
            html.body(
                html.script(raw(pkg_resources.resource_string(
                    __name__, os.path.sep.join(['resources', 'report', 'jquery.js']))),
                    type='text/javascript'),
                html.script(raw(pkg_resources.resource_string(
                    __name__, os.path.sep.join(['resources', 'report', 'main.js']))),
                    type='text/javascript'),
                html.p('Report generated on %s at %s by %s %s' % (
                    generated.strftime('%d-%b-%Y'),
                    generated.strftime('%H:%M:%S'),
                    __name__, __version__)),
                html.h2('Summary'),
#.........这里部分代码省略.........
开发者ID:Allan019,项目名称:gaia,代码行数:101,代码来源:runtests.py


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