rem
stringlengths 1
322k
| add
stringlengths 0
2.05M
| context
stringlengths 4
228k
| meta
stringlengths 156
215
|
---|---|---|---|
for ext, cmd in ARCHIVE_FORMATS: | for ext, unpackerClass, arg in ARCHIVE_FORMATS: | def unpackPackageOnly(self, output=None): """Unpack a downloaded package archive.""" filename = os.path.split(self.archiveFilename)[1] for ext, cmd in ARCHIVE_FORMATS: if filename[-len(ext):] == ext: break else: return "unknown extension for archive file: %s" % filename self.basename = filename[:-len(ext)] cmd = cmd % self.archiveFilename if self._cmd(output, self._db.preferences.buildDir, cmd): return "unpack command failed" | a57befcef5b0ba55fc6941f6703163ed733a3f07 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a57befcef5b0ba55fc6941f6703163ed733a3f07/pimp.py |
cmd = cmd % self.archiveFilename if self._cmd(output, self._db.preferences.buildDir, cmd): return "unpack command failed" | unpacker = unpackerClass(arg, dir=self._db.preferences.buildDir) rv = unpacker.unpack(self.archiveFilename, output=output) if rv: return rv | def unpackPackageOnly(self, output=None): """Unpack a downloaded package archive.""" filename = os.path.split(self.archiveFilename)[1] for ext, cmd in ARCHIVE_FORMATS: if filename[-len(ext):] == ext: break else: return "unknown extension for archive file: %s" % filename self.basename = filename[:-len(ext)] cmd = cmd % self.archiveFilename if self._cmd(output, self._db.preferences.buildDir, cmd): return "unpack command failed" | a57befcef5b0ba55fc6941f6703163ed733a3f07 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a57befcef5b0ba55fc6941f6703163ed733a3f07/pimp.py |
print 'PimpPackage_binary installPackageOnly' | def installPackageOnly(self, output=None): """Install a single source package. If output is given it should be a file-like object and it will receive a log of what happened.""" print 'PimpPackage_binary installPackageOnly' msgs = [] if self._dict.has_key('Pre-install-command'): msg.append("%s: Pre-install-command ignored" % self.fullname()) if self._dict.has_key('Install-command'): msgs.append("%s: Install-command ignored" % self.fullname()) if self._dict.has_key('Post-install-command'): msgs.append("%s: Post-install-command ignored" % self.fullname()) self.beforeInstall() | a57befcef5b0ba55fc6941f6703163ed733a3f07 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a57befcef5b0ba55fc6941f6703163ed733a3f07/pimp.py |
|
msgs = [] | if self._dict.has_key('Install-command'): return "%s: Binary package cannot have Install-command" % self.fullname() | def installPackageOnly(self, output=None): """Install a single source package. If output is given it should be a file-like object and it will receive a log of what happened.""" print 'PimpPackage_binary installPackageOnly' msgs = [] if self._dict.has_key('Pre-install-command'): msg.append("%s: Pre-install-command ignored" % self.fullname()) if self._dict.has_key('Install-command'): msgs.append("%s: Install-command ignored" % self.fullname()) if self._dict.has_key('Post-install-command'): msgs.append("%s: Post-install-command ignored" % self.fullname()) self.beforeInstall() | a57befcef5b0ba55fc6941f6703163ed733a3f07 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a57befcef5b0ba55fc6941f6703163ed733a3f07/pimp.py |
msg.append("%s: Pre-install-command ignored" % self.fullname()) if self._dict.has_key('Install-command'): msgs.append("%s: Install-command ignored" % self.fullname()) if self._dict.has_key('Post-install-command'): msgs.append("%s: Post-install-command ignored" % self.fullname()) | if _cmd(output, self._buildDirname, self._dict['Pre-install-command']): return "pre-install %s: running \"%s\" failed" % \ (self.fullname(), self._dict['Pre-install-command']) | def installPackageOnly(self, output=None): """Install a single source package. If output is given it should be a file-like object and it will receive a log of what happened.""" print 'PimpPackage_binary installPackageOnly' msgs = [] if self._dict.has_key('Pre-install-command'): msg.append("%s: Pre-install-command ignored" % self.fullname()) if self._dict.has_key('Install-command'): msgs.append("%s: Install-command ignored" % self.fullname()) if self._dict.has_key('Post-install-command'): msgs.append("%s: Post-install-command ignored" % self.fullname()) self.beforeInstall() | a57befcef5b0ba55fc6941f6703163ed733a3f07 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a57befcef5b0ba55fc6941f6703163ed733a3f07/pimp.py |
for ext, cmd in ARCHIVE_FORMATS: | for ext, unpackerClass, arg in ARCHIVE_FORMATS: | def installPackageOnly(self, output=None): """Install a single source package. If output is given it should be a file-like object and it will receive a log of what happened.""" print 'PimpPackage_binary installPackageOnly' msgs = [] if self._dict.has_key('Pre-install-command'): msg.append("%s: Pre-install-command ignored" % self.fullname()) if self._dict.has_key('Install-command'): msgs.append("%s: Install-command ignored" % self.fullname()) if self._dict.has_key('Post-install-command'): msgs.append("%s: Post-install-command ignored" % self.fullname()) self.beforeInstall() | a57befcef5b0ba55fc6941f6703163ed733a3f07 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a57befcef5b0ba55fc6941f6703163ed733a3f07/pimp.py |
return "unknown extension for archive file: %s" % filename cmd = cmd % self.archiveFilename if self._cmd(output, "/", cmd): return "unpack command failed" | return "%s: unknown extension for archive file: %s" % (self.fullname(), filename) self.basename = filename[:-len(ext)] install_renames = [] for k, newloc in self._db.preferences.installLocations: if not newloc: continue if k == "--install-lib": oldloc = DEFAULT_INSTALLDIR else: return "%s: Don't know installLocation %s" % (self.fullname(), k) install_renames.append((oldloc, newloc)) unpacker = unpackerClass(arg, dir="/", renames=install_renames) rv = unpacker.unpack(self.archiveFilename, output=output) if rv: return rv | def installPackageOnly(self, output=None): """Install a single source package. If output is given it should be a file-like object and it will receive a log of what happened.""" print 'PimpPackage_binary installPackageOnly' msgs = [] if self._dict.has_key('Pre-install-command'): msg.append("%s: Pre-install-command ignored" % self.fullname()) if self._dict.has_key('Install-command'): msgs.append("%s: Install-command ignored" % self.fullname()) if self._dict.has_key('Post-install-command'): msgs.append("%s: Post-install-command ignored" % self.fullname()) self.beforeInstall() | a57befcef5b0ba55fc6941f6703163ed733a3f07 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a57befcef5b0ba55fc6941f6703163ed733a3f07/pimp.py |
if self._cmd(output, self._buildDirname, self._dict['Post-install-command']): return "post-install %s: running \"%s\" failed" % \ | if _cmd(output, self._buildDirname, self._dict['Post-install-command']): return "%s: post-install: running \"%s\" failed" % \ | def installPackageOnly(self, output=None): """Install a single source package. If output is given it should be a file-like object and it will receive a log of what happened.""" print 'PimpPackage_binary installPackageOnly' msgs = [] if self._dict.has_key('Pre-install-command'): msg.append("%s: Pre-install-command ignored" % self.fullname()) if self._dict.has_key('Install-command'): msgs.append("%s: Install-command ignored" % self.fullname()) if self._dict.has_key('Post-install-command'): msgs.append("%s: Post-install-command ignored" % self.fullname()) self.beforeInstall() | a57befcef5b0ba55fc6941f6703163ed733a3f07 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a57befcef5b0ba55fc6941f6703163ed733a3f07/pimp.py |
if self._cmd(output, self._buildDirname, self._dict['Pre-install-command']): | if _cmd(output, self._buildDirname, self._dict['Pre-install-command']): | def installPackageOnly(self, output=None): """Install a single source package. If output is given it should be a file-like object and it will receive a log of what happened.""" if self._dict.has_key('Pre-install-command'): if self._cmd(output, self._buildDirname, self._dict['Pre-install-command']): return "pre-install %s: running \"%s\" failed" % \ (self.fullname(), self._dict['Pre-install-command']) self.beforeInstall() installcmd = self._dict.get('Install-command') if not installcmd: installcmd = '"%s" setup.py install' % sys.executable if self._cmd(output, self._buildDirname, installcmd): return "install %s: running \"%s\" failed" % \ (self.fullname(), installcmd) self.afterInstall() if self._dict.has_key('Post-install-command'): if self._cmd(output, self._buildDirname, self._dict['Post-install-command']): return "post-install %s: running \"%s\" failed" % \ (self.fullname(), self._dict['Post-install-command']) return None | a57befcef5b0ba55fc6941f6703163ed733a3f07 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a57befcef5b0ba55fc6941f6703163ed733a3f07/pimp.py |
installcmd = '"%s" setup.py install' % sys.executable if self._cmd(output, self._buildDirname, installcmd): | extra_args = "" for k, v in self._db.preferences.installLocations: if not v: if not unwanted_install_dir: unwanted_install_dir = tempfile.mkdtemp() v = unwanted_install_dir extra_args = extra_args + " %s \"%s\"" % (k, v) installcmd = '"%s" setup.py install %s' % (sys.executable, extra_args) if _cmd(output, self._buildDirname, installcmd): | def installPackageOnly(self, output=None): """Install a single source package. If output is given it should be a file-like object and it will receive a log of what happened.""" if self._dict.has_key('Pre-install-command'): if self._cmd(output, self._buildDirname, self._dict['Pre-install-command']): return "pre-install %s: running \"%s\" failed" % \ (self.fullname(), self._dict['Pre-install-command']) self.beforeInstall() installcmd = self._dict.get('Install-command') if not installcmd: installcmd = '"%s" setup.py install' % sys.executable if self._cmd(output, self._buildDirname, installcmd): return "install %s: running \"%s\" failed" % \ (self.fullname(), installcmd) self.afterInstall() if self._dict.has_key('Post-install-command'): if self._cmd(output, self._buildDirname, self._dict['Post-install-command']): return "post-install %s: running \"%s\" failed" % \ (self.fullname(), self._dict['Post-install-command']) return None | a57befcef5b0ba55fc6941f6703163ed733a3f07 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a57befcef5b0ba55fc6941f6703163ed733a3f07/pimp.py |
if self._cmd(output, self._buildDirname, self._dict['Post-install-command']): | if _cmd(output, self._buildDirname, self._dict['Post-install-command']): | def installPackageOnly(self, output=None): """Install a single source package. If output is given it should be a file-like object and it will receive a log of what happened.""" if self._dict.has_key('Pre-install-command'): if self._cmd(output, self._buildDirname, self._dict['Pre-install-command']): return "pre-install %s: running \"%s\" failed" % \ (self.fullname(), self._dict['Pre-install-command']) self.beforeInstall() installcmd = self._dict.get('Install-command') if not installcmd: installcmd = '"%s" setup.py install' % sys.executable if self._cmd(output, self._buildDirname, installcmd): return "install %s: running \"%s\" failed" % \ (self.fullname(), installcmd) self.afterInstall() if self._dict.has_key('Post-install-command'): if self._cmd(output, self._buildDirname, self._dict['Post-install-command']): return "post-install %s: running \"%s\" failed" % \ (self.fullname(), self._dict['Post-install-command']) return None | a57befcef5b0ba55fc6941f6703163ed733a3f07 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a57befcef5b0ba55fc6941f6703163ed733a3f07/pimp.py |
def _run(mode, verbose, force, args): | def _run(mode, verbose, force, args, prefargs): | def _run(mode, verbose, force, args): """Engine for the main program""" prefs = PimpPreferences() prefs.check() db = PimpDatabase(prefs) db.appendURL(prefs.pimpDatabase) if mode == 'dump': db.dump(sys.stdout) elif mode =='list': if not args: args = db.listnames() print "%-20.20s\t%s" % ("Package", "Description") print for pkgname in args: pkg = db.find(pkgname) if pkg: description = pkg.description() pkgname = pkg.fullname() else: description = 'Error: no such package' print "%-20.20s\t%s" % (pkgname, description) if verbose: print "\tHome page:\t", pkg.homepage() print "\tDownload URL:\t", pkg.downloadURL() elif mode =='status': if not args: args = db.listnames() print "%-20.20s\t%s\t%s" % ("Package", "Installed", "Message") print for pkgname in args: pkg = db.find(pkgname) if pkg: status, msg = pkg.installed() pkgname = pkg.fullname() else: status = 'error' msg = 'No such package' print "%-20.20s\t%-9.9s\t%s" % (pkgname, status, msg) if verbose and status == "no": prereq = pkg.prerequisites() for pkg, msg in prereq: if not pkg: pkg = '' else: pkg = pkg.fullname() print "%-20.20s\tRequirement: %s %s" % ("", pkg, msg) elif mode == 'install': if not args: print 'Please specify packages to install' sys.exit(1) inst = PimpInstaller(db) for pkgname in args: pkg = db.find(pkgname) if not pkg: print '%s: No such package' % pkgname continue list, messages = inst.prepareInstall(pkg, force) if messages and not force: print "%s: Not installed:" % pkgname for m in messages: print "\t", m else: if verbose: output = sys.stdout else: output = None messages = inst.install(list, output) if messages: print "%s: Not installed:" % pkgname for m in messages: print "\t", m | a57befcef5b0ba55fc6941f6703163ed733a3f07 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a57befcef5b0ba55fc6941f6703163ed733a3f07/pimp.py |
prefs = PimpPreferences() prefs.check() | prefs = PimpPreferences(**prefargs) rv = prefs.check() if rv: sys.stdout.write(rv) | def _run(mode, verbose, force, args): """Engine for the main program""" prefs = PimpPreferences() prefs.check() db = PimpDatabase(prefs) db.appendURL(prefs.pimpDatabase) if mode == 'dump': db.dump(sys.stdout) elif mode =='list': if not args: args = db.listnames() print "%-20.20s\t%s" % ("Package", "Description") print for pkgname in args: pkg = db.find(pkgname) if pkg: description = pkg.description() pkgname = pkg.fullname() else: description = 'Error: no such package' print "%-20.20s\t%s" % (pkgname, description) if verbose: print "\tHome page:\t", pkg.homepage() print "\tDownload URL:\t", pkg.downloadURL() elif mode =='status': if not args: args = db.listnames() print "%-20.20s\t%s\t%s" % ("Package", "Installed", "Message") print for pkgname in args: pkg = db.find(pkgname) if pkg: status, msg = pkg.installed() pkgname = pkg.fullname() else: status = 'error' msg = 'No such package' print "%-20.20s\t%-9.9s\t%s" % (pkgname, status, msg) if verbose and status == "no": prereq = pkg.prerequisites() for pkg, msg in prereq: if not pkg: pkg = '' else: pkg = pkg.fullname() print "%-20.20s\tRequirement: %s %s" % ("", pkg, msg) elif mode == 'install': if not args: print 'Please specify packages to install' sys.exit(1) inst = PimpInstaller(db) for pkgname in args: pkg = db.find(pkgname) if not pkg: print '%s: No such package' % pkgname continue list, messages = inst.prepareInstall(pkg, force) if messages and not force: print "%s: Not installed:" % pkgname for m in messages: print "\t", m else: if verbose: output = sys.stdout else: output = None messages = inst.install(list, output) if messages: print "%s: Not installed:" % pkgname for m in messages: print "\t", m | a57befcef5b0ba55fc6941f6703163ed733a3f07 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a57befcef5b0ba55fc6941f6703163ed733a3f07/pimp.py |
print "\tDownload URL:\t", pkg.downloadURL() | try: print "\tDownload URL:\t", pkg.downloadURL() except KeyError: pass | def _run(mode, verbose, force, args): """Engine for the main program""" prefs = PimpPreferences() prefs.check() db = PimpDatabase(prefs) db.appendURL(prefs.pimpDatabase) if mode == 'dump': db.dump(sys.stdout) elif mode =='list': if not args: args = db.listnames() print "%-20.20s\t%s" % ("Package", "Description") print for pkgname in args: pkg = db.find(pkgname) if pkg: description = pkg.description() pkgname = pkg.fullname() else: description = 'Error: no such package' print "%-20.20s\t%s" % (pkgname, description) if verbose: print "\tHome page:\t", pkg.homepage() print "\tDownload URL:\t", pkg.downloadURL() elif mode =='status': if not args: args = db.listnames() print "%-20.20s\t%s\t%s" % ("Package", "Installed", "Message") print for pkgname in args: pkg = db.find(pkgname) if pkg: status, msg = pkg.installed() pkgname = pkg.fullname() else: status = 'error' msg = 'No such package' print "%-20.20s\t%-9.9s\t%s" % (pkgname, status, msg) if verbose and status == "no": prereq = pkg.prerequisites() for pkg, msg in prereq: if not pkg: pkg = '' else: pkg = pkg.fullname() print "%-20.20s\tRequirement: %s %s" % ("", pkg, msg) elif mode == 'install': if not args: print 'Please specify packages to install' sys.exit(1) inst = PimpInstaller(db) for pkgname in args: pkg = db.find(pkgname) if not pkg: print '%s: No such package' % pkgname continue list, messages = inst.prepareInstall(pkg, force) if messages and not force: print "%s: Not installed:" % pkgname for m in messages: print "\t", m else: if verbose: output = sys.stdout else: output = None messages = inst.install(list, output) if messages: print "%s: Not installed:" % pkgname for m in messages: print "\t", m | a57befcef5b0ba55fc6941f6703163ed733a3f07 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a57befcef5b0ba55fc6941f6703163ed733a3f07/pimp.py |
print "Usage: pimp [-v] -s [package ...] List installed status" print " pimp [-v] -l [package ...] Show package information" print " pimp [-vf] -i package ... Install packages" print " pimp -d Dump database to stdout" | print "Usage: pimp [options] -s [package ...] List installed status" print " pimp [options] -l [package ...] Show package information" print " pimp [options] -i package ... Install packages" print " pimp -d Dump database to stdout" | def _help(): print "Usage: pimp [-v] -s [package ...] List installed status" print " pimp [-v] -l [package ...] Show package information" print " pimp [-vf] -i package ... Install packages" print " pimp -d Dump database to stdout" print "Options:" print " -v Verbose" print " -f Force installation" sys.exit(1) | a57befcef5b0ba55fc6941f6703163ed733a3f07 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a57befcef5b0ba55fc6941f6703163ed733a3f07/pimp.py |
print " -v Verbose" print " -f Force installation" | print " -v Verbose" print " -f Force installation" print " -D dir Set destination directory (default: site-packages)" | def _help(): print "Usage: pimp [-v] -s [package ...] List installed status" print " pimp [-v] -l [package ...] Show package information" print " pimp [-vf] -i package ... Install packages" print " pimp -d Dump database to stdout" print "Options:" print " -v Verbose" print " -f Force installation" sys.exit(1) | a57befcef5b0ba55fc6941f6703163ed733a3f07 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a57befcef5b0ba55fc6941f6703163ed733a3f07/pimp.py |
opts, args = getopt.getopt(sys.argv[1:], "slifvd") | opts, args = getopt.getopt(sys.argv[1:], "slifvdD:") | def _help(): print "Usage: pimp [-v] -s [package ...] List installed status" print " pimp [-v] -l [package ...] Show package information" print " pimp [-vf] -i package ... Install packages" print " pimp -d Dump database to stdout" print "Options:" print " -v Verbose" print " -f Force installation" sys.exit(1) | a57befcef5b0ba55fc6941f6703163ed733a3f07 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a57befcef5b0ba55fc6941f6703163ed733a3f07/pimp.py |
_run(mode, verbose, force, args) | _run(mode, verbose, force, args, prefargs) | def _help(): print "Usage: pimp [-v] -s [package ...] List installed status" print " pimp [-v] -l [package ...] Show package information" print " pimp [-vf] -i package ... Install packages" print " pimp -d Dump database to stdout" print "Options:" print " -v Verbose" print " -f Force installation" sys.exit(1) | a57befcef5b0ba55fc6941f6703163ed733a3f07 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a57befcef5b0ba55fc6941f6703163ed733a3f07/pimp.py |
'<<run-module>>': ['<F5>'], '<<debug-module>>': ['<Control-F5>'], | '<<import-module>>': ['<F5>'], '<<run-script>>': ['<Control-F5>'], | def flush(self): pass | 0f7bf9aa832457c0b2fb08989aef76eee9031e6e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/0f7bf9aa832457c0b2fb08989aef76eee9031e6e/ScriptBinding.py |
('Run module', '<<run-module>>'), ('Debug module', '<<debug-module>>'), | ('Import module', '<<import-module>>'), ('Run script', '<<run-script>>'), | def flush(self): pass | 0f7bf9aa832457c0b2fb08989aef76eee9031e6e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/0f7bf9aa832457c0b2fb08989aef76eee9031e6e/ScriptBinding.py |
def run_module_event(self, event, debugger=None): | def import_module_event(self, event): filename = self.getfilename() if not filename: return modname, ext = os.path.splitext(os.path.basename(filename)) if sys.modules.has_key(modname): mod = sys.modules[modname] else: mod = imp.new_module(modname) sys.modules[modname] = mod mod.__file__ = filename setattr(sys.modules['__main__'], modname, mod) dir = os.path.dirname(filename) dir = os.path.normpath(os.path.abspath(dir)) if dir not in sys.path: sys.path.insert(0, dir) flist = self.editwin.flist shell = flist.open_shell() interp = shell.interp interp.runcode("reload(%s)" % modname) def run_script_event(self, event): filename = self.getfilename() if not filename: return flist = self.editwin.flist shell = flist.open_shell() interp = shell.interp interp.execfile(filename) def getfilename(self): | def run_module_event(self, event, debugger=None): if not self.editwin.get_saved(): tkMessageBox.showerror("Not saved", "Please save first!", master=self.editwin.text) self.editwin.text.focus_set() return filename = self.editwin.io.filename if not filename: tkMessageBox.showerror("No file name", "This window has no file name", master=self.editwin.text) self.editwin.text.focus_set() return modname, ext = os.path.splitext(os.path.basename(filename)) if sys.modules.has_key(modname): mod = sys.modules[modname] else: mod = imp.new_module(modname) sys.modules[modname] = mod mod.__file__ = filename saveout = sys.stdout saveerr = sys.stderr owin = OnDemandOutputWindow(self.editwin.flist) try: sys.stderr = PseudoFile(owin, "stderr") try: sys.stdout = PseudoFile(owin, "stdout") try: if debugger: debugger.run("execfile(%s)" % `filename`, mod.__dict__) else: execfile(filename, mod.__dict__) except: (sys.last_type, sys.last_value, sys.last_traceback) = sys.exc_info() linecache.checkcache() traceback.print_exc() if not debugger and \ self.editwin.getvar("<<toggle-jit-stack-viewer>>"): from StackViewer import StackBrowser sv = StackBrowser(self.root, self.flist) finally: sys.stdout = saveout finally: sys.stderr = saveerr | 0f7bf9aa832457c0b2fb08989aef76eee9031e6e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/0f7bf9aa832457c0b2fb08989aef76eee9031e6e/ScriptBinding.py |
modname, ext = os.path.splitext(os.path.basename(filename)) if sys.modules.has_key(modname): mod = sys.modules[modname] else: mod = imp.new_module(modname) sys.modules[modname] = mod mod.__file__ = filename saveout = sys.stdout saveerr = sys.stderr owin = OnDemandOutputWindow(self.editwin.flist) try: sys.stderr = PseudoFile(owin, "stderr") try: sys.stdout = PseudoFile(owin, "stdout") try: if debugger: debugger.run("execfile(%s)" % `filename`, mod.__dict__) else: execfile(filename, mod.__dict__) except: (sys.last_type, sys.last_value, sys.last_traceback) = sys.exc_info() linecache.checkcache() traceback.print_exc() if not debugger and \ self.editwin.getvar("<<toggle-jit-stack-viewer>>"): from StackViewer import StackBrowser sv = StackBrowser(self.root, self.flist) finally: sys.stdout = saveout finally: sys.stderr = saveerr def debug_module_event(self, event): import Debugger debugger = Debugger.Debugger(self) self.run_module_event(event, debugger) def close_debugger(self): pass | return filename | def run_module_event(self, event, debugger=None): if not self.editwin.get_saved(): tkMessageBox.showerror("Not saved", "Please save first!", master=self.editwin.text) self.editwin.text.focus_set() return filename = self.editwin.io.filename if not filename: tkMessageBox.showerror("No file name", "This window has no file name", master=self.editwin.text) self.editwin.text.focus_set() return modname, ext = os.path.splitext(os.path.basename(filename)) if sys.modules.has_key(modname): mod = sys.modules[modname] else: mod = imp.new_module(modname) sys.modules[modname] = mod mod.__file__ = filename saveout = sys.stdout saveerr = sys.stderr owin = OnDemandOutputWindow(self.editwin.flist) try: sys.stderr = PseudoFile(owin, "stderr") try: sys.stdout = PseudoFile(owin, "stdout") try: if debugger: debugger.run("execfile(%s)" % `filename`, mod.__dict__) else: execfile(filename, mod.__dict__) except: (sys.last_type, sys.last_value, sys.last_traceback) = sys.exc_info() linecache.checkcache() traceback.print_exc() if not debugger and \ self.editwin.getvar("<<toggle-jit-stack-viewer>>"): from StackViewer import StackBrowser sv = StackBrowser(self.root, self.flist) finally: sys.stdout = saveout finally: sys.stderr = saveerr | 0f7bf9aa832457c0b2fb08989aef76eee9031e6e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/0f7bf9aa832457c0b2fb08989aef76eee9031e6e/ScriptBinding.py |
if type(iterable) not in (list, tuple, dict, file, xrange, str): iterable = tuple(iterable) it = iter(iterable) | def _update(self, iterable): # The main loop for update() and the subclass __init__() methods. data = self._data | 5b36223adb1bbf2da0373f99057d5a345a620682 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/5b36223adb1bbf2da0373f99057d5a345a620682/sets.py |
|
while True: try: for element in it: | if type(iterable) in (list, tuple, xrange): it = iter(iterable) while True: try: for element in it: data[element] = value return except TypeError: transform = getattr(element, "_as_immutable", None) if transform is None: raise data[transform()] = value else: for element in iterable: try: | def _update(self, iterable): # The main loop for update() and the subclass __init__() methods. data = self._data | 5b36223adb1bbf2da0373f99057d5a345a620682 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/5b36223adb1bbf2da0373f99057d5a345a620682/sets.py |
return except TypeError: transform = getattr(element, "_as_immutable", None) if transform is None: raise data[transform()] = value | except TypeError: transform = getattr(element, "_as_immutable", None) if transform is None: raise data[transform()] = value | def _update(self, iterable): # The main loop for update() and the subclass __init__() methods. data = self._data | 5b36223adb1bbf2da0373f99057d5a345a620682 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/5b36223adb1bbf2da0373f99057d5a345a620682/sets.py |
return getint( | return self.tk.getint( | def winfo_id(self): return getint( self.tk.call('winfo', 'id', self._w)) | b8418545a524c3f76ba129917cc25446b0df482a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b8418545a524c3f76ba129917cc25446b0df482a/Tkinter.py |
str = '%s %s%s' % (cmd, args, CRLF) | if args == "": str = '%s%s' % (cmd, CRLF) else: str = '%s %s%s' % (cmd, args, CRLF) | def putcmd(self, cmd, args=""): """Send a command to the server.""" str = '%s %s%s' % (cmd, args, CRLF) self.send(str) | ebc5d5bdf725625f1f68dadc52eb337609488318 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ebc5d5bdf725625f1f68dadc52eb337609488318/smtplib.py |
optionlist = string.join(options, ' ') self.putcmd("mail", "FROM:%s %s" % (quoteaddr(sender) ,optionlist)) | optionlist = ' ' + string.join(options, ' ') self.putcmd("mail", "FROM:%s%s" % (quoteaddr(sender) ,optionlist)) | def mail(self,sender,options=[]): """SMTP 'mail' command -- begins mail xfer session.""" optionlist = '' if options and self.does_esmtp: optionlist = string.join(options, ' ') self.putcmd("mail", "FROM:%s %s" % (quoteaddr(sender) ,optionlist)) return self.getreply() | ebc5d5bdf725625f1f68dadc52eb337609488318 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ebc5d5bdf725625f1f68dadc52eb337609488318/smtplib.py |
list.append(errordict[e], errorfirst[e], errorlast[e], e) | list.append((errordict[e], errorfirst[e], errorlast[e], e)) | def parsedir(dir, modify): os.chdir(dir) pat = re.compile('^[0-9]*$') errordict = {} errorfirst = {} errorlast = {} nok = nwarn = nbad = 0 # find all numeric file names and sort them files = filter(lambda fn, pat=pat: pat.match(fn) is not None, os.listdir('.')) files.sort(sort_numeric) for fn in files: # Lets try to parse the file. fp = open(fn) m = ErrorMessage(fp) sender = m.getaddr('From') print '%s\t%-40s\t'%(fn, sender[1]), if m.is_warning(): fp.close() print 'warning only' nwarn = nwarn + 1 if modify: os.rename(fn, ','+fn) | cbc73eb41f96477ecff2404449fd7028f25f3dc5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/cbc73eb41f96477ecff2404449fd7028f25f3dc5/mailerdaemon.py |
Execution: --help Display this help then exit. --version Output version information then exit. -t,--trace Print the line to be executed to sys.stdout. -c,--count Count the number of times a line is executed. Results are written in the results file, if given. -r,--report Generate a report from a results file; do not execute any code. (One of `-t', `-c' or `-r' must be specified) -s,--summary Generate a brief summary for each file. (Can only be used with -c or -r.) I/O: -f,--file= File name for accumulating results over several runs. (No file name means do not archive results) -d,--logdir= Directory to use when writing annotated log files. Log files are the module __name__ with `.` replaced by os.sep and with '.pyl' added. -m,--missing Annotate all executable lines which were not executed with a '>>>>>> '. -R,--no-report Do not generate the annotated reports. Useful if you want to accumulate several over tests. -C,--coverdir= Generate .cover files in this directory Selection: Do not trace or log lines from ... --ignore-module=[string] modules with the given __name__, and submodules of that module --ignore-dir=[string] files in the stated directory (multiple directories can be joined by os.pathsep) The selection options can be listed multiple times to ignore different modules. | Meta-options: --help Display this help then exit. --version Output version information then exit. Otherwise, exactly one of the following three options must be given: -t, --trace Print each line to sys.stdout before it is executed. -c, --count Count the number of times each line is executed and write the counts to <module>.cover for each module executed, in the module's directory. See also `--coverdir', `--file', `--no-report' below. -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 with `--count --file=FILE'. Modifiers: -f, --file=<file> File to accumulate counts over several runs. -R, --no-report Do not generate the coverage report files. Useful if you want to accumulate over several runs. -C, --coverdir=<dir> Directory where the report files. The coverage report for <package>.<module> is written to file <dir>/<package>/<module>.cover. -m, --missing Annotate executable lines that were not executed with '>>>>>> '. -s, --summary Write a brief summary on stdout for each file. (Can only be used with --count or --report.) Filters, may be repeated multiple times: --ignore-module=<mod> Ignore the given module and its submodules (if it is a package). --ignore-dir=<dir> Ignore files in the given directory (multiple directories can be joined by os.pathsep). | def usage(outfile): outfile.write("""Usage: %s [OPTIONS] <file> [ARGS] | 8fb89f9fd74a61e165437eec10be9ace4c3738cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8fb89f9fd74a61e165437eec10be9ace4c3738cb/trace.py |
def usage(outfile): outfile.write("""Usage: %s [OPTIONS] <file> [ARGS] | 8fb89f9fd74a61e165437eec10be9ace4c3738cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8fb89f9fd74a61e165437eec10be9ace4c3738cb/trace.py |
||
def __init__(self, modules = None, dirs = None): self._mods = modules or [] self._dirs = dirs or [] | 8fb89f9fd74a61e165437eec10be9ace4c3738cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8fb89f9fd74a61e165437eec10be9ace4c3738cb/trace.py |
||
def run(trace, cmd): import __main__ dict = __main__.__dict__ sys.settrace(trace) try: exec cmd in dict, dict finally: sys.settrace(None) def runctx(trace, cmd, globals=None, locals=None): if globals is None: globals = {} if locals is None: locals = {} sys.settrace(trace) try: exec cmd in dict, dict finally: sys.settrace(None) def runfunc(trace, func, *args, **kw): result = None sys.settrace(trace) try: result = apply(func, args, kw) finally: sys.settrace(None) return result | def run(trace, cmd): import __main__ dict = __main__.__dict__ sys.settrace(trace) try: exec cmd in dict, dict finally: sys.settrace(None) | 8fb89f9fd74a61e165437eec10be9ace4c3738cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8fb89f9fd74a61e165437eec10be9ace4c3738cb/trace.py |
|
def __init__(self, counts = {}, modules = {}): self.counts = counts.copy() self.modules = modules.copy() | def __init__(self, counts=None, calledfuncs=None, infile=None, outfile=None): self.counts = counts if self.counts is None: self.counts = {} self.counter = self.counts.copy() self.calledfuncs = calledfuncs if self.calledfuncs is None: self.calledfuncs = {} self.calledfuncs = self.calledfuncs.copy() self.infile = infile self.outfile = outfile if self.infile: try: thingie = pickle.load(open(self.infile, 'r')) if type(thingie) is types.DictType: 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,): pass except pickle.UnpicklingError: self.update(self.__class__(marshal.load(open(self.infile)))) | def __init__(self, counts = {}, modules = {}): self.counts = counts.copy() # map (filename, lineno) to count self.modules = modules.copy() # map filenames to modules | 8fb89f9fd74a61e165437eec10be9ace4c3738cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8fb89f9fd74a61e165437eec10be9ace4c3738cb/trace.py |
modules = self.modules other_modules = other.modules | other_calledfuncs = other.calledfuncs | def update(self, other): """Merge in the data from another CoverageResults""" counts = self.counts other_counts = other.counts modules = self.modules other_modules = other.modules | 8fb89f9fd74a61e165437eec10be9ace4c3738cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8fb89f9fd74a61e165437eec10be9ace4c3738cb/trace.py |
counts[key] = counts.get(key, 0) + other_counts[key] for key in other_modules.keys(): if modules.has_key(key): assert modules[key] == other_modules[key], \ "Strange! filename %s has two different module " \ "names: %s and %s" % \ (key, modules[key], other_modules[key]) | if key != 'calledfuncs': counts[key] = counts.get(key, 0) + other_counts[key] for key in other_calledfuncs.keys(): calledfuncs[key] = 1 def write_results(self, show_missing = 1, summary = 0, coverdir = None): """ @param coverdir """ for (filename, modulename, funcname,) in self.calledfuncs.keys(): print "filename: %s, modulename: %s, funcname: %s" % (filename, modulename, funcname,) import re per_file = {} for thingie in self.counts.keys(): if thingie != "calledfuncs": (filename, lineno,) = thingie lines_hit = per_file[filename] = per_file.get(filename, {}) lines_hit[lineno] = self.counts[(filename, lineno)] blank = re.compile(r'^\s*( sums = {} fnlist = [] tfdir = tempfile.gettempdir() for key in per_file.keys(): filename = key if filename == "<string>": continue if filename.startswith(tfdir): continue modulename = inspect.getmodulename(filename) if filename.endswith(".pyc") or filename.endswith(".pyo"): filename = filename[:-1] if coverdir: thiscoverdir = coverdir | def update(self, other): """Merge in the data from another CoverageResults""" counts = self.counts other_counts = other.counts modules = self.modules other_modules = other.modules | 8fb89f9fd74a61e165437eec10be9ace4c3738cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8fb89f9fd74a61e165437eec10be9ace4c3738cb/trace.py |
modules[key] = other_modules[key] | thiscoverdir = os.path.dirname(os.path.abspath(filename)) tx = None try: os.makedirs(thiscoverdir) except OSError, x: tx = x if not os.path.isdir(thiscoverdir): if tx: raise tx raise exceptions.IOError, "unknown error prevented creation of directory: %s" % thiscoverdir if "." in modulename: finalname = modulename.split(".")[-1] listfilename = os.path.join(thiscoverdir, finalname + ".cover") else: listfilename = os.path.join(thiscoverdir, modulename + ".cover") try: lines = open(filename, 'r').readlines() except IOError, err: sys.stderr.write("trace: Could not open %s for reading because: %s - skipping\n" % (`filename`, err)) continue try: outfile = open(listfilename, 'w') except IOError, err: sys.stderr.write( '%s: Could not open %s for writing because: %s" \ "- skipping\n' % ("trace", `listfilename`, err)) continue if show_missing: executable_linenos = find_executable_linenos(filename) else: executable_linenos = {} n_lines = 0 n_hits = 0 lines_hit = per_file[key] for i in range(len(lines)): line = lines[i] if lines_hit.has_key(i+1): outfile.write('%5d: ' % lines_hit[i+1]) n_hits = n_hits + 1 n_lines = n_lines + 1 elif blank.match(line): outfile.write(' . ') else: if executable_linenos.has_key(i+1) and \ string.find(lines[i], string.join([' outfile.write('>>>>>> ') else: outfile.write(' '*7) n_lines = n_lines + 1 outfile.write(string.expandtabs(lines[i], 8)) outfile.close() if summary and n_lines: percent = int(100 * n_hits / n_lines) sums[modulename] = n_lines, percent, modulename, filename if summary and sums: mods = sums.keys() mods.sort() print "lines cov% module (path)" for m in mods: n_lines, percent, modulename, filename = sums[m] print "%5d %3d%% %s (%s)" % sums[m] if self.outfile: try: pickle.dump((self.counts, self.calledfuncs,), open(self.outfile, 'w'), 1) except IOError, err: sys.stderr.write("cannot save counts files because %s" % err) | def update(self, other): """Merge in the data from another CoverageResults""" counts = self.counts other_counts = other.counts modules = self.modules other_modules = other.modules | 8fb89f9fd74a61e165437eec10be9ace4c3738cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8fb89f9fd74a61e165437eec10be9ace4c3738cb/trace.py |
def create_results_log(results, dirname = ".", show_missing = 1, save_counts = 0, summary = 0, coverdir = None): import re per_file = {} for filename, lineno in results.counts.keys(): lines_hit = per_file[filename] = per_file.get(filename, {}) lines_hit[lineno] = results.counts[(filename, lineno)] try: counts = marshal.load(open(os.path.join(dirname, "counts"))) modules = marshal.load(open(os.path.join(dirname, "modules"))) results.update(results.__class__(counts, modules)) except IOError: pass blank = re.compile(r'^\s*( sums = {} fnlist = [] tfdir = tempfile.gettempdir() for key in per_file.keys(): filename = key if filename == "<string>": continue if filename.startswith(tfdir): continue modulename = os.path.split(results.modules[key])[1] if filename.endswith(".pyc") or filename.endswith(".pyo"): filename = filename[:-1] if coverdir: listfilename = os.path.join(coverdir, modulename + ".cover") | class Trace: def __init__(self, count=1, trace=1, countfuncs=0, ignoremods=(), ignoredirs=(), infile=None, outfile=None): """ @param count true iff it should count number of times each line is executed @param trace true iff it should print out each line that is being counted @param countfuncs true iff it should just output a list of (filename, modulename, funcname,) for functions that were called at least once; This overrides `count' and `trace' @param ignoremods a list of the names of modules to ignore @param ignoredirs a list of the names of directories to ignore all of the (recursive) contents of @param infile file from which to read stored counts to be added into the results @param outfile file in which to write the results """ self.infile = infile self.outfile = outfile self.ignore = Ignore(ignoremods, ignoredirs) self.counts = {} self.blabbed = {} self.pathtobasename = {} self.donothing = 0 self.trace = trace self._calledfuncs = {} if countfuncs: self.globaltrace = self.globaltrace_countfuncs elif trace and count: self.globaltrace = self.globaltrace_lt self.localtrace = self.localtrace_trace_and_count elif trace: self.globaltrace = self.globaltrace_lt self.localtrace = self.localtrace_trace elif count: self.globaltrace = self.globaltrace_lt self.localtrace = self.localtrace_count | def create_results_log(results, dirname = ".", show_missing = 1, save_counts = 0, summary = 0, coverdir = None): import re # turn the counts data ("(filename, lineno) = count") into something # accessible on a per-file basis per_file = {} for filename, lineno in results.counts.keys(): lines_hit = per_file[filename] = per_file.get(filename, {}) lines_hit[lineno] = results.counts[(filename, lineno)] # try and merge existing counts and modules file from dirname try: counts = marshal.load(open(os.path.join(dirname, "counts"))) modules = marshal.load(open(os.path.join(dirname, "modules"))) results.update(results.__class__(counts, modules)) except IOError: pass # there are many places where this is insufficient, like a blank # line embedded in a multiline string. blank = re.compile(r'^\s*(#.*)?$') # accumulate summary info, if needed sums = {} # 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 == "<string>": continue # are these caused by code compiled using exec or something? if filename.startswith(tfdir): continue modulename = os.path.split(results.modules[key])[1] if filename.endswith(".pyc") or filename.endswith(".pyo"): filename = filename[:-1] if coverdir: listfilename = os.path.join(coverdir, modulename + ".cover") else: # XXX this is almost certainly not portable!!! fndir = os.path.dirname(filename) if os.path.isabs(filename): coverpath = fndir else: coverpath = os.path.join(dirname, fndir) # build list file name by appending a ".cover" to the module name # and sticking it into the specified directory if "." in modulename: # A module in a package finalname = modulename.split(".")[-1] listfilename = os.path.join(coverpath, finalname + ".cover") else: listfilename = os.path.join(coverpath, modulename + ".cover") # Get the original lines from the .py file try: lines = open(filename, 'r').readlines() except IOError, err: print >> sys.stderr, "trace: Could not open %s for reading " \ "because: %s - skipping" % (`filename`, err) continue try: outfile = open(listfilename, 'w') except IOError, err: sys.stderr.write( '%s: Could not open %s for writing because: %s" \ "- skipping\n' % ("trace", `listfilename`, err)) continue # If desired, get a list of the line numbers which represent # executable content (returned as a dict for better lookup speed) if show_missing: executable_linenos = find_executable_linenos(filename) else: executable_linenos = {} n_lines = 0 n_hits = 0 lines_hit = per_file[key] for i in range(len(lines)): line = lines[i] # do the blank/comment match to try to mark more lines # (help the reader find stuff that hasn't been covered) if lines_hit.has_key(i+1): # count precedes the lines that we captured outfile.write('%5d: ' % lines_hit[i+1]) n_hits = n_hits + 1 n_lines = n_lines + 1 elif blank.match(line): # blank lines and comments are preceded by dots outfile.write(' . ') else: # lines preceded by no marks weren't hit # Highlight them if so indicated, unless the line contains # '#pragma: NO COVER' (it is possible to embed this into # the text as a non-comment; no easy fix) if executable_linenos.has_key(i+1) and \ string.find(lines[i], string.join(['#pragma', 'NO COVER'])) == -1: outfile.write('>>>>>> ') else: outfile.write(' '*7) n_lines = n_lines + 1 outfile.write(string.expandtabs(lines[i], 8)) outfile.close() if summary and n_lines: percent = int(100 * n_hits / n_lines) sums[modulename] = n_lines, percent, modulename, filename if save_counts: # try and store counts and module info into dirname try: marshal.dump(results.counts, open(os.path.join(dirname, "counts"), "w")) marshal.dump(results.modules, open(os.path.join(dirname, "modules"), "w")) except IOError, err: sys.stderr.write("cannot save counts/modules " \ "files because %s" % err) if summary and sums: mods = sums.keys() mods.sort() print "lines cov% module (path)" for m in mods: n_lines, percent, modulename, filename = sums[m] print "%5d %3d%% %s (%s)" % sums[m] | 8fb89f9fd74a61e165437eec10be9ace4c3738cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8fb89f9fd74a61e165437eec10be9ace4c3738cb/trace.py |
fndir = os.path.dirname(filename) if os.path.isabs(filename): coverpath = fndir | self.donothing = 1 def run(self, cmd): import __main__ dict = __main__.__dict__ if not self.donothing: sys.settrace(self.globaltrace) try: exec cmd in dict, dict finally: if not self.donothing: sys.settrace(None) def runctx(self, cmd, globals=None, locals=None): if globals is None: globals = {} if locals is None: locals = {} if not self.donothing: sys.settrace(gself.lobaltrace) try: exec cmd in dict, dict finally: if not self.donothing: sys.settrace(None) def runfunc(self, func, *args, **kw): result = None if not self.donothing: sys.settrace(self.globaltrace) try: result = apply(func, args, kw) finally: if not self.donothing: sys.settrace(None) return result def globaltrace_countfuncs(self, frame, why, arg): """ Handles `call' events (why == 'call') and adds the (filename, modulename, funcname,) to the self._calledfuncs dict. """ if why == 'call': (filename, lineno, funcname, context, lineindex,) = inspect.getframeinfo(frame, 0) if filename: modulename = inspect.getmodulename(filename) | def create_results_log(results, dirname = ".", show_missing = 1, save_counts = 0, summary = 0, coverdir = None): import re # turn the counts data ("(filename, lineno) = count") into something # accessible on a per-file basis per_file = {} for filename, lineno in results.counts.keys(): lines_hit = per_file[filename] = per_file.get(filename, {}) lines_hit[lineno] = results.counts[(filename, lineno)] # try and merge existing counts and modules file from dirname try: counts = marshal.load(open(os.path.join(dirname, "counts"))) modules = marshal.load(open(os.path.join(dirname, "modules"))) results.update(results.__class__(counts, modules)) except IOError: pass # there are many places where this is insufficient, like a blank # line embedded in a multiline string. blank = re.compile(r'^\s*(#.*)?$') # accumulate summary info, if needed sums = {} # 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 == "<string>": continue # are these caused by code compiled using exec or something? if filename.startswith(tfdir): continue modulename = os.path.split(results.modules[key])[1] if filename.endswith(".pyc") or filename.endswith(".pyo"): filename = filename[:-1] if coverdir: listfilename = os.path.join(coverdir, modulename + ".cover") else: # XXX this is almost certainly not portable!!! fndir = os.path.dirname(filename) if os.path.isabs(filename): coverpath = fndir else: coverpath = os.path.join(dirname, fndir) # build list file name by appending a ".cover" to the module name # and sticking it into the specified directory if "." in modulename: # A module in a package finalname = modulename.split(".")[-1] listfilename = os.path.join(coverpath, finalname + ".cover") else: listfilename = os.path.join(coverpath, modulename + ".cover") # Get the original lines from the .py file try: lines = open(filename, 'r').readlines() except IOError, err: print >> sys.stderr, "trace: Could not open %s for reading " \ "because: %s - skipping" % (`filename`, err) continue try: outfile = open(listfilename, 'w') except IOError, err: sys.stderr.write( '%s: Could not open %s for writing because: %s" \ "- skipping\n' % ("trace", `listfilename`, err)) continue # If desired, get a list of the line numbers which represent # executable content (returned as a dict for better lookup speed) if show_missing: executable_linenos = find_executable_linenos(filename) else: executable_linenos = {} n_lines = 0 n_hits = 0 lines_hit = per_file[key] for i in range(len(lines)): line = lines[i] # do the blank/comment match to try to mark more lines # (help the reader find stuff that hasn't been covered) if lines_hit.has_key(i+1): # count precedes the lines that we captured outfile.write('%5d: ' % lines_hit[i+1]) n_hits = n_hits + 1 n_lines = n_lines + 1 elif blank.match(line): # blank lines and comments are preceded by dots outfile.write(' . ') else: # lines preceded by no marks weren't hit # Highlight them if so indicated, unless the line contains # '#pragma: NO COVER' (it is possible to embed this into # the text as a non-comment; no easy fix) if executable_linenos.has_key(i+1) and \ string.find(lines[i], string.join(['#pragma', 'NO COVER'])) == -1: outfile.write('>>>>>> ') else: outfile.write(' '*7) n_lines = n_lines + 1 outfile.write(string.expandtabs(lines[i], 8)) outfile.close() if summary and n_lines: percent = int(100 * n_hits / n_lines) sums[modulename] = n_lines, percent, modulename, filename if save_counts: # try and store counts and module info into dirname try: marshal.dump(results.counts, open(os.path.join(dirname, "counts"), "w")) marshal.dump(results.modules, open(os.path.join(dirname, "modules"), "w")) except IOError, err: sys.stderr.write("cannot save counts/modules " \ "files because %s" % err) if summary and sums: mods = sums.keys() mods.sort() print "lines cov% module (path)" for m in mods: n_lines, percent, modulename, filename = sums[m] print "%5d %3d%% %s (%s)" % sums[m] | 8fb89f9fd74a61e165437eec10be9ace4c3738cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8fb89f9fd74a61e165437eec10be9ace4c3738cb/trace.py |
coverpath = os.path.join(dirname, fndir) if "." in modulename: finalname = modulename.split(".")[-1] listfilename = os.path.join(coverpath, finalname + ".cover") | modulename = None self._calledfuncs[(filename, modulename, funcname,)] = 1 def globaltrace_lt(self, frame, why, arg): """ Handles `call' events (why == 'call') and if the code block being entered is to be ignored then it returns `None', else it returns `self.localtrace'. """ if why == 'call': (filename, lineno, funcname, context, lineindex,) = inspect.getframeinfo(frame, 0) if filename: modulename = inspect.getmodulename(filename) ignore_it = self.ignore.names(filename, modulename) if not ignore_it: if self.trace: print " --- modulename: %s, funcname: %s" % (modulename, funcname,) return self.localtrace | def create_results_log(results, dirname = ".", show_missing = 1, save_counts = 0, summary = 0, coverdir = None): import re # turn the counts data ("(filename, lineno) = count") into something # accessible on a per-file basis per_file = {} for filename, lineno in results.counts.keys(): lines_hit = per_file[filename] = per_file.get(filename, {}) lines_hit[lineno] = results.counts[(filename, lineno)] # try and merge existing counts and modules file from dirname try: counts = marshal.load(open(os.path.join(dirname, "counts"))) modules = marshal.load(open(os.path.join(dirname, "modules"))) results.update(results.__class__(counts, modules)) except IOError: pass # there are many places where this is insufficient, like a blank # line embedded in a multiline string. blank = re.compile(r'^\s*(#.*)?$') # accumulate summary info, if needed sums = {} # 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 == "<string>": continue # are these caused by code compiled using exec or something? if filename.startswith(tfdir): continue modulename = os.path.split(results.modules[key])[1] if filename.endswith(".pyc") or filename.endswith(".pyo"): filename = filename[:-1] if coverdir: listfilename = os.path.join(coverdir, modulename + ".cover") else: # XXX this is almost certainly not portable!!! fndir = os.path.dirname(filename) if os.path.isabs(filename): coverpath = fndir else: coverpath = os.path.join(dirname, fndir) # build list file name by appending a ".cover" to the module name # and sticking it into the specified directory if "." in modulename: # A module in a package finalname = modulename.split(".")[-1] listfilename = os.path.join(coverpath, finalname + ".cover") else: listfilename = os.path.join(coverpath, modulename + ".cover") # Get the original lines from the .py file try: lines = open(filename, 'r').readlines() except IOError, err: print >> sys.stderr, "trace: Could not open %s for reading " \ "because: %s - skipping" % (`filename`, err) continue try: outfile = open(listfilename, 'w') except IOError, err: sys.stderr.write( '%s: Could not open %s for writing because: %s" \ "- skipping\n' % ("trace", `listfilename`, err)) continue # If desired, get a list of the line numbers which represent # executable content (returned as a dict for better lookup speed) if show_missing: executable_linenos = find_executable_linenos(filename) else: executable_linenos = {} n_lines = 0 n_hits = 0 lines_hit = per_file[key] for i in range(len(lines)): line = lines[i] # do the blank/comment match to try to mark more lines # (help the reader find stuff that hasn't been covered) if lines_hit.has_key(i+1): # count precedes the lines that we captured outfile.write('%5d: ' % lines_hit[i+1]) n_hits = n_hits + 1 n_lines = n_lines + 1 elif blank.match(line): # blank lines and comments are preceded by dots outfile.write(' . ') else: # lines preceded by no marks weren't hit # Highlight them if so indicated, unless the line contains # '#pragma: NO COVER' (it is possible to embed this into # the text as a non-comment; no easy fix) if executable_linenos.has_key(i+1) and \ string.find(lines[i], string.join(['#pragma', 'NO COVER'])) == -1: outfile.write('>>>>>> ') else: outfile.write(' '*7) n_lines = n_lines + 1 outfile.write(string.expandtabs(lines[i], 8)) outfile.close() if summary and n_lines: percent = int(100 * n_hits / n_lines) sums[modulename] = n_lines, percent, modulename, filename if save_counts: # try and store counts and module info into dirname try: marshal.dump(results.counts, open(os.path.join(dirname, "counts"), "w")) marshal.dump(results.modules, open(os.path.join(dirname, "modules"), "w")) except IOError, err: sys.stderr.write("cannot save counts/modules " \ "files because %s" % err) if summary and sums: mods = sums.keys() mods.sort() print "lines cov% module (path)" for m in mods: n_lines, percent, modulename, filename = sums[m] print "%5d %3d%% %s (%s)" % sums[m] | 8fb89f9fd74a61e165437eec10be9ace4c3738cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8fb89f9fd74a61e165437eec10be9ace4c3738cb/trace.py |
listfilename = os.path.join(coverpath, modulename + ".cover") try: lines = open(filename, 'r').readlines() except IOError, err: print >> sys.stderr, "trace: Could not open %s for reading " \ "because: %s - skipping" % (`filename`, err) continue try: outfile = open(listfilename, 'w') except IOError, err: sys.stderr.write( '%s: Could not open %s for writing because: %s" \ "- skipping\n' % ("trace", `listfilename`, err)) continue if show_missing: executable_linenos = find_executable_linenos(filename) else: executable_linenos = {} n_lines = 0 n_hits = 0 lines_hit = per_file[key] for i in range(len(lines)): line = lines[i] if lines_hit.has_key(i+1): outfile.write('%5d: ' % lines_hit[i+1]) n_hits = n_hits + 1 n_lines = n_lines + 1 elif blank.match(line): outfile.write(' . ') else: if executable_linenos.has_key(i+1) and \ string.find(lines[i], string.join([' outfile.write('>>>>>> ') else: outfile.write(' '*7) n_lines = n_lines + 1 outfile.write(string.expandtabs(lines[i], 8)) outfile.close() if summary and n_lines: percent = int(100 * n_hits / n_lines) sums[modulename] = n_lines, percent, modulename, filename if save_counts: | return None def localtrace_trace_and_count(self, frame, why, arg): if why == 'line': (filename, lineno, funcname, context, lineindex,) = inspect.getframeinfo(frame, 1) key = (filename, lineno,) self.counts[key] = self.counts.get(key, 0) + 1 bname = self.pathtobasename.get(filename) if bname is None: bname = self.pathtobasename.setdefault(filename, os.path.basename(filename)) | def create_results_log(results, dirname = ".", show_missing = 1, save_counts = 0, summary = 0, coverdir = None): import re # turn the counts data ("(filename, lineno) = count") into something # accessible on a per-file basis per_file = {} for filename, lineno in results.counts.keys(): lines_hit = per_file[filename] = per_file.get(filename, {}) lines_hit[lineno] = results.counts[(filename, lineno)] # try and merge existing counts and modules file from dirname try: counts = marshal.load(open(os.path.join(dirname, "counts"))) modules = marshal.load(open(os.path.join(dirname, "modules"))) results.update(results.__class__(counts, modules)) except IOError: pass # there are many places where this is insufficient, like a blank # line embedded in a multiline string. blank = re.compile(r'^\s*(#.*)?$') # accumulate summary info, if needed sums = {} # 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 == "<string>": continue # are these caused by code compiled using exec or something? if filename.startswith(tfdir): continue modulename = os.path.split(results.modules[key])[1] if filename.endswith(".pyc") or filename.endswith(".pyo"): filename = filename[:-1] if coverdir: listfilename = os.path.join(coverdir, modulename + ".cover") else: # XXX this is almost certainly not portable!!! fndir = os.path.dirname(filename) if os.path.isabs(filename): coverpath = fndir else: coverpath = os.path.join(dirname, fndir) # build list file name by appending a ".cover" to the module name # and sticking it into the specified directory if "." in modulename: # A module in a package finalname = modulename.split(".")[-1] listfilename = os.path.join(coverpath, finalname + ".cover") else: listfilename = os.path.join(coverpath, modulename + ".cover") # Get the original lines from the .py file try: lines = open(filename, 'r').readlines() except IOError, err: print >> sys.stderr, "trace: Could not open %s for reading " \ "because: %s - skipping" % (`filename`, err) continue try: outfile = open(listfilename, 'w') except IOError, err: sys.stderr.write( '%s: Could not open %s for writing because: %s" \ "- skipping\n' % ("trace", `listfilename`, err)) continue # If desired, get a list of the line numbers which represent # executable content (returned as a dict for better lookup speed) if show_missing: executable_linenos = find_executable_linenos(filename) else: executable_linenos = {} n_lines = 0 n_hits = 0 lines_hit = per_file[key] for i in range(len(lines)): line = lines[i] # do the blank/comment match to try to mark more lines # (help the reader find stuff that hasn't been covered) if lines_hit.has_key(i+1): # count precedes the lines that we captured outfile.write('%5d: ' % lines_hit[i+1]) n_hits = n_hits + 1 n_lines = n_lines + 1 elif blank.match(line): # blank lines and comments are preceded by dots outfile.write(' . ') else: # lines preceded by no marks weren't hit # Highlight them if so indicated, unless the line contains # '#pragma: NO COVER' (it is possible to embed this into # the text as a non-comment; no easy fix) if executable_linenos.has_key(i+1) and \ string.find(lines[i], string.join(['#pragma', 'NO COVER'])) == -1: outfile.write('>>>>>> ') else: outfile.write(' '*7) n_lines = n_lines + 1 outfile.write(string.expandtabs(lines[i], 8)) outfile.close() if summary and n_lines: percent = int(100 * n_hits / n_lines) sums[modulename] = n_lines, percent, modulename, filename if save_counts: # try and store counts and module info into dirname try: marshal.dump(results.counts, open(os.path.join(dirname, "counts"), "w")) marshal.dump(results.modules, open(os.path.join(dirname, "modules"), "w")) except IOError, err: sys.stderr.write("cannot save counts/modules " \ "files because %s" % err) if summary and sums: mods = sums.keys() mods.sort() print "lines cov% module (path)" for m in mods: n_lines, percent, modulename, filename = sums[m] print "%5d %3d%% %s (%s)" % sums[m] | 8fb89f9fd74a61e165437eec10be9ace4c3738cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8fb89f9fd74a61e165437eec10be9ace4c3738cb/trace.py |
marshal.dump(results.counts, open(os.path.join(dirname, "counts"), "w")) marshal.dump(results.modules, open(os.path.join(dirname, "modules"), "w")) except IOError, err: sys.stderr.write("cannot save counts/modules " \ "files because %s" % err) if summary and sums: mods = sums.keys() mods.sort() print "lines cov% module (path)" for m in mods: n_lines, percent, modulename, filename = sums[m] print "%5d %3d%% %s (%s)" % sums[m] class Coverage: def __init__(self, ignore = Ignore()): self.ignore = ignore self.ignore_names = ignore._ignore self.counts = {} self.modules = {} def trace(self, frame, why, arg): | print "%s(%d): %s" % (bname, lineno, context[lineindex],), except IndexError: pass return self.localtrace def localtrace_trace(self, frame, why, arg): | def create_results_log(results, dirname = ".", show_missing = 1, save_counts = 0, summary = 0, coverdir = None): import re # turn the counts data ("(filename, lineno) = count") into something # accessible on a per-file basis per_file = {} for filename, lineno in results.counts.keys(): lines_hit = per_file[filename] = per_file.get(filename, {}) lines_hit[lineno] = results.counts[(filename, lineno)] # try and merge existing counts and modules file from dirname try: counts = marshal.load(open(os.path.join(dirname, "counts"))) modules = marshal.load(open(os.path.join(dirname, "modules"))) results.update(results.__class__(counts, modules)) except IOError: pass # there are many places where this is insufficient, like a blank # line embedded in a multiline string. blank = re.compile(r'^\s*(#.*)?$') # accumulate summary info, if needed sums = {} # 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 == "<string>": continue # are these caused by code compiled using exec or something? if filename.startswith(tfdir): continue modulename = os.path.split(results.modules[key])[1] if filename.endswith(".pyc") or filename.endswith(".pyo"): filename = filename[:-1] if coverdir: listfilename = os.path.join(coverdir, modulename + ".cover") else: # XXX this is almost certainly not portable!!! fndir = os.path.dirname(filename) if os.path.isabs(filename): coverpath = fndir else: coverpath = os.path.join(dirname, fndir) # build list file name by appending a ".cover" to the module name # and sticking it into the specified directory if "." in modulename: # A module in a package finalname = modulename.split(".")[-1] listfilename = os.path.join(coverpath, finalname + ".cover") else: listfilename = os.path.join(coverpath, modulename + ".cover") # Get the original lines from the .py file try: lines = open(filename, 'r').readlines() except IOError, err: print >> sys.stderr, "trace: Could not open %s for reading " \ "because: %s - skipping" % (`filename`, err) continue try: outfile = open(listfilename, 'w') except IOError, err: sys.stderr.write( '%s: Could not open %s for writing because: %s" \ "- skipping\n' % ("trace", `listfilename`, err)) continue # If desired, get a list of the line numbers which represent # executable content (returned as a dict for better lookup speed) if show_missing: executable_linenos = find_executable_linenos(filename) else: executable_linenos = {} n_lines = 0 n_hits = 0 lines_hit = per_file[key] for i in range(len(lines)): line = lines[i] # do the blank/comment match to try to mark more lines # (help the reader find stuff that hasn't been covered) if lines_hit.has_key(i+1): # count precedes the lines that we captured outfile.write('%5d: ' % lines_hit[i+1]) n_hits = n_hits + 1 n_lines = n_lines + 1 elif blank.match(line): # blank lines and comments are preceded by dots outfile.write(' . ') else: # lines preceded by no marks weren't hit # Highlight them if so indicated, unless the line contains # '#pragma: NO COVER' (it is possible to embed this into # the text as a non-comment; no easy fix) if executable_linenos.has_key(i+1) and \ string.find(lines[i], string.join(['#pragma', 'NO COVER'])) == -1: outfile.write('>>>>>> ') else: outfile.write(' '*7) n_lines = n_lines + 1 outfile.write(string.expandtabs(lines[i], 8)) outfile.close() if summary and n_lines: percent = int(100 * n_hits / n_lines) sums[modulename] = n_lines, percent, modulename, filename if save_counts: # try and store counts and module info into dirname try: marshal.dump(results.counts, open(os.path.join(dirname, "counts"), "w")) marshal.dump(results.modules, open(os.path.join(dirname, "modules"), "w")) except IOError, err: sys.stderr.write("cannot save counts/modules " \ "files because %s" % err) if summary and sums: mods = sums.keys() mods.sort() print "lines cov% module (path)" for m in mods: n_lines, percent, modulename, filename = sums[m] print "%5d %3d%% %s (%s)" % sums[m] | 8fb89f9fd74a61e165437eec10be9ace4c3738cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8fb89f9fd74a61e165437eec10be9ace4c3738cb/trace.py |
filename = frame.f_globals.get("__file__", None) if filename is None: filename = frame.f_code.co_filename | (filename, lineno, funcname, context, lineindex,) = inspect.getframeinfo(frame) bname = self.pathtobasename.get(filename) if bname is None: bname = self.pathtobasename.setdefault(filename, os.path.basename(filename)) | def trace(self, frame, why, arg): if why == 'line': # something is fishy about getting the file name filename = frame.f_globals.get("__file__", None) if filename is None: filename = frame.f_code.co_filename try: modulename = frame.f_globals["__name__"] except KeyError: # PyRun_String() for example # XXX what to do? modulename = None | 8fb89f9fd74a61e165437eec10be9ace4c3738cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8fb89f9fd74a61e165437eec10be9ace4c3738cb/trace.py |
modulename = frame.f_globals["__name__"] except KeyError: modulename = None ignore_it = self.ignore_names.get(modulename, -1) if ignore_it == -1: sys.settrace(None) ignore_it = self.ignore.names(filename, modulename) sys.settrace(self.trace) self.modules[filename] = modulename if not ignore_it: lineno = frame.f_lineno key = (filename, lineno) self.counts[key] = self.counts.get(key, 0) + 1 return self.trace | print "%s(%d): %s" % (bname, lineno, context[lineindex],), except IndexError: pass return self.localtrace def localtrace_count(self, frame, why, arg): if why == 'line': (filename, lineno, funcname, context, lineindex,) = inspect.getframeinfo(frame) key = (filename, lineno,) self.counts[key] = self.counts.get(key, 0) + 1 return self.localtrace | def trace(self, frame, why, arg): if why == 'line': # something is fishy about getting the file name filename = frame.f_globals.get("__file__", None) if filename is None: filename = frame.f_code.co_filename try: modulename = frame.f_globals["__name__"] except KeyError: # PyRun_String() for example # XXX what to do? modulename = None | 8fb89f9fd74a61e165437eec10be9ace4c3738cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8fb89f9fd74a61e165437eec10be9ace4c3738cb/trace.py |
return CoverageResults(self.counts, self.modules) class Trace: def __init__(self, ignore = Ignore()): self.ignore = ignore self.ignore_names = ignore._ignore self.files = {'<string>': None} def trace(self, frame, why, arg): if why == 'line': filename = frame.f_code.co_filename try: modulename = frame.f_globals["__name__"] except KeyError: modulename = None ignore_it = self.ignore_names.get(modulename, -1) if ignore_it == -1: sys.settrace(None) ignore_it = self.ignore.names(filename, modulename) sys.settrace(self.trace) if not ignore_it: lineno = frame.f_lineno files = self.files if filename != '<string>' and not files.has_key(filename): files[filename] = map(string.rstrip, open(filename).readlines()) if files[filename] != None: print '%s(%d): %s' % (os.path.basename(filename), lineno, files[filename][lineno-1]) else: print '%s(%d): ??' % (modulename, lineno) return self.trace | return CoverageResults(self.counts, infile=self.infile, outfile=self.outfile, calledfuncs=self._calledfuncs) | def results(self): return CoverageResults(self.counts, self.modules) | 8fb89f9fd74a61e165437eec10be9ace4c3738cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8fb89f9fd74a61e165437eec10be9ace4c3738cb/trace.py |
print >> sys.stderr, "%s: %s" % (sys.argv[0], msg) | sys.stderr.write("%s: %s\n" % (sys.argv[0], msg)) | def _err_exit(msg): print >> sys.stderr, "%s: %s" % (sys.argv[0], msg) sys.exit(1) | 8fb89f9fd74a61e165437eec10be9ace4c3738cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8fb89f9fd74a61e165437eec10be9ace4c3738cb/trace.py |
def main(argv = None): | def main(argv=None): | def main(argv = None): import getopt if argv is None: argv = sys.argv try: opts, prog_argv = getopt.getopt(argv[1:], "tcrRf:d:msC:", ["help", "version", "trace", "count", "report", "no-report", "file=", "logdir=", "missing", "ignore-module=", "ignore-dir=", "coverdir="]) except getopt.error, msg: print >> sys.stderr, "%s: %s" % (sys.argv[0], msg) print >> sys.stderr, "Try `%s --help' for more information" \ % sys.argv[0] sys.exit(1) trace = 0 count = 0 report = 0 no_report = 0 counts_file = None logdir = "." missing = 0 ignore_modules = [] ignore_dirs = [] coverdir = None summary = 0 for opt, val in opts: if opt == "--help": usage(sys.stdout) sys.exit(0) if opt == "--version": sys.stdout.write("trace 2.0\n") sys.exit(0) if opt == "-t" or opt == "--trace": trace = 1 continue if opt == "-c" or opt == "--count": count = 1 continue if opt == "-r" or opt == "--report": report = 1 continue if opt == "-R" or opt == "--no-report": no_report = 1 continue if opt == "-f" or opt == "--file": counts_file = val continue if opt == "-d" or opt == "--logdir": logdir = val continue if opt == "-m" or opt == "--missing": missing = 1 continue if opt == "-C" or opt == "--coverdir": coverdir = val continue if opt == "-s" or opt == "--summary": summary = 1 continue if opt == "--ignore-module": ignore_modules.append(val) continue if opt == "--ignore-dir": for s in string.split(val, os.pathsep): s = os.path.expandvars(s) # should I also call expanduser? (after all, could use $HOME) s = string.replace(s, "$prefix", os.path.join(sys.prefix, "lib", "python" + sys.version[:3])) s = string.replace(s, "$exec_prefix", os.path.join(sys.exec_prefix, "lib", "python" + sys.version[:3])) s = os.path.normpath(s) ignore_dirs.append(s) continue assert 0, "Should never get here" if len(prog_argv) == 0: _err_exit("missing name of file to run") if count + trace + report > 1: _err_exit("can only specify one of --trace, --count or --report") if count + trace + report == 0: _err_exit("must specify one of --trace, --count or --report") if report and counts_file is None: _err_exit("--report requires a --file") if report and no_report: _err_exit("cannot specify both --report and --no-report") if logdir is not None: # warn if the directory doesn't exist, but keep on going # (is this the correct behaviour?) if not os.path.isdir(logdir): sys.stderr.write( "trace: WARNING, --logdir directory %s is not available\n" % `logdir`) sys.argv = prog_argv progname = prog_argv[0] if eval(sys.version[:3])>1.3: sys.path[0] = os.path.split(progname)[0] # ??? # everything is ready ignore = Ignore(ignore_modules, ignore_dirs) if trace: t = Trace(ignore) try: run(t.trace, 'execfile(' + `progname` + ')') except IOError, err: _err_exit("Cannot run file %s because: %s" % \ (`sys.argv[0]`, err)) elif count: t = Coverage(ignore) try: run(t.trace, 'execfile(' + `progname` + ')') except IOError, err: _err_exit("Cannot run file %s because: %s" % \ (`sys.argv[0]`, err)) except SystemExit: pass results = t.results() # Add another lookup from the program's file name to its import name # This give the right results, but I'm not sure why ... results.modules[progname] = os.path.splitext(progname)[0] if counts_file: # add in archived data, if available try: old_counts, old_modules = marshal.load(open(counts_file, 'rb')) except IOError: pass else: results.update(CoverageResults(old_counts, old_modules)) if not no_report: create_results_log(results, logdir, missing, summary=summary, coverdir=coverdir) if counts_file: try: marshal.dump( (results.counts, results.modules), open(counts_file, 'wb')) except IOError, err: _err_exit("Cannot save counts file %s because: %s" % \ (`counts_file`, err)) elif report: old_counts, old_modules = marshal.load(open(counts_file, 'rb')) results = CoverageResults(old_counts, old_modules) create_results_log(results, logdir, missing, summary=summary, coverdir=coverdir) else: assert 0, "Should never get here" | 8fb89f9fd74a61e165437eec10be9ace4c3738cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8fb89f9fd74a61e165437eec10be9ace4c3738cb/trace.py |
opts, prog_argv = getopt.getopt(argv[1:], "tcrRf:d:msC:", | opts, prog_argv = getopt.getopt(argv[1:], "tcrRf:d:msC:l", | def main(argv = None): import getopt if argv is None: argv = sys.argv try: opts, prog_argv = getopt.getopt(argv[1:], "tcrRf:d:msC:", ["help", "version", "trace", "count", "report", "no-report", "file=", "logdir=", "missing", "ignore-module=", "ignore-dir=", "coverdir="]) except getopt.error, msg: print >> sys.stderr, "%s: %s" % (sys.argv[0], msg) print >> sys.stderr, "Try `%s --help' for more information" \ % sys.argv[0] sys.exit(1) trace = 0 count = 0 report = 0 no_report = 0 counts_file = None logdir = "." missing = 0 ignore_modules = [] ignore_dirs = [] coverdir = None summary = 0 for opt, val in opts: if opt == "--help": usage(sys.stdout) sys.exit(0) if opt == "--version": sys.stdout.write("trace 2.0\n") sys.exit(0) if opt == "-t" or opt == "--trace": trace = 1 continue if opt == "-c" or opt == "--count": count = 1 continue if opt == "-r" or opt == "--report": report = 1 continue if opt == "-R" or opt == "--no-report": no_report = 1 continue if opt == "-f" or opt == "--file": counts_file = val continue if opt == "-d" or opt == "--logdir": logdir = val continue if opt == "-m" or opt == "--missing": missing = 1 continue if opt == "-C" or opt == "--coverdir": coverdir = val continue if opt == "-s" or opt == "--summary": summary = 1 continue if opt == "--ignore-module": ignore_modules.append(val) continue if opt == "--ignore-dir": for s in string.split(val, os.pathsep): s = os.path.expandvars(s) # should I also call expanduser? (after all, could use $HOME) s = string.replace(s, "$prefix", os.path.join(sys.prefix, "lib", "python" + sys.version[:3])) s = string.replace(s, "$exec_prefix", os.path.join(sys.exec_prefix, "lib", "python" + sys.version[:3])) s = os.path.normpath(s) ignore_dirs.append(s) continue assert 0, "Should never get here" if len(prog_argv) == 0: _err_exit("missing name of file to run") if count + trace + report > 1: _err_exit("can only specify one of --trace, --count or --report") if count + trace + report == 0: _err_exit("must specify one of --trace, --count or --report") if report and counts_file is None: _err_exit("--report requires a --file") if report and no_report: _err_exit("cannot specify both --report and --no-report") if logdir is not None: # warn if the directory doesn't exist, but keep on going # (is this the correct behaviour?) if not os.path.isdir(logdir): sys.stderr.write( "trace: WARNING, --logdir directory %s is not available\n" % `logdir`) sys.argv = prog_argv progname = prog_argv[0] if eval(sys.version[:3])>1.3: sys.path[0] = os.path.split(progname)[0] # ??? # everything is ready ignore = Ignore(ignore_modules, ignore_dirs) if trace: t = Trace(ignore) try: run(t.trace, 'execfile(' + `progname` + ')') except IOError, err: _err_exit("Cannot run file %s because: %s" % \ (`sys.argv[0]`, err)) elif count: t = Coverage(ignore) try: run(t.trace, 'execfile(' + `progname` + ')') except IOError, err: _err_exit("Cannot run file %s because: %s" % \ (`sys.argv[0]`, err)) except SystemExit: pass results = t.results() # Add another lookup from the program's file name to its import name # This give the right results, but I'm not sure why ... results.modules[progname] = os.path.splitext(progname)[0] if counts_file: # add in archived data, if available try: old_counts, old_modules = marshal.load(open(counts_file, 'rb')) except IOError: pass else: results.update(CoverageResults(old_counts, old_modules)) if not no_report: create_results_log(results, logdir, missing, summary=summary, coverdir=coverdir) if counts_file: try: marshal.dump( (results.counts, results.modules), open(counts_file, 'wb')) except IOError, err: _err_exit("Cannot save counts file %s because: %s" % \ (`counts_file`, err)) elif report: old_counts, old_modules = marshal.load(open(counts_file, 'rb')) results = CoverageResults(old_counts, old_modules) create_results_log(results, logdir, missing, summary=summary, coverdir=coverdir) else: assert 0, "Should never get here" | 8fb89f9fd74a61e165437eec10be9ace4c3738cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8fb89f9fd74a61e165437eec10be9ace4c3738cb/trace.py |
"file=", "logdir=", "missing", | "file=", "missing", | def main(argv = None): import getopt if argv is None: argv = sys.argv try: opts, prog_argv = getopt.getopt(argv[1:], "tcrRf:d:msC:", ["help", "version", "trace", "count", "report", "no-report", "file=", "logdir=", "missing", "ignore-module=", "ignore-dir=", "coverdir="]) except getopt.error, msg: print >> sys.stderr, "%s: %s" % (sys.argv[0], msg) print >> sys.stderr, "Try `%s --help' for more information" \ % sys.argv[0] sys.exit(1) trace = 0 count = 0 report = 0 no_report = 0 counts_file = None logdir = "." missing = 0 ignore_modules = [] ignore_dirs = [] coverdir = None summary = 0 for opt, val in opts: if opt == "--help": usage(sys.stdout) sys.exit(0) if opt == "--version": sys.stdout.write("trace 2.0\n") sys.exit(0) if opt == "-t" or opt == "--trace": trace = 1 continue if opt == "-c" or opt == "--count": count = 1 continue if opt == "-r" or opt == "--report": report = 1 continue if opt == "-R" or opt == "--no-report": no_report = 1 continue if opt == "-f" or opt == "--file": counts_file = val continue if opt == "-d" or opt == "--logdir": logdir = val continue if opt == "-m" or opt == "--missing": missing = 1 continue if opt == "-C" or opt == "--coverdir": coverdir = val continue if opt == "-s" or opt == "--summary": summary = 1 continue if opt == "--ignore-module": ignore_modules.append(val) continue if opt == "--ignore-dir": for s in string.split(val, os.pathsep): s = os.path.expandvars(s) # should I also call expanduser? (after all, could use $HOME) s = string.replace(s, "$prefix", os.path.join(sys.prefix, "lib", "python" + sys.version[:3])) s = string.replace(s, "$exec_prefix", os.path.join(sys.exec_prefix, "lib", "python" + sys.version[:3])) s = os.path.normpath(s) ignore_dirs.append(s) continue assert 0, "Should never get here" if len(prog_argv) == 0: _err_exit("missing name of file to run") if count + trace + report > 1: _err_exit("can only specify one of --trace, --count or --report") if count + trace + report == 0: _err_exit("must specify one of --trace, --count or --report") if report and counts_file is None: _err_exit("--report requires a --file") if report and no_report: _err_exit("cannot specify both --report and --no-report") if logdir is not None: # warn if the directory doesn't exist, but keep on going # (is this the correct behaviour?) if not os.path.isdir(logdir): sys.stderr.write( "trace: WARNING, --logdir directory %s is not available\n" % `logdir`) sys.argv = prog_argv progname = prog_argv[0] if eval(sys.version[:3])>1.3: sys.path[0] = os.path.split(progname)[0] # ??? # everything is ready ignore = Ignore(ignore_modules, ignore_dirs) if trace: t = Trace(ignore) try: run(t.trace, 'execfile(' + `progname` + ')') except IOError, err: _err_exit("Cannot run file %s because: %s" % \ (`sys.argv[0]`, err)) elif count: t = Coverage(ignore) try: run(t.trace, 'execfile(' + `progname` + ')') except IOError, err: _err_exit("Cannot run file %s because: %s" % \ (`sys.argv[0]`, err)) except SystemExit: pass results = t.results() # Add another lookup from the program's file name to its import name # This give the right results, but I'm not sure why ... results.modules[progname] = os.path.splitext(progname)[0] if counts_file: # add in archived data, if available try: old_counts, old_modules = marshal.load(open(counts_file, 'rb')) except IOError: pass else: results.update(CoverageResults(old_counts, old_modules)) if not no_report: create_results_log(results, logdir, missing, summary=summary, coverdir=coverdir) if counts_file: try: marshal.dump( (results.counts, results.modules), open(counts_file, 'wb')) except IOError, err: _err_exit("Cannot save counts file %s because: %s" % \ (`counts_file`, err)) elif report: old_counts, old_modules = marshal.load(open(counts_file, 'rb')) results = CoverageResults(old_counts, old_modules) create_results_log(results, logdir, missing, summary=summary, coverdir=coverdir) else: assert 0, "Should never get here" | 8fb89f9fd74a61e165437eec10be9ace4c3738cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8fb89f9fd74a61e165437eec10be9ace4c3738cb/trace.py |
"coverdir="]) | "coverdir=", "listfuncs",]) | def main(argv = None): import getopt if argv is None: argv = sys.argv try: opts, prog_argv = getopt.getopt(argv[1:], "tcrRf:d:msC:", ["help", "version", "trace", "count", "report", "no-report", "file=", "logdir=", "missing", "ignore-module=", "ignore-dir=", "coverdir="]) except getopt.error, msg: print >> sys.stderr, "%s: %s" % (sys.argv[0], msg) print >> sys.stderr, "Try `%s --help' for more information" \ % sys.argv[0] sys.exit(1) trace = 0 count = 0 report = 0 no_report = 0 counts_file = None logdir = "." missing = 0 ignore_modules = [] ignore_dirs = [] coverdir = None summary = 0 for opt, val in opts: if opt == "--help": usage(sys.stdout) sys.exit(0) if opt == "--version": sys.stdout.write("trace 2.0\n") sys.exit(0) if opt == "-t" or opt == "--trace": trace = 1 continue if opt == "-c" or opt == "--count": count = 1 continue if opt == "-r" or opt == "--report": report = 1 continue if opt == "-R" or opt == "--no-report": no_report = 1 continue if opt == "-f" or opt == "--file": counts_file = val continue if opt == "-d" or opt == "--logdir": logdir = val continue if opt == "-m" or opt == "--missing": missing = 1 continue if opt == "-C" or opt == "--coverdir": coverdir = val continue if opt == "-s" or opt == "--summary": summary = 1 continue if opt == "--ignore-module": ignore_modules.append(val) continue if opt == "--ignore-dir": for s in string.split(val, os.pathsep): s = os.path.expandvars(s) # should I also call expanduser? (after all, could use $HOME) s = string.replace(s, "$prefix", os.path.join(sys.prefix, "lib", "python" + sys.version[:3])) s = string.replace(s, "$exec_prefix", os.path.join(sys.exec_prefix, "lib", "python" + sys.version[:3])) s = os.path.normpath(s) ignore_dirs.append(s) continue assert 0, "Should never get here" if len(prog_argv) == 0: _err_exit("missing name of file to run") if count + trace + report > 1: _err_exit("can only specify one of --trace, --count or --report") if count + trace + report == 0: _err_exit("must specify one of --trace, --count or --report") if report and counts_file is None: _err_exit("--report requires a --file") if report and no_report: _err_exit("cannot specify both --report and --no-report") if logdir is not None: # warn if the directory doesn't exist, but keep on going # (is this the correct behaviour?) if not os.path.isdir(logdir): sys.stderr.write( "trace: WARNING, --logdir directory %s is not available\n" % `logdir`) sys.argv = prog_argv progname = prog_argv[0] if eval(sys.version[:3])>1.3: sys.path[0] = os.path.split(progname)[0] # ??? # everything is ready ignore = Ignore(ignore_modules, ignore_dirs) if trace: t = Trace(ignore) try: run(t.trace, 'execfile(' + `progname` + ')') except IOError, err: _err_exit("Cannot run file %s because: %s" % \ (`sys.argv[0]`, err)) elif count: t = Coverage(ignore) try: run(t.trace, 'execfile(' + `progname` + ')') except IOError, err: _err_exit("Cannot run file %s because: %s" % \ (`sys.argv[0]`, err)) except SystemExit: pass results = t.results() # Add another lookup from the program's file name to its import name # This give the right results, but I'm not sure why ... results.modules[progname] = os.path.splitext(progname)[0] if counts_file: # add in archived data, if available try: old_counts, old_modules = marshal.load(open(counts_file, 'rb')) except IOError: pass else: results.update(CoverageResults(old_counts, old_modules)) if not no_report: create_results_log(results, logdir, missing, summary=summary, coverdir=coverdir) if counts_file: try: marshal.dump( (results.counts, results.modules), open(counts_file, 'wb')) except IOError, err: _err_exit("Cannot save counts file %s because: %s" % \ (`counts_file`, err)) elif report: old_counts, old_modules = marshal.load(open(counts_file, 'rb')) results = CoverageResults(old_counts, old_modules) create_results_log(results, logdir, missing, summary=summary, coverdir=coverdir) else: assert 0, "Should never get here" | 8fb89f9fd74a61e165437eec10be9ace4c3738cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8fb89f9fd74a61e165437eec10be9ace4c3738cb/trace.py |
print >> sys.stderr, "%s: %s" % (sys.argv[0], msg) print >> sys.stderr, "Try `%s --help' for more information" \ % sys.argv[0] | sys.stderr.write("%s: %s\n" % (sys.argv[0], msg)) sys.stderr.write("Try `%s --help' for more information\n" % sys.argv[0]) | def main(argv = None): import getopt if argv is None: argv = sys.argv try: opts, prog_argv = getopt.getopt(argv[1:], "tcrRf:d:msC:", ["help", "version", "trace", "count", "report", "no-report", "file=", "logdir=", "missing", "ignore-module=", "ignore-dir=", "coverdir="]) except getopt.error, msg: print >> sys.stderr, "%s: %s" % (sys.argv[0], msg) print >> sys.stderr, "Try `%s --help' for more information" \ % sys.argv[0] sys.exit(1) trace = 0 count = 0 report = 0 no_report = 0 counts_file = None logdir = "." missing = 0 ignore_modules = [] ignore_dirs = [] coverdir = None summary = 0 for opt, val in opts: if opt == "--help": usage(sys.stdout) sys.exit(0) if opt == "--version": sys.stdout.write("trace 2.0\n") sys.exit(0) if opt == "-t" or opt == "--trace": trace = 1 continue if opt == "-c" or opt == "--count": count = 1 continue if opt == "-r" or opt == "--report": report = 1 continue if opt == "-R" or opt == "--no-report": no_report = 1 continue if opt == "-f" or opt == "--file": counts_file = val continue if opt == "-d" or opt == "--logdir": logdir = val continue if opt == "-m" or opt == "--missing": missing = 1 continue if opt == "-C" or opt == "--coverdir": coverdir = val continue if opt == "-s" or opt == "--summary": summary = 1 continue if opt == "--ignore-module": ignore_modules.append(val) continue if opt == "--ignore-dir": for s in string.split(val, os.pathsep): s = os.path.expandvars(s) # should I also call expanduser? (after all, could use $HOME) s = string.replace(s, "$prefix", os.path.join(sys.prefix, "lib", "python" + sys.version[:3])) s = string.replace(s, "$exec_prefix", os.path.join(sys.exec_prefix, "lib", "python" + sys.version[:3])) s = os.path.normpath(s) ignore_dirs.append(s) continue assert 0, "Should never get here" if len(prog_argv) == 0: _err_exit("missing name of file to run") if count + trace + report > 1: _err_exit("can only specify one of --trace, --count or --report") if count + trace + report == 0: _err_exit("must specify one of --trace, --count or --report") if report and counts_file is None: _err_exit("--report requires a --file") if report and no_report: _err_exit("cannot specify both --report and --no-report") if logdir is not None: # warn if the directory doesn't exist, but keep on going # (is this the correct behaviour?) if not os.path.isdir(logdir): sys.stderr.write( "trace: WARNING, --logdir directory %s is not available\n" % `logdir`) sys.argv = prog_argv progname = prog_argv[0] if eval(sys.version[:3])>1.3: sys.path[0] = os.path.split(progname)[0] # ??? # everything is ready ignore = Ignore(ignore_modules, ignore_dirs) if trace: t = Trace(ignore) try: run(t.trace, 'execfile(' + `progname` + ')') except IOError, err: _err_exit("Cannot run file %s because: %s" % \ (`sys.argv[0]`, err)) elif count: t = Coverage(ignore) try: run(t.trace, 'execfile(' + `progname` + ')') except IOError, err: _err_exit("Cannot run file %s because: %s" % \ (`sys.argv[0]`, err)) except SystemExit: pass results = t.results() # Add another lookup from the program's file name to its import name # This give the right results, but I'm not sure why ... results.modules[progname] = os.path.splitext(progname)[0] if counts_file: # add in archived data, if available try: old_counts, old_modules = marshal.load(open(counts_file, 'rb')) except IOError: pass else: results.update(CoverageResults(old_counts, old_modules)) if not no_report: create_results_log(results, logdir, missing, summary=summary, coverdir=coverdir) if counts_file: try: marshal.dump( (results.counts, results.modules), open(counts_file, 'wb')) except IOError, err: _err_exit("Cannot save counts file %s because: %s" % \ (`counts_file`, err)) elif report: old_counts, old_modules = marshal.load(open(counts_file, 'rb')) results = CoverageResults(old_counts, old_modules) create_results_log(results, logdir, missing, summary=summary, coverdir=coverdir) else: assert 0, "Should never get here" | 8fb89f9fd74a61e165437eec10be9ace4c3738cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8fb89f9fd74a61e165437eec10be9ace4c3738cb/trace.py |
logdir = "." | def main(argv = None): import getopt if argv is None: argv = sys.argv try: opts, prog_argv = getopt.getopt(argv[1:], "tcrRf:d:msC:", ["help", "version", "trace", "count", "report", "no-report", "file=", "logdir=", "missing", "ignore-module=", "ignore-dir=", "coverdir="]) except getopt.error, msg: print >> sys.stderr, "%s: %s" % (sys.argv[0], msg) print >> sys.stderr, "Try `%s --help' for more information" \ % sys.argv[0] sys.exit(1) trace = 0 count = 0 report = 0 no_report = 0 counts_file = None logdir = "." missing = 0 ignore_modules = [] ignore_dirs = [] coverdir = None summary = 0 for opt, val in opts: if opt == "--help": usage(sys.stdout) sys.exit(0) if opt == "--version": sys.stdout.write("trace 2.0\n") sys.exit(0) if opt == "-t" or opt == "--trace": trace = 1 continue if opt == "-c" or opt == "--count": count = 1 continue if opt == "-r" or opt == "--report": report = 1 continue if opt == "-R" or opt == "--no-report": no_report = 1 continue if opt == "-f" or opt == "--file": counts_file = val continue if opt == "-d" or opt == "--logdir": logdir = val continue if opt == "-m" or opt == "--missing": missing = 1 continue if opt == "-C" or opt == "--coverdir": coverdir = val continue if opt == "-s" or opt == "--summary": summary = 1 continue if opt == "--ignore-module": ignore_modules.append(val) continue if opt == "--ignore-dir": for s in string.split(val, os.pathsep): s = os.path.expandvars(s) # should I also call expanduser? (after all, could use $HOME) s = string.replace(s, "$prefix", os.path.join(sys.prefix, "lib", "python" + sys.version[:3])) s = string.replace(s, "$exec_prefix", os.path.join(sys.exec_prefix, "lib", "python" + sys.version[:3])) s = os.path.normpath(s) ignore_dirs.append(s) continue assert 0, "Should never get here" if len(prog_argv) == 0: _err_exit("missing name of file to run") if count + trace + report > 1: _err_exit("can only specify one of --trace, --count or --report") if count + trace + report == 0: _err_exit("must specify one of --trace, --count or --report") if report and counts_file is None: _err_exit("--report requires a --file") if report and no_report: _err_exit("cannot specify both --report and --no-report") if logdir is not None: # warn if the directory doesn't exist, but keep on going # (is this the correct behaviour?) if not os.path.isdir(logdir): sys.stderr.write( "trace: WARNING, --logdir directory %s is not available\n" % `logdir`) sys.argv = prog_argv progname = prog_argv[0] if eval(sys.version[:3])>1.3: sys.path[0] = os.path.split(progname)[0] # ??? # everything is ready ignore = Ignore(ignore_modules, ignore_dirs) if trace: t = Trace(ignore) try: run(t.trace, 'execfile(' + `progname` + ')') except IOError, err: _err_exit("Cannot run file %s because: %s" % \ (`sys.argv[0]`, err)) elif count: t = Coverage(ignore) try: run(t.trace, 'execfile(' + `progname` + ')') except IOError, err: _err_exit("Cannot run file %s because: %s" % \ (`sys.argv[0]`, err)) except SystemExit: pass results = t.results() # Add another lookup from the program's file name to its import name # This give the right results, but I'm not sure why ... results.modules[progname] = os.path.splitext(progname)[0] if counts_file: # add in archived data, if available try: old_counts, old_modules = marshal.load(open(counts_file, 'rb')) except IOError: pass else: results.update(CoverageResults(old_counts, old_modules)) if not no_report: create_results_log(results, logdir, missing, summary=summary, coverdir=coverdir) if counts_file: try: marshal.dump( (results.counts, results.modules), open(counts_file, 'wb')) except IOError, err: _err_exit("Cannot save counts file %s because: %s" % \ (`counts_file`, err)) elif report: old_counts, old_modules = marshal.load(open(counts_file, 'rb')) results = CoverageResults(old_counts, old_modules) create_results_log(results, logdir, missing, summary=summary, coverdir=coverdir) else: assert 0, "Should never get here" | 8fb89f9fd74a61e165437eec10be9ace4c3738cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8fb89f9fd74a61e165437eec10be9ace4c3738cb/trace.py |
|
continue if opt == "-d" or opt == "--logdir": logdir = val | def main(argv = None): import getopt if argv is None: argv = sys.argv try: opts, prog_argv = getopt.getopt(argv[1:], "tcrRf:d:msC:", ["help", "version", "trace", "count", "report", "no-report", "file=", "logdir=", "missing", "ignore-module=", "ignore-dir=", "coverdir="]) except getopt.error, msg: print >> sys.stderr, "%s: %s" % (sys.argv[0], msg) print >> sys.stderr, "Try `%s --help' for more information" \ % sys.argv[0] sys.exit(1) trace = 0 count = 0 report = 0 no_report = 0 counts_file = None logdir = "." missing = 0 ignore_modules = [] ignore_dirs = [] coverdir = None summary = 0 for opt, val in opts: if opt == "--help": usage(sys.stdout) sys.exit(0) if opt == "--version": sys.stdout.write("trace 2.0\n") sys.exit(0) if opt == "-t" or opt == "--trace": trace = 1 continue if opt == "-c" or opt == "--count": count = 1 continue if opt == "-r" or opt == "--report": report = 1 continue if opt == "-R" or opt == "--no-report": no_report = 1 continue if opt == "-f" or opt == "--file": counts_file = val continue if opt == "-d" or opt == "--logdir": logdir = val continue if opt == "-m" or opt == "--missing": missing = 1 continue if opt == "-C" or opt == "--coverdir": coverdir = val continue if opt == "-s" or opt == "--summary": summary = 1 continue if opt == "--ignore-module": ignore_modules.append(val) continue if opt == "--ignore-dir": for s in string.split(val, os.pathsep): s = os.path.expandvars(s) # should I also call expanduser? (after all, could use $HOME) s = string.replace(s, "$prefix", os.path.join(sys.prefix, "lib", "python" + sys.version[:3])) s = string.replace(s, "$exec_prefix", os.path.join(sys.exec_prefix, "lib", "python" + sys.version[:3])) s = os.path.normpath(s) ignore_dirs.append(s) continue assert 0, "Should never get here" if len(prog_argv) == 0: _err_exit("missing name of file to run") if count + trace + report > 1: _err_exit("can only specify one of --trace, --count or --report") if count + trace + report == 0: _err_exit("must specify one of --trace, --count or --report") if report and counts_file is None: _err_exit("--report requires a --file") if report and no_report: _err_exit("cannot specify both --report and --no-report") if logdir is not None: # warn if the directory doesn't exist, but keep on going # (is this the correct behaviour?) if not os.path.isdir(logdir): sys.stderr.write( "trace: WARNING, --logdir directory %s is not available\n" % `logdir`) sys.argv = prog_argv progname = prog_argv[0] if eval(sys.version[:3])>1.3: sys.path[0] = os.path.split(progname)[0] # ??? # everything is ready ignore = Ignore(ignore_modules, ignore_dirs) if trace: t = Trace(ignore) try: run(t.trace, 'execfile(' + `progname` + ')') except IOError, err: _err_exit("Cannot run file %s because: %s" % \ (`sys.argv[0]`, err)) elif count: t = Coverage(ignore) try: run(t.trace, 'execfile(' + `progname` + ')') except IOError, err: _err_exit("Cannot run file %s because: %s" % \ (`sys.argv[0]`, err)) except SystemExit: pass results = t.results() # Add another lookup from the program's file name to its import name # This give the right results, but I'm not sure why ... results.modules[progname] = os.path.splitext(progname)[0] if counts_file: # add in archived data, if available try: old_counts, old_modules = marshal.load(open(counts_file, 'rb')) except IOError: pass else: results.update(CoverageResults(old_counts, old_modules)) if not no_report: create_results_log(results, logdir, missing, summary=summary, coverdir=coverdir) if counts_file: try: marshal.dump( (results.counts, results.modules), open(counts_file, 'wb')) except IOError, err: _err_exit("Cannot save counts file %s because: %s" % \ (`counts_file`, err)) elif report: old_counts, old_modules = marshal.load(open(counts_file, 'rb')) results = CoverageResults(old_counts, old_modules) create_results_log(results, logdir, missing, summary=summary, coverdir=coverdir) else: assert 0, "Should never get here" | 8fb89f9fd74a61e165437eec10be9ace4c3738cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8fb89f9fd74a61e165437eec10be9ace4c3738cb/trace.py |
|
if len(prog_argv) == 0: _err_exit("missing name of file to run") if count + trace + report > 1: _err_exit("can only specify one of --trace, --count or --report") if count + trace + report == 0: _err_exit("must specify one of --trace, --count or --report") if report and counts_file is None: _err_exit("--report requires a --file") | if listfuncs and (count or trace): _err_exit("cannot specify both --listfuncs and (--trace or --count)") if not count and not trace and not report and not listfuncs: _err_exit("must specify one of --trace, --count, --report or --listfuncs") | def main(argv = None): import getopt if argv is None: argv = sys.argv try: opts, prog_argv = getopt.getopt(argv[1:], "tcrRf:d:msC:", ["help", "version", "trace", "count", "report", "no-report", "file=", "logdir=", "missing", "ignore-module=", "ignore-dir=", "coverdir="]) except getopt.error, msg: print >> sys.stderr, "%s: %s" % (sys.argv[0], msg) print >> sys.stderr, "Try `%s --help' for more information" \ % sys.argv[0] sys.exit(1) trace = 0 count = 0 report = 0 no_report = 0 counts_file = None logdir = "." missing = 0 ignore_modules = [] ignore_dirs = [] coverdir = None summary = 0 for opt, val in opts: if opt == "--help": usage(sys.stdout) sys.exit(0) if opt == "--version": sys.stdout.write("trace 2.0\n") sys.exit(0) if opt == "-t" or opt == "--trace": trace = 1 continue if opt == "-c" or opt == "--count": count = 1 continue if opt == "-r" or opt == "--report": report = 1 continue if opt == "-R" or opt == "--no-report": no_report = 1 continue if opt == "-f" or opt == "--file": counts_file = val continue if opt == "-d" or opt == "--logdir": logdir = val continue if opt == "-m" or opt == "--missing": missing = 1 continue if opt == "-C" or opt == "--coverdir": coverdir = val continue if opt == "-s" or opt == "--summary": summary = 1 continue if opt == "--ignore-module": ignore_modules.append(val) continue if opt == "--ignore-dir": for s in string.split(val, os.pathsep): s = os.path.expandvars(s) # should I also call expanduser? (after all, could use $HOME) s = string.replace(s, "$prefix", os.path.join(sys.prefix, "lib", "python" + sys.version[:3])) s = string.replace(s, "$exec_prefix", os.path.join(sys.exec_prefix, "lib", "python" + sys.version[:3])) s = os.path.normpath(s) ignore_dirs.append(s) continue assert 0, "Should never get here" if len(prog_argv) == 0: _err_exit("missing name of file to run") if count + trace + report > 1: _err_exit("can only specify one of --trace, --count or --report") if count + trace + report == 0: _err_exit("must specify one of --trace, --count or --report") if report and counts_file is None: _err_exit("--report requires a --file") if report and no_report: _err_exit("cannot specify both --report and --no-report") if logdir is not None: # warn if the directory doesn't exist, but keep on going # (is this the correct behaviour?) if not os.path.isdir(logdir): sys.stderr.write( "trace: WARNING, --logdir directory %s is not available\n" % `logdir`) sys.argv = prog_argv progname = prog_argv[0] if eval(sys.version[:3])>1.3: sys.path[0] = os.path.split(progname)[0] # ??? # everything is ready ignore = Ignore(ignore_modules, ignore_dirs) if trace: t = Trace(ignore) try: run(t.trace, 'execfile(' + `progname` + ')') except IOError, err: _err_exit("Cannot run file %s because: %s" % \ (`sys.argv[0]`, err)) elif count: t = Coverage(ignore) try: run(t.trace, 'execfile(' + `progname` + ')') except IOError, err: _err_exit("Cannot run file %s because: %s" % \ (`sys.argv[0]`, err)) except SystemExit: pass results = t.results() # Add another lookup from the program's file name to its import name # This give the right results, but I'm not sure why ... results.modules[progname] = os.path.splitext(progname)[0] if counts_file: # add in archived data, if available try: old_counts, old_modules = marshal.load(open(counts_file, 'rb')) except IOError: pass else: results.update(CoverageResults(old_counts, old_modules)) if not no_report: create_results_log(results, logdir, missing, summary=summary, coverdir=coverdir) if counts_file: try: marshal.dump( (results.counts, results.modules), open(counts_file, 'wb')) except IOError, err: _err_exit("Cannot save counts file %s because: %s" % \ (`counts_file`, err)) elif report: old_counts, old_modules = marshal.load(open(counts_file, 'rb')) results = CoverageResults(old_counts, old_modules) create_results_log(results, logdir, missing, summary=summary, coverdir=coverdir) else: assert 0, "Should never get here" | 8fb89f9fd74a61e165437eec10be9ace4c3738cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8fb89f9fd74a61e165437eec10be9ace4c3738cb/trace.py |
if logdir is not None: if not os.path.isdir(logdir): sys.stderr.write( "trace: WARNING, --logdir directory %s is not available\n" % `logdir`) sys.argv = prog_argv progname = prog_argv[0] if eval(sys.version[:3])>1.3: sys.path[0] = os.path.split(progname)[0] | if report and not counts_file: _err_exit("--report requires a --file") if no_report and len(prog_argv) == 0: _err_exit("missing name of file to run") | def main(argv = None): import getopt if argv is None: argv = sys.argv try: opts, prog_argv = getopt.getopt(argv[1:], "tcrRf:d:msC:", ["help", "version", "trace", "count", "report", "no-report", "file=", "logdir=", "missing", "ignore-module=", "ignore-dir=", "coverdir="]) except getopt.error, msg: print >> sys.stderr, "%s: %s" % (sys.argv[0], msg) print >> sys.stderr, "Try `%s --help' for more information" \ % sys.argv[0] sys.exit(1) trace = 0 count = 0 report = 0 no_report = 0 counts_file = None logdir = "." missing = 0 ignore_modules = [] ignore_dirs = [] coverdir = None summary = 0 for opt, val in opts: if opt == "--help": usage(sys.stdout) sys.exit(0) if opt == "--version": sys.stdout.write("trace 2.0\n") sys.exit(0) if opt == "-t" or opt == "--trace": trace = 1 continue if opt == "-c" or opt == "--count": count = 1 continue if opt == "-r" or opt == "--report": report = 1 continue if opt == "-R" or opt == "--no-report": no_report = 1 continue if opt == "-f" or opt == "--file": counts_file = val continue if opt == "-d" or opt == "--logdir": logdir = val continue if opt == "-m" or opt == "--missing": missing = 1 continue if opt == "-C" or opt == "--coverdir": coverdir = val continue if opt == "-s" or opt == "--summary": summary = 1 continue if opt == "--ignore-module": ignore_modules.append(val) continue if opt == "--ignore-dir": for s in string.split(val, os.pathsep): s = os.path.expandvars(s) # should I also call expanduser? (after all, could use $HOME) s = string.replace(s, "$prefix", os.path.join(sys.prefix, "lib", "python" + sys.version[:3])) s = string.replace(s, "$exec_prefix", os.path.join(sys.exec_prefix, "lib", "python" + sys.version[:3])) s = os.path.normpath(s) ignore_dirs.append(s) continue assert 0, "Should never get here" if len(prog_argv) == 0: _err_exit("missing name of file to run") if count + trace + report > 1: _err_exit("can only specify one of --trace, --count or --report") if count + trace + report == 0: _err_exit("must specify one of --trace, --count or --report") if report and counts_file is None: _err_exit("--report requires a --file") if report and no_report: _err_exit("cannot specify both --report and --no-report") if logdir is not None: # warn if the directory doesn't exist, but keep on going # (is this the correct behaviour?) if not os.path.isdir(logdir): sys.stderr.write( "trace: WARNING, --logdir directory %s is not available\n" % `logdir`) sys.argv = prog_argv progname = prog_argv[0] if eval(sys.version[:3])>1.3: sys.path[0] = os.path.split(progname)[0] # ??? # everything is ready ignore = Ignore(ignore_modules, ignore_dirs) if trace: t = Trace(ignore) try: run(t.trace, 'execfile(' + `progname` + ')') except IOError, err: _err_exit("Cannot run file %s because: %s" % \ (`sys.argv[0]`, err)) elif count: t = Coverage(ignore) try: run(t.trace, 'execfile(' + `progname` + ')') except IOError, err: _err_exit("Cannot run file %s because: %s" % \ (`sys.argv[0]`, err)) except SystemExit: pass results = t.results() # Add another lookup from the program's file name to its import name # This give the right results, but I'm not sure why ... results.modules[progname] = os.path.splitext(progname)[0] if counts_file: # add in archived data, if available try: old_counts, old_modules = marshal.load(open(counts_file, 'rb')) except IOError: pass else: results.update(CoverageResults(old_counts, old_modules)) if not no_report: create_results_log(results, logdir, missing, summary=summary, coverdir=coverdir) if counts_file: try: marshal.dump( (results.counts, results.modules), open(counts_file, 'wb')) except IOError, err: _err_exit("Cannot save counts file %s because: %s" % \ (`counts_file`, err)) elif report: old_counts, old_modules = marshal.load(open(counts_file, 'rb')) results = CoverageResults(old_counts, old_modules) create_results_log(results, logdir, missing, summary=summary, coverdir=coverdir) else: assert 0, "Should never get here" | 8fb89f9fd74a61e165437eec10be9ace4c3738cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8fb89f9fd74a61e165437eec10be9ace4c3738cb/trace.py |
ignore = Ignore(ignore_modules, ignore_dirs) if trace: t = Trace(ignore) | if report: results = CoverageResults(infile=counts_file, outfile=counts_file) results.write_results(missing, summary=summary, coverdir=coverdir) else: sys.argv = prog_argv progname = prog_argv[0] if eval(sys.version[:3])>1.3: sys.path[0] = os.path.split(progname)[0] t = Trace(count, trace, countfuncs=listfuncs, ignoremods=ignore_modules, ignoredirs=ignore_dirs, infile=counts_file, outfile=counts_file) | def main(argv = None): import getopt if argv is None: argv = sys.argv try: opts, prog_argv = getopt.getopt(argv[1:], "tcrRf:d:msC:", ["help", "version", "trace", "count", "report", "no-report", "file=", "logdir=", "missing", "ignore-module=", "ignore-dir=", "coverdir="]) except getopt.error, msg: print >> sys.stderr, "%s: %s" % (sys.argv[0], msg) print >> sys.stderr, "Try `%s --help' for more information" \ % sys.argv[0] sys.exit(1) trace = 0 count = 0 report = 0 no_report = 0 counts_file = None logdir = "." missing = 0 ignore_modules = [] ignore_dirs = [] coverdir = None summary = 0 for opt, val in opts: if opt == "--help": usage(sys.stdout) sys.exit(0) if opt == "--version": sys.stdout.write("trace 2.0\n") sys.exit(0) if opt == "-t" or opt == "--trace": trace = 1 continue if opt == "-c" or opt == "--count": count = 1 continue if opt == "-r" or opt == "--report": report = 1 continue if opt == "-R" or opt == "--no-report": no_report = 1 continue if opt == "-f" or opt == "--file": counts_file = val continue if opt == "-d" or opt == "--logdir": logdir = val continue if opt == "-m" or opt == "--missing": missing = 1 continue if opt == "-C" or opt == "--coverdir": coverdir = val continue if opt == "-s" or opt == "--summary": summary = 1 continue if opt == "--ignore-module": ignore_modules.append(val) continue if opt == "--ignore-dir": for s in string.split(val, os.pathsep): s = os.path.expandvars(s) # should I also call expanduser? (after all, could use $HOME) s = string.replace(s, "$prefix", os.path.join(sys.prefix, "lib", "python" + sys.version[:3])) s = string.replace(s, "$exec_prefix", os.path.join(sys.exec_prefix, "lib", "python" + sys.version[:3])) s = os.path.normpath(s) ignore_dirs.append(s) continue assert 0, "Should never get here" if len(prog_argv) == 0: _err_exit("missing name of file to run") if count + trace + report > 1: _err_exit("can only specify one of --trace, --count or --report") if count + trace + report == 0: _err_exit("must specify one of --trace, --count or --report") if report and counts_file is None: _err_exit("--report requires a --file") if report and no_report: _err_exit("cannot specify both --report and --no-report") if logdir is not None: # warn if the directory doesn't exist, but keep on going # (is this the correct behaviour?) if not os.path.isdir(logdir): sys.stderr.write( "trace: WARNING, --logdir directory %s is not available\n" % `logdir`) sys.argv = prog_argv progname = prog_argv[0] if eval(sys.version[:3])>1.3: sys.path[0] = os.path.split(progname)[0] # ??? # everything is ready ignore = Ignore(ignore_modules, ignore_dirs) if trace: t = Trace(ignore) try: run(t.trace, 'execfile(' + `progname` + ')') except IOError, err: _err_exit("Cannot run file %s because: %s" % \ (`sys.argv[0]`, err)) elif count: t = Coverage(ignore) try: run(t.trace, 'execfile(' + `progname` + ')') except IOError, err: _err_exit("Cannot run file %s because: %s" % \ (`sys.argv[0]`, err)) except SystemExit: pass results = t.results() # Add another lookup from the program's file name to its import name # This give the right results, but I'm not sure why ... results.modules[progname] = os.path.splitext(progname)[0] if counts_file: # add in archived data, if available try: old_counts, old_modules = marshal.load(open(counts_file, 'rb')) except IOError: pass else: results.update(CoverageResults(old_counts, old_modules)) if not no_report: create_results_log(results, logdir, missing, summary=summary, coverdir=coverdir) if counts_file: try: marshal.dump( (results.counts, results.modules), open(counts_file, 'wb')) except IOError, err: _err_exit("Cannot save counts file %s because: %s" % \ (`counts_file`, err)) elif report: old_counts, old_modules = marshal.load(open(counts_file, 'rb')) results = CoverageResults(old_counts, old_modules) create_results_log(results, logdir, missing, summary=summary, coverdir=coverdir) else: assert 0, "Should never get here" | 8fb89f9fd74a61e165437eec10be9ace4c3738cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8fb89f9fd74a61e165437eec10be9ace4c3738cb/trace.py |
run(t.trace, 'execfile(' + `progname` + ')') | t.run('execfile(' + `progname` + ')') | def main(argv = None): import getopt if argv is None: argv = sys.argv try: opts, prog_argv = getopt.getopt(argv[1:], "tcrRf:d:msC:", ["help", "version", "trace", "count", "report", "no-report", "file=", "logdir=", "missing", "ignore-module=", "ignore-dir=", "coverdir="]) except getopt.error, msg: print >> sys.stderr, "%s: %s" % (sys.argv[0], msg) print >> sys.stderr, "Try `%s --help' for more information" \ % sys.argv[0] sys.exit(1) trace = 0 count = 0 report = 0 no_report = 0 counts_file = None logdir = "." missing = 0 ignore_modules = [] ignore_dirs = [] coverdir = None summary = 0 for opt, val in opts: if opt == "--help": usage(sys.stdout) sys.exit(0) if opt == "--version": sys.stdout.write("trace 2.0\n") sys.exit(0) if opt == "-t" or opt == "--trace": trace = 1 continue if opt == "-c" or opt == "--count": count = 1 continue if opt == "-r" or opt == "--report": report = 1 continue if opt == "-R" or opt == "--no-report": no_report = 1 continue if opt == "-f" or opt == "--file": counts_file = val continue if opt == "-d" or opt == "--logdir": logdir = val continue if opt == "-m" or opt == "--missing": missing = 1 continue if opt == "-C" or opt == "--coverdir": coverdir = val continue if opt == "-s" or opt == "--summary": summary = 1 continue if opt == "--ignore-module": ignore_modules.append(val) continue if opt == "--ignore-dir": for s in string.split(val, os.pathsep): s = os.path.expandvars(s) # should I also call expanduser? (after all, could use $HOME) s = string.replace(s, "$prefix", os.path.join(sys.prefix, "lib", "python" + sys.version[:3])) s = string.replace(s, "$exec_prefix", os.path.join(sys.exec_prefix, "lib", "python" + sys.version[:3])) s = os.path.normpath(s) ignore_dirs.append(s) continue assert 0, "Should never get here" if len(prog_argv) == 0: _err_exit("missing name of file to run") if count + trace + report > 1: _err_exit("can only specify one of --trace, --count or --report") if count + trace + report == 0: _err_exit("must specify one of --trace, --count or --report") if report and counts_file is None: _err_exit("--report requires a --file") if report and no_report: _err_exit("cannot specify both --report and --no-report") if logdir is not None: # warn if the directory doesn't exist, but keep on going # (is this the correct behaviour?) if not os.path.isdir(logdir): sys.stderr.write( "trace: WARNING, --logdir directory %s is not available\n" % `logdir`) sys.argv = prog_argv progname = prog_argv[0] if eval(sys.version[:3])>1.3: sys.path[0] = os.path.split(progname)[0] # ??? # everything is ready ignore = Ignore(ignore_modules, ignore_dirs) if trace: t = Trace(ignore) try: run(t.trace, 'execfile(' + `progname` + ')') except IOError, err: _err_exit("Cannot run file %s because: %s" % \ (`sys.argv[0]`, err)) elif count: t = Coverage(ignore) try: run(t.trace, 'execfile(' + `progname` + ')') except IOError, err: _err_exit("Cannot run file %s because: %s" % \ (`sys.argv[0]`, err)) except SystemExit: pass results = t.results() # Add another lookup from the program's file name to its import name # This give the right results, but I'm not sure why ... results.modules[progname] = os.path.splitext(progname)[0] if counts_file: # add in archived data, if available try: old_counts, old_modules = marshal.load(open(counts_file, 'rb')) except IOError: pass else: results.update(CoverageResults(old_counts, old_modules)) if not no_report: create_results_log(results, logdir, missing, summary=summary, coverdir=coverdir) if counts_file: try: marshal.dump( (results.counts, results.modules), open(counts_file, 'wb')) except IOError, err: _err_exit("Cannot save counts file %s because: %s" % \ (`counts_file`, err)) elif report: old_counts, old_modules = marshal.load(open(counts_file, 'rb')) results = CoverageResults(old_counts, old_modules) create_results_log(results, logdir, missing, summary=summary, coverdir=coverdir) else: assert 0, "Should never get here" | 8fb89f9fd74a61e165437eec10be9ace4c3738cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8fb89f9fd74a61e165437eec10be9ace4c3738cb/trace.py |
_err_exit("Cannot run file %s because: %s" % \ (`sys.argv[0]`, err)) elif count: t = Coverage(ignore) try: run(t.trace, 'execfile(' + `progname` + ')') except IOError, err: _err_exit("Cannot run file %s because: %s" % \ (`sys.argv[0]`, err)) | _err_exit("Cannot run file %s because: %s" % (`sys.argv[0]`, err)) | def main(argv = None): import getopt if argv is None: argv = sys.argv try: opts, prog_argv = getopt.getopt(argv[1:], "tcrRf:d:msC:", ["help", "version", "trace", "count", "report", "no-report", "file=", "logdir=", "missing", "ignore-module=", "ignore-dir=", "coverdir="]) except getopt.error, msg: print >> sys.stderr, "%s: %s" % (sys.argv[0], msg) print >> sys.stderr, "Try `%s --help' for more information" \ % sys.argv[0] sys.exit(1) trace = 0 count = 0 report = 0 no_report = 0 counts_file = None logdir = "." missing = 0 ignore_modules = [] ignore_dirs = [] coverdir = None summary = 0 for opt, val in opts: if opt == "--help": usage(sys.stdout) sys.exit(0) if opt == "--version": sys.stdout.write("trace 2.0\n") sys.exit(0) if opt == "-t" or opt == "--trace": trace = 1 continue if opt == "-c" or opt == "--count": count = 1 continue if opt == "-r" or opt == "--report": report = 1 continue if opt == "-R" or opt == "--no-report": no_report = 1 continue if opt == "-f" or opt == "--file": counts_file = val continue if opt == "-d" or opt == "--logdir": logdir = val continue if opt == "-m" or opt == "--missing": missing = 1 continue if opt == "-C" or opt == "--coverdir": coverdir = val continue if opt == "-s" or opt == "--summary": summary = 1 continue if opt == "--ignore-module": ignore_modules.append(val) continue if opt == "--ignore-dir": for s in string.split(val, os.pathsep): s = os.path.expandvars(s) # should I also call expanduser? (after all, could use $HOME) s = string.replace(s, "$prefix", os.path.join(sys.prefix, "lib", "python" + sys.version[:3])) s = string.replace(s, "$exec_prefix", os.path.join(sys.exec_prefix, "lib", "python" + sys.version[:3])) s = os.path.normpath(s) ignore_dirs.append(s) continue assert 0, "Should never get here" if len(prog_argv) == 0: _err_exit("missing name of file to run") if count + trace + report > 1: _err_exit("can only specify one of --trace, --count or --report") if count + trace + report == 0: _err_exit("must specify one of --trace, --count or --report") if report and counts_file is None: _err_exit("--report requires a --file") if report and no_report: _err_exit("cannot specify both --report and --no-report") if logdir is not None: # warn if the directory doesn't exist, but keep on going # (is this the correct behaviour?) if not os.path.isdir(logdir): sys.stderr.write( "trace: WARNING, --logdir directory %s is not available\n" % `logdir`) sys.argv = prog_argv progname = prog_argv[0] if eval(sys.version[:3])>1.3: sys.path[0] = os.path.split(progname)[0] # ??? # everything is ready ignore = Ignore(ignore_modules, ignore_dirs) if trace: t = Trace(ignore) try: run(t.trace, 'execfile(' + `progname` + ')') except IOError, err: _err_exit("Cannot run file %s because: %s" % \ (`sys.argv[0]`, err)) elif count: t = Coverage(ignore) try: run(t.trace, 'execfile(' + `progname` + ')') except IOError, err: _err_exit("Cannot run file %s because: %s" % \ (`sys.argv[0]`, err)) except SystemExit: pass results = t.results() # Add another lookup from the program's file name to its import name # This give the right results, but I'm not sure why ... results.modules[progname] = os.path.splitext(progname)[0] if counts_file: # add in archived data, if available try: old_counts, old_modules = marshal.load(open(counts_file, 'rb')) except IOError: pass else: results.update(CoverageResults(old_counts, old_modules)) if not no_report: create_results_log(results, logdir, missing, summary=summary, coverdir=coverdir) if counts_file: try: marshal.dump( (results.counts, results.modules), open(counts_file, 'wb')) except IOError, err: _err_exit("Cannot save counts file %s because: %s" % \ (`counts_file`, err)) elif report: old_counts, old_modules = marshal.load(open(counts_file, 'rb')) results = CoverageResults(old_counts, old_modules) create_results_log(results, logdir, missing, summary=summary, coverdir=coverdir) else: assert 0, "Should never get here" | 8fb89f9fd74a61e165437eec10be9ace4c3738cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8fb89f9fd74a61e165437eec10be9ace4c3738cb/trace.py |
results.modules[progname] = os.path.splitext(progname)[0] if counts_file: try: old_counts, old_modules = marshal.load(open(counts_file, 'rb')) except IOError: pass else: results.update(CoverageResults(old_counts, old_modules)) | def main(argv = None): import getopt if argv is None: argv = sys.argv try: opts, prog_argv = getopt.getopt(argv[1:], "tcrRf:d:msC:", ["help", "version", "trace", "count", "report", "no-report", "file=", "logdir=", "missing", "ignore-module=", "ignore-dir=", "coverdir="]) except getopt.error, msg: print >> sys.stderr, "%s: %s" % (sys.argv[0], msg) print >> sys.stderr, "Try `%s --help' for more information" \ % sys.argv[0] sys.exit(1) trace = 0 count = 0 report = 0 no_report = 0 counts_file = None logdir = "." missing = 0 ignore_modules = [] ignore_dirs = [] coverdir = None summary = 0 for opt, val in opts: if opt == "--help": usage(sys.stdout) sys.exit(0) if opt == "--version": sys.stdout.write("trace 2.0\n") sys.exit(0) if opt == "-t" or opt == "--trace": trace = 1 continue if opt == "-c" or opt == "--count": count = 1 continue if opt == "-r" or opt == "--report": report = 1 continue if opt == "-R" or opt == "--no-report": no_report = 1 continue if opt == "-f" or opt == "--file": counts_file = val continue if opt == "-d" or opt == "--logdir": logdir = val continue if opt == "-m" or opt == "--missing": missing = 1 continue if opt == "-C" or opt == "--coverdir": coverdir = val continue if opt == "-s" or opt == "--summary": summary = 1 continue if opt == "--ignore-module": ignore_modules.append(val) continue if opt == "--ignore-dir": for s in string.split(val, os.pathsep): s = os.path.expandvars(s) # should I also call expanduser? (after all, could use $HOME) s = string.replace(s, "$prefix", os.path.join(sys.prefix, "lib", "python" + sys.version[:3])) s = string.replace(s, "$exec_prefix", os.path.join(sys.exec_prefix, "lib", "python" + sys.version[:3])) s = os.path.normpath(s) ignore_dirs.append(s) continue assert 0, "Should never get here" if len(prog_argv) == 0: _err_exit("missing name of file to run") if count + trace + report > 1: _err_exit("can only specify one of --trace, --count or --report") if count + trace + report == 0: _err_exit("must specify one of --trace, --count or --report") if report and counts_file is None: _err_exit("--report requires a --file") if report and no_report: _err_exit("cannot specify both --report and --no-report") if logdir is not None: # warn if the directory doesn't exist, but keep on going # (is this the correct behaviour?) if not os.path.isdir(logdir): sys.stderr.write( "trace: WARNING, --logdir directory %s is not available\n" % `logdir`) sys.argv = prog_argv progname = prog_argv[0] if eval(sys.version[:3])>1.3: sys.path[0] = os.path.split(progname)[0] # ??? # everything is ready ignore = Ignore(ignore_modules, ignore_dirs) if trace: t = Trace(ignore) try: run(t.trace, 'execfile(' + `progname` + ')') except IOError, err: _err_exit("Cannot run file %s because: %s" % \ (`sys.argv[0]`, err)) elif count: t = Coverage(ignore) try: run(t.trace, 'execfile(' + `progname` + ')') except IOError, err: _err_exit("Cannot run file %s because: %s" % \ (`sys.argv[0]`, err)) except SystemExit: pass results = t.results() # Add another lookup from the program's file name to its import name # This give the right results, but I'm not sure why ... results.modules[progname] = os.path.splitext(progname)[0] if counts_file: # add in archived data, if available try: old_counts, old_modules = marshal.load(open(counts_file, 'rb')) except IOError: pass else: results.update(CoverageResults(old_counts, old_modules)) if not no_report: create_results_log(results, logdir, missing, summary=summary, coverdir=coverdir) if counts_file: try: marshal.dump( (results.counts, results.modules), open(counts_file, 'wb')) except IOError, err: _err_exit("Cannot save counts file %s because: %s" % \ (`counts_file`, err)) elif report: old_counts, old_modules = marshal.load(open(counts_file, 'rb')) results = CoverageResults(old_counts, old_modules) create_results_log(results, logdir, missing, summary=summary, coverdir=coverdir) else: assert 0, "Should never get here" | 8fb89f9fd74a61e165437eec10be9ace4c3738cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8fb89f9fd74a61e165437eec10be9ace4c3738cb/trace.py |
|
create_results_log(results, logdir, missing, summary=summary, coverdir=coverdir) if counts_file: try: marshal.dump( (results.counts, results.modules), open(counts_file, 'wb')) except IOError, err: _err_exit("Cannot save counts file %s because: %s" % \ (`counts_file`, err)) elif report: old_counts, old_modules = marshal.load(open(counts_file, 'rb')) results = CoverageResults(old_counts, old_modules) create_results_log(results, logdir, missing, summary=summary, coverdir=coverdir) else: assert 0, "Should never get here" | results.write_results(missing, summary=summary, coverdir=coverdir) | def main(argv = None): import getopt if argv is None: argv = sys.argv try: opts, prog_argv = getopt.getopt(argv[1:], "tcrRf:d:msC:", ["help", "version", "trace", "count", "report", "no-report", "file=", "logdir=", "missing", "ignore-module=", "ignore-dir=", "coverdir="]) except getopt.error, msg: print >> sys.stderr, "%s: %s" % (sys.argv[0], msg) print >> sys.stderr, "Try `%s --help' for more information" \ % sys.argv[0] sys.exit(1) trace = 0 count = 0 report = 0 no_report = 0 counts_file = None logdir = "." missing = 0 ignore_modules = [] ignore_dirs = [] coverdir = None summary = 0 for opt, val in opts: if opt == "--help": usage(sys.stdout) sys.exit(0) if opt == "--version": sys.stdout.write("trace 2.0\n") sys.exit(0) if opt == "-t" or opt == "--trace": trace = 1 continue if opt == "-c" or opt == "--count": count = 1 continue if opt == "-r" or opt == "--report": report = 1 continue if opt == "-R" or opt == "--no-report": no_report = 1 continue if opt == "-f" or opt == "--file": counts_file = val continue if opt == "-d" or opt == "--logdir": logdir = val continue if opt == "-m" or opt == "--missing": missing = 1 continue if opt == "-C" or opt == "--coverdir": coverdir = val continue if opt == "-s" or opt == "--summary": summary = 1 continue if opt == "--ignore-module": ignore_modules.append(val) continue if opt == "--ignore-dir": for s in string.split(val, os.pathsep): s = os.path.expandvars(s) # should I also call expanduser? (after all, could use $HOME) s = string.replace(s, "$prefix", os.path.join(sys.prefix, "lib", "python" + sys.version[:3])) s = string.replace(s, "$exec_prefix", os.path.join(sys.exec_prefix, "lib", "python" + sys.version[:3])) s = os.path.normpath(s) ignore_dirs.append(s) continue assert 0, "Should never get here" if len(prog_argv) == 0: _err_exit("missing name of file to run") if count + trace + report > 1: _err_exit("can only specify one of --trace, --count or --report") if count + trace + report == 0: _err_exit("must specify one of --trace, --count or --report") if report and counts_file is None: _err_exit("--report requires a --file") if report and no_report: _err_exit("cannot specify both --report and --no-report") if logdir is not None: # warn if the directory doesn't exist, but keep on going # (is this the correct behaviour?) if not os.path.isdir(logdir): sys.stderr.write( "trace: WARNING, --logdir directory %s is not available\n" % `logdir`) sys.argv = prog_argv progname = prog_argv[0] if eval(sys.version[:3])>1.3: sys.path[0] = os.path.split(progname)[0] # ??? # everything is ready ignore = Ignore(ignore_modules, ignore_dirs) if trace: t = Trace(ignore) try: run(t.trace, 'execfile(' + `progname` + ')') except IOError, err: _err_exit("Cannot run file %s because: %s" % \ (`sys.argv[0]`, err)) elif count: t = Coverage(ignore) try: run(t.trace, 'execfile(' + `progname` + ')') except IOError, err: _err_exit("Cannot run file %s because: %s" % \ (`sys.argv[0]`, err)) except SystemExit: pass results = t.results() # Add another lookup from the program's file name to its import name # This give the right results, but I'm not sure why ... results.modules[progname] = os.path.splitext(progname)[0] if counts_file: # add in archived data, if available try: old_counts, old_modules = marshal.load(open(counts_file, 'rb')) except IOError: pass else: results.update(CoverageResults(old_counts, old_modules)) if not no_report: create_results_log(results, logdir, missing, summary=summary, coverdir=coverdir) if counts_file: try: marshal.dump( (results.counts, results.modules), open(counts_file, 'wb')) except IOError, err: _err_exit("Cannot save counts file %s because: %s" % \ (`counts_file`, err)) elif report: old_counts, old_modules = marshal.load(open(counts_file, 'rb')) results = CoverageResults(old_counts, old_modules) create_results_log(results, logdir, missing, summary=summary, coverdir=coverdir) else: assert 0, "Should never get here" | 8fb89f9fd74a61e165437eec10be9ace4c3738cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8fb89f9fd74a61e165437eec10be9ace4c3738cb/trace.py |
fp.write("%s = %s\n" % (key, value)) | fp.write("%s = %s\n" % (key, str(value).replace('\n', '\n\t'))) | def write(self, fp): """Write an .ini-format representation of the configuration state.""" if self.__defaults: fp.write("[DEFAULT]\n") for (key, value) in self.__defaults.items(): fp.write("%s = %s\n" % (key, value)) fp.write("\n") for section in self.sections(): fp.write("[" + section + "]\n") sectdict = self.__sections[section] for (key, value) in sectdict.items(): if key == "__name__": continue fp.write("%s = %s\n" % (key, value)) fp.write("\n") | 63a6f820451f75d73870412cafb71a9d4ad3f8b2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/63a6f820451f75d73870412cafb71a9d4ad3f8b2/ConfigParser.py |
fp.write("%s = %s\n" % (key, value)) | fp.write("%s = %s\n" % (key, str(value).replace('\n', '\n\t'))) | def write(self, fp): """Write an .ini-format representation of the configuration state.""" if self.__defaults: fp.write("[DEFAULT]\n") for (key, value) in self.__defaults.items(): fp.write("%s = %s\n" % (key, value)) fp.write("\n") for section in self.sections(): fp.write("[" + section + "]\n") sectdict = self.__sections[section] for (key, value) in sectdict.items(): if key == "__name__": continue fp.write("%s = %s\n" % (key, value)) fp.write("\n") | 63a6f820451f75d73870412cafb71a9d4ad3f8b2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/63a6f820451f75d73870412cafb71a9d4ad3f8b2/ConfigParser.py |
def group(i): | def group(self, i): | def group(i): | a20887644445cc7d064bf0f95ef220871a563326 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a20887644445cc7d064bf0f95ef220871a563326/re.py |
def assemble_set(self, position, labels): | def assemble(self, position, labels): | def assemble_set(self, position, labels): | a20887644445cc7d064bf0f95ef220871a563326 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a20887644445cc7d064bf0f95ef220871a563326/re.py |
if c in self.set[2]: | if c in self.set: | def assemble_set(self, position, labels): | a20887644445cc7d064bf0f95ef220871a563326 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a20887644445cc7d064bf0f95ef220871a563326/re.py |
result = result + `char` | result = result + char | def __repr__(self): | a20887644445cc7d064bf0f95ef220871a563326 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a20887644445cc7d064bf0f95ef220871a563326/re.py |
if stack[-1][0][1] > 0: | if stack[-1][0].register > 0: | def compile(pattern, flags=0): stack = [] index = 0 label = 0 register = 1 groupindex = {} callouts = [] while (index < len(pattern)): char = pattern[index] index = index + 1 if char == '\\': if index < len(pattern): next = pattern[index] index = index + 1 if next == 't': stack.append([Exact(chr(9))]) elif next == 'n': stack.append([Exact(chr(10))]) elif next == 'r': stack.append([Exact(chr(13))]) elif next == 'f': stack.append([Exact(chr(12))]) elif next == 'a': stack.append([Exact(chr(7))]) elif next == 'e': stack.append([Exact(chr(27))]) elif next in '0123456789': value = next while (index < len(pattern)) and \ (pattern[index] in string.digits): value = value + pattern[index] index = index + 1 if (len(value) == 3) or \ ((len(value) == 2) and (value[0] == '0')): value = string.atoi(value, 8) if value > 255: raise error, 'octal char out of range' stack.append([Exact(chr(value))]) elif value == '0': stack.append([Exact(chr(0))]) elif len(value) > 3: raise error, 'too many digits' else: value = string.atoi(value) if value >= register: raise error, ('cannot reference a register ' 'not yet used') elif value == 0: raise error, ('register 0 cannot be used ' 'during match') stack.append([MatchMemory(value)]) elif next == 'x': value = '' while (index < len(pattern)) and \ (pattern[index] in string.hexdigits): value = value + pattern[index] index = index + 1 value = string.atoi(value, 16) if value > 255: raise error, 'hex char out of range' stack.append([Exact(chr(value))]) elif next == 'c': if index >= len(pattern): raise error, '\\c at end of re' elif pattern[index] in 'abcdefghijklmnopqrstuvwxyz': stack.append(Exact(chr(ord(pattern[index]) - ord('a') + 1))) else: stack.append(Exact(chr(ord(pattern[index]) ^ 64))) index = index + 1 elif next == 'A': stack.append([BegBuf()]) elif next == 'Z': stack.append([EndBuf()]) elif next == 'b': stack.append([WordBound()]) elif next == 'B': stack.append([NotWordBound()]) elif next == 'w': stack.append([SyntaxSpec('word')]) elif next == 'W': stack.append([NotSyntaxSpec('word')]) elif next == 's': stack.append([SyntaxSpec('whitespace')]) elif next == 'S': stack.append([NotSyntaxSpec('whitespace')]) elif next == 'd': stack.append([SyntaxSpec('digit')]) elif next == 'D': stack.append([NotSyntaxSpec('digit')]) elif next in 'GluLUQE': # some perl-isms that we don't support raise error, '\\' + next + ' not supported' else: stack.append([Exact(pattern[index])]) else: raise error, 'backslash at the end of a string' elif char == '|': if len(stack) == 0: raise error, 'nothing to alternate' expr = [] while (len(stack) != 0) and \ (stack[-1][0].name != '(') and \ (stack[-1][0].name != '|'): expr = stack[-1] + expr del stack[-1] stack.append([FailureJump(label)] + \ expr + \ [Jump(-1), Label(label)]) stack.append([('|',)]) label = label + 1 elif char == '(': if index >= len(pattern): raise error, 'no matching close paren' elif pattern[index] == '?': # Perl style (?...) extensions index = index + 1 if index >= len(pattern): raise error, 'extension ends prematurely' elif pattern[index] == 'P': # Python extensions index = index + 1 if index >= len(pattern): raise error, 'extension ends prematurely' elif pattern[index] == '<': # Handle Python symbolic group names (?<...>...) index = index + 1 end = string.find(pattern, '>', index) if end == -1: raise error, 'no end to symbolic group name' name = pattern[index:end] # XXX check syntax of name index = end + 1 groupindex[name] = register stack.append([OpenParen(register)]) register = register + 1 elif pattern[index] == '=': # backreference to symbolic group name if index >= len(pattern): raise error, '(?P= at the end of the pattern' start = index + 1 end = string.find(pattern, ')', start) if end == -1: raise error, 'no ) to end symbolic group name' name = pattern[start:end] if name not in groupindex: raise error, ('symbolic group name ' + name + \ ' has not been used yet') stack.append([MatchMemory(groupindex[name])]) index = end + 1 elif pattern[index] == '!': # function callout if index >= len(pattern): raise error, 'no function callout name' start = index + 1 end = string.find(pattern, ')', start) if end == -1: raise error, 'no ) to end function callout name' name = pattern[start:end] if name not in callouts: raise error, ('function callout name not listed ' 'in callouts dict') stack.append([FunctionCallout(name)]) else: raise error, 'unknown Python extension' elif pattern[index] == ':': # grouping, but no registers index = index + 1 stack.append([('(', -1)]) elif pattern[index] == '#': # comment index = index + 1 end = string.find(pattern, ')', index) if end == -1: raise error, 'no end to comment' index = end + 1 elif pattern[index] == '=': raise error, ('zero-width positive lookahead ' 'assertion is unsupported') elif pattern[index] == '!': raise error, ('zero-width negative lookahead ' 'assertion is unsupported') elif pattern[index] in 'iImMsSxX': while (index < len(pattern)) and (pattern[index] != ')'): if pattern[index] == 'iI': flags = flags | IGNORECASE elif pattern[index] == 'mM': flags = flags | MULTILINE elif pattern[index] == 'sS': flags = flags | DOTALL elif pattern[index] in 'xX': flags = flags | VERBOSE else: raise error, 'unknown flag' index = index + 1 index = index + 1 else: raise error, 'unknown extension' else: stack.append([OpenParen(register)]) register = register + 1 elif char == ')': # make one expression out of everything on the stack up to # the marker left by the last parenthesis expr = [] while (len(stack) > 0) and (stack[-1][0].name != '('): expr = stack[-1] + expr del stack[-1] if len(stack) == 0: raise error, 'too many close parens' if len(expr) == 0: raise error, 'nothing inside parens' # check to see if alternation used correctly if (expr[-1].name == '|'): raise error, 'alternation with nothing on the right' # remove markers left by alternation expr = filter(lambda x: x.name != '|', expr) # clean up jumps inserted by alternation need_label = 0 for i in range(len(expr)): if (expr[i].name == 'jump') and (expr[i].label == -1): expr[i] = JumpOpcode(label) need_label = 1 if need_label: expr.append(Label(label)) label = label + 1 if stack[-1][0][1] > 0: expr = [StartMemory(stack[-1][0].register)] + \ expr + \ [EndMemory(stack[-1][0].register)] del stack[-1] stack.append(expr) elif char == '{': if len(stack) == 0: raise error, 'no expression to repeat' end = string.find(pattern, '}', index) if end == -1: raise error, ('no close curly bracket to match' ' open curly bracket') fields = map(string.strip, string.split(pattern[index:end], ',')) index = end + 1 minimal = 0 if (index < len(pattern)) and (pattern[index] == '?'): minimal = 1 index = index + 1 if len(fields) == 1: # {n} or {n}? (there's really no difference) try: count = string.atoi(fields[0]) except ValueError: raise error, ('count must be an integer ' 'inside curly braces') if count > 65535: raise error, 'repeat count out of range' expr = [] while count > 0: expr = expr + stack[-1] count = count - 1 del stack[-1] stack.append(expr) elif len(fields) == 2: # {n,} or {n,m} if fields[1] == '': # {n,} try: min = string.atoi(fields[0]) except ValueError: raise error, ('minimum must be an integer ' 'inside curly braces') if min > 65535: raise error, 'minimum repeat count out of range' expr = [] while min > 0: expr = expr + stack[-1] min = min - 1 registers = registers_used(stack[-1]) if minimal: expr = expr + \ ([Jump(label + 1), Label(label)] + \ stack[-1] + \ [Label(label + 1), FailureJump(label, registers)]) else: expr = expr + \ ([Label(label), FailureJump(label + 1, registers)] + stack[-1] + [StarJump(label), Label(label + 1)]) del stack[-1] stack.append(expr) label = label + 2 else: # {n,m} try: min = string.atoi(fields[0]) except ValueError: raise error, ('minimum must be an integer ' 'inside curly braces') try: max = string.atoi(fields[1]) except ValueError: raise error, ('maximum must be an integer ' 'inside curly braces') if min > 65535: raise error, ('minumim repeat count out ' 'of range') if max > 65535: raise error, ('maximum repeat count out ' 'of range') if min > max: raise error, ('minimum repeat count must be ' 'less than the maximum ' 'repeat count') expr = [] while min > 0: expr = expr + stack[-1] min = min - 1 max = max - 1 if minimal: while max > 0: expr = expr + \ [FailureJump(label), Jump(label + 1), Label(label)] + \ stack[-1] + \ [Label(label + 1)] label = label + 2 del stack[-1] stack.append(expr) else: while max > 0: expr = expr + \ [FailureJump(label)] + \ stack[-1] max = max - 1 del stack[-1] stack.append(expr + [Label(label)]) label = label + 1 else: raise error, ('there need to be one or two fields ' 'in a {} expression') index = end + 1 elif char == '}': raise error, 'unbalanced close curly brace' elif char == '*': # Kleene closure if len(stack) == 0: raise error, 'the Kleene closure needs something to repeat' registers = registers_used(stack[-1]) if (index < len(pattern)) and (pattern[index] == '?'): # non-greedy matching expr = [JumpInstructions(label + 1), Label(label)] + \ stack[-1] + \ [Label(label + 1), FailureJump(label)] index = index + 1 else: # greedy matching expr = [Label(label), FailureJump(label + 1)] + \ stack[-1] + \ [StarJump(label), Label(label + 1)] del stack[-1] stack.append(expr) label = label + 2 elif char == '+': # positive closure if len(stack) == 0: raise error, 'the positive closure needs something to repeat' registers = registers_used(stack[-1]) if (index < len(pattern)) and (pattern[index] == '?'): # non-greedy expr = [Label(label)] + \ stack[-1] + \ [FailureJump(label)] label = label + 1 index = index + 1 else: # greedy expr = [DummyFailureJump(label + 1), Label(label), FailureJump(label + 2), Label(label + 1)] + \ stack[-1] + \ [StarJump(label), Label(label + 2)] label = label + 3 del stack[-1] stack.append(expr) elif char == '?': if len(stack) == 0: raise error, 'need something to be optional' registers = registers_used(stack[-1]) if (index < len(pattern)) and (pattern[index] == '?'): # non-greedy matching expr = [FailureJump(label), Jump(label + 1), Label(label)] + \ stack[-1] + \ [Label(label + 1)] label = label + 2 index = index + 1 else: # greedy matching expr = [FailureJump(label)] + \ stack[-1] + \ [Label(label)] label = label + 1 del stack[-1] stack.append(expr) elif char == '.': if flags & DOTALL: stack.append(Set(map(chr, range(256)))) else: stack.append([AnyChar()]) elif char == '^': if flags & MULTILINE: stack.append([Bol()]) else: stack.append([BegBuf()]) elif char == '$': if flags & MULTILINE: stack.append([Eol()]) else: stack.append([EndBuf()]) elif char == '#': if flags & VERBOSE: # comment index = index + 1 end = string.find(pattern, '\n', index) if end == -1: index = len(pattern) else: index = end + 1 else: stack.append([Exact(char)]) elif char in string.whitespace: if flags & VERBOSE: stack.append([Exact(char)]) elif char == '[': if index >= len(pattern): raise error, 'incomplete set' negate = 0 last = '' set = [] if pattern[index] == '^': negate = 1 index = index + 1 if index >= len(pattern): raise error, 'incomplete set' if pattern[index] in ']-': set.append(pattern[index]) last = pattern[index] index = index + 1 while (index < len(pattern)) and (pattern[index] != ']'): next = pattern[index] index = index + 1 if next == '-': if (index >= len(pattern)) or (pattern[index] == ']'): raise error, 'incomplete range in set' if last > pattern[index]: raise error, 'range arguments out of order in set' for next in map(chr, \ range(ord(last), \ ord(pattern[index]) + 1)): if next not in set: set.append(next) last = '' index = index + 1 elif next == '\\': # expand syntax meta-characters and add to set if index >= len(pattern): raise error, 'incomplete set' elif (pattern[index] == ']'): raise error, 'backslash at the end of a set' elif pattern[index] == 'w': for next in syntax_table.keys(): if 'word' in syntax_table[next]: set.append(next) elif pattern[index] == 'W': for next in syntax_table.keys(): if 'word' not in syntax_table[next]: set.append(next) elif pattern[index] == 'd': for next in syntax_table.keys(): if 'digit' in syntax_table[next]: set.append(next) elif pattern[index] == 'D': for next in syntax_table.keys(): if 'digit' not in syntax_table[next]: set.append(next) elif pattern[index] == 's': for next in syntax_table.keys(): if 'whitespace' in syntax_table[next]: set.append(next) elif pattern[index] == 'S': for next in syntax_table.keys(): if 'whitespace' not in syntax_table[next]: set.append(next) else: raise error, 'unknown meta in set' last = '' index = index + 1 else: if next not in set: set.append(next) last = next if pattern[index] != ']': raise error, 'incomplete set' index = index + 1 if negate: notset = [] for char in map(chr, range(256)): if char not in set: notset.append(char) stack.append([Set(notset)]) else: stack.append([Set(set)]) else: stack.append([Exact(char)]) code = [] while len(stack) > 0: if stack[-1][0].name == '(': raise error, 'too many open parens' code = stack[-1] + code del stack[-1] if len(code) == 0: raise error, 'no code generated' if (code[-1].name == '|'): raise error, 'alternation with nothing on the right' code = filter(lambda x: x.name != '|', code) need_label = 0 for i in range(len(code)): if (code[i].name == 'jump') and (code[i].label == -1): code[i] = Jump(label) need_label = 1 if need_label: code.append(Label(label)) label = label + 1 code.append(End()) return RegexObject(pattern, flags, code, register, groupindex, callouts) | a20887644445cc7d064bf0f95ef220871a563326 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a20887644445cc7d064bf0f95ef220871a563326/re.py |
def compile(pattern, flags=0): stack = [] index = 0 label = 0 register = 1 groupindex = {} callouts = [] while (index < len(pattern)): char = pattern[index] index = index + 1 if char == '\\': if index < len(pattern): next = pattern[index] index = index + 1 if next == 't': stack.append([Exact(chr(9))]) elif next == 'n': stack.append([Exact(chr(10))]) elif next == 'r': stack.append([Exact(chr(13))]) elif next == 'f': stack.append([Exact(chr(12))]) elif next == 'a': stack.append([Exact(chr(7))]) elif next == 'e': stack.append([Exact(chr(27))]) elif next in '0123456789': value = next while (index < len(pattern)) and \ (pattern[index] in string.digits): value = value + pattern[index] index = index + 1 if (len(value) == 3) or \ ((len(value) == 2) and (value[0] == '0')): value = string.atoi(value, 8) if value > 255: raise error, 'octal char out of range' stack.append([Exact(chr(value))]) elif value == '0': stack.append([Exact(chr(0))]) elif len(value) > 3: raise error, 'too many digits' else: value = string.atoi(value) if value >= register: raise error, ('cannot reference a register ' 'not yet used') elif value == 0: raise error, ('register 0 cannot be used ' 'during match') stack.append([MatchMemory(value)]) elif next == 'x': value = '' while (index < len(pattern)) and \ (pattern[index] in string.hexdigits): value = value + pattern[index] index = index + 1 value = string.atoi(value, 16) if value > 255: raise error, 'hex char out of range' stack.append([Exact(chr(value))]) elif next == 'c': if index >= len(pattern): raise error, '\\c at end of re' elif pattern[index] in 'abcdefghijklmnopqrstuvwxyz': stack.append(Exact(chr(ord(pattern[index]) - ord('a') + 1))) else: stack.append(Exact(chr(ord(pattern[index]) ^ 64))) index = index + 1 elif next == 'A': stack.append([BegBuf()]) elif next == 'Z': stack.append([EndBuf()]) elif next == 'b': stack.append([WordBound()]) elif next == 'B': stack.append([NotWordBound()]) elif next == 'w': stack.append([SyntaxSpec('word')]) elif next == 'W': stack.append([NotSyntaxSpec('word')]) elif next == 's': stack.append([SyntaxSpec('whitespace')]) elif next == 'S': stack.append([NotSyntaxSpec('whitespace')]) elif next == 'd': stack.append([SyntaxSpec('digit')]) elif next == 'D': stack.append([NotSyntaxSpec('digit')]) elif next in 'GluLUQE': # some perl-isms that we don't support raise error, '\\' + next + ' not supported' else: stack.append([Exact(pattern[index])]) else: raise error, 'backslash at the end of a string' elif char == '|': if len(stack) == 0: raise error, 'nothing to alternate' expr = [] while (len(stack) != 0) and \ (stack[-1][0].name != '(') and \ (stack[-1][0].name != '|'): expr = stack[-1] + expr del stack[-1] stack.append([FailureJump(label)] + \ expr + \ [Jump(-1), Label(label)]) stack.append([('|',)]) label = label + 1 elif char == '(': if index >= len(pattern): raise error, 'no matching close paren' elif pattern[index] == '?': # Perl style (?...) extensions index = index + 1 if index >= len(pattern): raise error, 'extension ends prematurely' elif pattern[index] == 'P': # Python extensions index = index + 1 if index >= len(pattern): raise error, 'extension ends prematurely' elif pattern[index] == '<': # Handle Python symbolic group names (?<...>...) index = index + 1 end = string.find(pattern, '>', index) if end == -1: raise error, 'no end to symbolic group name' name = pattern[index:end] # XXX check syntax of name index = end + 1 groupindex[name] = register stack.append([OpenParen(register)]) register = register + 1 elif pattern[index] == '=': # backreference to symbolic group name if index >= len(pattern): raise error, '(?P= at the end of the pattern' start = index + 1 end = string.find(pattern, ')', start) if end == -1: raise error, 'no ) to end symbolic group name' name = pattern[start:end] if name not in groupindex: raise error, ('symbolic group name ' + name + \ ' has not been used yet') stack.append([MatchMemory(groupindex[name])]) index = end + 1 elif pattern[index] == '!': # function callout if index >= len(pattern): raise error, 'no function callout name' start = index + 1 end = string.find(pattern, ')', start) if end == -1: raise error, 'no ) to end function callout name' name = pattern[start:end] if name not in callouts: raise error, ('function callout name not listed ' 'in callouts dict') stack.append([FunctionCallout(name)]) else: raise error, 'unknown Python extension' elif pattern[index] == ':': # grouping, but no registers index = index + 1 stack.append([('(', -1)]) elif pattern[index] == '#': # comment index = index + 1 end = string.find(pattern, ')', index) if end == -1: raise error, 'no end to comment' index = end + 1 elif pattern[index] == '=': raise error, ('zero-width positive lookahead ' 'assertion is unsupported') elif pattern[index] == '!': raise error, ('zero-width negative lookahead ' 'assertion is unsupported') elif pattern[index] in 'iImMsSxX': while (index < len(pattern)) and (pattern[index] != ')'): if pattern[index] == 'iI': flags = flags | IGNORECASE elif pattern[index] == 'mM': flags = flags | MULTILINE elif pattern[index] == 'sS': flags = flags | DOTALL elif pattern[index] in 'xX': flags = flags | VERBOSE else: raise error, 'unknown flag' index = index + 1 index = index + 1 else: raise error, 'unknown extension' else: stack.append([OpenParen(register)]) register = register + 1 elif char == ')': # make one expression out of everything on the stack up to # the marker left by the last parenthesis expr = [] while (len(stack) > 0) and (stack[-1][0].name != '('): expr = stack[-1] + expr del stack[-1] if len(stack) == 0: raise error, 'too many close parens' if len(expr) == 0: raise error, 'nothing inside parens' # check to see if alternation used correctly if (expr[-1].name == '|'): raise error, 'alternation with nothing on the right' # remove markers left by alternation expr = filter(lambda x: x.name != '|', expr) # clean up jumps inserted by alternation need_label = 0 for i in range(len(expr)): if (expr[i].name == 'jump') and (expr[i].label == -1): expr[i] = JumpOpcode(label) need_label = 1 if need_label: expr.append(Label(label)) label = label + 1 if stack[-1][0][1] > 0: expr = [StartMemory(stack[-1][0].register)] + \ expr + \ [EndMemory(stack[-1][0].register)] del stack[-1] stack.append(expr) elif char == '{': if len(stack) == 0: raise error, 'no expression to repeat' end = string.find(pattern, '}', index) if end == -1: raise error, ('no close curly bracket to match' ' open curly bracket') fields = map(string.strip, string.split(pattern[index:end], ',')) index = end + 1 minimal = 0 if (index < len(pattern)) and (pattern[index] == '?'): minimal = 1 index = index + 1 if len(fields) == 1: # {n} or {n}? (there's really no difference) try: count = string.atoi(fields[0]) except ValueError: raise error, ('count must be an integer ' 'inside curly braces') if count > 65535: raise error, 'repeat count out of range' expr = [] while count > 0: expr = expr + stack[-1] count = count - 1 del stack[-1] stack.append(expr) elif len(fields) == 2: # {n,} or {n,m} if fields[1] == '': # {n,} try: min = string.atoi(fields[0]) except ValueError: raise error, ('minimum must be an integer ' 'inside curly braces') if min > 65535: raise error, 'minimum repeat count out of range' expr = [] while min > 0: expr = expr + stack[-1] min = min - 1 registers = registers_used(stack[-1]) if minimal: expr = expr + \ ([Jump(label + 1), Label(label)] + \ stack[-1] + \ [Label(label + 1), FailureJump(label, registers)]) else: expr = expr + \ ([Label(label), FailureJump(label + 1, registers)] + stack[-1] + [StarJump(label), Label(label + 1)]) del stack[-1] stack.append(expr) label = label + 2 else: # {n,m} try: min = string.atoi(fields[0]) except ValueError: raise error, ('minimum must be an integer ' 'inside curly braces') try: max = string.atoi(fields[1]) except ValueError: raise error, ('maximum must be an integer ' 'inside curly braces') if min > 65535: raise error, ('minumim repeat count out ' 'of range') if max > 65535: raise error, ('maximum repeat count out ' 'of range') if min > max: raise error, ('minimum repeat count must be ' 'less than the maximum ' 'repeat count') expr = [] while min > 0: expr = expr + stack[-1] min = min - 1 max = max - 1 if minimal: while max > 0: expr = expr + \ [FailureJump(label), Jump(label + 1), Label(label)] + \ stack[-1] + \ [Label(label + 1)] label = label + 2 del stack[-1] stack.append(expr) else: while max > 0: expr = expr + \ [FailureJump(label)] + \ stack[-1] max = max - 1 del stack[-1] stack.append(expr + [Label(label)]) label = label + 1 else: raise error, ('there need to be one or two fields ' 'in a {} expression') index = end + 1 elif char == '}': raise error, 'unbalanced close curly brace' elif char == '*': # Kleene closure if len(stack) == 0: raise error, 'the Kleene closure needs something to repeat' registers = registers_used(stack[-1]) if (index < len(pattern)) and (pattern[index] == '?'): # non-greedy matching expr = [JumpInstructions(label + 1), Label(label)] + \ stack[-1] + \ [Label(label + 1), FailureJump(label)] index = index + 1 else: # greedy matching expr = [Label(label), FailureJump(label + 1)] + \ stack[-1] + \ [StarJump(label), Label(label + 1)] del stack[-1] stack.append(expr) label = label + 2 elif char == '+': # positive closure if len(stack) == 0: raise error, 'the positive closure needs something to repeat' registers = registers_used(stack[-1]) if (index < len(pattern)) and (pattern[index] == '?'): # non-greedy expr = [Label(label)] + \ stack[-1] + \ [FailureJump(label)] label = label + 1 index = index + 1 else: # greedy expr = [DummyFailureJump(label + 1), Label(label), FailureJump(label + 2), Label(label + 1)] + \ stack[-1] + \ [StarJump(label), Label(label + 2)] label = label + 3 del stack[-1] stack.append(expr) elif char == '?': if len(stack) == 0: raise error, 'need something to be optional' registers = registers_used(stack[-1]) if (index < len(pattern)) and (pattern[index] == '?'): # non-greedy matching expr = [FailureJump(label), Jump(label + 1), Label(label)] + \ stack[-1] + \ [Label(label + 1)] label = label + 2 index = index + 1 else: # greedy matching expr = [FailureJump(label)] + \ stack[-1] + \ [Label(label)] label = label + 1 del stack[-1] stack.append(expr) elif char == '.': if flags & DOTALL: stack.append(Set(map(chr, range(256)))) else: stack.append([AnyChar()]) elif char == '^': if flags & MULTILINE: stack.append([Bol()]) else: stack.append([BegBuf()]) elif char == '$': if flags & MULTILINE: stack.append([Eol()]) else: stack.append([EndBuf()]) elif char == '#': if flags & VERBOSE: # comment index = index + 1 end = string.find(pattern, '\n', index) if end == -1: index = len(pattern) else: index = end + 1 else: stack.append([Exact(char)]) elif char in string.whitespace: if flags & VERBOSE: stack.append([Exact(char)]) elif char == '[': if index >= len(pattern): raise error, 'incomplete set' negate = 0 last = '' set = [] if pattern[index] == '^': negate = 1 index = index + 1 if index >= len(pattern): raise error, 'incomplete set' if pattern[index] in ']-': set.append(pattern[index]) last = pattern[index] index = index + 1 while (index < len(pattern)) and (pattern[index] != ']'): next = pattern[index] index = index + 1 if next == '-': if (index >= len(pattern)) or (pattern[index] == ']'): raise error, 'incomplete range in set' if last > pattern[index]: raise error, 'range arguments out of order in set' for next in map(chr, \ range(ord(last), \ ord(pattern[index]) + 1)): if next not in set: set.append(next) last = '' index = index + 1 elif next == '\\': # expand syntax meta-characters and add to set if index >= len(pattern): raise error, 'incomplete set' elif (pattern[index] == ']'): raise error, 'backslash at the end of a set' elif pattern[index] == 'w': for next in syntax_table.keys(): if 'word' in syntax_table[next]: set.append(next) elif pattern[index] == 'W': for next in syntax_table.keys(): if 'word' not in syntax_table[next]: set.append(next) elif pattern[index] == 'd': for next in syntax_table.keys(): if 'digit' in syntax_table[next]: set.append(next) elif pattern[index] == 'D': for next in syntax_table.keys(): if 'digit' not in syntax_table[next]: set.append(next) elif pattern[index] == 's': for next in syntax_table.keys(): if 'whitespace' in syntax_table[next]: set.append(next) elif pattern[index] == 'S': for next in syntax_table.keys(): if 'whitespace' not in syntax_table[next]: set.append(next) else: raise error, 'unknown meta in set' last = '' index = index + 1 else: if next not in set: set.append(next) last = next if pattern[index] != ']': raise error, 'incomplete set' index = index + 1 if negate: notset = [] for char in map(chr, range(256)): if char not in set: notset.append(char) stack.append([Set(notset)]) else: stack.append([Set(set)]) else: stack.append([Exact(char)]) code = [] while len(stack) > 0: if stack[-1][0].name == '(': raise error, 'too many open parens' code = stack[-1] + code del stack[-1] if len(code) == 0: raise error, 'no code generated' if (code[-1].name == '|'): raise error, 'alternation with nothing on the right' code = filter(lambda x: x.name != '|', code) need_label = 0 for i in range(len(code)): if (code[i].name == 'jump') and (code[i].label == -1): code[i] = Jump(label) need_label = 1 if need_label: code.append(Label(label)) label = label + 1 code.append(End()) return RegexObject(pattern, flags, code, register, groupindex, callouts) | a20887644445cc7d064bf0f95ef220871a563326 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a20887644445cc7d064bf0f95ef220871a563326/re.py |
||
def gauss(mu, sigma): # When x and y are two variables from [0, 1), uniformly # distributed, then # # cos(2*pi*x)*log(1-y) # sin(2*pi*x)*log(1-y) # # are two *independent* variables with normal distribution # (mu = 0, sigma = 1). # (Lambert Meertens) global gauss_next if gauss_next != None: z = gauss_next gauss_next = None else: x2pi = random() * TWOPI log1_y = log(1.0 - random()) z = cos(x2pi) * log1_y gauss_next = sin(x2pi) * log1_y return mu + z*sigma | 84c89489403c04b2fde0d5d8141599b598e20250 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/84c89489403c04b2fde0d5d8141599b598e20250/random.py |
||
log1_y = log(1.0 - random()) z = cos(x2pi) * log1_y gauss_next = sin(x2pi) * log1_y | g2rad = sqrt(-2.0 * log(1.0 - random())) z = cos(x2pi) * g2rad gauss_next = sin(x2pi) * g2rad | def gauss(mu, sigma): # When x and y are two variables from [0, 1), uniformly # distributed, then # # cos(2*pi*x)*log(1-y) # sin(2*pi*x)*log(1-y) # # are two *independent* variables with normal distribution # (mu = 0, sigma = 1). # (Lambert Meertens) global gauss_next if gauss_next != None: z = gauss_next gauss_next = None else: x2pi = random() * TWOPI log1_y = log(1.0 - random()) z = cos(x2pi) * log1_y gauss_next = sin(x2pi) * log1_y return mu + z*sigma | 84c89489403c04b2fde0d5d8141599b598e20250 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/84c89489403c04b2fde0d5d8141599b598e20250/random.py |
pkg = PimpPackage(self, dict(p)) | p = dict(p) flavor = p.get('Flavor') if flavor == 'source': pkg = PimpPackage_source(self, p) elif flavor == 'binary': pkg = PimpPackage_binary(self, p) else: pkg = PimpPackage(self, dict(p)) | def _appendPackages(self, packages): """Given a list of dictionaries containing package descriptions create the PimpPackage objects and append them to our internal storage.""" for p in packages: pkg = PimpPackage(self, dict(p)) self._packages.append(pkg) | 1d3730ef47bcca7b678759a7198c470c83ac4761 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1d3730ef47bcca7b678759a7198c470c83ac4761/pimp.py |
def homepage(self): return self._dict['Home-page'] | def homepage(self): return self._dict.get('Home-page') | def homepage(self): return self._dict['Home-page'] | 1d3730ef47bcca7b678759a7198c470c83ac4761 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1d3730ef47bcca7b678759a7198c470c83ac4761/pimp.py |
if not self._dict['Prerequisites']: | if not self._dict.get('Prerequisites'): | def prerequisites(self): """Return a list of prerequisites for this package. The list contains 2-tuples, of which the first item is either a PimpPackage object or None, and the second is a descriptive string. The first item can be None if this package depends on something that isn't pimp-installable, in which case the descriptive string should tell the user what to do.""" rv = [] if not self._dict.get('Download-URL'): return [(None, "This package needs to be installed manually")] if not self._dict['Prerequisites']: return [] for item in self._dict['Prerequisites']: if type(item) == str: pkg = None descr = str(item) else: name = item['Name'] if item.has_key('Version'): name = name + '-' + item['Version'] if item.has_key('Flavor'): name = name + '-' + item['Flavor'] pkg = self._db.find(name) if not pkg: descr = "Requires unknown %s"%name else: descr = pkg.description() rv.append((pkg, descr)) return rv | 1d3730ef47bcca7b678759a7198c470c83ac4761 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1d3730ef47bcca7b678759a7198c470c83ac4761/pimp.py |
def downloadSinglePackage(self, output=None): | def downloadPackageOnly(self, output=None): | def downloadSinglePackage(self, output=None): """Download a single package, if needed. An MD5 signature is used to determine whether download is needed, and to test that we actually downloaded what we expected. If output is given it is a file-like object that will receive a log of what happens. If anything unforeseen happened the method returns an error message string. """ scheme, loc, path, query, frag = urlparse.urlsplit(self._dict['Download-URL']) path = urllib.url2pathname(path) filename = os.path.split(path)[1] self.archiveFilename = os.path.join(self._db.preferences.downloadDir, filename) if not self._archiveOK(): if scheme == 'manual': return "Please download package manually and save as %s" % self.archiveFilename if self._cmd(output, self._db.preferences.downloadDir, "curl", "--output", self.archiveFilename, self._dict['Download-URL']): return "download command failed" if not os.path.exists(self.archiveFilename) and not NO_EXECUTE: return "archive not found after download" if not self._archiveOK(): return "archive does not have correct MD5 checksum" | 1d3730ef47bcca7b678759a7198c470c83ac4761 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1d3730ef47bcca7b678759a7198c470c83ac4761/pimp.py |
def unpackSinglePackage(self, output=None): | def unpackPackageOnly(self, output=None): | def unpackSinglePackage(self, output=None): """Unpack a downloaded package archive.""" filename = os.path.split(self.archiveFilename)[1] for ext, cmd in ARCHIVE_FORMATS: if filename[-len(ext):] == ext: break else: return "unknown extension for archive file: %s" % filename basename = filename[:-len(ext)] cmd = cmd % self.archiveFilename self._buildDirname = os.path.join(self._db.preferences.buildDir, basename) if self._cmd(output, self._db.preferences.buildDir, cmd): return "unpack command failed" setupname = os.path.join(self._buildDirname, "setup.py") if not os.path.exists(setupname) and not NO_EXECUTE: return "no setup.py found after unpack of archive" | 1d3730ef47bcca7b678759a7198c470c83ac4761 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1d3730ef47bcca7b678759a7198c470c83ac4761/pimp.py |
self._buildDirname = os.path.join(self._db.preferences.buildDir, basename) | def unpackSinglePackage(self, output=None): """Unpack a downloaded package archive.""" filename = os.path.split(self.archiveFilename)[1] for ext, cmd in ARCHIVE_FORMATS: if filename[-len(ext):] == ext: break else: return "unknown extension for archive file: %s" % filename basename = filename[:-len(ext)] cmd = cmd % self.archiveFilename self._buildDirname = os.path.join(self._db.preferences.buildDir, basename) if self._cmd(output, self._db.preferences.buildDir, cmd): return "unpack command failed" setupname = os.path.join(self._buildDirname, "setup.py") if not os.path.exists(setupname) and not NO_EXECUTE: return "no setup.py found after unpack of archive" | 1d3730ef47bcca7b678759a7198c470c83ac4761 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1d3730ef47bcca7b678759a7198c470c83ac4761/pimp.py |
|
setupname = os.path.join(self._buildDirname, "setup.py") if not os.path.exists(setupname) and not NO_EXECUTE: return "no setup.py found after unpack of archive" | def installPackageOnly(self, output=None): """Default install method, to be overridden by subclasses""" return "Cannot automatically install package %s" % self.fullname() | def unpackSinglePackage(self, output=None): """Unpack a downloaded package archive.""" filename = os.path.split(self.archiveFilename)[1] for ext, cmd in ARCHIVE_FORMATS: if filename[-len(ext):] == ext: break else: return "unknown extension for archive file: %s" % filename basename = filename[:-len(ext)] cmd = cmd % self.archiveFilename self._buildDirname = os.path.join(self._db.preferences.buildDir, basename) if self._cmd(output, self._db.preferences.buildDir, cmd): return "unpack command failed" setupname = os.path.join(self._buildDirname, "setup.py") if not os.path.exists(setupname) and not NO_EXECUTE: return "no setup.py found after unpack of archive" | 1d3730ef47bcca7b678759a7198c470c83ac4761 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1d3730ef47bcca7b678759a7198c470c83ac4761/pimp.py |
msg = self.downloadSinglePackage(output) | msg = self.downloadPackageOnly(output) | def installSinglePackage(self, output=None): """Download, unpack and install a single package. If output is given it should be a file-like object and it will receive a log of what happened.""" if not self._dict['Download-URL']: return "%s: This package needs to be installed manually" % _fmtpackagename(self) msg = self.downloadSinglePackage(output) if msg: return "download %s: %s" % (self.fullname(), msg) msg = self.unpackSinglePackage(output) if msg: return "unpack %s: %s" % (self.fullname(), msg) if self._dict.has_key('Pre-install-command'): if self._cmd(output, self._buildDirname, self._dict['Pre-install-command']): return "pre-install %s: running \"%s\" failed" % \ (self.fullname(), self._dict['Pre-install-command']) old_contents = os.listdir(self._db.preferences.installDir) installcmd = self._dict.get('Install-command') if not installcmd: installcmd = '"%s" setup.py install' % sys.executable if self._cmd(output, self._buildDirname, installcmd): return "install %s: running \"%s\" failed" % self.fullname() new_contents = os.listdir(self._db.preferences.installDir) self._interpretPthFiles(old_contents, new_contents) if self._dict.has_key('Post-install-command'): if self._cmd(output, self._buildDirname, self._dict['Post-install-command']): return "post-install %s: running \"%s\" failed" % \ (self.fullname(), self._dict['Post-install-command']) return None | 1d3730ef47bcca7b678759a7198c470c83ac4761 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1d3730ef47bcca7b678759a7198c470c83ac4761/pimp.py |
msg = self.unpackSinglePackage(output) | msg = self.unpackPackageOnly(output) | def installSinglePackage(self, output=None): """Download, unpack and install a single package. If output is given it should be a file-like object and it will receive a log of what happened.""" if not self._dict['Download-URL']: return "%s: This package needs to be installed manually" % _fmtpackagename(self) msg = self.downloadSinglePackage(output) if msg: return "download %s: %s" % (self.fullname(), msg) msg = self.unpackSinglePackage(output) if msg: return "unpack %s: %s" % (self.fullname(), msg) if self._dict.has_key('Pre-install-command'): if self._cmd(output, self._buildDirname, self._dict['Pre-install-command']): return "pre-install %s: running \"%s\" failed" % \ (self.fullname(), self._dict['Pre-install-command']) old_contents = os.listdir(self._db.preferences.installDir) installcmd = self._dict.get('Install-command') if not installcmd: installcmd = '"%s" setup.py install' % sys.executable if self._cmd(output, self._buildDirname, installcmd): return "install %s: running \"%s\" failed" % self.fullname() new_contents = os.listdir(self._db.preferences.installDir) self._interpretPthFiles(old_contents, new_contents) if self._dict.has_key('Post-install-command'): if self._cmd(output, self._buildDirname, self._dict['Post-install-command']): return "post-install %s: running \"%s\" failed" % \ (self.fullname(), self._dict['Post-install-command']) return None | 1d3730ef47bcca7b678759a7198c470c83ac4761 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1d3730ef47bcca7b678759a7198c470c83ac4761/pimp.py |
if self._dict.has_key('Pre-install-command'): if self._cmd(output, self._buildDirname, self._dict['Pre-install-command']): return "pre-install %s: running \"%s\" failed" % \ (self.fullname(), self._dict['Pre-install-command']) old_contents = os.listdir(self._db.preferences.installDir) installcmd = self._dict.get('Install-command') if not installcmd: installcmd = '"%s" setup.py install' % sys.executable if self._cmd(output, self._buildDirname, installcmd): return "install %s: running \"%s\" failed" % self.fullname() | return self.installPackageOnly(output) def beforeInstall(self): """Bookkeeping before installation: remember what we have in site-packages""" self._old_contents = os.listdir(self._db.preferences.installDir) def afterInstall(self): """Bookkeeping after installation: interpret any new .pth files that have appeared""" | def installSinglePackage(self, output=None): """Download, unpack and install a single package. If output is given it should be a file-like object and it will receive a log of what happened.""" if not self._dict['Download-URL']: return "%s: This package needs to be installed manually" % _fmtpackagename(self) msg = self.downloadSinglePackage(output) if msg: return "download %s: %s" % (self.fullname(), msg) msg = self.unpackSinglePackage(output) if msg: return "unpack %s: %s" % (self.fullname(), msg) if self._dict.has_key('Pre-install-command'): if self._cmd(output, self._buildDirname, self._dict['Pre-install-command']): return "pre-install %s: running \"%s\" failed" % \ (self.fullname(), self._dict['Pre-install-command']) old_contents = os.listdir(self._db.preferences.installDir) installcmd = self._dict.get('Install-command') if not installcmd: installcmd = '"%s" setup.py install' % sys.executable if self._cmd(output, self._buildDirname, installcmd): return "install %s: running \"%s\" failed" % self.fullname() new_contents = os.listdir(self._db.preferences.installDir) self._interpretPthFiles(old_contents, new_contents) if self._dict.has_key('Post-install-command'): if self._cmd(output, self._buildDirname, self._dict['Post-install-command']): return "post-install %s: running \"%s\" failed" % \ (self.fullname(), self._dict['Post-install-command']) return None | 1d3730ef47bcca7b678759a7198c470c83ac4761 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1d3730ef47bcca7b678759a7198c470c83ac4761/pimp.py |
self._interpretPthFiles(old_contents, new_contents) if self._dict.has_key('Post-install-command'): if self._cmd(output, self._buildDirname, self._dict['Post-install-command']): return "post-install %s: running \"%s\" failed" % \ (self.fullname(), self._dict['Post-install-command']) return None def _interpretPthFiles(self, old_contents, new_contents): """Evaluate any new .pth files that have appeared after installing""" | def installSinglePackage(self, output=None): """Download, unpack and install a single package. If output is given it should be a file-like object and it will receive a log of what happened.""" if not self._dict['Download-URL']: return "%s: This package needs to be installed manually" % _fmtpackagename(self) msg = self.downloadSinglePackage(output) if msg: return "download %s: %s" % (self.fullname(), msg) msg = self.unpackSinglePackage(output) if msg: return "unpack %s: %s" % (self.fullname(), msg) if self._dict.has_key('Pre-install-command'): if self._cmd(output, self._buildDirname, self._dict['Pre-install-command']): return "pre-install %s: running \"%s\" failed" % \ (self.fullname(), self._dict['Pre-install-command']) old_contents = os.listdir(self._db.preferences.installDir) installcmd = self._dict.get('Install-command') if not installcmd: installcmd = '"%s" setup.py install' % sys.executable if self._cmd(output, self._buildDirname, installcmd): return "install %s: running \"%s\" failed" % self.fullname() new_contents = os.listdir(self._db.preferences.installDir) self._interpretPthFiles(old_contents, new_contents) if self._dict.has_key('Post-install-command'): if self._cmd(output, self._buildDirname, self._dict['Post-install-command']): return "post-install %s: running \"%s\" failed" % \ (self.fullname(), self._dict['Post-install-command']) return None | 1d3730ef47bcca7b678759a7198c470c83ac4761 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1d3730ef47bcca7b678759a7198c470c83ac4761/pimp.py |
|
if fn in old_contents: | if fn in self._old_contents: | def _interpretPthFiles(self, old_contents, new_contents): """Evaluate any new .pth files that have appeared after installing""" for fn in new_contents: if fn in old_contents: continue if fn[-4:] != '.pth': continue fullname = os.path.join(self._db.preferences.installDir, fn) f = open(fullname) for line in f.readlines(): if not line: continue if line[0] == '#': continue if line[:6] == 'import': exec line continue if line[-1] == '\n': line = line[:-1] if not os.path.isabs(line): line = os.path.join(self._db.preferences.installDir, line) line = os.path.realpath(line) if not line in sys.path: sys.path.append(line) | 1d3730ef47bcca7b678759a7198c470c83ac4761 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1d3730ef47bcca7b678759a7198c470c83ac4761/pimp.py |
sys.path.append(line) | sys.path.append(line) class PimpPackage_binary(PimpPackage): def unpackPackageOnly(self, output=None): """We don't unpack binary packages until installing""" pass def installPackageOnly(self, output=None): """Install a single source package. If output is given it should be a file-like object and it will receive a log of what happened.""" msgs = [] if self._dict.has_key('Pre-install-command'): msg.append("%s: Pre-install-command ignored" % self.fullname()) if self._dict.has_key('Install-command'): msgs.append("%s: Install-command ignored" % self.fullname()) if self._dict.has_key('Post-install-command'): msgs.append("%s: Post-install-command ignored" % self.fullname()) self.beforeInstall() filename = os.path.split(self.archiveFilename)[1] for ext, cmd in ARCHIVE_FORMATS: if filename[-len(ext):] == ext: break else: return "unknown extension for archive file: %s" % filename prefixmod = '-C /' cmd = cmd % self.archiveFilename if self._cmd(output, self._db.preferences.buildDir, cmd, prefixmod): return "unpack command failed" self.afterInstall() if self._dict.has_key('Post-install-command'): if self._cmd(output, self._buildDirname, self._dict['Post-install-command']): return "post-install %s: running \"%s\" failed" % \ (self.fullname(), self._dict['Post-install-command']) return None class PimpPackage_source(PimpPackage): def unpackPackageOnly(self, output=None): """Unpack a source package and check that setup.py exists""" PimpPackage.unpackPackageOnly(self, output) self._buildDirname = os.path.join(self._db.preferences.buildDir, basename) setupname = os.path.join(self._buildDirname, "setup.py") if not os.path.exists(setupname) and not NO_EXECUTE: return "no setup.py found after unpack of archive" def installPackageOnly(self, output=None): """Install a single source package. If output is given it should be a file-like object and it will receive a log of what happened.""" if self._dict.has_key('Pre-install-command'): if self._cmd(output, self._buildDirname, self._dict['Pre-install-command']): return "pre-install %s: running \"%s\" failed" % \ (self.fullname(), self._dict['Pre-install-command']) self.beforeInstall() installcmd = self._dict.get('Install-command') if not installcmd: installcmd = '"%s" setup.py install' % sys.executable if self._cmd(output, self._buildDirname, installcmd): return "install %s: running \"%s\" failed" % self.fullname() self.afterInstall() if self._dict.has_key('Post-install-command'): if self._cmd(output, self._buildDirname, self._dict['Post-install-command']): return "post-install %s: running \"%s\" failed" % \ (self.fullname(), self._dict['Post-install-command']) return None | def _interpretPthFiles(self, old_contents, new_contents): """Evaluate any new .pth files that have appeared after installing""" for fn in new_contents: if fn in old_contents: continue if fn[-4:] != '.pth': continue fullname = os.path.join(self._db.preferences.installDir, fn) f = open(fullname) for line in f.readlines(): if not line: continue if line[0] == '#': continue if line[:6] == 'import': exec line continue if line[-1] == '\n': line = line[:-1] if not os.path.isabs(line): line = os.path.join(self._db.preferences.installDir, line) line = os.path.realpath(line) if not line in sys.path: sys.path.append(line) | 1d3730ef47bcca7b678759a7198c470c83ac4761 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1d3730ef47bcca7b678759a7198c470c83ac4761/pimp.py |
output = struct.pack("iiiiiii", 0x950412de, | output = struct.pack("Iiiiiii", 0x950412deL, | def generate(): "Return the generated output." global MESSAGES keys = MESSAGES.keys() # the keys are sorted in the .mo file keys.sort() offsets = [] ids = strs = '' for id in keys: # For each string, we need size and file offset. Each string is NUL # terminated; the NUL does not count into the size. offsets.append((len(ids), len(id), len(strs), len(MESSAGES[id]))) ids += id + '\0' strs += MESSAGES[id] + '\0' output = '' # The header is 7 32-bit unsigned integers. We don't use hash tables, so # the keys start right after the index tables. # translated string. keystart = 7*4+16*len(keys) # and the values start after the keys valuestart = keystart + len(ids) koffsets = [] voffsets = [] # The string table first has the list of keys, then the list of values. # Each entry has first the size of the string, then the file offset. for o1, l1, o2, l2 in offsets: koffsets += [l1, o1+keystart] voffsets += [l2, o2+valuestart] offsets = koffsets + voffsets output = struct.pack("iiiiiii", 0x950412de, # Magic 0, # Version len(keys), # # of entries 7*4, # start of key index 7*4+len(keys)*8, # start of value index 0, 0) # size and offset of hash table output += array.array("i", offsets).tostring() output += ids output += strs return output | 30f69d60a52c2b07efbf334260cea08d299a2b75 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/30f69d60a52c2b07efbf334260cea08d299a2b75/msgfmt.py |
f2 = self.tar.extractfile("/S-SPARSE-WITH-NULLS") | f2 = self.tar.extractfile("S-SPARSE-WITH-NULLS") | def test_sparse(self): """Test sparse member extraction. """ if self.sep != "|": f1 = self.tar.extractfile("S-SPARSE") f2 = self.tar.extractfile("/S-SPARSE-WITH-NULLS") self.assert_(f1.read() == f2.read(), "_FileObject failed on sparse file member") | 31a97c95bc4eb520dd91bad6c1a67229852334b5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/31a97c95bc4eb520dd91bad6c1a67229852334b5/test_tarfile.py |
filename = "/0-REGTYPE-TEXT" | filename = "0-REGTYPE-TEXT" | def test_readlines(self): """Test readlines() method of _FileObject. """ if self.sep != "|": filename = "/0-REGTYPE-TEXT" self.tar.extract(filename, dirname()) lines1 = file(os.path.join(dirname(), filename), "rU").readlines() lines2 = self.tar.extractfile(filename).readlines() self.assert_(lines1 == lines2, "_FileObject.readline() does not work correctly") | 31a97c95bc4eb520dd91bad6c1a67229852334b5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/31a97c95bc4eb520dd91bad6c1a67229852334b5/test_tarfile.py |
filename = "/0-REGTYPE" | filename = "0-REGTYPE" | def test_seek(self): """Test seek() method of _FileObject, incl. random reading. """ if self.sep != "|": filename = "/0-REGTYPE" self.tar.extract(filename, dirname()) data = file(os.path.join(dirname(), filename), "rb").read() | 31a97c95bc4eb520dd91bad6c1a67229852334b5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/31a97c95bc4eb520dd91bad6c1a67229852334b5/test_tarfile.py |
ssl = socket.ssl(sock, self.key_file, self.cert_file) | realsock = sock if hasattr(sock, "_sock"): realsock = sock._sock ssl = socket.ssl(realsock, self.key_file, self.cert_file) | def connect(self): "Connect to a host on a given (SSL) port." | cf6dac61977013e816df1390ade52ce4f73e82ef /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/cf6dac61977013e816df1390ade52ce4f73e82ef/httplib.py |
if sys.platform[:4] != 'java': value = u"%(x)s, %()s" % {'x':u"abc", u''.encode('utf-8'):"def"} else: value = u"%(x)s, %()s" % {'x':u"abc", u'':"def"} | value = u"%(x)s, %()s" % {'x':u"abc", u'':"def"} | def test_fixup(s): s2 = u'\ud800\udc01' test_lecmp(s, s2) s2 = u'\ud900\udc01' test_lecmp(s, s2) s2 = u'\uda00\udc01' test_lecmp(s, s2) s2 = u'\udb00\udc01' test_lecmp(s, s2) s2 = u'\ud800\udd01' test_lecmp(s, s2) s2 = u'\ud900\udd01' test_lecmp(s, s2) s2 = u'\uda00\udd01' test_lecmp(s, s2) s2 = u'\udb00\udd01' test_lecmp(s, s2) s2 = u'\ud800\ude01' test_lecmp(s, s2) s2 = u'\ud900\ude01' test_lecmp(s, s2) s2 = u'\uda00\ude01' test_lecmp(s, s2) s2 = u'\udb00\ude01' test_lecmp(s, s2) s2 = u'\ud800\udfff' test_lecmp(s, s2) s2 = u'\ud900\udfff' test_lecmp(s, s2) s2 = u'\uda00\udfff' test_lecmp(s, s2) s2 = u'\udb00\udfff' test_lecmp(s, s2) | 43c50ebad143367680b896b369900516fdc20409 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/43c50ebad143367680b896b369900516fdc20409/test_unicode.py |
print 'd=', d | def message(str = "Hello, world!", id = MESSAGE_ID): """Show a simple alert with a text message""" d = GetNewDialog(id, -1) d.SetDialogDefaultItem(1) print 'd=', d tp, h, rect = d.GetDialogItem(2) SetDialogItemText(h, str) while 1: n = ModalDialog(None) if n == 1: break | a332b7fe15a2360fd3e6adb90cdd941e2110cd0e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a332b7fe15a2360fd3e6adb90cdd941e2110cd0e/EditPythonPrefs.py |
|
return [0]*7, None return map(lambda x: ord(x), opr.data), opr | return [0]*9, None options = map(lambda x: ord(x), opr.data) while len(options) < 9: options = options + [0] return options, opr | def getoptions(id): try: opr = GetResource('Popt', id) except (MacOS.Error, Res.Error): return [0]*7, None return map(lambda x: ord(x), opr.data), opr | a332b7fe15a2360fd3e6adb90cdd941e2110cd0e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a332b7fe15a2360fd3e6adb90cdd941e2110cd0e/EditPythonPrefs.py |
print 'Created new GUSI option' ngusi_opr = Resource(gusi_opr.data) | ngusi_opr = Resource(newdata) | def edit_preferences(): preff_handle = openpreffile(WRITE) l, sr = getprefpath(PATH_STRINGS_ID) if l == None: message('Cannot find any sys.path resource! (Old python?)') sys.exit(0) fss, dr, fss_changed = getprefdir(DIRECTORY_ID) if fss == None: fss = macfs.FSSpec(os.getcwd()) fss_changed = 1 options, opr = getoptions(OPTIONS_ID) saved_options = options[:] creator, type, delaycons, gusi_opr = getgusioptions(GUSI_ID) saved_gusi_options = creator, type, delaycons # Let the user play away result = interact(l, fss, (options, creator, type, delaycons), 'System-wide preferences') # See what we have to update, and how if result == None: sys.exit(0) pathlist, nfss, (options, creator, type, delaycons) = result if nfss != fss: fss_changed = 1 if fss_changed: alias = nfss.NewAlias() if dr: dr.data = alias.data dr.ChangedResource() else: dr = Resource(alias.data) dr.AddResource('alis', DIRECTORY_ID, '') if pathlist != l: if pathlist == []: if sr.HomeResFile() == preff_handle: sr.RemoveResource() elif sr.HomeResFile() == preff_handle: sr.data = listtores(pathlist) sr.ChangedResource() else: sr = Resource(listtores(pathlist)) sr.AddResource('STR#', PATH_STRINGS_ID, '') if options != saved_options: newdata = reduce(lambda x, y: x+chr(y), options, '') if opr and opr.HomeResFile() == preff_handle: opr.data = newdata opr.ChangedResource() else: opr = Resource(newdata) opr.AddResource('Popt', OPTIONS_ID, '') if (creator, type, delaycons) != saved_gusi_options: newdata = setgusioptions(gusi_opr, creator, type, delaycons) if gusi_opr.HomeResFile() == preff_handle: gusi_opr.data = newdata gusi_opr.ChangedResource() else: print 'Created new GUSI option' ngusi_opr = Resource(gusi_opr.data) ngusi_opr.AddResource('GU\267I', GUSI_ID, '') CloseResFile(preff_handle) | a332b7fe15a2360fd3e6adb90cdd941e2110cd0e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a332b7fe15a2360fd3e6adb90cdd941e2110cd0e/EditPythonPrefs.py |
if not opr: | if not gusi_opr: | def edit_applet(name): pref_handle = openpreffile(READ) app_handle = openapplet(name) notfound = '' l, sr = getprefpath(OVERRIDE_PATH_STRINGS_ID) if l == None: notfound = 'path' l, dummy = getprefpath(PATH_STRINGS_ID) if l == None: message('Cannot find any sys.path resource! (Old python?)') sys.exit(0) fss, dr, fss_changed = getprefdir(OVERRIDE_DIRECTORY_ID) if fss == None: if notfound: notfound = notfound + ', directory' else: notfound = 'directory' fss, dummy, dummy2 = getprefdir(DIRECTORY_ID) if fss == None: fss = macfs.FSSpec(os.getcwd()) fss_changed = 1 options, opr = getoptions(OVERRIDE_OPTIONS_ID) if not opr: if notfound: notfound = notfound + ', options' else: notfound = 'options' options, dummy = getoptions(OPTIONS_ID) saved_options = options[:] creator, type, delaycons, gusi_opr = getgusioptions(OVERRIDE_GUSI_ID) if not opr: if notfound: notfound = notfound + ', GUSI options' else: notfound = 'GUSI options' creator, type, delaycons, dummy = getgusioptions(GUSI_ID) saved_gusi_options = creator, type, delaycons dummy = dummy2 = None # Discard them. if notfound: message('Warning: initial %s taken from system-wide defaults'%notfound) # Let the user play away result = interact(l, fss, (options, creator, type, delaycons), name) # See what we have to update, and how if result == None: sys.exit(0) pathlist, nfss, options = result if nfss != fss: fss_changed = 1 if fss_changed: alias = nfss.NewAlias() if dr: dr.data = alias.data dr.ChangedResource() else: dr = Resource(alias.data) dr.AddResource('alis', OVERRIDE_DIRECTORY_ID, '') if pathlist != l: if pathlist == []: if sr.HomeResFile() == app_handle: sr.RemoveResource() elif sr and sr.HomeResFile() == app_handle: sr.data = listtores(pathlist) sr.ChangedResource() else: sr = Resource(listtores(pathlist)) sr.AddResource('STR#', OVERRIDE_PATH_STRINGS_ID, '') if options != saved_options: newdata = reduce(lambda x, y: x+chr(y), options, '') if opr and opr.HomeResFile() == app_handle: opr.data = newdata opr.ChangedResource() else: opr = Resource(newdata) opr.AddResource('Popt', OVERRIDE_OPTIONS_ID, '') if (creator, type, delaycons) != saved_gusi_options: newdata = setgusioptions(gusi_opr, creator, type, delaycons) if gusi_opr.HomeResFile == app_handle: gusi_opr.data = newdata gusi_opr.ChangedResource() else: gusi_opr = Resource(gusi_opr.data) gusi_opr.AddResource('GU\267I', OVERRIDE_GUSI_ID, '') CloseResFile(app_handle) | a332b7fe15a2360fd3e6adb90cdd941e2110cd0e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a332b7fe15a2360fd3e6adb90cdd941e2110cd0e/EditPythonPrefs.py |
creator, type, delaycons, dummy = getgusioptions(GUSI_ID) | creator, type, delaycons, gusi_opr = getgusioptions(GUSI_ID) | def edit_applet(name): pref_handle = openpreffile(READ) app_handle = openapplet(name) notfound = '' l, sr = getprefpath(OVERRIDE_PATH_STRINGS_ID) if l == None: notfound = 'path' l, dummy = getprefpath(PATH_STRINGS_ID) if l == None: message('Cannot find any sys.path resource! (Old python?)') sys.exit(0) fss, dr, fss_changed = getprefdir(OVERRIDE_DIRECTORY_ID) if fss == None: if notfound: notfound = notfound + ', directory' else: notfound = 'directory' fss, dummy, dummy2 = getprefdir(DIRECTORY_ID) if fss == None: fss = macfs.FSSpec(os.getcwd()) fss_changed = 1 options, opr = getoptions(OVERRIDE_OPTIONS_ID) if not opr: if notfound: notfound = notfound + ', options' else: notfound = 'options' options, dummy = getoptions(OPTIONS_ID) saved_options = options[:] creator, type, delaycons, gusi_opr = getgusioptions(OVERRIDE_GUSI_ID) if not opr: if notfound: notfound = notfound + ', GUSI options' else: notfound = 'GUSI options' creator, type, delaycons, dummy = getgusioptions(GUSI_ID) saved_gusi_options = creator, type, delaycons dummy = dummy2 = None # Discard them. if notfound: message('Warning: initial %s taken from system-wide defaults'%notfound) # Let the user play away result = interact(l, fss, (options, creator, type, delaycons), name) # See what we have to update, and how if result == None: sys.exit(0) pathlist, nfss, options = result if nfss != fss: fss_changed = 1 if fss_changed: alias = nfss.NewAlias() if dr: dr.data = alias.data dr.ChangedResource() else: dr = Resource(alias.data) dr.AddResource('alis', OVERRIDE_DIRECTORY_ID, '') if pathlist != l: if pathlist == []: if sr.HomeResFile() == app_handle: sr.RemoveResource() elif sr and sr.HomeResFile() == app_handle: sr.data = listtores(pathlist) sr.ChangedResource() else: sr = Resource(listtores(pathlist)) sr.AddResource('STR#', OVERRIDE_PATH_STRINGS_ID, '') if options != saved_options: newdata = reduce(lambda x, y: x+chr(y), options, '') if opr and opr.HomeResFile() == app_handle: opr.data = newdata opr.ChangedResource() else: opr = Resource(newdata) opr.AddResource('Popt', OVERRIDE_OPTIONS_ID, '') if (creator, type, delaycons) != saved_gusi_options: newdata = setgusioptions(gusi_opr, creator, type, delaycons) if gusi_opr.HomeResFile == app_handle: gusi_opr.data = newdata gusi_opr.ChangedResource() else: gusi_opr = Resource(gusi_opr.data) gusi_opr.AddResource('GU\267I', OVERRIDE_GUSI_ID, '') CloseResFile(app_handle) | a332b7fe15a2360fd3e6adb90cdd941e2110cd0e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a332b7fe15a2360fd3e6adb90cdd941e2110cd0e/EditPythonPrefs.py |
pathlist, nfss, options = result | pathlist, nfss, (options, creator, type, delaycons) = result | def edit_applet(name): pref_handle = openpreffile(READ) app_handle = openapplet(name) notfound = '' l, sr = getprefpath(OVERRIDE_PATH_STRINGS_ID) if l == None: notfound = 'path' l, dummy = getprefpath(PATH_STRINGS_ID) if l == None: message('Cannot find any sys.path resource! (Old python?)') sys.exit(0) fss, dr, fss_changed = getprefdir(OVERRIDE_DIRECTORY_ID) if fss == None: if notfound: notfound = notfound + ', directory' else: notfound = 'directory' fss, dummy, dummy2 = getprefdir(DIRECTORY_ID) if fss == None: fss = macfs.FSSpec(os.getcwd()) fss_changed = 1 options, opr = getoptions(OVERRIDE_OPTIONS_ID) if not opr: if notfound: notfound = notfound + ', options' else: notfound = 'options' options, dummy = getoptions(OPTIONS_ID) saved_options = options[:] creator, type, delaycons, gusi_opr = getgusioptions(OVERRIDE_GUSI_ID) if not opr: if notfound: notfound = notfound + ', GUSI options' else: notfound = 'GUSI options' creator, type, delaycons, dummy = getgusioptions(GUSI_ID) saved_gusi_options = creator, type, delaycons dummy = dummy2 = None # Discard them. if notfound: message('Warning: initial %s taken from system-wide defaults'%notfound) # Let the user play away result = interact(l, fss, (options, creator, type, delaycons), name) # See what we have to update, and how if result == None: sys.exit(0) pathlist, nfss, options = result if nfss != fss: fss_changed = 1 if fss_changed: alias = nfss.NewAlias() if dr: dr.data = alias.data dr.ChangedResource() else: dr = Resource(alias.data) dr.AddResource('alis', OVERRIDE_DIRECTORY_ID, '') if pathlist != l: if pathlist == []: if sr.HomeResFile() == app_handle: sr.RemoveResource() elif sr and sr.HomeResFile() == app_handle: sr.data = listtores(pathlist) sr.ChangedResource() else: sr = Resource(listtores(pathlist)) sr.AddResource('STR#', OVERRIDE_PATH_STRINGS_ID, '') if options != saved_options: newdata = reduce(lambda x, y: x+chr(y), options, '') if opr and opr.HomeResFile() == app_handle: opr.data = newdata opr.ChangedResource() else: opr = Resource(newdata) opr.AddResource('Popt', OVERRIDE_OPTIONS_ID, '') if (creator, type, delaycons) != saved_gusi_options: newdata = setgusioptions(gusi_opr, creator, type, delaycons) if gusi_opr.HomeResFile == app_handle: gusi_opr.data = newdata gusi_opr.ChangedResource() else: gusi_opr = Resource(gusi_opr.data) gusi_opr.AddResource('GU\267I', OVERRIDE_GUSI_ID, '') CloseResFile(app_handle) | a332b7fe15a2360fd3e6adb90cdd941e2110cd0e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a332b7fe15a2360fd3e6adb90cdd941e2110cd0e/EditPythonPrefs.py |
if gusi_opr.HomeResFile == app_handle: | id, type, name = gusi_opr.GetResInfo() if gusi_opr.HomeResFile() == app_handle and id == OVERRIDE_GUSI_ID: | def edit_applet(name): pref_handle = openpreffile(READ) app_handle = openapplet(name) notfound = '' l, sr = getprefpath(OVERRIDE_PATH_STRINGS_ID) if l == None: notfound = 'path' l, dummy = getprefpath(PATH_STRINGS_ID) if l == None: message('Cannot find any sys.path resource! (Old python?)') sys.exit(0) fss, dr, fss_changed = getprefdir(OVERRIDE_DIRECTORY_ID) if fss == None: if notfound: notfound = notfound + ', directory' else: notfound = 'directory' fss, dummy, dummy2 = getprefdir(DIRECTORY_ID) if fss == None: fss = macfs.FSSpec(os.getcwd()) fss_changed = 1 options, opr = getoptions(OVERRIDE_OPTIONS_ID) if not opr: if notfound: notfound = notfound + ', options' else: notfound = 'options' options, dummy = getoptions(OPTIONS_ID) saved_options = options[:] creator, type, delaycons, gusi_opr = getgusioptions(OVERRIDE_GUSI_ID) if not opr: if notfound: notfound = notfound + ', GUSI options' else: notfound = 'GUSI options' creator, type, delaycons, dummy = getgusioptions(GUSI_ID) saved_gusi_options = creator, type, delaycons dummy = dummy2 = None # Discard them. if notfound: message('Warning: initial %s taken from system-wide defaults'%notfound) # Let the user play away result = interact(l, fss, (options, creator, type, delaycons), name) # See what we have to update, and how if result == None: sys.exit(0) pathlist, nfss, options = result if nfss != fss: fss_changed = 1 if fss_changed: alias = nfss.NewAlias() if dr: dr.data = alias.data dr.ChangedResource() else: dr = Resource(alias.data) dr.AddResource('alis', OVERRIDE_DIRECTORY_ID, '') if pathlist != l: if pathlist == []: if sr.HomeResFile() == app_handle: sr.RemoveResource() elif sr and sr.HomeResFile() == app_handle: sr.data = listtores(pathlist) sr.ChangedResource() else: sr = Resource(listtores(pathlist)) sr.AddResource('STR#', OVERRIDE_PATH_STRINGS_ID, '') if options != saved_options: newdata = reduce(lambda x, y: x+chr(y), options, '') if opr and opr.HomeResFile() == app_handle: opr.data = newdata opr.ChangedResource() else: opr = Resource(newdata) opr.AddResource('Popt', OVERRIDE_OPTIONS_ID, '') if (creator, type, delaycons) != saved_gusi_options: newdata = setgusioptions(gusi_opr, creator, type, delaycons) if gusi_opr.HomeResFile == app_handle: gusi_opr.data = newdata gusi_opr.ChangedResource() else: gusi_opr = Resource(gusi_opr.data) gusi_opr.AddResource('GU\267I', OVERRIDE_GUSI_ID, '') CloseResFile(app_handle) | a332b7fe15a2360fd3e6adb90cdd941e2110cd0e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a332b7fe15a2360fd3e6adb90cdd941e2110cd0e/EditPythonPrefs.py |
gusi_opr = Resource(gusi_opr.data) gusi_opr.AddResource('GU\267I', OVERRIDE_GUSI_ID, '') | ngusi_opr = Resource(newdata) ngusi_opr.AddResource('GU\267I', OVERRIDE_GUSI_ID, '') | def edit_applet(name): pref_handle = openpreffile(READ) app_handle = openapplet(name) notfound = '' l, sr = getprefpath(OVERRIDE_PATH_STRINGS_ID) if l == None: notfound = 'path' l, dummy = getprefpath(PATH_STRINGS_ID) if l == None: message('Cannot find any sys.path resource! (Old python?)') sys.exit(0) fss, dr, fss_changed = getprefdir(OVERRIDE_DIRECTORY_ID) if fss == None: if notfound: notfound = notfound + ', directory' else: notfound = 'directory' fss, dummy, dummy2 = getprefdir(DIRECTORY_ID) if fss == None: fss = macfs.FSSpec(os.getcwd()) fss_changed = 1 options, opr = getoptions(OVERRIDE_OPTIONS_ID) if not opr: if notfound: notfound = notfound + ', options' else: notfound = 'options' options, dummy = getoptions(OPTIONS_ID) saved_options = options[:] creator, type, delaycons, gusi_opr = getgusioptions(OVERRIDE_GUSI_ID) if not opr: if notfound: notfound = notfound + ', GUSI options' else: notfound = 'GUSI options' creator, type, delaycons, dummy = getgusioptions(GUSI_ID) saved_gusi_options = creator, type, delaycons dummy = dummy2 = None # Discard them. if notfound: message('Warning: initial %s taken from system-wide defaults'%notfound) # Let the user play away result = interact(l, fss, (options, creator, type, delaycons), name) # See what we have to update, and how if result == None: sys.exit(0) pathlist, nfss, options = result if nfss != fss: fss_changed = 1 if fss_changed: alias = nfss.NewAlias() if dr: dr.data = alias.data dr.ChangedResource() else: dr = Resource(alias.data) dr.AddResource('alis', OVERRIDE_DIRECTORY_ID, '') if pathlist != l: if pathlist == []: if sr.HomeResFile() == app_handle: sr.RemoveResource() elif sr and sr.HomeResFile() == app_handle: sr.data = listtores(pathlist) sr.ChangedResource() else: sr = Resource(listtores(pathlist)) sr.AddResource('STR#', OVERRIDE_PATH_STRINGS_ID, '') if options != saved_options: newdata = reduce(lambda x, y: x+chr(y), options, '') if opr and opr.HomeResFile() == app_handle: opr.data = newdata opr.ChangedResource() else: opr = Resource(newdata) opr.AddResource('Popt', OVERRIDE_OPTIONS_ID, '') if (creator, type, delaycons) != saved_gusi_options: newdata = setgusioptions(gusi_opr, creator, type, delaycons) if gusi_opr.HomeResFile == app_handle: gusi_opr.data = newdata gusi_opr.ChangedResource() else: gusi_opr = Resource(gusi_opr.data) gusi_opr.AddResource('GU\267I', OVERRIDE_GUSI_ID, '') CloseResFile(app_handle) | a332b7fe15a2360fd3e6adb90cdd941e2110cd0e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a332b7fe15a2360fd3e6adb90cdd941e2110cd0e/EditPythonPrefs.py |
self.build_scripts = os.path.join(self.build_base, 'scripts') | self.build_scripts = os.path.join(self.build_base, 'scripts-' + sys.version[0:3]) | def finalize_options (self): | 9432523c983092187b3e3d657e078956eaaf58c5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9432523c983092187b3e3d657e078956eaaf58c5/build.py |
if not self.have_fork: for k in ('QUERY_STRING', 'REMOTE_HOST', 'CONTENT_LENGTH', 'HTTP_USER_AGENT', 'HTTP_COOKIE'): env.setdefault(k, "") | for k in ('QUERY_STRING', 'REMOTE_HOST', 'CONTENT_LENGTH', 'HTTP_USER_AGENT', 'HTTP_COOKIE'): env.setdefault(k, "") | def run_cgi(self): """Execute a CGI script.""" dir, rest = self.cgi_info i = rest.rfind('?') if i >= 0: rest, query = rest[:i], rest[i+1:] else: query = '' i = rest.find('/') if i >= 0: script, rest = rest[:i], rest[i:] else: script, rest = rest, '' scriptname = dir + '/' + script scriptfile = self.translate_path(scriptname) if not os.path.exists(scriptfile): self.send_error(404, "No such CGI script (%r)" % scriptname) return if not os.path.isfile(scriptfile): self.send_error(403, "CGI script is not a plain file (%r)" % scriptname) return ispy = self.is_python(scriptname) if not ispy: if not (self.have_fork or self.have_popen2 or self.have_popen3): self.send_error(403, "CGI script is not a Python script (%r)" % scriptname) return if not self.is_executable(scriptfile): self.send_error(403, "CGI script is not executable (%r)" % scriptname) return | ced83d7d242efe1df4da6c22498fbd65ace6b9dc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ced83d7d242efe1df4da6c22498fbd65ace6b9dc/CGIHTTPServer.py |
underline=0,indicatoron=FALSE,highlightthickness=0, | indicatoron=FALSE,highlightthickness=0, | def __init__(self,parent): Frame.__init__(self, parent,borderwidth=2,relief=RIDGE) self.button=Radiobutton(self,padx=5,pady=5,takefocus=FALSE, underline=0,indicatoron=FALSE,highlightthickness=0, borderwidth=0,selectcolor=self.cget('bg')) self.button.pack() | fd0c7693beb8def1f7e8ebe5f457ae8557da7e12 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/fd0c7693beb8def1f7e8ebe5f457ae8557da7e12/tabpage.py |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.