Index: Tools/scripts/trace.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/trace.py,v retrieving revision 1.12 diff -c -r1.12 trace.py *** Tools/scripts/trace.py 11 Dec 2002 21:43:13 -0000 1.12 --- Tools/scripts/trace.py 18 Dec 2002 19:34:18 -0000 *************** *** 1,5 **** --- 1,7 ---- #!/usr/bin/env python + __cvsid = '$Id$' + # portions copyright 2001, Autonomous Zones Industries, Inc., all rights... # err... reserved and offered to the public under the terms of the # Python 2.2 license. *************** *** 29,34 **** --- 31,38 ---- # """program/module to trace Python program or function execution + See usage string below for usage details. + Sample use, command line: trace.py -c -f counts --ignore-dir '$prefix' spam.py eggs trace.py -t --ignore-dir '$prefix' spam.py eggs *************** *** 67,72 **** --- 71,79 ---- and write the counts to .cover for each module executed, in the module's directory. See also `--coverdir', `--file', `--no-report' below. + -l, --listfuncs Keep track of which functions are executed at least + once and write the results to sys.stdout after the the + program exits. -r, --report Generate a report from a counts file; do not execute any code. `--file' must specify the results file to read, which must have been created in a previous run *************** *** 161,172 **** # try and merge existing counts file try: thingie = pickle.load(open(self.infile, 'r')) ! if type(thingie) is types.DictType: ! # backwards compatibility for old trace.py after ! # Zooko touched it but before calledfuncs --Zooko ! # 2001年10月24日 ! self.update(self.__class__(thingie)) ! elif type(thingie) is types.TupleType and len(thingie) == 2: counts, calledfuncs = thingie self.update(self.__class__(counts, calledfuncs)) except (IOError, EOFError): --- 168,174 ---- # try and merge existing counts file try: thingie = pickle.load(open(self.infile, 'r')) ! if type(thingie) is types.TupleType and len(thingie) == 2: counts, calledfuncs = thingie self.update(self.__class__(counts, calledfuncs)) except (IOError, EOFError): *************** *** 183,194 **** other_counts = other.counts other_calledfuncs = other.calledfuncs ! for key in other_counts.keys(): ! if key != 'calledfuncs': ! # backwards compatibility for abortive attempt to ! # stuff calledfuncs into self.counts, by Zooko ! # --Zooko 2001年10月24日 ! counts[key] = counts.get(key, 0) + other_counts[key] for key in other_calledfuncs.keys(): calledfuncs[key] = 1 --- 185,192 ---- other_counts = other.counts other_calledfuncs = other.calledfuncs ! for k, v in other_counts.items(): ! counts[k] = counts.get(k, 0) + v for key in other_calledfuncs.keys(): calledfuncs[key] = 1 *************** *** 206,218 **** # accessible on a per-file basis per_file = {} for thingie in self.counts.keys(): ! if thingie != "calledfuncs": ! # backwards compatibility for abortive attempt to ! # stuff calledfuncs into self.counts, by Zooko --Zooko ! # 2001年10月24日 ! filename, lineno = thingie ! lines_hit = per_file[filename] = per_file.get(filename, {}) ! lines_hit[lineno] = self.counts[(filename, lineno)] # there are many places where this is insufficient, like a blank # line embedded in a multiline string. --- 204,212 ---- # accessible on a per-file basis per_file = {} for thingie in self.counts.keys(): ! filename, lineno = thingie ! lines_hit = per_file[filename] = per_file.get(filename, {}) ! lines_hit[lineno] = self.counts[(filename, lineno)] # there are many places where this is insufficient, like a blank # line embedded in a multiline string. *************** *** 223,239 **** # generate file paths for the coverage files we are going to write... fnlist = [] ! tfdir = tempfile.gettempdir() for key in per_file.keys(): filename = key # skip some "files" we don't care about... if filename == "": continue - # are these caused by code compiled using exec or something? - if filename.startswith(tfdir): - continue - modulename = inspect.getmodulename(filename) if filename.endswith(".pyc") or filename.endswith(".pyo"): --- 217,229 ---- # generate file paths for the coverage files we are going to write... fnlist = [] ! for key in per_file.keys(): filename = key # skip some "files" we don't care about... if filename == "": continue modulename = inspect.getmodulename(filename) if filename.endswith(".pyc") or filename.endswith(".pyo"): *************** *** 244,251 **** else: thiscoverdir = os.path.dirname(os.path.abspath(filename)) ! # the code from here to "<<<" is the contents of the `fileutil.make_dirs()' function in the Mojo Nation project. --Zooko 2001-10-14 ! # http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/mojonation/evil/common/fileutil.py?rev=HEAD&content-type=text/vnd.viewcvs-markup tx = None try: os.makedirs(thiscoverdir) --- 234,241 ---- else: thiscoverdir = os.path.dirname(os.path.abspath(filename)) ! # the code from here to "<<<" is the contents of fileutil.make_dirs() in the pyutil project. --Zooko 2002-12-18 ! # http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/pyutil/pyutil_new/pyutil/fileutil.py?rev=HEAD&content-type=text/vnd.viewcvs-markup tx = None try: os.makedirs(thiscoverdir)

AltStyle によって変換されたページ (->オリジナル) /