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


Python trace.find_strings方法代码示例

本文整理汇总了Python中trace.find_strings方法的典型用法代码示例。如果您正苦于以下问题:Python trace.find_strings方法的具体用法?Python trace.find_strings怎么用?Python trace.find_strings使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在trace的用法示例。


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

示例1: _find_docstrings

# 需要导入模块: import trace [as 别名]
# 或者: from trace import find_strings [as 别名]
def _find_docstrings(self, filename):
        # A replacement for trace.find_strings() which was deprecated in
        # Python 3.2 and removed in 3.6.
        strs = set()
        prev = token.INDENT  # so module docstring is detected as docstring
        with open(filename) as f:
            tokens = tokenize.generate_tokens(f.readline)
            for ttype, tstr, start, end, line in tokens:
                if ttype == token.STRING and prev == token.INDENT:
                    strs.update(range(start[0], end[0] + 1))
                prev = ttype
        return strs 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:14,代码来源:profilehooks.py

示例2: test_deprecated_find_strings

# 需要导入模块: import trace [as 别名]
# 或者: from trace import find_strings [as 别名]
def test_deprecated_find_strings(self):
        with open(TESTFN, 'w') as fd:
            self.addCleanup(unlink, TESTFN)
        with self.assertWarns(DeprecationWarning):
            trace.find_strings(fd.name) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:7,代码来源:test_trace.py

示例3: find_source_lines

# 需要导入模块: import trace [as 别名]
# 或者: from trace import find_strings [as 别名]
def find_source_lines(self):
        """Mark all executable source lines in fn as executed 0 times."""
        strs = trace.find_strings(self.filename)
        lines = trace.find_lines_from_code(self.fn.__code__, strs)
        self.firstcodelineno = sys.maxint
        for lineno in lines:
            self.firstcodelineno = min(self.firstcodelineno, lineno)
            self.sourcelines.setdefault(lineno, 0)
        if self.firstcodelineno == sys.maxint:
            self.firstcodelineno = self.firstlineno 
开发者ID:lrq3000,项目名称:pyFileFixity,代码行数:12,代码来源:profilehooks.py

示例4: opt_coverage

# 需要导入模块: import trace [as 别名]
# 或者: from trace import find_strings [as 别名]
def opt_coverage(self):
        """
        Generate coverage information in the given directory (relative to
        trial temporary working directory). Requires Python 2.3.3.
        """
        coverdir = 'coverage'
        print "Setting coverage directory to %s." % (coverdir,)
        import trace

        # begin monkey patch ---------------------------
        #   Before Python 2.4, this function asserted that 'filename' had
        #   to end with '.py'  This is wrong for at least two reasons:
        #   1.  We might be wanting to find executable line nos in a script
        #   2.  The implementation should use os.splitext
        #   This monkey patch is the same function as in the stdlib (v2.3)
        #   but with the assertion removed.
        def find_executable_linenos(filename):
            """Return dict where keys are line numbers in the line number
            table.
            """
            #assert filename.endswith('.py') # YOU BASTARDS
            try:
                prog = open(filename).read()
                prog = '\n'.join(prog.splitlines()) + '\n'
            except IOError, err:
                sys.stderr.write("Not printing coverage data for %r: %s\n"
                                 % (filename, err))
                sys.stderr.flush()
                return {}
            code = compile(prog, filename, "exec")
            strs = trace.find_strings(filename)
            return trace.find_lines(code, strs) 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:34,代码来源:trial.py

示例5: find_source_lines

# 需要导入模块: import trace [as 别名]
# 或者: from trace import find_strings [as 别名]
def find_source_lines(self):
        """Mark all executable source lines in fn as executed 0 times."""
        strs = trace.find_strings(self.filename)
        lines = trace.find_lines_from_code(self.fn.func_code, strs)
        self.firstcodelineno = sys.maxint
        for lineno in lines:
            self.firstcodelineno = min(self.firstcodelineno, lineno)
            self.sourcelines.setdefault(lineno, 0)
        if self.firstcodelineno == sys.maxint:
            self.firstcodelineno = self.firstlineno 
开发者ID:Tautulli,项目名称:Tautulli,代码行数:12,代码来源:profilehooks.py


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