• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python html.br函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: append_log_html

    def append_log_html(self, report, additional_html):
        log = html.div(class_='log')
        if report.longrepr:
            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())

        for header, content in report.sections:
            log.append(' {0} '.format(header).center(80, '-'))
            log.append(html.br())
            log.append(content)

        if len(log) == 0:
            log = html.div(class_='empty log')
            log.append('No log output captured.')
        additional_html.append(log)
开发者ID:redixin,项目名称:pytest-html,代码行数:27,代码来源:plugin.py


示例2: append_log_html

        def append_log_html(self, report, additional_html):
            log = html.div(class_='log')
            if report.longrepr:
                for line in report.longreprtext.splitlines():
                    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())

            for section in report.sections:
                header, content = map(escape, section)
                log.append(' {0} '.format(header).center(80, '-'))
                log.append(html.br())
                if ANSI:
                    converter = Ansi2HTMLConverter(inline=False, escaped=False)
                    content = converter.convert(content, full=False)
                log.append(raw(content))

            if len(log) == 0:
                log = html.div(class_='empty log')
                log.append('No log output captured.')
            additional_html.append(log)
开发者ID:davehunt,项目名称:pytest-html,代码行数:29,代码来源:plugin.py


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


示例4: simple_list_project

 def simple_list_project(self, user, index, projectname):
     # we only serve absolute links so we don't care about the route's slash
     abort_if_invalid_projectname(projectname)
     stage = self.getstage(user, index)
     projectname = ensure_unicode(projectname)
     info = stage.get_project_info(projectname)
     if info and info.name != projectname:
         redirect("/%s/+simple/%s/" % (stage.name, info.name))
     result = stage.getreleaselinks(projectname)
     if isinstance(result, int):
         if result == 404:
             # we don't want pip/easy_install to try the whole simple
             # page -- we know for sure there is no fitting project
             # because all devpi indexes perform package name normalization
             abort(200, "no such project %r" % projectname)
         if result >= 500:
             abort(502, "upstream server has internal error")
         if result < 0:
             abort(502, "upstream server not reachable")
     links = []
     for entry in result:
         relpath = entry.relpath
         href = "/" + relpath
         href = URL(request.path).relpath(href)
         if entry.eggfragment:
             href += "#egg=%s" % entry.eggfragment
         elif entry.md5:
             href += "#md5=%s" % entry.md5
         links.extend([
              "/".join(relpath.split("/", 2)[:2]) + " ",
              html.a(entry.basename, href=href),
              html.br(), "\n",
         ])
     return simple_html_body("%s: links for %s" % (stage.name, projectname),
                             links).unicode(indent=2)
开发者ID:kenatbasis,项目名称:devpi,代码行数:35,代码来源:views.py


示例5: simple_list_project

    def simple_list_project(self, user, index, projectname):
        # we only serve absolute links so we don't care about the route's slash
        stage = self.getstage(user, index)
        result = stage.getreleaselinks(projectname)
        if isinstance(result, int):
            if result == 404:
                abort(404, "no such project")
            if result >= 500:
                abort(502, "upstream server has internal error")
            if result < 0:
                abort(502, "upstream server not reachable")

        links = []
        for entry in result:
            href = "/pkg/" + entry.relpath
            if entry.eggfragment:
                href += "#egg=%s" % entry.eggfragment
            elif entry.md5:
                href += "#md5=%s" % entry.md5
            links.append((href, entry.basename))

        # construct html
        body = []
        for entry in links:
            body.append(html.a(entry[1], href=entry[0]))
            body.append(html.br())
        return simple_html_body("%s: links for %s" % (stage.name, projectname),
                                body).unicode()
开发者ID:zerotired,项目名称:devpi,代码行数:28,代码来源:views.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: simple_list_all

 def simple_list_all(self, user, index):
     stage = self.getstage(user, index)
     names = stage.getprojectnames()
     body = []
     for name in names:
         body.append(html.a(name, href=name + "/"))
         body.append(html.br())
     return simple_html_body("%s: list of accessed projects" % stage.name,
                             body).unicode()
开发者ID:zerotired,项目名称:devpi,代码行数:9,代码来源:views.py


示例9: simple_list_project

    def simple_list_project(self):
        request = self.request
        name = self.context.name
        # we only serve absolute links so we don't care about the route's slash
        abort_if_invalid_projectname(request, name)
        stage = self.context.stage
        if stage.get_projectname(name) is None:
            # we return 200 instead of !=200 so that pip/easy_install don't
            # ask for the full simple page although we know it doesn't exist
            # XXX change that when pip-6.0 is released?
            abort(request, 200, "no such project %r" % name)

        projectname = self.context.projectname
        try:
            result = stage.get_releaselinks(projectname)
        except stage.UpstreamError as e:
            threadlog.error(e.msg)
            abort(request, 502, e.msg)
        links = []
        for link in result:
            relpath = link.entrypath
            href = "/" + relpath
            href = URL(request.path_info).relpath(href)
            if link.eggfragment:
                href += "#egg=%s" % link.eggfragment
            elif link.hash_spec:
                href += "#" + link.hash_spec
            links.extend([
                 "/".join(relpath.split("/", 2)[:2]) + " ",
                 html.a(link.basename, href=href),
                 html.br(), "\n",
            ])
        title = "%s: links for %s" % (stage.name, projectname)
        if stage.has_pypi_base(projectname):
            refresh_title = "Refresh" if stage.ixconfig["type"] == "mirror" else \
                            "Refresh PyPI links"
            refresh_url = request.route_url(
                "/{user}/{index}/+simple/{name}/refresh",
                user=self.context.username, index=self.context.index,
                name=projectname)
            refresh_form = [
                html.form(
                    html.input(
                        type="submit", value=refresh_title, name="refresh"),
                    action=refresh_url,
                    method="post"),
                "\n"]
        else:
            refresh_form = []
        return Response(html.html(
            html.head(
                html.title(title)),
            html.body(
                html.h1(title), "\n",
                refresh_form,
                links)).unicode(indent=2))
开发者ID:uceo,项目名称:uceo-2015,代码行数:56,代码来源:views.py


示例10: _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


示例11: _append_screenshot

    def _append_screenshot(self, name, log):
        name = re.sub('[^A-Za-z0-9_.]+', '_', name)

        images_saved = os.path.join(self.project_root, 'screenshots')

        if os.path.isdir(images_saved) and len(os.listdir(images_saved)) > 0:

            log.append(html.h3('Screenshots'))

            for file in os.listdir(images_saved):
                image_path = os.path.join(images_saved, file)
                if name in image_path:
                    self.used_screens.append(image_path)
                    # use relative path in img src
                    source = image_path.replace(self.project_root, '.')
                    log.append(source)
                    log.append(html.br())
                    log.append(html.img(src=source))
                    log.append(html.br())
开发者ID:salsita,项目名称:shishito,代码行数:19,代码来源:junithtml.py


示例12: simple_list_project

    def simple_list_project(self):
        request = self.request
        name = self.context.name
        # we only serve absolute links so we don't care about the route's slash
        abort_if_invalid_projectname(request, name)
        stage = self.context.stage
        projectname = stage.get_projectname(name)
        if projectname is None:
            abort(request, 200, "no such project %r" % projectname)

        if name != projectname:
            redirect("/%s/+simple/%s/" % (stage.name, projectname))
        try:
            result = stage.get_releaselinks(projectname)
        except stage.UpstreamError as e:
            threadlog.error(e.msg)
            abort(request, 502, e.msg)
        links = []
        for link in result:
            relpath = link.entrypath
            href = "/" + relpath
            href = URL(request.path).relpath(href)
            if link.eggfragment:
                href += "#egg=%s" % link.eggfragment
            elif link.md5:
                href += "#md5=%s" % link.md5
            links.extend([
                 "/".join(relpath.split("/", 2)[:2]) + " ",
                 html.a(link.basename, href=href),
                 html.br(), "\n",
            ])
        title = "%s: links for %s" % (stage.name, projectname)
        if stage.has_pypi_base(projectname):
            refresh_title = "Refresh" if stage.ixconfig["type"] == "mirror" else \
                            "Refresh PyPI links"
            refresh_url = request.route_url(
                "/{user}/{index}/+simple/{name}/refresh",
                user=self.context.username, index=self.context.index,
                name=projectname)
            refresh_form = [
                html.form(
                    html.input(
                        type="submit", value=refresh_title, name="refresh"),
                    action=refresh_url,
                    method="post"),
                "\n"]
        else:
            refresh_form = []
        return Response(html.html(
            html.head(
                html.title(title)),
            html.body(
                html.h1(title), "\n",
                refresh_form,
                links)).unicode(indent=2))
开发者ID:t-8ch,项目名称:devpi,代码行数:55,代码来源:views.py


示例13: _append_crash_message_section

 def _append_crash_message_section(log, report):
     try:
         message = report.longrepr.reprcrash.message
         log.append(html.h3('Crash Message'))
         crash_message_p = html.p(class_='crash_message')
         for line in message.splitlines():
             crash_message_p.append(escape(line))
             crash_message_p.append(html.br())
         log.append(crash_message_p)
     except:
         return
开发者ID:salsita,项目名称:shishito,代码行数:11,代码来源:junithtml.py


示例14: _extract_html

        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'))
开发者ID:Allan019,项目名称:gaia,代码行数:53,代码来源:runtests.py


示例15: _extract_html

        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",
                )
            )
开发者ID:JDaniel1990,项目名称:gaia,代码行数:52,代码来源:runtests.py


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


示例17: _append_stacktrace_section

 def _append_stacktrace_section(log, report):
     log.append(html.h3('Stacktrace'))
     stacktrace_p = html.p(class_='stacktrace')
     for line in str(report.longrepr).splitlines():
         separator = line.startswith('_ ' * 10)
         if separator:
             stacktrace_p.append(line[:80])
         else:
             exception = line.startswith("E   ")
             if exception:
                 stacktrace_p.append(html.span(raw(escape(line)),
                                               class_='error'))
             else:
                 stacktrace_p.append(raw(escape(line)))
         stacktrace_p.append(html.br())
     log.append(stacktrace_p)
开发者ID:salsita,项目名称:shishito,代码行数:16,代码来源:junithtml.py


示例18: _appendrow

    def _appendrow(self, result, report):
        names = mangle_testnames(report.nodeid.split("::"))
        testclass = (names[:-1])
        if self.prefix:
            testclass.insert(0, self.prefix)
        testclass = ".".join(testclass)
        testmethod = names[-1]
        time = getattr(report, 'duration', 0.0)

        additional_html = []

        if not 'Passed' in result:
            if report.longrepr:
                log = html.div(class_='log')
                for line in str(report.longrepr).splitlines():
                    line = line.decode('utf8')
                    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())
                if not os.path.exists(self.screenshot_path):
                    os.makedirs(self.screenshot_path)
                self.append_screenshot(testmethod, log)
                additional_html.append(log)
        output = self._write_captured_output(report)
        info = output.split(" ")
        links_html = []
        for i in range(0, len(info)):
            if ("http" in info[i] and "browserstack.com" in info[i]):
                links_html.append(html.a("link", href=info[i], target='_blank'))
                links_html.append(' ')

        self.test_logs.append(html.tr([
                                          html.td(result, class_='col-result'),
                                          html.td(testclass, class_='col-class'),
                                          html.td(testmethod, class_='col-name'),
                                          html.td(round(time), class_='col-duration'),
                                          html.td(links_html, class_='col-links'),
                                          html.td(additional_html, class_='debug')],
                                      class_=result.lower() + ' results-table-row'))
开发者ID:Argimon,项目名称:shishito,代码行数:47,代码来源:junithtml.py


示例19: findlinks_view

def findlinks_view(context, request):
    title = "%s: all package links without root/pypi" % (context.stage.name)
    projectnames = set()
    for stage, names in context.stage.op_sro("list_projectnames_perstage"):
        if stage.ixconfig["type"] == "mirror":
            continue
        projectnames.update(names)
    all_links = []
    basenames = set()
    for projectname in sorted(projectnames):
        for stage, res in context.stage.op_sro_check_pypi_whitelist(
                "get_releaselinks_perstage", projectname=projectname):
            if stage.ixconfig["type"] == "mirror":
                continue
            for link in res:
                if link.eggfragment:
                    key = link.eggfragment
                else:
                    key = link.basename
                if key not in basenames:
                    basenames.add(key)
                    all_links.append(link)
    links = []
    for link in sorted(all_links, key=attrgetter('basename')):
        href = url_for_entrypath(request, link.entrypath)
        entry = link.entry
        if entry.eggfragment:
            href += "#egg=%s" % entry.eggfragment
        elif entry.md5:
            href += "#md5=%s" % entry.md5
        links.extend([
            "/".join(link.entrypath.split("/", 2)[:2]) + " ",
            html.a(link.basename, href=href),
            html.br(), "\n"])
    if not links:
        links = [html.p('No releases.')]
    return Response(html.html(
        html.head(
            html.title(title)),
        html.body(
            html.h1(title), "\n",
            links)).unicode(indent=2))
开发者ID:msabramo,项目名称:devpi-findlinks,代码行数:42,代码来源:main.py


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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python html.div函数代码示例发布时间:2022-05-25
下一篇:
Python html.body函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap