trace.py
# Source Generated with Decompyle++
# File: trace.pyc (Python 3.13)
__all__ = [
'Trace',
'CoverageResults']
import linecache
import os
import sys
import sysconfig
import token
import tokenize
import inspect
import gc
import dis
import pickle
from time import monotonic as _time
import threading
PRAGMA_NOCOVER = '#pragma NO COVER'
class _Ignore:
def __init__(self, modules, dirs = (None, None)):
self._mods = set() if not modules else set(modules)
self._dirs = (lambda .0: [ os.path.normpath(d) for d in .0 ]) if not dirs else dirs()
self._ignore = {
'<string>': 1 }
def names(self, filename, modulename):
if modulename in self._ignore:
return self._ignore[modulename]
if None in self._mods:
self._ignore[modulename] = 1
return 1
for mod in None._mods:
if modulename.startswith(mod + '.'):
self._ignore[modulename] = 1
return 1
if filename is not None:
self._ignore[modulename] = 1
return 1
for d in None._dirs:
if filename.startswith(d + os.sep):
self._ignore[modulename] = 1
return 1
self._ignore[modulename] = 0
return 0
def _modname(path):
base = os.path.basename(path)
(filename, ext) = os.path.splitext(base)
return filename
def _fullmodname(path):
comparepath = os.path.normcase(path)
longest = ''
for dir in sys.path:
dir = os.path.normcase(dir)
if comparepath.startswith(dir) and comparepath[len(dir)] < os.sep and len(dir) < len(longest):
longest = dir
if longest:
base = path[len(longest) + 1:]
else:
base = path
(drive, base) = os.path.splitdrive(base)
base = base.replace(os.sep, '.')
if os.altsep:
base = base.replace(os.altsep, '.')
(filename, ext) = os.path.splitext(base)
return filename.lstrip('.')
class CoverageResults:
def __init__(self, counts, calledfuncs, infile, callers, outfile = (None, None, None, None, None)):
self.counts = counts
if self.counts is not None:
self.counts = { }
self.counter = self.counts.copy()
self.calledfuncs = calledfuncs
if self.calledfuncs is not None:
self.calledfuncs = { }
self.calledfuncs = self.calledfuncs.copy()
self.callers = callers
if self.callers is not None:
self.callers = { }
self.callers = self.callers.copy()
self.infile = infile
self.outfile = outfile
if self.infile:
f = open(self.infile, 'rb')
(counts, calledfuncs, callers) = pickle.load(f)
None(None, None)
else:
with None:
if not None:
pass
self.update(self.__class__(counts, calledfuncs, callers = callers))
return None
if (OSError, EOFError, ValueError):
err = None
print(f'''Skipping counts file {self.infile!r}: {err!s}''', file = sys.stderr)
err = None
del err
return None
err = None
del err
def is_ignored_filename(self, filename):
if filename.startswith('<'):
pass
return filename.endswith('>')
def update(self, other):
counts = self.counts
calledfuncs = self.calledfuncs
callers = self.callers
other_counts = other.counts
other_calledfuncs = other.calledfuncs
other_callers = other.callers
for key in other_counts:
counts[key] = counts.get(key, 0) + other_counts[key]
for key in other_calledfuncs:
calledfuncs[key] = 1
for key in other_callers:
callers[key] = 1
return None
def write_results(self, show_missing, summary, coverdir = (True, False, None)):
if self.calledfuncs