Python trace.find_strings() Examples
The following are 7
code examples of trace.find_strings().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
trace
, or try the search function
.
Example #1
Source File: profilehooks.py From verge3d-blender-addon with GNU General Public License v3.0 | 5 votes |
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
Example #2
Source File: test_trace.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
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)
Example #3
Source File: profilehooks.py From pyFileFixity with MIT License | 5 votes |
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
Example #4
Source File: test_trace.py From ironpython3 with Apache License 2.0 | 5 votes |
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)
Example #5
Source File: test_trace.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
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)
Example #6
Source File: trial.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
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)
Example #7
Source File: profilehooks.py From Tautulli with GNU General Public License v3.0 | 5 votes |
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