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


Python templite.Templite类代码示例

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


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

示例1: test_reusability

    def test_reusability(self):
        # A single Templite can be used more than once with different data.
        globs = {
            'upper': lambda x: x.upper(),
            'punct': '!',
            }

        template = Templite("This is {{name|upper}}{{punct}}", globs)
        self.assertEqual(template.render({'name':'Ned'}), "This is NED!")
        self.assertEqual(template.render({'name':'Ben'}), "This is BEN!")
开发者ID:dstufft,项目名称:coveragepy,代码行数:10,代码来源:test_templite.py

示例2: index_file

 def index_file(self):
     index_tmpl = Templite(data('index.html'), self.template_globals)
     self.totals = sum([ f['nums'] for f in self.files ])
     html = index_tmpl.render({'arcs': self.arcs,
      'extra_css': self.extra_css,
      'files': self.files,
      'totals': self.totals})
     if sys.version_info < (3, 0):
         html = html.decode('utf-8')
     self.write_html(os.path.join(self.directory, 'index.html'), html)
     self.status.write(self.directory)
开发者ID:connoryang,项目名称:dec-eve-serenity,代码行数:11,代码来源:html.py

示例3: index_file

    def index_file(self):
        """Write the index.html file for this report."""
        index_tmpl = Templite(data("htmlfiles/index.html"), globals())

        files = self.files
        arcs = self.arcs

        totals = sum([f['nums'] for f in files])

        fhtml = open(os.path.join(self.directory, "index.html"), "w")
        fhtml.write(index_tmpl.render(locals()))
        fhtml.close()
开发者ID:AndryulE,项目名称:kitsune,代码行数:12,代码来源:html.py

示例4: index_file

    def index_file(self):
        """Write the index.html file for this report."""
        index_tmpl = Templite(data("index.html"), self.template_globals)

        self.totals = sum(f["nums"] for f in self.files)

        html = index_tmpl.render(
            {"arcs": self.arcs, "extra_css": self.extra_css, "files": self.files, "totals": self.totals}
        )

        self.write_html(os.path.join(self.directory, "index.html"), html)

        # Write the latest hashes for next time.
        self.status.write(self.directory)
开发者ID:th0,项目名称:test2,代码行数:14,代码来源:html.py

示例5: __init__

 def __init__(self, coverage, ignore_errors=False):
     super(HtmlReporter, self).__init__(coverage, ignore_errors)
     self.directory = None
     self.source_tmpl = Templite(data("htmlfiles/pyfile.html"), globals())
     
     self.files = []
     self.arcs = coverage.data.has_arcs()
开发者ID:AndryulE,项目名称:kitsune,代码行数:7,代码来源:html.py

示例6: __init__

    def __init__(self, cov, config):
        super(HtmlReporter, self).__init__(cov, config)
        self.directory = None
        title = self.config.html_title
        if env.PY2:
            title = title.decode("utf8")
        self.template_globals = {
            'escape': escape,
            'pair': pair,
            'title': title,
            '__url__': coverage.__url__,
            '__version__': coverage.__version__,
            }
        self.source_tmpl = Templite(
            data("pyfile.html"), self.template_globals
            )

        self.coverage = cov

        self.files = []
        self.arcs = self.coverage.data.has_arcs()
        self.status = HtmlStatus()
        self.extra_css = None
        self.totals = Numbers()
        self.time_stamp = datetime.datetime.now().strftime('%Y-%m-%d %H:%M')
开发者ID:ziadsawalha,项目名称:coveragepy,代码行数:25,代码来源:html.py

示例7: index_file

    def index_file(self):
        """Write the index.html file for this report."""
        index_tmpl = Templite(data("index.html"), self.template_globals)

        self.totals = sum(f['nums'] for f in self.files)

        html = index_tmpl.render({
            'has_arcs': self.has_arcs,
            'extra_css': self.extra_css,
            'files': self.files,
            'totals': self.totals,
            'time_stamp': self.time_stamp,
        })

        self.write_html(os.path.join(self.directory, "index.html"), html)

        # Write the latest hashes for next time.
        self.status.write(self.directory)
开发者ID:pycom,项目名称:EricShort,代码行数:18,代码来源:html.py

示例8: index_file

    def index_file(self):
        """Write the index.html file for this report."""
        index_tmpl = Templite(
            data("htmlfiles/index.html"), self.template_globals
            )

        files = self.files
        arcs = self.arcs

        totals = sum([f['nums'] for f in files])

        self.write_html(
            os.path.join(self.directory, "index.html"),
            index_tmpl.render(locals())
            )

        # Write the latest hashes for next time.
        self.status.write(self.directory)
开发者ID:335969568,项目名称:Blink-1,代码行数:18,代码来源:html.py

示例9: index_file

    def index_file(self):
        """Write the index.html file for this report."""
        index_tmpl = Templite(
            data("htmlfiles/index.html"), self.template_globals
            )

        files = self.files
        arcs = self.arcs

        self.totals = totals = sum([f['nums'] for f in files])
        extra_css = self.extra_css

        html = index_tmpl.render(locals())
        if sys.version_info < (3, 0):
            html = html.decode("utf-8")
        self.write_html(
            os.path.join(self.directory, "index.html"),
            html
            )

        # Write the latest hashes for next time.
        self.status.write(self.directory)
开发者ID:Cameronlroberts,项目名称:Projects,代码行数:22,代码来源:html.py

示例10: __init__

 def __init__(self, cov, config):
     super(HtmlReporter, self).__init__(cov, config)
     self.directory = None
     self.template_globals = {'escape': escape,
      'title': self.config.html_title,
      '__url__': coverage.__url__,
      '__version__': coverage.__version__}
     self.source_tmpl = Templite(data('pyfile.html'), self.template_globals)
     self.coverage = cov
     self.files = []
     self.arcs = self.coverage.data.has_arcs()
     self.status = HtmlStatus()
     self.extra_css = None
     self.totals = Numbers()
开发者ID:connoryang,项目名称:dec-eve-serenity,代码行数:14,代码来源:html.py

示例11: index_file

    def index_file(self):
        """Write the index.html file for this report."""
        index_tmpl = Templite(
            data("index.html"), self.template_globals
            )

        self.totals = sum(f['nums'] for f in self.files)

        html = index_tmpl.render({
            'arcs': self.arcs,
            'extra_css': self.extra_css,
            'files': self.files,
            'totals': self.totals,
        })

        if sys.version_info < (3, 0):
            html = html.decode("utf-8")
        self.write_html(
            os.path.join(self.directory, "index.html"),
            html
            )

        # Write the latest hashes for next time.
        self.status.write(self.directory)
开发者ID:brifordwylie,项目名称:coveragepy,代码行数:24,代码来源:html.py

示例12: __init__

    def __init__(self, cov, ignore_errors=False):
        super(HtmlReporter, self).__init__(cov, ignore_errors)
        self.directory = None
        self.template_globals = {
            'escape': escape,
            '__url__': coverage.__url__,
            '__version__': coverage.__version__,
            }
        self.source_tmpl = Templite(
            data("htmlfiles/pyfile.html"), self.template_globals
            )

        self.coverage = cov

        self.files = []
        self.arcs = self.coverage.data.has_arcs()
        self.status = HtmlStatus()
开发者ID:335969568,项目名称:Blink-1,代码行数:17,代码来源:html.py

示例13: __init__

    def __init__(self, cov, config):
        super(HtmlReporter, self).__init__(cov, config)
        self.directory = None
        title = self.config.html_title
        if env.PY2:
            title = title.decode("utf8")
        self.template_globals = {
            "escape": escape,
            "pair": pair,
            "title": title,
            "__url__": coverage.__url__,
            "__version__": coverage.__version__,
        }
        self.source_tmpl = Templite(data("pyfile.html"), self.template_globals)

        self.coverage = cov

        self.files = []
        self.arcs = self.coverage.data.has_arcs()
        self.status = HtmlStatus()
        self.extra_css = None
        self.totals = Numbers()
开发者ID:th0,项目名称:test2,代码行数:22,代码来源:html.py

示例14: HtmlReporter

class HtmlReporter(Reporter):
    """HTML reporting."""

    def __init__(self, coverage, ignore_errors=False):
        super(HtmlReporter, self).__init__(coverage, ignore_errors)
        self.directory = None
        self.source_tmpl = Templite(data("htmlfiles/pyfile.html"), globals())

        self.files = []
        self.arcs = coverage.data.has_arcs()

    def report(self, morfs, config=None):
        """Generate an HTML report for `morfs`.

        `morfs` is a list of modules or filenames.  `config` is a
        CoverageConfig instance.

        """
        assert config.html_dir, "must provide a directory for html reporting"

        # Process all the files.
        self.report_files(self.html_file, morfs, config, config.html_dir)

        if not self.files:
            raise CoverageException("No data to report.")

        # Write the index file.
        self.index_file()

        # Create the once-per-directory files.
        for static in ["style.css", "coverage_html.js", "jquery-1.3.2.min.js", "jquery.tablesorter.min.js"]:
            shutil.copyfile(data_filename("htmlfiles/" + static), os.path.join(self.directory, static))

    def html_file(self, cu, analysis):
        """Generate an HTML file for one source file."""

        source = cu.source_file().read()

        nums = analysis.numbers

        missing_branch_arcs = analysis.missing_branch_arcs()
        n_par = 0  # accumulated below.
        arcs = self.arcs

        # These classes determine which lines are highlighted by default.
        c_run = "run hide_run"
        c_exc = "exc"
        c_mis = "mis"
        c_par = "par " + c_run

        lines = []

        for lineno, line in enumerate(source_token_lines(source)):
            lineno += 1  # 1-based line numbers.
            # Figure out how to mark this line.
            line_class = []
            annotate_html = ""
            annotate_title = ""
            if lineno in analysis.statements:
                line_class.append("stm")
            if lineno in analysis.excluded:
                line_class.append(c_exc)
            elif lineno in analysis.missing:
                line_class.append(c_mis)
            elif self.arcs and lineno in missing_branch_arcs:
                line_class.append(c_par)
                n_par += 1
                annlines = []
                for b in missing_branch_arcs[lineno]:
                    if b < 0:
                        annlines.append("exit")
                    else:
                        annlines.append(str(b))
                annotate_html = "&nbsp;&nbsp; ".join(annlines)
                if len(annlines) > 1:
                    annotate_title = "no jumps to these line numbers"
                elif len(annlines) == 1:
                    annotate_title = "no jump to this line number"
            elif lineno in analysis.statements:
                line_class.append(c_run)

            # Build the HTML for the line
            html = []
            for tok_type, tok_text in line:
                if tok_type == "ws":
                    html.append(escape(tok_text))
                else:
                    tok_html = escape(tok_text) or "&nbsp;"
                    html.append("<span class='%s'>%s</span>" % (tok_type, tok_html))

            lines.append(
                {
                    "html": "".join(html),
                    "number": lineno,
                    "class": " ".join(line_class) or "pln",
                    "annotate": annotate_html,
                    "annotate_title": annotate_title,
                }
            )

#.........这里部分代码省略.........
开发者ID:jokajak,项目名称:itweb,代码行数:101,代码来源:html.py

示例15: HtmlReporter

class HtmlReporter(Reporter):
    """HTML reporting."""
    
    def __init__(self, coverage, ignore_errors=False):
        super(HtmlReporter, self).__init__(coverage, ignore_errors)
        self.directory = None
        self.source_tmpl = Templite(data("htmlfiles/pyfile.html"), globals())
        
        self.files = []
        self.arcs = coverage.data.has_arcs()

    def report(self, morfs, directory, omit_prefixes=None):
        """Generate an HTML report for `morfs`.
        
        `morfs` is a list of modules or filenames.  `directory` is where to put
        the HTML files. `omit_prefixes` is a list of strings, prefixes of
        modules to omit from the report.
        
        """
        assert directory, "must provide a directory for html reporting"
        
        # Process all the files.
        self.report_files(self.html_file, morfs, directory, omit_prefixes)

        # Write the index file.
        self.index_file()

        # Create the once-per-directory files.
        for static in [
            "style.css", "coverage_html.js",
            "jquery-1.3.2.min.js", "jquery.tablesorter.min.js"
            ]:
            shutil.copyfile(
                data_filename("htmlfiles/" + static),
                os.path.join(directory, static)
                )

    def html_file(self, cu, analysis):
        """Generate an HTML file for one source file."""
        
        source = cu.source_file().read()

        nums = analysis.numbers        

        missing_branch_arcs = analysis.missing_branch_arcs()
        n_par = 0   # accumulated below.
        arcs = self.arcs

        # These classes determine which lines are highlighted by default.
        c_run = " run hide_run"
        c_exc = " exc"
        c_mis = " mis"
        c_par = " par" + c_run

        lines = []
        
        for lineno, line in enumerate(source_token_lines(source)):
            lineno += 1     # 1-based line numbers.
            # Figure out how to mark this line.
            line_class = ""
            annotate_html = ""
            annotate_title = ""
            if lineno in analysis.statements:
                line_class += " stm"
            if lineno in analysis.excluded:
                line_class += c_exc
            elif lineno in analysis.missing:
                line_class += c_mis
            elif self.arcs and lineno in missing_branch_arcs:
                line_class += c_par
                n_par += 1
                annlines = []
                for b in missing_branch_arcs[lineno]:
                    if b == -1:
                        annlines.append("exit")
                    else:
                        annlines.append(str(b))
                annotate_html = "&nbsp;&nbsp; ".join(annlines)
                if len(annlines) > 1:
                    annotate_title = "no jumps to these line numbers"
                elif len(annlines) == 1:
                    annotate_title = "no jump to this line number"
            elif lineno in analysis.statements:
                line_class += c_run
            
            # Build the HTML for the line
            html = ""
            for tok_type, tok_text in line:
                if tok_type == "ws":
                    html += escape(tok_text)
                else:
                    tok_html = escape(tok_text) or '&nbsp;'
                    html += "<span class='%s'>%s</span>" % (tok_type, tok_html)

            lines.append({
                'html': html,
                'number': lineno,
                'class': line_class.strip() or "pln",
                'annotate': annotate_html,
                'annotate_title': annotate_title,
#.........这里部分代码省略.........
开发者ID:AndryulE,项目名称:kitsune,代码行数:101,代码来源:html.py


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