當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。