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


Python html.a函数代码示例

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


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

示例1: append_extra_html

    def append_extra_html(self, extra, additional_html, links_html):
        href = None
        if extra.get('format') == extras.FORMAT_IMAGE:
            href = '#'
            image = 'data:image/png;base64,{0}'.format(
                    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(html.div(raw(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(' ')
开发者ID:redixin,项目名称:pytest-html,代码行数:30,代码来源:plugin.py

示例2: make_html_report

def make_html_report(path, report):
    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)

    body_els = []
    keys = report.keys()
    keys.sort()
    links = []
    for key in keys:
        links.append(html.li(html.a(key, href="#" + key)))
    body_els.append(html.ul(links))
    for key in keys:
        body_els.append(html.a(html.h1(key), id=key))
        body_els.append(tabelize(report[key]))
    with open(path, 'w') as f:
        doc = html.html(html.head(html.style('table, td {border: 1px solid;}')), html.body(body_els))
        f.write(str(doc))
开发者ID:Mozilla-TWQA,项目名称:fxos-certsuite,代码行数:26,代码来源:cert.py

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

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

示例5: fill

 def fill(self):
     super(HPage, self).fill()
     self.menubar[:] = html.ul(
         html.li(html.a("home", href="index.html", class_="menu")),
         html.li(html.a("install", href="install.html", class_="menu")),
         html.li(html.a("usage", href="usage.html", class_="menu")),
         id="menubar",
     )
开发者ID:emgee,项目名称:hype,代码行数:8,代码来源:confrest.py

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

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

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

示例9: test_prepare_line_basic

def test_prepare_line_basic():
    result = prepare_line_helper(['see if this works'])
    assert result == 'see <span class="keyword">if</span> this works'
    result = prepare_line_helper(['see if this ',
                                html.a('works', name='works'),' too'])
    assert result == ('see <span class="keyword">if</span> this '
                      '<a name="works">works</a> too')
    result = prepare_line_helper(['see if something else works'])
    assert result == ('see <span class="keyword">if</span> something '
                      '<span class="keyword">else</span> works')
    result = prepare_line_helper(['see if something ',
                                html.a('else', name='else'), ' works too'])
    assert result == ('see <span class="keyword">if</span> something '
                      '<a name="else">else</a> works too')
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:14,代码来源:test_html.py

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

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

示例12: _link_to_debug_event

    def _link_to_debug_event(self, name, log):
        name = re.sub('[^A-Za-z0-9_.]+', '_', name)
        browser_name = self.prefix.split(",")[0].replace('[', '').lower()

        source = os.path.join(self.project_root, 'debug_events', browser_name + '_' + name + '.json')
        self.used_debug_events.append(source)
        return [html.a("Console log", href='debug_events/' + browser_name + '_' + name + '.json'), ' ']
开发者ID:salsita,项目名称:shishito,代码行数:7,代码来源:junithtml.py

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

示例14: suite_start

    def suite_start(self, data):
        self.suite_times["start"] = data["time"]
        self.suite_name = data["source"]
        with open(os.path.join(base_path, "style.css")) as f:
            self.head = html.head(
                html.meta(charset="utf-8"),
                html.title(data["source"]),
                html.style(raw(f.read())))

        date_format = "%d %b %Y %H:%M:%S"
        version_info = data.get("version_info")
        if version_info:
            self.env["Device identifier"] = version_info.get("device_id")
            self.env["Device firmware (base)"] = version_info.get("device_firmware_version_base")
            self.env["Device firmware (date)"] = (
                datetime.utcfromtimestamp(int(version_info.get("device_firmware_date"))).strftime(date_format) if
                "device_firmware_date" in version_info else None)
            self.env["Device firmware (incremental)"] = version_info.get("device_firmware_version_incremental")
            self.env["Device firmware (release)"] = version_info.get("device_firmware_version_release")
            self.env["Gaia date"] = (
                datetime.utcfromtimestamp(int(version_info.get("gaia_date"))).strftime(date_format) if
                "gaia_date" in version_info else None)
            self.env["Gecko version"] = version_info.get("application_version")
            self.env["Gecko build"] = version_info.get("application_buildid")

            if version_info.get("application_changeset"):
                self.env["Gecko revision"] = version_info.get("application_changeset")
                if version_info.get("application_repository"):
                    self.env["Gecko revision"] = html.a(
                        version_info.get("application_changeset"),
                        href="/".join([version_info.get("application_repository"),
                                       version_info.get("application_changeset")]),
                        target="_blank")

            if version_info.get("gaia_changeset"):
                self.env["Gaia revision"] = html.a(
                    version_info.get("gaia_changeset")[:12],
                    href="https://github.com/mozilla-b2g/gaia/commit/%s" % version_info.get("gaia_changeset"),
                    target="_blank")

        device_info = data.get("device_info")
        if device_info:
            self.env["Device uptime"] = device_info.get("uptime")
            self.env["Device memory"] = device_info.get("memtotal")
            self.env["Device serial"] = device_info.get("id")
开发者ID:Andrel322,项目名称:gecko-dev,代码行数:45,代码来源:html.py

示例15: _link_to_browserstack_log

 def _link_to_browserstack_log(self, output):
     info = output.split(" ")
     link_html = []
     for i in range(0, len(info)):
         match_obj = re.search(r'(https?://www.browserstack.com/automate/builds/[\w]*/sessions/[\w]*)/', info[i])
         if match_obj:
             link_html.append(html.a("Browserstack", href=match_obj.group(1), target='_blank'))
             link_html.append(' ')
     return link_html
开发者ID:salsita,项目名称:shishito,代码行数:9,代码来源:junithtml.py


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