rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
SITE_CO = compile(SITE_PY, "<-bundlebuilder->", "exec")
SITE_CO = compile(SITE_PY, "<-bundlebuilder.py->", "exec")
def report(self): # XXX something decent import pprint pprint.pprint(self.__dict__)
74bdca8a207af74796b7e4a117886be92818f6cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/74bdca8a207af74796b7e4a117886be92818f6cb/bundlebuilder.py
EXECVE_WRAPPER = """\ import os from sys import argv, executable resources = os.path.join(os.path.dirname(os.path.dirname(argv[0])), "Resources") mainprogram = os.path.join(resources, "%(mainprogram)s") assert os.path.exists(mainprogram) argv.insert(1, mainprogram) os.environ["PYTHONPATH"] = resources %(setexecutable)s os.execve(executable, argv, os.environ)
BOOTSTRAP_SCRIPT = """\ execdir=$(dirname ${0}) executable=${execdir}/%(executable)s resdir=$(dirname ${execdir})/Resources main=${resdir}/%(mainprogram)s PYTHONPATH=$resdir export PYTHONPATH exec ${executable} ${main} ${1}
def report(self): # XXX something decent import pprint pprint.pprint(self.__dict__)
74bdca8a207af74796b7e4a117886be92818f6cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/74bdca8a207af74796b7e4a117886be92818f6cb/bundlebuilder.py
setExecutableTemplate = """executable = os.path.join(resources, "%s")""" pythonhomeSnippet = """os.environ["home"] = resources"""
def report(self): # XXX something decent import pprint pprint.pprint(self.__dict__)
74bdca8a207af74796b7e4a117886be92818f6cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/74bdca8a207af74796b7e4a117886be92818f6cb/bundlebuilder.py
if self.executable is None: self.executable = sys.executable
def setup(self): if self.standalone and self.mainprogram is None: raise BundleBuilderError, ("must specify 'mainprogram' when " "building a standalone application.") if self.mainprogram is None and self.executable is None: raise BundleBuilderError, ("must specify either or both of " "'executable' and 'mainprogram'")
74bdca8a207af74796b7e4a117886be92818f6cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/74bdca8a207af74796b7e4a117886be92818f6cb/bundlebuilder.py
execpath = pathjoin(self.execdir, self.name)
execname = self.name
def preProcess(self): resdir = "Contents/Resources" if self.executable is not None: if self.mainprogram is None: execpath = pathjoin(self.execdir, self.name) else: execpath = pathjoin(resdir, os.path.basename(self.executable)) if not self.symlink_exec: self.files.append((self.executable, execpath)) self.binaries.append(execpath) self.execpath = execpath # For execve wrapper setexecutable = setExecutableTemplate % os.path.basename(self.executable) else: setexecutable = "" # XXX for locals() call
74bdca8a207af74796b7e4a117886be92818f6cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/74bdca8a207af74796b7e4a117886be92818f6cb/bundlebuilder.py
execpath = pathjoin(resdir, os.path.basename(self.executable))
execname = os.path.basename(self.executable) execpath = pathjoin(self.execdir, execname)
def preProcess(self): resdir = "Contents/Resources" if self.executable is not None: if self.mainprogram is None: execpath = pathjoin(self.execdir, self.name) else: execpath = pathjoin(resdir, os.path.basename(self.executable)) if not self.symlink_exec: self.files.append((self.executable, execpath)) self.binaries.append(execpath) self.execpath = execpath # For execve wrapper setexecutable = setExecutableTemplate % os.path.basename(self.executable) else: setexecutable = "" # XXX for locals() call
74bdca8a207af74796b7e4a117886be92818f6cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/74bdca8a207af74796b7e4a117886be92818f6cb/bundlebuilder.py
setexecutable = setExecutableTemplate % os.path.basename(self.executable) else: setexecutable = ""
def preProcess(self): resdir = "Contents/Resources" if self.executable is not None: if self.mainprogram is None: execpath = pathjoin(self.execdir, self.name) else: execpath = pathjoin(resdir, os.path.basename(self.executable)) if not self.symlink_exec: self.files.append((self.executable, execpath)) self.binaries.append(execpath) self.execpath = execpath # For execve wrapper setexecutable = setExecutableTemplate % os.path.basename(self.executable) else: setexecutable = "" # XXX for locals() call
74bdca8a207af74796b7e4a117886be92818f6cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/74bdca8a207af74796b7e4a117886be92818f6cb/bundlebuilder.py
open(mainwrapperpath, "w").write(EXECVE_WRAPPER % locals())
open(mainwrapperpath, "w").write(BOOTSTRAP_SCRIPT % locals())
def preProcess(self): resdir = "Contents/Resources" if self.executable is not None: if self.mainprogram is None: execpath = pathjoin(self.execdir, self.name) else: execpath = pathjoin(resdir, os.path.basename(self.executable)) if not self.symlink_exec: self.files.append((self.executable, execpath)) self.binaries.append(execpath) self.execpath = execpath # For execve wrapper setexecutable = setExecutableTemplate % os.path.basename(self.executable) else: setexecutable = "" # XXX for locals() call
74bdca8a207af74796b7e4a117886be92818f6cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/74bdca8a207af74796b7e4a117886be92818f6cb/bundlebuilder.py
if self.missingModules:
if self.missingModules or self.maybeMissingModules:
def postProcess(self): self.addPythonModules() if self.strip and not self.symlink: self.stripBinaries()
74bdca8a207af74796b7e4a117886be92818f6cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/74bdca8a207af74796b7e4a117886be92818f6cb/bundlebuilder.py
self.missingModules.extend(mf.any_missing())
if hasattr(mf, "any_missing_maybe"): missing, maybe = mf.any_missing_maybe() else: missing = mf.any_missing() maybe = [] self.missingModules.extend(missing) self.maybeMissingModules.extend(maybe)
def findDependencies(self): self.message("Finding module dependencies", 1) import modulefinder mf = modulefinder.ModuleFinder(excludes=self.excludeModules) # manually add our own site.py site = mf.add_module("site") site.__code__ = SITE_CO mf.scan_code(SITE_CO, site)
74bdca8a207af74796b7e4a117886be92818f6cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/74bdca8a207af74796b7e4a117886be92818f6cb/bundlebuilder.py
missingsub = [name for name in missing if "." in name] missing = [name for name in missing if "." not in name]
if self.maybeMissingModules: maybe = self.maybeMissingModules else: maybe = [name for name in missing if "." in name] missing = [name for name in missing if "." not in name]
def reportMissing(self): missing = [name for name in self.missingModules if name not in MAYMISS_MODULES] missingsub = [name for name in missing if "." in name] missing = [name for name in missing if "." not in name] missing.sort() missingsub.sort() if missing: self.message("Warning: couldn't find the following modules:", 1) self.message(" " + ", ".join(missing)) if missingsub: self.message("Warning: couldn't find the following submodules " "(but it's probably OK since modulefinder can't distinguish " "between from \"module import submodule\" and " "\"from module import name\"):", 1) self.message(" " + ", ".join(missingsub))
74bdca8a207af74796b7e4a117886be92818f6cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/74bdca8a207af74796b7e4a117886be92818f6cb/bundlebuilder.py
missingsub.sort()
maybe.sort() if maybe: self.message("Warning: couldn't find the following submodules:", 1) self.message(" (Note that these could be false alarms -- " "it's not always", 1) self.message(" possible to distinguish between from \"package import submodule\" ", 1) self.message(" and \"from package import name\")", 1) for name in maybe: self.message(" ? " + name, 1)
def reportMissing(self): missing = [name for name in self.missingModules if name not in MAYMISS_MODULES] missingsub = [name for name in missing if "." in name] missing = [name for name in missing if "." not in name] missing.sort() missingsub.sort() if missing: self.message("Warning: couldn't find the following modules:", 1) self.message(" " + ", ".join(missing)) if missingsub: self.message("Warning: couldn't find the following submodules " "(but it's probably OK since modulefinder can't distinguish " "between from \"module import submodule\" and " "\"from module import name\"):", 1) self.message(" " + ", ".join(missingsub))
74bdca8a207af74796b7e4a117886be92818f6cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/74bdca8a207af74796b7e4a117886be92818f6cb/bundlebuilder.py
self.message(" " + ", ".join(missing)) if missingsub: self.message("Warning: couldn't find the following submodules " "(but it's probably OK since modulefinder can't distinguish " "between from \"module import submodule\" and " "\"from module import name\"):", 1) self.message(" " + ", ".join(missingsub))
for name in missing: self.message(" ? " + name, 1) def report(self): import pprint pprint.pprint(self.__dict__) if self.standalone: self.reportMissing()
def reportMissing(self): missing = [name for name in self.missingModules if name not in MAYMISS_MODULES] missingsub = [name for name in missing if "." in name] missing = [name for name in missing if "." not in name] missing.sort() missingsub.sort() if missing: self.message("Warning: couldn't find the following modules:", 1) self.message(" " + ", ".join(missing)) if missingsub: self.message("Warning: couldn't find the following submodules " "(but it's probably OK since modulefinder can't distinguish " "between from \"module import submodule\" and " "\"from module import name\"):", 1) self.message(" " + ", ".join(missingsub))
74bdca8a207af74796b7e4a117886be92818f6cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/74bdca8a207af74796b7e4a117886be92818f6cb/bundlebuilder.py
"""Like nstransfercmd() but returns only the socket."""
"""Like ntransfercmd() but returns only the socket."""
def transfercmd(self, cmd, rest=None): """Like nstransfercmd() but returns only the socket.""" return self.ntransfercmd(cmd, rest)[0]
b6aca6afe2c46b57810c0f3e726e6dae5336d324 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b6aca6afe2c46b57810c0f3e726e6dae5336d324/ftplib.py
return int(resp[3:].strip())
s = resp[3:].strip() try: return int(s) except OverflowError: return long(s)
def size(self, filename): '''Retrieve the size of a file.''' # Note that the RFC doesn't say anything about 'SIZE' resp = self.sendcmd('SIZE ' + filename) if resp[:3] == '213': return int(resp[3:].strip())
b6aca6afe2c46b57810c0f3e726e6dae5336d324 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b6aca6afe2c46b57810c0f3e726e6dae5336d324/ftplib.py
if m: return int(m.group(1)) return None
if not m: return None s = m.group(1) try: return int(s) except OverflowError: return long(s)
def parse150(resp): '''Parse the '150' response for a RETR request. Returns the expected transfer size or None; size is not guaranteed to be present in the 150 message. ''' if resp[:3] != '150': raise error_reply, resp global _150_re if _150_re is None: import re _150_re = re.compile("150 .* \((\d+) bytes\)", re.IGNORECASE) m = _150_re.match(resp) if m: return int(m.group(1)) return None
b6aca6afe2c46b57810c0f3e726e6dae5336d324 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b6aca6afe2c46b57810c0f3e726e6dae5336d324/ftplib.py
opts, args = getopt.getopt(sys.argv[1:], 'm:qv')
opts, args = getopt.getopt(sys.argv[1:], 't:m:qva')
def main(): try: opts, args = getopt.getopt(sys.argv[1:], 'm:qv') except getopt.error, msg: sys.stdout = sys.stderr print msg print __doc__%vars(webchecker) sys.exit(2) for o, a in opts: if o == '-m': webchecker.maxpage = string.atoi(a) if o == '-q': webchecker.verbose = 0 if o == '-v': webchecker.verbose = webchecker.verbose + 1 root = Tk(className='Webchecker') root.protocol("WM_DELETE_WINDOW", root.quit) c = CheckerWindow(root) if args: for arg in args[:-1]: c.addroot(arg) c.suggestroot(args[-1]) root.mainloop()
a8946406dfd6f4ecaf090325eed64241b36b5d4a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a8946406dfd6f4ecaf090325eed64241b36b5d4a/wcgui.py
self.__todo = ListPanel(mp, "To check", self.showinfo) self.__done = ListPanel(mp, "Checked", self.showinfo) self.__bad = ListPanel(mp, "Bad links", self.showinfo) self.__errors = ListPanel(mp, "Pages w/ bad links", self.showinfo)
self.__todo = ListPanel(mp, "To check", self, self.showinfo) self.__done = ListPanel(mp, "Checked", self, self.showinfo) self.__bad = ListPanel(mp, "Bad links", self, self.showinfo) self.__errors = ListPanel(mp, "Pages w/ bad links", self, self.showinfo)
def __init__(self, parent, root=webchecker.DEFROOT): self.__parent = parent
a8946406dfd6f4ecaf090325eed64241b36b5d4a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a8946406dfd6f4ecaf090325eed64241b36b5d4a/wcgui.py
self.__checking.config(text="Checking "+url)
self.__checking.config(text="Checking "+self.format_url(url))
def dosomething(self): if self.__busy: return self.__busy = 1 if self.todo: l = self.__todo.selectedindices() if l: i = l[0] else: i = 0 self.__todo.list.select_set(i) self.__todo.list.yview(i) url = self.__todo.items[i] self.__checking.config(text="Checking "+url) self.__parent.update() self.dopage(url) else: self.stop() self.__busy = 0 self.go()
a8946406dfd6f4ecaf090325eed64241b36b5d4a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a8946406dfd6f4ecaf090325eed64241b36b5d4a/wcgui.py
d.put("URL: %s\n" % url)
d.put("URL: %s\n" % self.format_url(url))
def showinfo(self, url): d = self.__details d.clear() d.put("URL: %s\n" % url) if self.bad.has_key(url): d.put("Error: %s\n" % str(self.bad[url])) if url in self.roots: d.put("Note: This is a root URL\n") if self.done.has_key(url): d.put("Status: checked\n") o = self.done[url] elif self.todo.has_key(url): d.put("Status: to check\n") o = self.todo[url] else: d.put("Status: unknown (!)\n") o = [] if self.errors.has_key(url): d.put("Bad links from this page:\n") for triple in self.errors[url]: link, rawlink, msg = triple d.put(" HREF %s" % link) if link != rawlink: d.put(" (%s)" %rawlink) d.put("\n") d.put(" error %s\n" % str(msg)) self.__mp.showpanel("Details") for source, rawlink in o: d.put("Origin: %s" % source) if rawlink != url: d.put(" (%s)" % rawlink) d.put("\n") d.text.yview("1.0")
a8946406dfd6f4ecaf090325eed64241b36b5d4a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a8946406dfd6f4ecaf090325eed64241b36b5d4a/wcgui.py
if self.errors.has_key(url):
if (not url[1]) and self.errors.has_key(url[0]):
def showinfo(self, url): d = self.__details d.clear() d.put("URL: %s\n" % url) if self.bad.has_key(url): d.put("Error: %s\n" % str(self.bad[url])) if url in self.roots: d.put("Note: This is a root URL\n") if self.done.has_key(url): d.put("Status: checked\n") o = self.done[url] elif self.todo.has_key(url): d.put("Status: to check\n") o = self.todo[url] else: d.put("Status: unknown (!)\n") o = [] if self.errors.has_key(url): d.put("Bad links from this page:\n") for triple in self.errors[url]: link, rawlink, msg = triple d.put(" HREF %s" % link) if link != rawlink: d.put(" (%s)" %rawlink) d.put("\n") d.put(" error %s\n" % str(msg)) self.__mp.showpanel("Details") for source, rawlink in o: d.put("Origin: %s" % source) if rawlink != url: d.put(" (%s)" % rawlink) d.put("\n") d.text.yview("1.0")
a8946406dfd6f4ecaf090325eed64241b36b5d4a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a8946406dfd6f4ecaf090325eed64241b36b5d4a/wcgui.py
for triple in self.errors[url]:
for triple in self.errors[url[0]]:
def showinfo(self, url): d = self.__details d.clear() d.put("URL: %s\n" % url) if self.bad.has_key(url): d.put("Error: %s\n" % str(self.bad[url])) if url in self.roots: d.put("Note: This is a root URL\n") if self.done.has_key(url): d.put("Status: checked\n") o = self.done[url] elif self.todo.has_key(url): d.put("Status: to check\n") o = self.todo[url] else: d.put("Status: unknown (!)\n") o = [] if self.errors.has_key(url): d.put("Bad links from this page:\n") for triple in self.errors[url]: link, rawlink, msg = triple d.put(" HREF %s" % link) if link != rawlink: d.put(" (%s)" %rawlink) d.put("\n") d.put(" error %s\n" % str(msg)) self.__mp.showpanel("Details") for source, rawlink in o: d.put("Origin: %s" % source) if rawlink != url: d.put(" (%s)" % rawlink) d.put("\n") d.text.yview("1.0")
a8946406dfd6f4ecaf090325eed64241b36b5d4a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a8946406dfd6f4ecaf090325eed64241b36b5d4a/wcgui.py
d.put(" HREF %s" % link) if link != rawlink: d.put(" (%s)" %rawlink)
d.put(" HREF %s" % self.format_url(link)) if self.format_url(link) != rawlink: d.put(" (%s)" %rawlink)
def showinfo(self, url): d = self.__details d.clear() d.put("URL: %s\n" % url) if self.bad.has_key(url): d.put("Error: %s\n" % str(self.bad[url])) if url in self.roots: d.put("Note: This is a root URL\n") if self.done.has_key(url): d.put("Status: checked\n") o = self.done[url] elif self.todo.has_key(url): d.put("Status: to check\n") o = self.todo[url] else: d.put("Status: unknown (!)\n") o = [] if self.errors.has_key(url): d.put("Bad links from this page:\n") for triple in self.errors[url]: link, rawlink, msg = triple d.put(" HREF %s" % link) if link != rawlink: d.put(" (%s)" %rawlink) d.put("\n") d.put(" error %s\n" % str(msg)) self.__mp.showpanel("Details") for source, rawlink in o: d.put("Origin: %s" % source) if rawlink != url: d.put(" (%s)" % rawlink) d.put("\n") d.text.yview("1.0")
a8946406dfd6f4ecaf090325eed64241b36b5d4a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a8946406dfd6f4ecaf090325eed64241b36b5d4a/wcgui.py
if rawlink != url:
if rawlink != self.format_url(url):
def showinfo(self, url): d = self.__details d.clear() d.put("URL: %s\n" % url) if self.bad.has_key(url): d.put("Error: %s\n" % str(self.bad[url])) if url in self.roots: d.put("Note: This is a root URL\n") if self.done.has_key(url): d.put("Status: checked\n") o = self.done[url] elif self.todo.has_key(url): d.put("Status: to check\n") o = self.todo[url] else: d.put("Status: unknown (!)\n") o = [] if self.errors.has_key(url): d.put("Bad links from this page:\n") for triple in self.errors[url]: link, rawlink, msg = triple d.put(" HREF %s" % link) if link != rawlink: d.put(" (%s)" %rawlink) d.put("\n") d.put(" error %s\n" % str(msg)) self.__mp.showpanel("Details") for source, rawlink in o: d.put("Origin: %s" % source) if rawlink != url: d.put(" (%s)" % rawlink) d.put("\n") d.text.yview("1.0")
a8946406dfd6f4ecaf090325eed64241b36b5d4a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a8946406dfd6f4ecaf090325eed64241b36b5d4a/wcgui.py
self.__errors.insert(url)
self.__errors.insert((url, ''))
def seterror(self, url, triple): webchecker.Checker.seterror(self, url, triple) self.__errors.insert(url) self.newstatus()
a8946406dfd6f4ecaf090325eed64241b36b5d4a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a8946406dfd6f4ecaf090325eed64241b36b5d4a/wcgui.py
def __init__(self, mp, name, showinfo=None):
def __init__(self, mp, name, checker, showinfo=None):
def __init__(self, mp, name, showinfo=None): self.mp = mp self.name = name self.showinfo = showinfo self.panel = mp.addpanel(name) self.list, self.frame = tktools.make_list_box( self.panel, width=60, height=5) self.list.config(exportselection=0) if showinfo: self.list.bind('<Double-Button-1>', self.doubleclick) self.items = []
a8946406dfd6f4ecaf090325eed64241b36b5d4a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a8946406dfd6f4ecaf090325eed64241b36b5d4a/wcgui.py
self.showinfo(self.list.get(l[0]))
self.showinfo(self.items[l[0]])
def doubleclick(self, event): l = self.selectedindices() if l: self.showinfo(self.list.get(l[0]))
a8946406dfd6f4ecaf090325eed64241b36b5d4a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a8946406dfd6f4ecaf090325eed64241b36b5d4a/wcgui.py
self.list.insert(i, url)
self.list.insert(i, self.checker.format_url(url))
def insert(self, url): if url not in self.items: if not self.items: self.mp.showpanel(self.name) # (I tried sorting alphabetically, but the display is too jumpy) i = len(self.items) self.list.insert(i, url) self.list.yview(i) self.items.insert(i, url)
a8946406dfd6f4ecaf090325eed64241b36b5d4a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a8946406dfd6f4ecaf090325eed64241b36b5d4a/wcgui.py
if self.basetype: Output("
Output("
def generate(self): # XXX This should use long strings and %(varname)s substitution!
5bb2f6497f6b4455e4da64ef049bf43cd1c2215a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5bb2f6497f6b4455e4da64ef049bf43cd1c2215a/bgenObjectDefinition.py
else: Output(" self.prefix, self.typename)
def generate(self): # XXX This should use long strings and %(varname)s substitution!
5bb2f6497f6b4455e4da64ef049bf43cd1c2215a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5bb2f6497f6b4455e4da64ef049bf43cd1c2215a/bgenObjectDefinition.py
env['CONTENT_TYPE'] = self.headers.type
if self.headers.typeheader is None: env['CONTENT_TYPE'] = self.headers.type else: env['CONTENT_TYPE'] = self.headers.typeheader
def run_cgi(self): """Execute a CGI script.""" dir, rest = self.cgi_info i = string.rfind(rest, '?') if i >= 0: rest, query = rest[:i], rest[i+1:] else: query = '' i = string.find(rest, '/') 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 (%s)" % `scriptname`) return if not os.path.isfile(scriptfile): self.send_error(403, "CGI script is not a plain file (%s)" % `scriptname`) return if not executable(scriptfile): self.send_error(403, "CGI script is not executable (%s)" % `scriptname`) return nobody = nobody_uid() self.send_response(200, "Script output follows") self.wfile.flush() # Always flush before forking pid = os.fork() if pid != 0: # Parent pid, sts = os.waitpid(pid, 0) if sts: self.log_error("CGI script exit status x%x" % sts) return # Child try: # Reference: http://hoohoo.ncsa.uiuc.edu/cgi/env.html # XXX Much of the following could be prepared ahead of time! env = {} env['SERVER_SOFTWARE'] = self.version_string() env['SERVER_NAME'] = self.server.server_name env['GATEWAY_INTERFACE'] = 'CGI/1.1' env['SERVER_PROTOCOL'] = self.protocol_version env['SERVER_PORT'] = str(self.server.server_port) env['REQUEST_METHOD'] = self.command uqrest = urllib.unquote(rest) env['PATH_INFO'] = uqrest env['PATH_TRANSLATED'] = self.translate_path(uqrest) env['SCRIPT_NAME'] = scriptname if query: env['QUERY_STRING'] = query host = self.address_string() if host != self.client_address[0]: env['REMOTE_HOST'] = host env['REMOTE_ADDR'] = self.client_address[0] # AUTH_TYPE # REMOTE_USER # REMOTE_IDENT env['CONTENT_TYPE'] = self.headers.type length = self.headers.getheader('content-length') if length: env['CONTENT_LENGTH'] = length accept = [] for line in self.headers.getallmatchingheaders('accept'): if line[:1] in string.whitespace: accept.append(string.strip(line)) else: accept = accept + string.split(line[7:]) env['HTTP_ACCEPT'] = string.joinfields(accept, ',') ua = self.headers.getheader('user-agent') if ua: env['HTTP_USER_AGENT'] = ua # XXX Other HTTP_* headers decoded_query = string.replace(query, '+', ' ') try: os.setuid(nobody) except os.error: pass os.dup2(self.rfile.fileno(), 0) os.dup2(self.wfile.fileno(), 1) print scriptfile, script, decoded_query os.execve(scriptfile, [script, decoded_query], env) except: self.server.handle_error(self.request, self.client_address) os._exit(127)
01fc65d92fcf774c4b14fb0e744ad4d08c825168 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/01fc65d92fcf774c4b14fb0e744ad4d08c825168/CGIHTTPServer.py
def print_debug(msg): if debug: print msg def _open(fullpath):
def needs_declaration(fullpath):
def print_debug(msg): if debug: print msg
568973181aa523bbcf7f827b3a2eb2affd96ea67 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/568973181aa523bbcf7f827b3a2eb2affd96ea67/findnocoding.py
size = os.stat(fullpath).st_size except OSError, err: print_debug("%s: permission denied: %s" % (fullpath, err))
infile = open(fullpath, 'rU') except IOError:
def _open(fullpath): try: size = os.stat(fullpath).st_size except OSError, err: # Permission denied - ignore the file print_debug("%s: permission denied: %s" % (fullpath, err)) return None if size > 1024*1024: # too big print_debug("%s: the file is too big: %d bytes" % (fullpath, size)) return None try: return open(fullpath, 'rU') except IOError, err: # Access denied, or a special file - ignore it print_debug("%s: access denied: %s" % (fullpath, err)) return None
568973181aa523bbcf7f827b3a2eb2affd96ea67 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/568973181aa523bbcf7f827b3a2eb2affd96ea67/findnocoding.py
if size > 1024*1024: print_debug("%s: the file is too big: %d bytes" % (fullpath, size)) return None try: return open(fullpath, 'rU') except IOError, err: print_debug("%s: access denied: %s" % (fullpath, err)) return None def has_python_ext(fullpath): return fullpath.endswith(".py") or fullpath.endswith(".pyw") def looks_like_python(fullpath): infile = _open(fullpath) if infile is None:
line1 = infile.readline() line2 = infile.readline() if get_declaration(line1) or get_declaration(line2): infile.close()
def _open(fullpath): try: size = os.stat(fullpath).st_size except OSError, err: # Permission denied - ignore the file print_debug("%s: permission denied: %s" % (fullpath, err)) return None if size > 1024*1024: # too big print_debug("%s: the file is too big: %d bytes" % (fullpath, size)) return None try: return open(fullpath, 'rU') except IOError, err: # Access denied, or a special file - ignore it print_debug("%s: access denied: %s" % (fullpath, err)) return None
568973181aa523bbcf7f827b3a2eb2affd96ea67 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/568973181aa523bbcf7f827b3a2eb2affd96ea67/findnocoding.py
line = infile.readline()
rest = infile.read()
def looks_like_python(fullpath): infile = _open(fullpath) if infile is None: return False line = infile.readline() infile.close() if binary_re.search(line): # file appears to be binary print_debug("%s: appears to be binary" % fullpath) return False if fullpath.endswith(".py") or fullpath.endswith(".pyw"): return True elif "python" in line: # disguised Python script (e.g. CGI) return True return False
568973181aa523bbcf7f827b3a2eb2affd96ea67 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/568973181aa523bbcf7f827b3a2eb2affd96ea67/findnocoding.py
if binary_re.search(line): print_debug("%s: appears to be binary" % fullpath)
if has_correct_encoding(line1+line2+rest, "ascii"):
def looks_like_python(fullpath): infile = _open(fullpath) if infile is None: return False line = infile.readline() infile.close() if binary_re.search(line): # file appears to be binary print_debug("%s: appears to be binary" % fullpath) return False if fullpath.endswith(".py") or fullpath.endswith(".pyw"): return True elif "python" in line: # disguised Python script (e.g. CGI) return True return False
568973181aa523bbcf7f827b3a2eb2affd96ea67 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/568973181aa523bbcf7f827b3a2eb2affd96ea67/findnocoding.py
if fullpath.endswith(".py") or fullpath.endswith(".pyw"): return True elif "python" in line: return True return False def can_be_compiled(fullpath): infile = _open(fullpath) if infile is None: return False code = infile.read() infile.close() try: compile(code, fullpath, "exec") except Exception, err: print_debug("%s: cannot compile: %s" % (fullpath, err)) return False
def looks_like_python(fullpath): infile = _open(fullpath) if infile is None: return False line = infile.readline() infile.close() if binary_re.search(line): # file appears to be binary print_debug("%s: appears to be binary" % fullpath) return False if fullpath.endswith(".py") or fullpath.endswith(".pyw"): return True elif "python" in line: # disguised Python script (e.g. CGI) return True return False
568973181aa523bbcf7f827b3a2eb2affd96ea67 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/568973181aa523bbcf7f827b3a2eb2affd96ea67/findnocoding.py
def walk_python_files(paths, is_python=looks_like_python, exclude_dirs=None): """\ Recursively yield all Python source files below the given paths.
usage = """Usage: %s [-cd] paths... -c: recognize Python source files trying to compile them -d: debug output""" % sys.argv[0]
def walk_python_files(paths, is_python=looks_like_python, exclude_dirs=None): """\ Recursively yield all Python source files below the given paths. paths: a list of files and/or directories to be checked. is_python: a function that takes a file name and checks whether it is a Python source file exclude_dirs: a list of directory base names that should be excluded in the search """ if exclude_dirs is None: exclude_dirs=[] for path in paths: print_debug("testing: %s" % path) if os.path.isfile(path): if is_python(path): yield path elif os.path.isdir(path): print_debug(" it is a directory") for dirpath, dirnames, filenames in os.walk(path): for exclude in exclude_dirs: if exclude in dirnames: dirnames.remove(exclude) for filename in filenames: fullpath = os.path.join(dirpath, filename) print_debug("testing: %s" % fullpath) if is_python(fullpath): yield fullpath else: print_debug(" unknown type")
568973181aa523bbcf7f827b3a2eb2affd96ea67 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/568973181aa523bbcf7f827b3a2eb2affd96ea67/findnocoding.py
paths: a list of files and/or directories to be checked. is_python: a function that takes a file name and checks whether it is a Python source file exclude_dirs: a list of directory base names that should be excluded in the search """ if exclude_dirs is None: exclude_dirs=[] for path in paths: print_debug("testing: %s" % path) if os.path.isfile(path): if is_python(path): yield path elif os.path.isdir(path): print_debug(" it is a directory") for dirpath, dirnames, filenames in os.walk(path): for exclude in exclude_dirs: if exclude in dirnames: dirnames.remove(exclude) for filename in filenames: fullpath = os.path.join(dirpath, filename) print_debug("testing: %s" % fullpath) if is_python(fullpath): yield fullpath else: print_debug(" unknown type")
try: opts, args = getopt.getopt(sys.argv[1:], 'cd') except getopt.error, msg: print >>sys.stderr, msg print >>sys.stderr, usage sys.exit(1) is_python = pysource.looks_like_python debug = False for o, a in opts: if o == '-c': is_python = pysource.can_be_compiled elif o == '-d': debug = True if not args: print >>sys.stderr, usage sys.exit(1) for fullpath in pysource.walk_python_files(args, is_python): if debug: print "Testing for coding: %s" % fullpath result = needs_declaration(fullpath) if result: print fullpath
def walk_python_files(paths, is_python=looks_like_python, exclude_dirs=None): """\ Recursively yield all Python source files below the given paths. paths: a list of files and/or directories to be checked. is_python: a function that takes a file name and checks whether it is a Python source file exclude_dirs: a list of directory base names that should be excluded in the search """ if exclude_dirs is None: exclude_dirs=[] for path in paths: print_debug("testing: %s" % path) if os.path.isfile(path): if is_python(path): yield path elif os.path.isdir(path): print_debug(" it is a directory") for dirpath, dirnames, filenames in os.walk(path): for exclude in exclude_dirs: if exclude in dirnames: dirnames.remove(exclude) for filename in filenames: fullpath = os.path.join(dirpath, filename) print_debug("testing: %s" % fullpath) if is_python(fullpath): yield fullpath else: print_debug(" unknown type")
568973181aa523bbcf7f827b3a2eb2affd96ea67 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/568973181aa523bbcf7f827b3a2eb2affd96ea67/findnocoding.py
if __name__ == "__main__": for fullpath in walk_python_files(['.']): print fullpath print "----------" for fullpath in walk_python_files(['.'], is_python=can_be_compiled): print fullpath
def walk_python_files(paths, is_python=looks_like_python, exclude_dirs=None): """\ Recursively yield all Python source files below the given paths. paths: a list of files and/or directories to be checked. is_python: a function that takes a file name and checks whether it is a Python source file exclude_dirs: a list of directory base names that should be excluded in the search """ if exclude_dirs is None: exclude_dirs=[] for path in paths: print_debug("testing: %s" % path) if os.path.isfile(path): if is_python(path): yield path elif os.path.isdir(path): print_debug(" it is a directory") for dirpath, dirnames, filenames in os.walk(path): for exclude in exclude_dirs: if exclude in dirnames: dirnames.remove(exclude) for filename in filenames: fullpath = os.path.join(dirpath, filename) print_debug("testing: %s" % fullpath) if is_python(fullpath): yield fullpath else: print_debug(" unknown type")
568973181aa523bbcf7f827b3a2eb2affd96ea67 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/568973181aa523bbcf7f827b3a2eb2affd96ea67/findnocoding.py
"""Tix maintains a list of directory under which which
"""Tix maintains a list of directories under which
def tix_addbitmapdir(self, directory): """Tix maintains a list of directory under which which the tix_getimage and tix_getbitmap commands will search for image files. The standard bitmap direc tory is $TIX_LIBRARY/bitmaps. The addbitmapdir com mand adds directory into this list. By using this command, the image files of an applications can also be located using the tix_getimage or tix_getbitmap command. """ return self.tk.call('tix', 'addbitmapdir', directory)
723293cb49f479a41dc893d72c2d6502587d52cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/723293cb49f479a41dc893d72c2d6502587d52cb/Tix.py
search for image files. The standard bitmap direc tory is $TIX_LIBRARY/bitmaps. The addbitmapdir com mand adds directory into this list. By using this
search for image files. The standard bitmap directory is $TIX_LIBRARY/bitmaps. The addbitmapdir command adds directory into this list. By using this
def tix_addbitmapdir(self, directory): """Tix maintains a list of directory under which which the tix_getimage and tix_getbitmap commands will search for image files. The standard bitmap direc tory is $TIX_LIBRARY/bitmaps. The addbitmapdir com mand adds directory into this list. By using this command, the image files of an applications can also be located using the tix_getimage or tix_getbitmap command. """ return self.tk.call('tix', 'addbitmapdir', directory)
723293cb49f479a41dc893d72c2d6502587d52cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/723293cb49f479a41dc893d72c2d6502587d52cb/Tix.py
"""Query or modify the configuration options of the Tix application context. If no option is specified, returns a list describing all of the available options (see Tk_ConfigureInfo for information on the format of this list). If option is specified with no value, then the command returns a list describing the one named option (this list will be identical to the corresponding sublist of the value returned if no option is specified). If one or more option-value pairs are specified, then the command modifies the given option(s) to have the given value(s); in this case the command returns an empty string. Option may be any of the options described in the CONFIGURATION OPTIONS section.
"""Query or modify the configuration options of the Tix application context. If no option is specified, returns a dictionary all of the available options. If option is specified with no value, then the command returns a list describing the one named option (this list will be identical to the corresponding sublist of the value returned if no option is specified). If one or more option-value pairs are specified, then the command modifies the given option(s) to have the given value(s); in this case the command returns an empty string. Option may be any of the configuration options.
def tix_configure(self, cnf=None, **kw): """Query or modify the configuration options of the Tix application context. If no option is specified, returns a list describing all of the available options (see Tk_ConfigureInfo for information on the format of this list). If option is specified with no value, then the command returns a list describing the one named option (this list will be identical to the corresponding sublist of the value returned if no option is specified). If one or more option-value pairs are specified, then the command modifies the given option(s) to have the given value(s); in this case the command returns an empty string. Option may be any of the options described in the CONFIGURATION OPTIONS section. """ return apply(self.tk.call, ('tix', configure) + self._options(cnf,kw) )
723293cb49f479a41dc893d72c2d6502587d52cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/723293cb49f479a41dc893d72c2d6502587d52cb/Tix.py
return apply(self.tk.call, ('tix', configure) + self._options(cnf,kw) )
if kw: cnf = _cnfmerge((cnf, kw)) elif cnf: cnf = _cnfmerge(cnf) if cnf is None: cnf = {} for x in self.tk.split(self.tk.call('tix', 'configure')): cnf[x[0][1:]] = (x[0][1:],) + x[1:] return cnf if isinstance(cnf, StringType): x = self.tk.split(self.tk.call('tix', 'configure', '-'+cnf)) return (x[0][1:],) + x[1:] return self.tk.call(('tix', 'configure') + self._options(cnf))
def tix_configure(self, cnf=None, **kw): """Query or modify the configuration options of the Tix application context. If no option is specified, returns a list describing all of the available options (see Tk_ConfigureInfo for information on the format of this list). If option is specified with no value, then the command returns a list describing the one named option (this list will be identical to the corresponding sublist of the value returned if no option is specified). If one or more option-value pairs are specified, then the command modifies the given option(s) to have the given value(s); in this case the command returns an empty string. Option may be any of the options described in the CONFIGURATION OPTIONS section. """ return apply(self.tk.call, ('tix', configure) + self._options(cnf,kw) )
723293cb49f479a41dc893d72c2d6502587d52cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/723293cb49f479a41dc893d72c2d6502587d52cb/Tix.py
"""Returns the file selection dialog that may be shared among different modules of this application. This command will create a file selection dialog widget when it is called the first time. This dialog will be returned by all subsequent calls to tix filedialog. An optional dlgclass parameter can be passed to specified what type of file selection dialog widget is desired. Possible options are 'tix' 'FileSelectDialog' or 'tixExFileSelectDialog'.
"""Returns the file selection dialog that may be shared among different calls from this application. This command will create a file selection dialog widget when it is called the first time. This dialog will be returned by all subsequent calls to tix_filedialog. An optional dlgclass parameter can be passed to specified what type of file selection dialog widget is desired. Possible options are tix FileSelectDialog or tixExFileSelectDialog.
def tix_filedialog(self, dlgclass=None): """Returns the file selection dialog that may be shared among different modules of this application. This command will create a file selection dialog widget when it is called the first time. This dialog will be returned by all subsequent calls to tix filedialog. An optional dlgclass parameter can be passed to specified what type of file selection dialog widget is desired. Possible options are 'tix' 'FileSelectDialog' or 'tixExFileSelectDialog'. """ if dlgclass is not None: return self.tk.call('tix', 'filedialog', dlgclass) else: return self.tk.call('tix', 'filedialog')
723293cb49f479a41dc893d72c2d6502587d52cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/723293cb49f479a41dc893d72c2d6502587d52cb/Tix.py
"""Locates a bitmap file of the name name.xpm or name in one of the bitmap directories (self, see the tix_addbitmapdir command above). By using tix_getbitmap, you can advoid hard coding the pathnames of the bitmap files in your application. When successful, it returns the complete pathname of the bitmap file, prefixed with the character '@'. The returned value can be used to configure the -bitmap option of the TK and Tix widgets.
"""Locates a bitmap file of the name name.xpm or name in one of the bitmap directories (see the tix_addbitmapdir command above). By using tix_getbitmap, you can avoid hard coding the pathnames of the bitmap files in your application. When successful, it returns the complete pathname of the bitmap file, prefixed with the character '@'. The returned value can be used to configure the -bitmap option of the TK and Tix widgets.
def tix_getbitmap(self, name): """Locates a bitmap file of the name name.xpm or name in one of the bitmap directories (self, see the tix_addbitmapdir command above). By using tix_getbitmap, you can advoid hard coding the pathnames of the bitmap files in your application. When successful, it returns the complete pathname of the bitmap file, prefixed with the character '@'. The returned value can be used to configure the -bitmap option of the TK and Tix widgets. """ return self.tk.call('tix', 'getbitmap', name)
723293cb49f479a41dc893d72c2d6502587d52cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/723293cb49f479a41dc893d72c2d6502587d52cb/Tix.py
"""Locates an image file of the name name.xpm, name.xbm or name.ppm in one of the bitmap directo ries (see the addbitmapdir command above). If more than one file with the same name (but different extensions) exist, then the image type is chosen according to the depth of the X display: xbm images are chosen on monochrome displays and color images are chosen on color displays. By using tix getim age, you can advoid hard coding the pathnames of the image files in your application. When success ful, this command returns the name of the newly created image, which can be used to configure the -image option of the TK and Tix widgets.
"""Locates an image file of the name name.xpm, name.xbm or name.ppm in one of the bitmap directories (see the addbitmapdir command above). If more than one file with the same name (but different extensions) exist, then the image type is chosen according to the depth of the X display: xbm images are chosen on monochrome displays and color images are chosen on color displays. By using tix_ getimage, you can advoid hard coding the pathnames of the image files in your application. When successful, this command returns the name of the newly created image, which can be used to configure the -image option of the Tk and Tix widgets.
def tix_getimage(self, name): """Locates an image file of the name name.xpm, name.xbm or name.ppm in one of the bitmap directo ries (see the addbitmapdir command above). If more than one file with the same name (but different extensions) exist, then the image type is chosen according to the depth of the X display: xbm images are chosen on monochrome displays and color images are chosen on color displays. By using tix getim age, you can advoid hard coding the pathnames of the image files in your application. When success ful, this command returns the name of the newly created image, which can be used to configure the -image option of the TK and Tix widgets. """ return self.tk.call('tix', 'getimage', name)
723293cb49f479a41dc893d72c2d6502587d52cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/723293cb49f479a41dc893d72c2d6502587d52cb/Tix.py
scheme mechanism. Available options are:
scheme mechanism. Available options include:
def tix_option_get(self, name): """Gets the options manitained by the Tix scheme mechanism. Available options are:
723293cb49f479a41dc893d72c2d6502587d52cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/723293cb49f479a41dc893d72c2d6502587d52cb/Tix.py
"""Resets the scheme and fontset of the Tix application to newScheme and newFontSet, respectively. This affects only those widgets created after this call. Therefore, it is best to call the resetop tions command before the creation of any widgets in a Tix application. The optional parameter newScmPrio can be given to reset the priority level of the TK options set by the Tix schemes. Because of the way TK handles the X option database, after tixwish has started up, it is not possible to reset the color schemes and font sets using the tix config command. Instead, the tix resetoptions command must be used.
"""Resets the scheme and fontset of the Tix application to newScheme and newFontSet, respectively. This affects only those widgets created after this call. Therefore, it is best to call the resetoptions command before the creation of any widgets in a Tix application. The optional parameter newScmPrio can be given to reset the priority level of the Tk options set by the Tix schemes. Because of the way Tk handles the X option database, after Tix has been has imported and inited, it is not possible to reset the color schemes and font sets using the tix config command. Instead, the tix_resetoptions command must be used.
def tix_resetoptions(self, newScheme, newFontSet, newScmPrio=None): """Resets the scheme and fontset of the Tix application to newScheme and newFontSet, respectively. This affects only those widgets created after this call. Therefore, it is best to call the resetop tions command before the creation of any widgets in a Tix application.
723293cb49f479a41dc893d72c2d6502587d52cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/723293cb49f479a41dc893d72c2d6502587d52cb/Tix.py
def __init__(self, screenName=None, baseName=None, className='Tix'): Tkinter.Tk.__init__(self, screenName, baseName, className) tixlib = os.environ.get('TIX_LIBRARY') self.tk.eval('global auto_path; lappend auto_path [file dir [info nameof]]') if tixlib is not None: self.tk.eval('global auto_path; lappend auto_path {%s}' % tixlib) self.tk.eval('global tcl_pkgPath; lappend tcl_pkgPath {%s}' % tixlib) # Load Tix - this should work dynamically or statically # If it's static, lib/tix8.1/pkgIndex.tcl should have # 'load {} Tix' # If it's dynamic, lib/tix8.1/pkgIndex.tcl should have # 'load libtix8.1.8.3.so Tix' self.tk.eval('package require Tix')
723293cb49f479a41dc893d72c2d6502587d52cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/723293cb49f479a41dc893d72c2d6502587d52cb/Tix.py
elif type(option) != type(''):
elif not isinstance(option, StringType):
def config_all(self, option, value): """Set configuration options for all subwidgets (and self).""" if option == '': return elif type(option) != type(''): option = `option` if type(value) != type(''): value = `value` names = self._subwidget_names() for name in names: self.tk.call(name, 'configure', '-' + option, value)
723293cb49f479a41dc893d72c2d6502587d52cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/723293cb49f479a41dc893d72c2d6502587d52cb/Tix.py
if type(value) != type(''):
if not isinstance(value, StringType):
def config_all(self, option, value): """Set configuration options for all subwidgets (and self).""" if option == '': return elif type(option) != type(''): option = `option` if type(value) != type(''): value = `value` names = self._subwidget_names() for name in names: self.tk.call(name, 'configure', '-' + option, value)
723293cb49f479a41dc893d72c2d6502587d52cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/723293cb49f479a41dc893d72c2d6502587d52cb/Tix.py
label Label message Message"""
label Label message Message"""
def __getitem__(self,key): return self.tk.call(self.stylename, 'cget', '-%s'%key)
723293cb49f479a41dc893d72c2d6502587d52cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/723293cb49f479a41dc893d72c2d6502587d52cb/Tix.py
static = ['options', 'installcolormap', 'initwait', 'statusbar', 'cursor']
static = ['options', 'installcolormap', 'initwait', 'statusbar', 'cursor']
def __init__(self, master=None, cnf={}, **kw): # static seem to be -installcolormap -initwait -statusbar -cursor static = ['options', 'installcolormap', 'initwait', 'statusbar', 'cursor'] TixWidget.__init__(self, master, 'tixBalloon', static, cnf, kw) self.subwidget_list['label'] = _dummyLabel(self, 'label', destroy_physically=0) self.subwidget_list['message'] = _dummyLabel(self, 'message', destroy_physically=0)
723293cb49f479a41dc893d72c2d6502587d52cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/723293cb49f479a41dc893d72c2d6502587d52cb/Tix.py
destroy_physically=0)
destroy_physically=0)
def __init__(self, master=None, cnf={}, **kw): # static seem to be -installcolormap -initwait -statusbar -cursor static = ['options', 'installcolormap', 'initwait', 'statusbar', 'cursor'] TixWidget.__init__(self, master, 'tixBalloon', static, cnf, kw) self.subwidget_list['label'] = _dummyLabel(self, 'label', destroy_physically=0) self.subwidget_list['message'] = _dummyLabel(self, 'message', destroy_physically=0)
723293cb49f479a41dc893d72c2d6502587d52cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/723293cb49f479a41dc893d72c2d6502587d52cb/Tix.py
destroy_physically=0)
destroy_physically=0)
def __init__(self, master=None, cnf={}, **kw): # static seem to be -installcolormap -initwait -statusbar -cursor static = ['options', 'installcolormap', 'initwait', 'statusbar', 'cursor'] TixWidget.__init__(self, master, 'tixBalloon', static, cnf, kw) self.subwidget_list['label'] = _dummyLabel(self, 'label', destroy_physically=0) self.subwidget_list['message'] = _dummyLabel(self, 'message', destroy_physically=0)
723293cb49f479a41dc893d72c2d6502587d52cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/723293cb49f479a41dc893d72c2d6502587d52cb/Tix.py
['orientation', 'options'], cnf, kw)
['orientation', 'options'], cnf, kw)
def __init__(self, master=None, cnf={}, **kw): TixWidget.__init__(self, master, 'tixButtonBox', ['orientation', 'options'], cnf, kw)
723293cb49f479a41dc893d72c2d6502587d52cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/723293cb49f479a41dc893d72c2d6502587d52cb/Tix.py
(self._w, 'add', name) + self._options(cnf, kw))
(self._w, 'add', name) + self._options(cnf, kw))
def add(self, name, cnf={}, **kw): """Add a button with given name to box."""
723293cb49f479a41dc893d72c2d6502587d52cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/723293cb49f479a41dc893d72c2d6502587d52cb/Tix.py
['editable', 'dropdown', 'fancy', 'options'], cnf, kw)
['editable', 'dropdown', 'fancy', 'options'], cnf, kw)
def __init__ (self, master=None, cnf={}, **kw): TixWidget.__init__(self, master, 'tixComboBox', ['editable', 'dropdown', 'fancy', 'options'], cnf, kw) self.subwidget_list['label'] = _dummyLabel(self, 'label') self.subwidget_list['entry'] = _dummyEntry(self, 'entry') self.subwidget_list['arrow'] = _dummyButton(self, 'arrow') self.subwidget_list['slistbox'] = _dummyScrolledListBox(self, 'slistbox') try: self.subwidget_list['tick'] = _dummyButton(self, 'tick') self.subwidget_list['cross'] = _dummyButton(self, 'cross') except TypeError: # unavailable when -fancy not specified pass
723293cb49f479a41dc893d72c2d6502587d52cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/723293cb49f479a41dc893d72c2d6502587d52cb/Tix.py
'slistbox')
'slistbox')
def __init__ (self, master=None, cnf={}, **kw): TixWidget.__init__(self, master, 'tixComboBox', ['editable', 'dropdown', 'fancy', 'options'], cnf, kw) self.subwidget_list['label'] = _dummyLabel(self, 'label') self.subwidget_list['entry'] = _dummyEntry(self, 'entry') self.subwidget_list['arrow'] = _dummyButton(self, 'arrow') self.subwidget_list['slistbox'] = _dummyScrolledListBox(self, 'slistbox') try: self.subwidget_list['tick'] = _dummyButton(self, 'tick') self.subwidget_list['cross'] = _dummyButton(self, 'cross') except TypeError: # unavailable when -fancy not specified pass
723293cb49f479a41dc893d72c2d6502587d52cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/723293cb49f479a41dc893d72c2d6502587d52cb/Tix.py
if line == '\037\014\n':
if line == '\037\014\n' or line == '\037':
def _search_end(self): while 1: pos = self.fp.tell() line = self.fp.readline() if not line: return if line == '\037\014\n': self.fp.seek(pos) return
6abc685a03763a44f4b7abb2a5d0f3c6b2853ac5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6abc685a03763a44f4b7abb2a5d0f3c6b2853ac5/mailbox.py
try: r, w, e = select.select(r, w, e, timeout) except select.error, err: if err[0] != EINTR: raise
if [] == r == w == e: time.sleep(timeout) else: try: r, w, e = select.select(r, w, e, timeout) except select.error, err: if err[0] not in (EINTR, ENOENT): raise
def poll(timeout=0.0, map=None): if map is None: map = socket_map if map: r = []; w = []; e = [] for fd, obj in map.items(): if obj.readable(): r.append(fd) if obj.writable(): w.append(fd) try: r, w, e = select.select(r, w, e, timeout) except select.error, err: if err[0] != EINTR: raise for fd in r: obj = map.get(fd) if obj is None: continue read(obj) for fd in w: obj = map.get(fd) if obj is None: continue write(obj)
d8ce87ad84d748fb648b874d7dd9d9a3a835ec3d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d8ce87ad84d748fb648b874d7dd9d9a3a835ec3d/asyncore.py
while url[-1] in ');:,.?\'"':
while url[-1] in '();:,.?\'"<>':
def translate(text, pre=0): global translate_prog if not translate_prog: url = '\(http\|ftp\|https\)://[^ \t\r\n]*' email = '\<[-a-zA-Z0-9._]+@[-a-zA-Z0-9._]+' translate_prog = prog = regex.compile(url + '\|' + email) else: prog = translate_prog i = 0 list = [] while 1: j = prog.search(text, i) if j < 0: break list.append(escape(text[i:j])) i = j url = prog.group(0) while url[-1] in ');:,.?\'"': url = url[:-1] url = escape(url) if not pre or (pre and PROCESS_PREFORMAT): if ':' in url: repl = '<A HREF="%s">%s</A>' % (url, url) else: repl = '<A HREF="mailto:%s">&lt;%s&gt;</A>' % (url, url) else: repl = url list.append(repl) i = i + len(url) j = len(text) list.append(escape(text[i:j])) return string.join(list, '')
0721358969aa14f5f38601f0d921a6ec5432e5d6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0721358969aa14f5f38601f0d921a6ec5432e5d6/faqwiz.py
i = i + len(url)
def translate(text, pre=0): global translate_prog if not translate_prog: url = '\(http\|ftp\|https\)://[^ \t\r\n]*' email = '\<[-a-zA-Z0-9._]+@[-a-zA-Z0-9._]+' translate_prog = prog = regex.compile(url + '\|' + email) else: prog = translate_prog i = 0 list = [] while 1: j = prog.search(text, i) if j < 0: break list.append(escape(text[i:j])) i = j url = prog.group(0) while url[-1] in ');:,.?\'"': url = url[:-1] url = escape(url) if not pre or (pre and PROCESS_PREFORMAT): if ':' in url: repl = '<A HREF="%s">%s</A>' % (url, url) else: repl = '<A HREF="mailto:%s">&lt;%s&gt;</A>' % (url, url) else: repl = url list.append(repl) i = i + len(url) j = len(text) list.append(escape(text[i:j])) return string.join(list, '')
0721358969aa14f5f38601f0d921a6ec5432e5d6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0721358969aa14f5f38601f0d921a6ec5432e5d6/faqwiz.py
if self.addr == types.TupleType:
if type(self.addr) == types.TupleType:
def __repr__ (self): try: status = [] if self.accepting and self.addr: status.append ('listening') elif self.connected: status.append ('connected') if self.addr: if self.addr == types.TupleType: status.append ('%s:%d' % self.addr) else: status.append (self.addr) return '<%s %s at %x>' % (self.__class__.__name__, ' '.join (status), id (self)) except: pass
1efbe425f5c8b822c2b65e7d8041c0197941f97a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1efbe425f5c8b822c2b65e7d8041c0197941f97a/asyncore.py
file.warn ("exclude (!) doesn't apply to " + "whole directory trees")
manifest.warn ("exclude (!) doesn't apply to " + "whole directory trees")
def read_manifest (self):
e9436da6863e18f710e0908cb8d4be4b571a172d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e9436da6863e18f710e0908cb8d4be4b571a172d/dist.py
file.warn ("can't have multiple words unless first word " + "('%s') is a directory name" % words[0])
manifest.warn ("can't have multiple words unless first word " + "('%s') is a directory name" % words[0])
def read_manifest (self):
e9436da6863e18f710e0908cb8d4be4b571a172d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e9436da6863e18f710e0908cb8d4be4b571a172d/dist.py
file.warn ("no files excluded by '%s'" % pattern)
manifest.warn ("no files excluded by '%s'" % pattern)
def read_manifest (self):
e9436da6863e18f710e0908cb8d4be4b571a172d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e9436da6863e18f710e0908cb8d4be4b571a172d/dist.py
if debuginfo: self.move_file(debuginfo[0], self.dist_dir)
def run (self):
c982bbde1c5012202187b8e398fd631b6cec214b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c982bbde1c5012202187b8e398fd631b6cec214b/bdist_rpm.py
if data[0][-1] in (',', '.') or data[0].lower() in _daynames:
if data[0].endswith(',') or data[0].lower() in _daynames:
def parsedate_tz(data): """Convert a date string to a time tuple. Accounts for military timezones. """ data = data.split() if data[0][-1] in (',', '.') or data[0].lower() in _daynames: # There's a dayname here. Skip it del data[0] if len(data) == 3: # RFC 850 date, deprecated stuff = data[0].split('-') if len(stuff) == 3: data = stuff + data[1:] if len(data) == 4: s = data[3] i = s.find('+') if i > 0: data[3:] = [s[:i], s[i+1:]] else: data.append('') # Dummy tz if len(data) < 5: return None data = data[:5] [dd, mm, yy, tm, tz] = data mm = mm.lower() if mm not in _monthnames: dd, mm = mm, dd.lower() if mm not in _monthnames: return None mm = _monthnames.index(mm) + 1 if mm > 12: mm -= 12 if dd[-1] == ',': dd = dd[:-1] i = yy.find(':') if i > 0: yy, tm = tm, yy if yy[-1] == ',': yy = yy[:-1] if not yy[0].isdigit(): yy, tz = tz, yy if tm[-1] == ',': tm = tm[:-1] tm = tm.split(':') if len(tm) == 2: [thh, tmm] = tm tss = '0' elif len(tm) == 3: [thh, tmm, tss] = tm else: return None try: yy = int(yy) dd = int(dd) thh = int(thh) tmm = int(tmm) tss = int(tss) except ValueError: return None tzoffset = None tz = tz.upper() if _timezones.has_key(tz): tzoffset = _timezones[tz] else: try: tzoffset = int(tz) except ValueError: pass # Convert a timezone offset into seconds ; -0500 -> -18000 if tzoffset: if tzoffset < 0: tzsign = -1 tzoffset = -tzoffset else: tzsign = 1 tzoffset = tzsign * ( (tzoffset/100)*3600 + (tzoffset % 100)*60) tuple = (yy, mm, dd, thh, tmm, tss, 0, 0, 0, tzoffset) return tuple
ba97659f5fedddac67587a0da94f486fd920cfb0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ba97659f5fedddac67587a0da94f486fd920cfb0/_parseaddr.py
self.literal = message
self.literal = MapCRLF.sub(CRLF, message)
def append(self, mailbox, flags, date_time, message): """Append message to named mailbox.
47404fffff3e36699786082d0ee6565872d627e1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/47404fffff3e36699786082d0ee6565872d627e1/imaplib.py
test_mesg = 'From: %(user)s@localhost%(lf)sSubject: IMAP4 test%(lf)s%(lf)sdata...%(lf)s' % {'user':USER, 'lf':CRLF}
test_mesg = 'From: %(user)s@localhost%(lf)sSubject: IMAP4 test%(lf)s%(lf)sdata...%(lf)s' % {'user':USER, 'lf':'\n'}
def Time2Internaldate(date_time): """Convert 'date_time' to IMAP4 INTERNALDATE representation. Return string in form: '"DD-Mmm-YYYY HH:MM:SS +HHMM"' """ if isinstance(date_time, (int, float)): tt = time.localtime(date_time) elif isinstance(date_time, (tuple, time.struct_time)): tt = date_time elif isinstance(date_time, str) and (date_time[0],date_time[-1]) == ('"','"'): return date_time # Assume in correct format else: raise ValueError("date_time not of a known type") dt = time.strftime("%d-%b-%Y %H:%M:%S", tt) if dt[0] == '0': dt = ' ' + dt[1:] if time.daylight and tt[-1]: zone = -time.altzone else: zone = -time.timezone return '"' + dt + " %+03d%02d" % divmod(zone/60, 60) + '"'
47404fffff3e36699786082d0ee6565872d627e1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/47404fffff3e36699786082d0ee6565872d627e1/imaplib.py
st2 = parser.sequence2ast(t)
try: st2 = parser.sequence2ast(t) except parser.ParserError: print "Failing syntax tree:" pprint.pprint(t) raise
def roundtrip(f, s): st1 = f(s) t = st1.totuple() st2 = parser.sequence2ast(t)
e1578ce20464dfda61d3b113f95fd006783beed6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e1578ce20464dfda61d3b113f95fd006783beed6/test_parser.py
return
return command
def reinitialize_command (self, command): """Reinitializes a command to the state it was in when first returned by 'get_command_obj()': ie., initialized but not yet finalized. This gives provides the opportunity to sneak option values in programmatically, overriding or supplementing user-supplied values from the config files and command line. You'll have to re-finalize the command object (by calling 'finalize_options()' or 'ensure_finalized()') before using it for real.
282c7a0230b578147a89a18ec22410b830edddfe /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/282c7a0230b578147a89a18ec22410b830edddfe/dist.py
def __init__(self, s, charset=None, maxlinelen=MAXLINELEN, header_name=None):
def __init__(self, s, charset=None, maxlinelen=None, header_name=None):
def __init__(self, s, charset=None, maxlinelen=MAXLINELEN, header_name=None): """Create a MIME-compliant header that can contain many languages.
812031b95555e607ccec74f31aabc7601a53ed8a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/812031b95555e607ccec74f31aabc7601a53ed8a/Header.py
The maximum line length can either be specified by maxlinelen, or you can pass in the name of the header field (e.g. "Subject") to let this class guess the best line length to use to prevent wrapping. The default maxlinelen is 76.
The maximum line length can be specified explicitly via maxlinelen. You can also pass None for maxlinelen and the name of a header field (e.g. "Subject") to let the constructor guess the best line length to use. The default maxlinelen is 76.
def __init__(self, s, charset=None, maxlinelen=MAXLINELEN, header_name=None): """Create a MIME-compliant header that can contain many languages.
812031b95555e607ccec74f31aabc7601a53ed8a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/812031b95555e607ccec74f31aabc7601a53ed8a/Header.py
self._maxlinelen = maxlinelen if header_name is not None: self.guess_maxlinelen(header_name)
if maxlinelen is None: if header_name is None: self._maxlinelen = MAXLINELEN else: self.guess_maxlinelen(header_name) else: self._maxlinelen = maxlinelen
def __init__(self, s, charset=None, maxlinelen=MAXLINELEN, header_name=None): """Create a MIME-compliant header that can contain many languages.
812031b95555e607ccec74f31aabc7601a53ed8a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/812031b95555e607ccec74f31aabc7601a53ed8a/Header.py
if charset.encoded_header_len(encoded) < self._maxlinelen:
elen = charset.encoded_header_len(encoded) if elen <= self._maxlinelen:
def _split(self, s, charset): # Split up a header safely for use with encode_chunks. BAW: this # appears to be a private convenience method. splittable = charset.to_splittable(s) encoded = charset.from_splittable(splittable) if charset.encoded_header_len(encoded) < self._maxlinelen: return [(encoded, charset)] else: # Divide and conquer. BAW: halfway depends on integer division. # When porting to Python 2.2, use the // operator. halfway = len(splittable) // 2 first = charset.from_splittable(splittable[:halfway], 0) last = charset.from_splittable(splittable[halfway:], 0) return self._split(first, charset) + self._split(last, charset)
812031b95555e607ccec74f31aabc7601a53ed8a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/812031b95555e607ccec74f31aabc7601a53ed8a/Header.py
halfway = len(splittable) // 2
halfway = _intdiv2(len(splittable))
def _split(self, s, charset): # Split up a header safely for use with encode_chunks. BAW: this # appears to be a private convenience method. splittable = charset.to_splittable(s) encoded = charset.from_splittable(splittable) if charset.encoded_header_len(encoded) < self._maxlinelen: return [(encoded, charset)] else: # Divide and conquer. BAW: halfway depends on integer division. # When porting to Python 2.2, use the // operator. halfway = len(splittable) // 2 first = charset.from_splittable(splittable[:halfway], 0) last = charset.from_splittable(splittable[halfway:], 0) return self._split(first, charset) + self._split(last, charset)
812031b95555e607ccec74f31aabc7601a53ed8a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/812031b95555e607ccec74f31aabc7601a53ed8a/Header.py
os.mkdir(dst)
os.makedirs(dst) copystat(src, dst)
def copytree(src, dst, symlinks=False): """Recursively copy a directory tree using copy2(). The destination directory must not already exist. If exception(s) occur, an Error is raised with a list of reasons. If the optional symlinks flag is true, symbolic links in the source tree result in symbolic links in the destination tree; if it is false, the contents of the files pointed to by symbolic links are copied. XXX Consider this example code rather than the ultimate tool. """ names = os.listdir(src) os.mkdir(dst) errors = [] for name in names: srcname = os.path.join(src, name) dstname = os.path.join(dst, name) try: if symlinks and os.path.islink(srcname): linkto = os.readlink(srcname) os.symlink(linkto, dstname) elif os.path.isdir(srcname): copytree(srcname, dstname, symlinks) else: copy2(srcname, dstname) # XXX What about devices, sockets etc.? except (IOError, os.error), why: errors.append((srcname, dstname, why)) if errors: raise Error, errors
e4172eadf3fb9c1de591305ad4ca4ce3e252abd3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e4172eadf3fb9c1de591305ad4ca4ce3e252abd3/shutil.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
8f0bd5657a384199d9203c753cecdd0a9b1f9bcb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8f0bd5657a384199d9203c753cecdd0a9b1f9bcb/msgfmt.py
files=Open(**options).show() return files.split()
return Open(**options).show()
def askopenfilenames(**options): """Ask for multiple filenames to open Returns a list of filenames or empty list if cancel button selected """ options["multiple"]=1 files=Open(**options).show() return files.split()
d6efae500ce3e955b95b324954defa1a9f2d9e96 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d6efae500ce3e955b95b324954defa1a9f2d9e96/tkFileDialog.py
'db4': {'libs': ('db-4.1', 'db-4.0',),
'db4': {'libs': ('db-4.1', 'db41', 'db-4.0', 'db4',),
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
28df64ac472862ce0f03f932407e71a35ce61f19 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/28df64ac472862ce0f03f932407e71a35ce61f19/setup.py
'db3': {'libs': ('db-3.3', 'db-3.2', 'db-3.1'),
'db3': {'libs': ('db-3.3', 'db-3.2', 'db-3.1', 'db3',),
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
28df64ac472862ce0f03f932407e71a35ce61f19 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/28df64ac472862ce0f03f932407e71a35ce61f19/setup.py
"""parse the input lines from a robot.txt file.
"""parse the input lines from a robots.txt file.
def parse(self, lines): """parse the input lines from a robot.txt file. We allow that a user-agent: line is not preceded by one or more blank lines.""" state = 0 linenumber = 0 entry = Entry()
2d95f1ad570791a5dffb16addd74b35b46f77fdc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2d95f1ad570791a5dffb16addd74b35b46f77fdc/robotparser.py
_debug("Checking robot.txt allowance for:\n user agent: %s\n url: %s" %
_debug("Checking robots.txt allowance for:\n user agent: %s\n url: %s" %
def can_fetch(self, useragent, url): """using the parsed robots.txt decide if useragent can fetch url""" _debug("Checking robot.txt allowance for:\n user agent: %s\n url: %s" % (useragent, url)) if self.disallow_all: return False if self.allow_all: return True # search for given user agent matches # the first match counts url = urllib.quote(urlparse.urlparse(urllib.unquote(url))[2]) or "/" for entry in self.entries: if entry.applies_to(useragent): return entry.allowance(url) # try the default entry last if self.default_entry: return self.default_entry.allowance(url) # agent not found ==> access granted return True
2d95f1ad570791a5dffb16addd74b35b46f77fdc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2d95f1ad570791a5dffb16addd74b35b46f77fdc/robotparser.py
finalized. This gives provides the opportunity to sneak option
finalized. This provides the opportunity to sneak option
def reinitialize_command (self, command): """Reinitializes a command to the state it was in when first returned by 'get_command_obj()': ie., initialized but not yet finalized. This gives provides the opportunity to sneak option values in programmatically, overriding or supplementing user-supplied values from the config files and command line. You'll have to re-finalize the command object (by calling 'finalize_options()' or 'ensure_finalized()') before using it for real.
7d9c705b234ad2ad013db1649e5fd2ffc2a59a75 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7d9c705b234ad2ad013db1649e5fd2ffc2a59a75/dist.py
('dbserv2.theopalgroup.com', '/mediumfile'), ('dbserv2.theopalgroup.com', '/smallfile'),
def test(): """Test this module. A hodge podge of tests collected here, because they have too many external dependencies for the regular test suite. """ import sys import getopt opts, args = getopt.getopt(sys.argv[1:], 'd') dl = 0 for o, a in opts: if o == '-d': dl = dl + 1 host = 'www.python.org' selector = '/' if args[0:]: host = args[0] if args[1:]: selector = args[1] h = HTTP() h.set_debuglevel(dl) h.connect(host) h.putrequest('GET', selector) h.endheaders() status, reason, headers = h.getreply() print 'status =', status print 'reason =', reason print "read", len(h.getfile().read()) print if headers: for header in headers.headers: print header.strip() print # minimal test that code to extract host from url works class HTTP11(HTTP): _http_vsn = 11 _http_vsn_str = 'HTTP/1.1' h = HTTP11('www.python.org') h.putrequest('GET', 'http://www.python.org/~jeremy/') h.endheaders() h.getreply() h.close() if hasattr(socket, 'ssl'): for host, selector in (('sourceforge.net', '/projects/python'), ('dbserv2.theopalgroup.com', '/mediumfile'), ('dbserv2.theopalgroup.com', '/smallfile'), ): print "https://%s%s" % (host, selector) hs = HTTPS() hs.set_debuglevel(dl) hs.connect(host) hs.putrequest('GET', selector) hs.endheaders() status, reason, headers = hs.getreply() print 'status =', status print 'reason =', reason print "read", len(hs.getfile().read()) print if headers: for header in headers.headers: print header.strip() print # Test a buggy server -- returns garbled status line. # http://www.yahoo.com/promotions/mom_com97/supermom.html c = HTTPConnection("promotions.yahoo.com") c.set_debuglevel(1) c.connect() c.request("GET", "/promotions/mom_com97/supermom.html") r = c.getresponse() print r.status, r.version lines = r.read().split("\n") print "\n".join(lines[:5]) c = HTTPConnection("promotions.yahoo.com", strict=1) c.set_debuglevel(1) c.connect() c.request("GET", "/promotions/mom_com97/supermom.html") try: r = c.getresponse() except BadStatusLine, err: print "strict mode failed as expected" print err else: print "XXX strict mode should have failed" for strict in 0, 1: h = HTTP(strict=strict) h.connect("promotions.yahoo.com") h.putrequest('GET', "/promotions/mom_com97/supermom.html") h.endheaders() status, reason, headers = h.getreply() assert (strict and status == -1) or status == 200, (strict, status)
77628658ca71260d2a69bbb7f35f3f6e5df796be /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/77628658ca71260d2a69bbb7f35f3f6e5df796be/httplib.py
c = HTTPConnection("promotions.yahoo.com") c.set_debuglevel(1) c.connect() c.request("GET", "/promotions/mom_com97/supermom.html") r = c.getresponse() print r.status, r.version lines = r.read().split("\n") print "\n".join(lines[:5]) c = HTTPConnection("promotions.yahoo.com", strict=1) c.set_debuglevel(1) c.connect() c.request("GET", "/promotions/mom_com97/supermom.html") try: r = c.getresponse() except BadStatusLine, err: print "strict mode failed as expected" print err else: print "XXX strict mode should have failed" for strict in 0, 1: h = HTTP(strict=strict) h.connect("promotions.yahoo.com") h.putrequest('GET', "/promotions/mom_com97/supermom.html") h.endheaders() status, reason, headers = h.getreply() assert (strict and status == -1) or status == 200, (strict, status)
def test(): """Test this module. A hodge podge of tests collected here, because they have too many external dependencies for the regular test suite. """ import sys import getopt opts, args = getopt.getopt(sys.argv[1:], 'd') dl = 0 for o, a in opts: if o == '-d': dl = dl + 1 host = 'www.python.org' selector = '/' if args[0:]: host = args[0] if args[1:]: selector = args[1] h = HTTP() h.set_debuglevel(dl) h.connect(host) h.putrequest('GET', selector) h.endheaders() status, reason, headers = h.getreply() print 'status =', status print 'reason =', reason print "read", len(h.getfile().read()) print if headers: for header in headers.headers: print header.strip() print # minimal test that code to extract host from url works class HTTP11(HTTP): _http_vsn = 11 _http_vsn_str = 'HTTP/1.1' h = HTTP11('www.python.org') h.putrequest('GET', 'http://www.python.org/~jeremy/') h.endheaders() h.getreply() h.close() if hasattr(socket, 'ssl'): for host, selector in (('sourceforge.net', '/projects/python'), ('dbserv2.theopalgroup.com', '/mediumfile'), ('dbserv2.theopalgroup.com', '/smallfile'), ): print "https://%s%s" % (host, selector) hs = HTTPS() hs.set_debuglevel(dl) hs.connect(host) hs.putrequest('GET', selector) hs.endheaders() status, reason, headers = hs.getreply() print 'status =', status print 'reason =', reason print "read", len(hs.getfile().read()) print if headers: for header in headers.headers: print header.strip() print # Test a buggy server -- returns garbled status line. # http://www.yahoo.com/promotions/mom_com97/supermom.html c = HTTPConnection("promotions.yahoo.com") c.set_debuglevel(1) c.connect() c.request("GET", "/promotions/mom_com97/supermom.html") r = c.getresponse() print r.status, r.version lines = r.read().split("\n") print "\n".join(lines[:5]) c = HTTPConnection("promotions.yahoo.com", strict=1) c.set_debuglevel(1) c.connect() c.request("GET", "/promotions/mom_com97/supermom.html") try: r = c.getresponse() except BadStatusLine, err: print "strict mode failed as expected" print err else: print "XXX strict mode should have failed" for strict in 0, 1: h = HTTP(strict=strict) h.connect("promotions.yahoo.com") h.putrequest('GET', "/promotions/mom_com97/supermom.html") h.endheaders() status, reason, headers = h.getreply() assert (strict and status == -1) or status == 200, (strict, status)
77628658ca71260d2a69bbb7f35f3f6e5df796be /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/77628658ca71260d2a69bbb7f35f3f6e5df796be/httplib.py
flags = _fcntl.fcntl(fd, _fcntl.F_GETFD, 0) if flags >= 0:
try: flags = _fcntl.fcntl(fd, _fcntl.F_GETFD, 0) except IOError: pass else:
def _set_cloexec(fd): flags = _fcntl.fcntl(fd, _fcntl.F_GETFD, 0) if flags >= 0: # flags read successfully, modify flags |= _fcntl.FD_CLOEXEC _fcntl.fcntl(fd, _fcntl.F_SETFD, flags)
f09994e5273e358c5fc764db681bd3dafecc3e2d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f09994e5273e358c5fc764db681bd3dafecc3e2d/tempfile.py
return os.path.join(sys.exec_prefix, "lib", "python" + sys.version[:3], "config", "config.h")
return os.path.join(sys.exec_prefix, "include", "python" + sys.version[:3], "config.h")
def get_config_h_filename(): """Return full pathname of installed config.h file.""" return os.path.join(sys.exec_prefix, "lib", "python" + sys.version[:3], "config", "config.h")
6a1b53c16538b3d503b19aa039f4a54bc757bc21 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6a1b53c16538b3d503b19aa039f4a54bc757bc21/sysconfig.py
folderbox = Listbox(right)
folderbox = Listbox(right, {'exportselection': 0})
def main(): global root, tk, top, mid, bot global folderbox, foldermenu, scanbox, scanmenu, viewer global folder, seq global mh, mhf # Parse command line options folder = 'inbox' seq = 'all' try: opts, args = getopt.getopt(sys.argv[1:], '') except getopt.error, msg: print msg sys.exit(2) for arg in args: if arg[:1] == '+': folder = arg[1:] else: seq = arg # Initialize MH mh = mhlib.MH() mhf = mh.openfolder(folder) # Build widget hierarchy root = Tk() tk = root.tk top = Frame(root) top.pack({'expand': 1, 'fill': 'both'}) # Build right part: folder list right = Frame(top) right.pack({'fill': 'y', 'side': 'right'}) folderbar = Scrollbar(right, {'relief': 'sunken', 'bd': 2}) folderbar.pack({'fill': 'y', 'side': 'right'}) folderbox = Listbox(right) folderbox.pack({'expand': 1, 'fill': 'both', 'side': 'left'}) foldermenu = Menu(root) foldermenu.add('command', {'label': 'Open Folder', 'command': open_folder}) foldermenu.add('separator') foldermenu.add('command', {'label': 'Quit', 'command': 'exit'}) foldermenu.bind('<ButtonRelease-3>', folder_unpost) folderbox['yscrollcommand'] = (folderbar, 'set') folderbar['command'] = (folderbox, 'yview') folderbox.bind('<Double-1>', open_folder, 1) folderbox.bind('<3>', folder_post) # Build left part: scan list left = Frame(top) left.pack({'expand': 1, 'fill': 'both', 'side': 'left'}) scanbar = Scrollbar(left, {'relief': 'sunken', 'bd': 2}) scanbar.pack({'fill': 'y', 'side': 'right'}) scanbox = Listbox(left, {'font': 'fixed'}) scanbox.pack({'expand': 1, 'fill': 'both', 'side': 'left'}) scanmenu = Menu(root) scanmenu.add('command', {'label': 'Open Message', 'command': open_message}) scanmenu.add('command', {'label': 'Remove Message', 'command': remove_message}) scanmenu.add('command', {'label': 'Refile Message', 'command': refile_message}) scanmenu.add('separator') scanmenu.add('command', {'label': 'Quit', 'command': 'exit'}) scanmenu.bind('<ButtonRelease-3>', scan_unpost) scanbox['yscrollcommand'] = (scanbar, 'set') scanbar['command'] = (scanbox, 'yview') scanbox.bind('<Double-1>', open_message) scanbox.bind('<3>', scan_post) # Separator between middle and bottom part rule2 = Frame(root, {'bg': 'black'}) rule2.pack({'fill': 'x'}) # Build bottom part: current message bot = Frame(root) bot.pack({'expand': 1, 'fill': 'both'}) # viewer = None # Window manager commands root.minsize(800, 1) # Make window resizable # Fill folderbox with text setfolders() # Fill scanbox with text rescan() # Enter mainloop root.mainloop()
78b0c82535af09fde940d1b040f9da72c20f7c70 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/78b0c82535af09fde940d1b040f9da72c20f7c70/mbox.py
def open_folder(*e):
def open_folder(e=None):
def open_folder(*e): global folder, mhf sel = folderbox.curselection() if len(sel) != 1: if len(sel) > 1: msg = "Please open one folder at a time" else: msg = "Please select a folder to open" dialog(root, "Can't Open Folder", msg, "", 0, "OK") return i = sel[0] folder = folderbox.get(i) mhf = mh.openfolder(folder) rescan()
78b0c82535af09fde940d1b040f9da72c20f7c70 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/78b0c82535af09fde940d1b040f9da72c20f7c70/mbox.py
def open_message(*e):
def open_message(e=None):
def open_message(*e): global viewer sel = scanbox.curselection() if len(sel) != 1: if len(sel) > 1: msg = "Please open one message at a time" else: msg = "Please select a message to open" dialog(root, "Can't Open Message", msg, "", 0, "OK") return cursor = scanbox['cursor'] scanbox['cursor'] = 'watch' tk.call('update', 'idletasks') i = sel[0] line = scanbox.get(i) if scanparser.match(line) >= 0: num = string.atoi(scanparser.group(1)) m = mhf.openmessage(num) if viewer: viewer.destroy() from MimeViewer import MimeViewer viewer = MimeViewer(bot, '+%s/%d' % (folder, num), m) viewer.pack() viewer.show() scanbox['cursor'] = cursor
78b0c82535af09fde940d1b040f9da72c20f7c70 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/78b0c82535af09fde940d1b040f9da72c20f7c70/mbox.py
def remove_message():
def remove_message(e=None):
def remove_message(): itop = scanbox.nearest(0) sel = scanbox.curselection() if not sel: dialog(root, "No Message To Remove", "Please select a message to remove", "", 0, "OK") return todo = [] for i in sel: line = scanbox.get(i) if scanparser.match(line) >= 0: todo.append(string.atoi(scanparser.group(1))) mhf.removemessages(todo) rescan() fixfocus(min(todo), itop)
78b0c82535af09fde940d1b040f9da72c20f7c70 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/78b0c82535af09fde940d1b040f9da72c20f7c70/mbox.py
def refile_message():
def refile_message(e=None):
def refile_message(): global lastrefile, tofolder itop = scanbox.nearest(0) sel = scanbox.curselection() if not sel: dialog(root, "No Message To Refile", "Please select a message to refile", "", 0, "OK") return foldersel = folderbox.curselection() if len(foldersel) != 1: if not foldersel: msg = "Please select a folder to refile to" else: msg = "Please select exactly one folder to refile to" dialog(root, "No Folder To Refile", msg, "", 0, "OK") return refileto = folderbox.get(foldersel[0]) todo = [] for i in sel: line = scanbox.get(i) if scanparser.match(line) >= 0: todo.append(string.atoi(scanparser.group(1))) print 'refile', todo, tofolder if lastrefile != refileto or not tofolder: print 'new folder' lastrefile = refileto tofolder = None tofolder = mh.openfolder(lastrefile) mhf.refilemessages(todo, tofolder) rescan() fixfocus(min(todo), itop)
78b0c82535af09fde940d1b040f9da72c20f7c70 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/78b0c82535af09fde940d1b040f9da72c20f7c70/mbox.py
print 'refile', todo, tofolder
def refile_message(): global lastrefile, tofolder itop = scanbox.nearest(0) sel = scanbox.curselection() if not sel: dialog(root, "No Message To Refile", "Please select a message to refile", "", 0, "OK") return foldersel = folderbox.curselection() if len(foldersel) != 1: if not foldersel: msg = "Please select a folder to refile to" else: msg = "Please select exactly one folder to refile to" dialog(root, "No Folder To Refile", msg, "", 0, "OK") return refileto = folderbox.get(foldersel[0]) todo = [] for i in sel: line = scanbox.get(i) if scanparser.match(line) >= 0: todo.append(string.atoi(scanparser.group(1))) print 'refile', todo, tofolder if lastrefile != refileto or not tofolder: print 'new folder' lastrefile = refileto tofolder = None tofolder = mh.openfolder(lastrefile) mhf.refilemessages(todo, tofolder) rescan() fixfocus(min(todo), itop)
78b0c82535af09fde940d1b040f9da72c20f7c70 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/78b0c82535af09fde940d1b040f9da72c20f7c70/mbox.py
print 'new folder'
def refile_message(): global lastrefile, tofolder itop = scanbox.nearest(0) sel = scanbox.curselection() if not sel: dialog(root, "No Message To Refile", "Please select a message to refile", "", 0, "OK") return foldersel = folderbox.curselection() if len(foldersel) != 1: if not foldersel: msg = "Please select a folder to refile to" else: msg = "Please select exactly one folder to refile to" dialog(root, "No Folder To Refile", msg, "", 0, "OK") return refileto = folderbox.get(foldersel[0]) todo = [] for i in sel: line = scanbox.get(i) if scanparser.match(line) >= 0: todo.append(string.atoi(scanparser.group(1))) print 'refile', todo, tofolder if lastrefile != refileto or not tofolder: print 'new folder' lastrefile = refileto tofolder = None tofolder = mh.openfolder(lastrefile) mhf.refilemessages(todo, tofolder) rescan() fixfocus(min(todo), itop)
78b0c82535af09fde940d1b040f9da72c20f7c70 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/78b0c82535af09fde940d1b040f9da72c20f7c70/mbox.py
print 'yview', `itop`
def fixfocus(near, itop): n = scanbox.size() for i in range(n): line = scanbox.get(`i`) if scanparser.match(line) >= 0: num = string.atoi(scanparser.group(1)) if num >= near: break else: i = 'end' scanbox.select_from(i) print 'yview', `itop` scanbox.yview(itop)
78b0c82535af09fde940d1b040f9da72c20f7c70 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/78b0c82535af09fde940d1b040f9da72c20f7c70/mbox.py
Single = group("^'", "[^\]'") Double = group('^"', '[^\]"') Single3 = group("^'''", "[^\]'''") Double3 = group('^"""', '[^\]"""')
Single = group("[^'\]", "[\].") + "*'" Double = group('[^"\]', '[\].') + '*"' Single3 = group("[^'\]","[\].","'[^'\]","'[\].","''[^'\]","''[\].") + "*'''" Double3 = group('[^"\]','[\].','"[^"\]','"[\].','""[^"\]','""[\].') + '*"""'
def group(*choices): return '\(' + string.join(choices, '\|') + '\)'
de65527e4b0925692f0d75f388116b7958a390bb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/de65527e4b0925692f0d75f388116b7958a390bb/tokenize.py