rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
genpluginproject("ppc", "_Icn", libraries=["IconServicesLib"], outputdir="::Lib:Carbon")
genpluginproject("ppc", "_Icn", libraries=["IconServicesLib"], libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
def genpluginproject(architecture, module, project=None, projectdir=None, sources=[], sourcedirs=[], libraries=[], extradirs=[], extraexportsymbols=[], outputdir=":::Lib:lib-dynload", libraryflags=None, stdlibraryflags=None, prefixname=None): if architecture == "all": # For the time being we generate two project files. Not as nice as # a single multitarget project, but easier to implement for now. genpluginproject("ppc", module, project, projectdir, sources, sourcedirs, libraries, extradirs, extraexportsymbols, outputdir, libraryflags, stdlibraryflags, prefixname) genpluginproject("carbon", module, project, projectdir, sources, sourcedirs, libraries, extradirs, extraexportsymbols, outputdir, libraryflags, stdlibraryflags, prefixname) return templatename = "template-%s" % architecture targetname = "%s.%s" % (module, architecture) dllname = "%s.%s.slb" % (module, architecture) if not project: if architecture != "ppc": project = "%s.%s.mcp"%(module, architecture) else: project = "%s.mcp"%module if not projectdir: projectdir = PROJECTDIR if not sources: sources = [module + 'module.c'] if not sourcedirs: for moduledir in MODULEDIRS: if '%' in moduledir: # For historical reasons an initial _ in the modulename # is not reflected in the folder name if module[0] == '_': modulewithout_ = module[1:] else: modulewithout_ = module moduledir = moduledir % modulewithout_ fn = os.path.join(projectdir, os.path.join(moduledir, sources[0])) if os.path.exists(fn): moduledir, sourcefile = os.path.split(fn) sourcedirs = [relpath(projectdir, moduledir)] sources[0] = sourcefile break else: print "Warning: %s: sourcefile not found: %s"%(module, sources[0]) sourcedirs = [] if prefixname: pass elif architecture == "carbon": prefixname = "mwerks_carbonplugin_config.h" else: prefixname = "mwerks_plugin_config.h" dict = { "sysprefix" : relpath(projectdir, sys.prefix), "sources" : sources, "extrasearchdirs" : sourcedirs + extradirs, "libraries": libraries, "mac_outputdir" : outputdir, "extraexportsymbols" : extraexportsymbols, "mac_targetname" : targetname, "mac_dllname" : dllname, "prefixname" : prefixname, } if libraryflags: dict['libraryflags'] = libraryflags if stdlibraryflags: dict['stdlibraryflags'] = stdlibraryflags mkcwproject.mkproject(os.path.join(projectdir, project), module, dict, force=FORCEREBUILD, templatename=templatename)
150f9fc415d529faf327290ae61f0a86035b25ed /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/150f9fc415d529faf327290ae61f0a86035b25ed/genpluginprojects.py
genpluginproject("all", "_Qd", outputdir="::Lib:Carbon") genpluginproject("ppc", "_Qt", libraries=["QuickTimeLib"], outputdir="::Lib:Carbon") genpluginproject("carbon", "_Qt", outputdir="::Lib:Carbon") genpluginproject("all", "_Qdoffs", outputdir="::Lib:Carbon")
genpluginproject("all", "_Qd", stdlibraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") genpluginproject("ppc", "_Qt", libraries=["QuickTimeLib"], libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") genpluginproject("carbon", "_Qt", libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") genpluginproject("all", "_Qdoffs", stdlibraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
def genpluginproject(architecture, module, project=None, projectdir=None, sources=[], sourcedirs=[], libraries=[], extradirs=[], extraexportsymbols=[], outputdir=":::Lib:lib-dynload", libraryflags=None, stdlibraryflags=None, prefixname=None): if architecture == "all": # For the time being we generate two project files. Not as nice as # a single multitarget project, but easier to implement for now. genpluginproject("ppc", module, project, projectdir, sources, sourcedirs, libraries, extradirs, extraexportsymbols, outputdir, libraryflags, stdlibraryflags, prefixname) genpluginproject("carbon", module, project, projectdir, sources, sourcedirs, libraries, extradirs, extraexportsymbols, outputdir, libraryflags, stdlibraryflags, prefixname) return templatename = "template-%s" % architecture targetname = "%s.%s" % (module, architecture) dllname = "%s.%s.slb" % (module, architecture) if not project: if architecture != "ppc": project = "%s.%s.mcp"%(module, architecture) else: project = "%s.mcp"%module if not projectdir: projectdir = PROJECTDIR if not sources: sources = [module + 'module.c'] if not sourcedirs: for moduledir in MODULEDIRS: if '%' in moduledir: # For historical reasons an initial _ in the modulename # is not reflected in the folder name if module[0] == '_': modulewithout_ = module[1:] else: modulewithout_ = module moduledir = moduledir % modulewithout_ fn = os.path.join(projectdir, os.path.join(moduledir, sources[0])) if os.path.exists(fn): moduledir, sourcefile = os.path.split(fn) sourcedirs = [relpath(projectdir, moduledir)] sources[0] = sourcefile break else: print "Warning: %s: sourcefile not found: %s"%(module, sources[0]) sourcedirs = [] if prefixname: pass elif architecture == "carbon": prefixname = "mwerks_carbonplugin_config.h" else: prefixname = "mwerks_plugin_config.h" dict = { "sysprefix" : relpath(projectdir, sys.prefix), "sources" : sources, "extrasearchdirs" : sourcedirs + extradirs, "libraries": libraries, "mac_outputdir" : outputdir, "extraexportsymbols" : extraexportsymbols, "mac_targetname" : targetname, "mac_dllname" : dllname, "prefixname" : prefixname, } if libraryflags: dict['libraryflags'] = libraryflags if stdlibraryflags: dict['stdlibraryflags'] = stdlibraryflags mkcwproject.mkproject(os.path.join(projectdir, project), module, dict, force=FORCEREBUILD, templatename=templatename)
150f9fc415d529faf327290ae61f0a86035b25ed /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/150f9fc415d529faf327290ae61f0a86035b25ed/genpluginprojects.py
genpluginproject("ppc", "_TE", libraries=["CarbonAccessors.o", "DragLib"], outputdir="::Lib:Carbon")
genpluginproject("ppc", "_TE", libraries=["CarbonAccessors.o", "DragLib"], stdlibraryflags="Debug, WeakImport", libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
def genpluginproject(architecture, module, project=None, projectdir=None, sources=[], sourcedirs=[], libraries=[], extradirs=[], extraexportsymbols=[], outputdir=":::Lib:lib-dynload", libraryflags=None, stdlibraryflags=None, prefixname=None): if architecture == "all": # For the time being we generate two project files. Not as nice as # a single multitarget project, but easier to implement for now. genpluginproject("ppc", module, project, projectdir, sources, sourcedirs, libraries, extradirs, extraexportsymbols, outputdir, libraryflags, stdlibraryflags, prefixname) genpluginproject("carbon", module, project, projectdir, sources, sourcedirs, libraries, extradirs, extraexportsymbols, outputdir, libraryflags, stdlibraryflags, prefixname) return templatename = "template-%s" % architecture targetname = "%s.%s" % (module, architecture) dllname = "%s.%s.slb" % (module, architecture) if not project: if architecture != "ppc": project = "%s.%s.mcp"%(module, architecture) else: project = "%s.mcp"%module if not projectdir: projectdir = PROJECTDIR if not sources: sources = [module + 'module.c'] if not sourcedirs: for moduledir in MODULEDIRS: if '%' in moduledir: # For historical reasons an initial _ in the modulename # is not reflected in the folder name if module[0] == '_': modulewithout_ = module[1:] else: modulewithout_ = module moduledir = moduledir % modulewithout_ fn = os.path.join(projectdir, os.path.join(moduledir, sources[0])) if os.path.exists(fn): moduledir, sourcefile = os.path.split(fn) sourcedirs = [relpath(projectdir, moduledir)] sources[0] = sourcefile break else: print "Warning: %s: sourcefile not found: %s"%(module, sources[0]) sourcedirs = [] if prefixname: pass elif architecture == "carbon": prefixname = "mwerks_carbonplugin_config.h" else: prefixname = "mwerks_plugin_config.h" dict = { "sysprefix" : relpath(projectdir, sys.prefix), "sources" : sources, "extrasearchdirs" : sourcedirs + extradirs, "libraries": libraries, "mac_outputdir" : outputdir, "extraexportsymbols" : extraexportsymbols, "mac_targetname" : targetname, "mac_dllname" : dllname, "prefixname" : prefixname, } if libraryflags: dict['libraryflags'] = libraryflags if stdlibraryflags: dict['stdlibraryflags'] = stdlibraryflags mkcwproject.mkproject(os.path.join(projectdir, project), module, dict, force=FORCEREBUILD, templatename=templatename)
150f9fc415d529faf327290ae61f0a86035b25ed /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/150f9fc415d529faf327290ae61f0a86035b25ed/genpluginprojects.py
genpluginproject("ppc", "_Mlte", libraries=["Textension"], outputdir="::Lib:Carbon")
genpluginproject("ppc", "_Mlte", libraries=["Textension"], libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
def genpluginproject(architecture, module, project=None, projectdir=None, sources=[], sourcedirs=[], libraries=[], extradirs=[], extraexportsymbols=[], outputdir=":::Lib:lib-dynload", libraryflags=None, stdlibraryflags=None, prefixname=None): if architecture == "all": # For the time being we generate two project files. Not as nice as # a single multitarget project, but easier to implement for now. genpluginproject("ppc", module, project, projectdir, sources, sourcedirs, libraries, extradirs, extraexportsymbols, outputdir, libraryflags, stdlibraryflags, prefixname) genpluginproject("carbon", module, project, projectdir, sources, sourcedirs, libraries, extradirs, extraexportsymbols, outputdir, libraryflags, stdlibraryflags, prefixname) return templatename = "template-%s" % architecture targetname = "%s.%s" % (module, architecture) dllname = "%s.%s.slb" % (module, architecture) if not project: if architecture != "ppc": project = "%s.%s.mcp"%(module, architecture) else: project = "%s.mcp"%module if not projectdir: projectdir = PROJECTDIR if not sources: sources = [module + 'module.c'] if not sourcedirs: for moduledir in MODULEDIRS: if '%' in moduledir: # For historical reasons an initial _ in the modulename # is not reflected in the folder name if module[0] == '_': modulewithout_ = module[1:] else: modulewithout_ = module moduledir = moduledir % modulewithout_ fn = os.path.join(projectdir, os.path.join(moduledir, sources[0])) if os.path.exists(fn): moduledir, sourcefile = os.path.split(fn) sourcedirs = [relpath(projectdir, moduledir)] sources[0] = sourcefile break else: print "Warning: %s: sourcefile not found: %s"%(module, sources[0]) sourcedirs = [] if prefixname: pass elif architecture == "carbon": prefixname = "mwerks_carbonplugin_config.h" else: prefixname = "mwerks_plugin_config.h" dict = { "sysprefix" : relpath(projectdir, sys.prefix), "sources" : sources, "extrasearchdirs" : sourcedirs + extradirs, "libraries": libraries, "mac_outputdir" : outputdir, "extraexportsymbols" : extraexportsymbols, "mac_targetname" : targetname, "mac_dllname" : dllname, "prefixname" : prefixname, } if libraryflags: dict['libraryflags'] = libraryflags if stdlibraryflags: dict['stdlibraryflags'] = stdlibraryflags mkcwproject.mkproject(os.path.join(projectdir, project), module, dict, force=FORCEREBUILD, templatename=templatename)
150f9fc415d529faf327290ae61f0a86035b25ed /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/150f9fc415d529faf327290ae61f0a86035b25ed/genpluginprojects.py
os.kill(pid, signal.SIGALARM)
os.kill(pid, signal.SIGALRM) print >> sys.__stdout__, " child sent SIGALRM to", pid
def force_test_exit(): # Sigh, both imports seem necessary to avoid errors. import os fork_pid = os.fork() if fork_pid == 0: # In child import os, time try: # Wait 5 seconds longer than the expected alarm to give enough # time for the normal sequence of events to occur. This is # just a stop-gap to prevent the test from hanging. time.sleep(MAX_DURATION + 5) print >> sys.__stdout__, ' child should not have to kill parent' for i in range(3): os.kill(pid, signal.SIGALARM) finally: os._exit(0) # In parent (or error) return fork_pid
da1455c5cc512a58a35962cf8fbb875963e6c2a3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/da1455c5cc512a58a35962cf8fbb875963e6c2a3/test_signal.py
return data[:-3] + '\n'
return data.replace('\r\r\n', '\n')
def normalize_output(data): # Some operating systems do conversions on newline. We could possibly # fix that by doing the appropriate termios.tcsetattr()s. I couldn't # figure out the right combo on Tru64 and I don't have an IRIX box. # So just normalize the output and doc the problem O/Ses by allowing # certain combinations for some platforms, but avoid allowing other # differences (like extra whitespace, trailing garbage, etc.) # This is about the best we can do without getting some feedback # from someone more knowledgable. # OSF/1 (Tru64) apparently turns \n into \r\r\n. if data.endswith('\r\r\n'): return data[:-3] + '\n' # IRIX apparently turns \n into \r\n. if data.endswith('\r\n'): return data[:-2] + '\n' return data
3ea84218d1aa617c33b8fa65c3255df0dac77f9c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/3ea84218d1aa617c33b8fa65c3255df0dac77f9c/test_pty.py
return data[:-2] + '\n'
return data.replace('\r\n', '\n')
def normalize_output(data): # Some operating systems do conversions on newline. We could possibly # fix that by doing the appropriate termios.tcsetattr()s. I couldn't # figure out the right combo on Tru64 and I don't have an IRIX box. # So just normalize the output and doc the problem O/Ses by allowing # certain combinations for some platforms, but avoid allowing other # differences (like extra whitespace, trailing garbage, etc.) # This is about the best we can do without getting some feedback # from someone more knowledgable. # OSF/1 (Tru64) apparently turns \n into \r\r\n. if data.endswith('\r\r\n'): return data[:-3] + '\n' # IRIX apparently turns \n into \r\n. if data.endswith('\r\n'): return data[:-2] + '\n' return data
3ea84218d1aa617c33b8fa65c3255df0dac77f9c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/3ea84218d1aa617c33b8fa65c3255df0dac77f9c/test_pty.py
def synopsis(filename, cache={}): """Get the one-line summary out of a module file.""" mtime = os.stat(filename)[stat.ST_MTIME] lastupdate, result = cache.get(filename, (0, None)) # XXX what if ext is 'rb' type in imp_getsuffixes? if lastupdate < mtime: file = open(filename) line = file.readline() while line[:1] == '#' or strip(line) == '': line = file.readline() if not line: break if line[-2:] == '\\\n': line = line[:-2] + file.readline() line = strip(line) if line[:3] == '"""': line = line[3:] while strip(line) == '': line = file.readline() if not line: break result = strip(split(line, '"""')[0]) else: result = None file.close() cache[filename] = (mtime, result) return result
af4215be4e43ddf4f8775f622d9db3233f712894 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/af4215be4e43ddf4f8775f622d9db3233f712894/pydoc.py
line = file.readline() while line[:1] == '
if info and 'b' in info[2]: try: module = imp.load_module(info[0], file, filename, info[1:]) except: return None result = split(module.__doc__ or '', '\n')[0] else:
def synopsis(filename, cache={}): """Get the one-line summary out of a module file.""" mtime = os.stat(filename)[stat.ST_MTIME] lastupdate, result = cache.get(filename, (0, None)) # XXX what if ext is 'rb' type in imp_getsuffixes? if lastupdate < mtime: file = open(filename) line = file.readline() while line[:1] == '#' or strip(line) == '': line = file.readline() if not line: break if line[-2:] == '\\\n': line = line[:-2] + file.readline() line = strip(line) if line[:3] == '"""': line = line[3:] while strip(line) == '': line = file.readline() if not line: break result = strip(split(line, '"""')[0]) else: result = None file.close() cache[filename] = (mtime, result) return result
af4215be4e43ddf4f8775f622d9db3233f712894 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/af4215be4e43ddf4f8775f622d9db3233f712894/pydoc.py
if not line: break if line[-2:] == '\\\n': line = line[:-2] + file.readline() line = strip(line) if line[:3] == '"""': line = line[3:] while strip(line) == '':
while line[:1] == '
def synopsis(filename, cache={}): """Get the one-line summary out of a module file.""" mtime = os.stat(filename)[stat.ST_MTIME] lastupdate, result = cache.get(filename, (0, None)) # XXX what if ext is 'rb' type in imp_getsuffixes? if lastupdate < mtime: file = open(filename) line = file.readline() while line[:1] == '#' or strip(line) == '': line = file.readline() if not line: break if line[-2:] == '\\\n': line = line[:-2] + file.readline() line = strip(line) if line[:3] == '"""': line = line[3:] while strip(line) == '': line = file.readline() if not line: break result = strip(split(line, '"""')[0]) else: result = None file.close() cache[filename] = (mtime, result) return result
af4215be4e43ddf4f8775f622d9db3233f712894 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/af4215be4e43ddf4f8775f622d9db3233f712894/pydoc.py
result = strip(split(line, '"""')[0]) else: result = None
line = strip(line) if line[:4] == 'r"""': line = line[1:] if line[:3] == '"""': line = line[3:] if line[-1:] == '\\': line = line[:-1] while not strip(line): line = file.readline() if not line: break result = strip(split(line, '"""')[0]) else: result = None
def synopsis(filename, cache={}): """Get the one-line summary out of a module file.""" mtime = os.stat(filename)[stat.ST_MTIME] lastupdate, result = cache.get(filename, (0, None)) # XXX what if ext is 'rb' type in imp_getsuffixes? if lastupdate < mtime: file = open(filename) line = file.readline() while line[:1] == '#' or strip(line) == '': line = file.readline() if not line: break if line[-2:] == '\\\n': line = line[:-2] + file.readline() line = strip(line) if line[:3] == '"""': line = line[3:] while strip(line) == '': line = file.readline() if not line: break result = strip(split(line, '"""')[0]) else: result = None file.close() cache[filename] = (mtime, result) return result
af4215be4e43ddf4f8775f622d9db3233f712894 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/af4215be4e43ddf4f8775f622d9db3233f712894/pydoc.py
def stripid(text): """Remove the hexadecimal id from a Python object representation.""" # The behaviour of %p is implementation-dependent, so we need an example. for pattern in [' at 0x[0-9a-f]{6,}>$', ' at [0-9A-F]{8,}>$']: if re.search(pattern, repr(Exception)): return re.sub(pattern, '>', text) return text
af4215be4e43ddf4f8775f622d9db3233f712894 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/af4215be4e43ddf4f8775f622d9db3233f712894/pydoc.py
def modulename(path): """Return the Python module name for a given path, or None.""" filename = os.path.basename(path) suffixes = map(lambda (suffix, mode, kind): (len(suffix), suffix), imp.get_suffixes()) suffixes.sort() suffixes.reverse() for length, suffix in suffixes: if len(filename) > length and filename[-length:] == suffix: return filename[:-length]
def stripid(text): """Remove the hexadecimal id from a Python object representation.""" # The behaviour of %p is implementation-dependent, so we need an example. for pattern in [' at 0x[0-9a-f]{6,}>$', ' at [0-9A-F]{8,}>$']: if re.search(pattern, repr(Exception)): return re.sub(pattern, '>', text) return text
af4215be4e43ddf4f8775f622d9db3233f712894 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/af4215be4e43ddf4f8775f622d9db3233f712894/pydoc.py
return re.sub(r'((\\[\\abfnrtv\'"]|\\x..|\\u....)+)',
return re.sub(r'((\\[\\abfnrtv\'"]|\\[0-9]..|\\x..|\\u....)+)',
def repr_string(self, x, level): test = cram(x, self.maxstring) testrepr = repr(test) if '\\' in test and '\\' not in replace(testrepr, (r'\\', '')): # Backslashes are only literal in the string and are never # needed to make any special characters, so show a raw string. return 'r' + testrepr[0] + self.escape(test) + testrepr[0] return re.sub(r'((\\[\\abfnrtv\'"]|\\x..|\\u....)+)', r'<font color="#c040c0">\1</font>', self.escape(testrepr))
af4215be4e43ddf4f8775f622d9db3233f712894 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/af4215be4e43ddf4f8775f622d9db3233f712894/pydoc.py
def section(self, title, fgcol, bgcol, contents, width=20,
def section(self, title, fgcol, bgcol, contents, width=10,
def section(self, title, fgcol, bgcol, contents, width=20, prelude='', marginalia=None, gap='&nbsp;&nbsp;'): """Format a section with a heading.""" if marginalia is None: marginalia = '&nbsp;' * width result = '''
af4215be4e43ddf4f8775f622d9db3233f712894 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/af4215be4e43ddf4f8775f622d9db3233f712894/pydoc.py
marginalia = '&nbsp;' * width
marginalia = '<tt>' + '&nbsp;' * width + '</tt>'
def section(self, title, fgcol, bgcol, contents, width=20, prelude='', marginalia=None, gap='&nbsp;&nbsp;'): """Format a section with a heading.""" if marginalia is None: marginalia = '&nbsp;' * width result = '''
af4215be4e43ddf4f8775f622d9db3233f712894 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/af4215be4e43ddf4f8775f622d9db3233f712894/pydoc.py
return result + '<td width="100%%">%s</td></tr></table>' % contents
return result + '\n<td width="100%%">%s</td></tr></table>' % contents
def section(self, title, fgcol, bgcol, contents, width=20, prelude='', marginalia=None, gap='&nbsp;&nbsp;'): """Format a section with a heading.""" if marginalia is None: marginalia = '&nbsp;' * width result = '''
af4215be4e43ddf4f8775f622d9db3233f712894 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/af4215be4e43ddf4f8775f622d9db3233f712894/pydoc.py
if 0 and hasattr(object, '__all__'): visible = lambda key, all=object.__all__: key in all else: visible = lambda key: key[:1] != '_'
def docmodule(self, object, name=None): """Produce HTML documentation for a module object.""" name = object.__name__ # ignore the passed-in name parts = split(name, '.') links = [] for i in range(len(parts)-1): links.append( '<a href="%s.html"><font color="#ffffff">%s</font></a>' % (join(parts[:i+1], '.'), parts[i])) linkedname = join(links + parts[-1:], '.') head = '<big><big><strong>%s</strong></big></big>' % linkedname try: path = inspect.getabsfile(object) filelink = '<a href="file:%s">%s</a>' % (path, path) except TypeError: filelink = '(built-in)' info = [] if hasattr(object, '__version__'): version = str(object.__version__) if version[:11] == '$' + 'Revision: ' and version[-1:] == '$': version = strip(version[11:-1]) info.append('version %s' % self.escape(version)) if hasattr(object, '__date__'): info.append(self.escape(str(object.__date__))) if info: head = head + ' (%s)' % join(info, ', ') result = self.heading( head, '#ffffff', '#7799ee', '<a href=".">index</a><br>' + filelink)
af4215be4e43ddf4f8775f622d9db3233f712894 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/af4215be4e43ddf4f8775f622d9db3233f712894/pydoc.py
if visible(key) and ( inspect.getmodule(value) or object) is object:
if (inspect.getmodule(value) or object) is object:
def docmodule(self, object, name=None): """Produce HTML documentation for a module object.""" name = object.__name__ # ignore the passed-in name parts = split(name, '.') links = [] for i in range(len(parts)-1): links.append( '<a href="%s.html"><font color="#ffffff">%s</font></a>' % (join(parts[:i+1], '.'), parts[i])) linkedname = join(links + parts[-1:], '.') head = '<big><big><strong>%s</strong></big></big>' % linkedname try: path = inspect.getabsfile(object) filelink = '<a href="file:%s">%s</a>' % (path, path) except TypeError: filelink = '(built-in)' info = [] if hasattr(object, '__version__'): version = str(object.__version__) if version[:11] == '$' + 'Revision: ' and version[-1:] == '$': version = strip(version[11:-1]) info.append('version %s' % self.escape(version)) if hasattr(object, '__date__'): info.append(self.escape(str(object.__date__))) if info: head = head + ' (%s)' % join(info, ', ') result = self.heading( head, '#ffffff', '#7799ee', '<a href=".">index</a><br>' + filelink)
af4215be4e43ddf4f8775f622d9db3233f712894 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/af4215be4e43ddf4f8775f622d9db3233f712894/pydoc.py
if visible(key) and (inspect.isbuiltin(value) or inspect.getmodule(value) is object):
if inspect.isbuiltin(value) or inspect.getmodule(value) is object:
def docmodule(self, object, name=None): """Produce HTML documentation for a module object.""" name = object.__name__ # ignore the passed-in name parts = split(name, '.') links = [] for i in range(len(parts)-1): links.append( '<a href="%s.html"><font color="#ffffff">%s</font></a>' % (join(parts[:i+1], '.'), parts[i])) linkedname = join(links + parts[-1:], '.') head = '<big><big><strong>%s</strong></big></big>' % linkedname try: path = inspect.getabsfile(object) filelink = '<a href="file:%s">%s</a>' % (path, path) except TypeError: filelink = '(built-in)' info = [] if hasattr(object, '__version__'): version = str(object.__version__) if version[:11] == '$' + 'Revision: ' and version[-1:] == '$': version = strip(version[11:-1]) info.append('version %s' % self.escape(version)) if hasattr(object, '__date__'): info.append(self.escape(str(object.__date__))) if info: head = head + ' (%s)' % join(info, ', ') result = self.heading( head, '#ffffff', '#7799ee', '<a href=".">index</a><br>' + filelink)
af4215be4e43ddf4f8775f622d9db3233f712894 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/af4215be4e43ddf4f8775f622d9db3233f712894/pydoc.py
if visible(key): constants.append((key, value))
constants.append((key, value))
def docmodule(self, object, name=None): """Produce HTML documentation for a module object.""" name = object.__name__ # ignore the passed-in name parts = split(name, '.') links = [] for i in range(len(parts)-1): links.append( '<a href="%s.html"><font color="#ffffff">%s</font></a>' % (join(parts[:i+1], '.'), parts[i])) linkedname = join(links + parts[-1:], '.') head = '<big><big><strong>%s</strong></big></big>' % linkedname try: path = inspect.getabsfile(object) filelink = '<a href="file:%s">%s</a>' % (path, path) except TypeError: filelink = '(built-in)' info = [] if hasattr(object, '__version__'): version = str(object.__version__) if version[:11] == '$' + 'Revision: ' and version[-1:] == '$': version = strip(version[11:-1]) info.append('version %s' % self.escape(version)) if hasattr(object, '__date__'): info.append(self.escape(str(object.__date__))) if info: head = head + ' (%s)' % join(info, ', ') result = self.heading( head, '#ffffff', '#7799ee', '<a href=".">index</a><br>' + filelink)
af4215be4e43ddf4f8775f622d9db3233f712894 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/af4215be4e43ddf4f8775f622d9db3233f712894/pydoc.py
if file[:1] != '_': path = os.path.join(object.__path__[0], file) modname = modulename(file) if modname and modname not in modnames: modpkgs.append((modname, name, 0, 0)) modnames.append(modname) elif ispackage(path): modpkgs.append((file, name, 1, 0))
path = os.path.join(object.__path__[0], file) modname = inspect.getmodulename(file) if modname and modname not in modnames: modpkgs.append((modname, name, 0, 0)) modnames.append(modname) elif ispackage(path): modpkgs.append((file, name, 1, 0))
def docmodule(self, object, name=None): """Produce HTML documentation for a module object.""" name = object.__name__ # ignore the passed-in name parts = split(name, '.') links = [] for i in range(len(parts)-1): links.append( '<a href="%s.html"><font color="#ffffff">%s</font></a>' % (join(parts[:i+1], '.'), parts[i])) linkedname = join(links + parts[-1:], '.') head = '<big><big><strong>%s</strong></big></big>' % linkedname try: path = inspect.getabsfile(object) filelink = '<a href="file:%s">%s</a>' % (path, path) except TypeError: filelink = '(built-in)' info = [] if hasattr(object, '__version__'): version = str(object.__version__) if version[:11] == '$' + 'Revision: ' and version[-1:] == '$': version = strip(version[11:-1]) info.append('version %s' % self.escape(version)) if hasattr(object, '__date__'): info.append(self.escape(str(object.__date__))) if info: head = head + ' (%s)' % join(info, ', ') result = self.heading( head, '#ffffff', '#7799ee', '<a href=".">index</a><br>' + filelink)
af4215be4e43ddf4f8775f622d9db3233f712894 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/af4215be4e43ddf4f8775f622d9db3233f712894/pydoc.py
doc = self.small(doc and '<tt>%s<br>&nbsp;</tt>' % doc or '<tt>&nbsp;</tt>') return self.section(title, '
doc = self.small(doc and '<tt>%s<br>&nbsp;</tt>' % doc or self.small('&nbsp;')) return self.section(title, '
def docclass(self, object, name=None, funcs={}, classes={}): """Produce HTML documentation for a class object.""" realname = object.__name__ name = name or realname bases = object.__bases__ contents = ''
af4215be4e43ddf4f8775f622d9db3233f712894 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/af4215be4e43ddf4f8775f622d9db3233f712894/pydoc.py
doc = doc and '<tt>%s</tt>' % doc return '<dl><dt>%s<dd>%s</dl>\n' % (decl, self.small(doc))
doc = doc and '<dd>' + self.small('<tt>%s</tt>' % doc) return '<dl><dt>%s%s</dl>\n' % (decl, doc)
def docroutine(self, object, name=None, funcs={}, classes={}, methods={}, cl=None): """Produce HTML documentation for a function or method object.""" realname = object.__name__ name = name or realname anchor = (cl and cl.__name__ or '') + '-' + name note = '' skipdocs = 0 if inspect.ismethod(object): if cl: if object.im_class is not cl: base = object.im_class url = '#%s-%s' % (base.__name__, name) basename = base.__name__ if base.__module__ != cl.__module__: url = base.__module__ + '.html' + url basename = base.__module__ + '.' + basename note = ' from <a href="%s">%s</a>' % (url, basename) skipdocs = 1 else: note = (object.im_self and ' method of ' + self.repr(object.im_self) or ' unbound %s method' % object.im_class.__name__) object = object.im_func
af4215be4e43ddf4f8775f622d9db3233f712894 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/af4215be4e43ddf4f8775f622d9db3233f712894/pydoc.py
if file[:1] != '_' and os.path.isfile(path): modname = modulename(file)
if os.path.isfile(path): modname = inspect.getmodulename(file)
def found(name, ispackage, modpkgs=modpkgs, shadowed=shadowed, seen=seen): if not seen.has_key(name): modpkgs.append((name, '', ispackage, shadowed.has_key(name))) seen[name] = 1 shadowed[name] = 1
af4215be4e43ddf4f8775f622d9db3233f712894 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/af4215be4e43ddf4f8775f622d9db3233f712894/pydoc.py
namesec = name lines = split(strip(getdoc(object)), '\n') if len(lines) == 1: if lines[0]: namesec = namesec + ' - ' + lines[0] lines = [] elif len(lines) >= 2 and not rstrip(lines[1]): if lines[0]: namesec = namesec + ' - ' + lines[0] lines = lines[2:] result = self.section('NAME', namesec)
synop, desc = splitdoc(getdoc(object)) result = self.section('NAME', name + (synop and ' - ' + synop))
def docmodule(self, object, name=None): """Produce text documentation for a given module object.""" name = object.__name__ # ignore the passed-in name namesec = name lines = split(strip(getdoc(object)), '\n') if len(lines) == 1: if lines[0]: namesec = namesec + ' - ' + lines[0] lines = [] elif len(lines) >= 2 and not rstrip(lines[1]): if lines[0]: namesec = namesec + ' - ' + lines[0] lines = lines[2:] result = self.section('NAME', namesec)
af4215be4e43ddf4f8775f622d9db3233f712894 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/af4215be4e43ddf4f8775f622d9db3233f712894/pydoc.py
if lines: result = result + self.section('DESCRIPTION', join(lines, '\n'))
if desc: result = result + self.section('DESCRIPTION', desc)
def docmodule(self, object, name=None): """Produce text documentation for a given module object.""" name = object.__name__ # ignore the passed-in name namesec = name lines = split(strip(getdoc(object)), '\n') if len(lines) == 1: if lines[0]: namesec = namesec + ' - ' + lines[0] lines = [] elif len(lines) >= 2 and not rstrip(lines[1]): if lines[0]: namesec = namesec + ' - ' + lines[0] lines = lines[2:] result = self.section('NAME', namesec)
af4215be4e43ddf4f8775f622d9db3233f712894 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/af4215be4e43ddf4f8775f622d9db3233f712894/pydoc.py
if key[:1] != '_': constants.append((key, value))
constants.append((key, value))
def docmodule(self, object, name=None): """Produce text documentation for a given module object.""" name = object.__name__ # ignore the passed-in name namesec = name lines = split(strip(getdoc(object)), '\n') if len(lines) == 1: if lines[0]: namesec = namesec + ' - ' + lines[0] lines = [] elif len(lines) >= 2 and not rstrip(lines[1]): if lines[0]: namesec = namesec + ' - ' + lines[0] lines = lines[2:] result = self.section('NAME', namesec)
af4215be4e43ddf4f8775f622d9db3233f712894 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/af4215be4e43ddf4f8775f622d9db3233f712894/pydoc.py
if file[:1] != '_': path = os.path.join(object.__path__[0], file) modname = modulename(file) if modname and modname not in modpkgs: modpkgs.append(modname) elif ispackage(path): modpkgs.append(file + ' (package)')
path = os.path.join(object.__path__[0], file) modname = inspect.getmodulename(file) if modname and modname not in modpkgs: modpkgs.append(modname) elif ispackage(path): modpkgs.append(file + ' (package)')
def docmodule(self, object, name=None): """Produce text documentation for a given module object.""" name = object.__name__ # ignore the passed-in name namesec = name lines = split(strip(getdoc(object)), '\n') if len(lines) == 1: if lines[0]: namesec = namesec + ' - ' + lines[0] lines = [] elif len(lines) >= 2 and not rstrip(lines[1]): if lines[0]: namesec = namesec + ' - ' + lines[0] lines = lines[2:] result = self.section('NAME', namesec)
af4215be4e43ddf4f8775f622d9db3233f712894 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/af4215be4e43ddf4f8775f622d9db3233f712894/pydoc.py
return lambda a: pipepager(a, os.environ['PAGER'])
if sys.platform == 'win32': return lambda a: tempfilepager(a, os.environ['PAGER']) else: return lambda a: pipepager(a, os.environ['PAGER'])
def getpager(): """Decide what method to use for paging through text.""" if type(sys.stdout) is not types.FileType: return plainpager if not sys.stdin.isatty() or not sys.stdout.isatty(): return plainpager if os.environ.has_key('PAGER'): return lambda a: pipepager(a, os.environ['PAGER']) if sys.platform == 'win32': return lambda a: tempfilepager(a, 'more <') if hasattr(os, 'system') and os.system('less 2>/dev/null') == 0: return lambda a: pipepager(a, 'less') import tempfile filename = tempfile.mktemp() open(filename, 'w').close() try: if hasattr(os, 'system') and os.system('more %s' % filename) == 0: return lambda text: pipepager(text, 'more') else: return ttypager finally: os.unlink(filename)
af4215be4e43ddf4f8775f622d9db3233f712894 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/af4215be4e43ddf4f8775f622d9db3233f712894/pydoc.py
raise DocImportError(filename, sys.exc_info())
raise ErrorDuringImport(filename, sys.exc_info())
def locate(path): """Locate an object by name (or dotted path), importing as necessary.""" if not path: # special case: imp.find_module('') strangely succeeds return None if type(path) is not types.StringType: return path parts = split(path, '.') n = len(parts) while n > 0: path = join(parts[:n], '.') try: module = freshimport(path) except: # Did the error occur before or after the module was found? (exc, value, tb) = info = sys.exc_info() if sys.modules.has_key(path): # An error occured while executing the imported module. raise ErrorDuringImport(sys.modules[path].__file__, info) elif exc is SyntaxError: # A SyntaxError occurred before we could execute the module. raise ErrorDuringImport(value.filename, info) elif exc is ImportError and \ split(lower(str(value)))[:2] == ['no', 'module']: # The module was not found. n = n - 1 continue else: # Some other error occurred before executing the module. raise DocImportError(filename, sys.exc_info()) try: x = module for p in parts[n:]: x = getattr(x, p) return x except AttributeError: n = n - 1 continue if hasattr(__builtins__, path): return getattr(__builtins__, path) return None
af4215be4e43ddf4f8775f622d9db3233f712894 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/af4215be4e43ddf4f8775f622d9db3233f712894/pydoc.py
page = html.page('Python: ' + describe(object),
page = html.page(describe(object),
def writedoc(key): """Write HTML documentation to a file in the current directory.""" try: object = locate(key) except ErrorDuringImport, value: print value else: if object: page = html.page('Python: ' + describe(object), html.document(object, object.__name__)) file = open(key + '.html', 'w') file.write(page) file.close() print 'wrote', key + '.html' else: print 'no Python documentation found for %s' % repr(key)
af4215be4e43ddf4f8775f622d9db3233f712894 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/af4215be4e43ddf4f8775f622d9db3233f712894/pydoc.py
modname = modulename(path)
modname = inspect.getmodulename(path)
def writedocs(dir, pkgpath='', done={}): """Write out HTML documentation for all modules in a directory tree.""" for file in os.listdir(dir): path = os.path.join(dir, file) if ispackage(path): writedocs(path, pkgpath + file + '.') elif os.path.isfile(path): modname = modulename(path) if modname: modname = pkgpath + modname if not done.has_key(modname): done[modname] = 1 writedoc(modname)
af4215be4e43ddf4f8775f622d9db3233f712894 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/af4215be4e43ddf4f8775f622d9db3233f712894/pydoc.py
modname = modulename(path)
modname = inspect.getmodulename(path)
def run(self, key, callback, completer=None): self.quit = 0 seen = {}
af4215be4e43ddf4f8775f622d9db3233f712894 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/af4215be4e43ddf4f8775f622d9db3233f712894/pydoc.py
print modname, '-', desc or '(no description)'
print modname, desc and '- ' + desc try: import warnings except ImportError: pass else: warnings.filterwarnings('ignore')
def callback(path, modname, desc): if modname[-9:] == '.__init__': modname = modname[:-9] + ' (package)' print modname, '-', desc or '(no description)'
af4215be4e43ddf4f8775f622d9db3233f712894 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/af4215be4e43ddf4f8775f622d9db3233f712894/pydoc.py
try: import ic ic.launchurl(url)
try: import ic
def open(self, event=None, url=None): url = url or self.server.url try: import webbrowser webbrowser.open(url) except ImportError: # pre-webbrowser.py compatibility if sys.platform == 'win32': os.system('start "%s"' % url) elif sys.platform == 'mac': try: import ic ic.launchurl(url) except ImportError: pass else: rc = os.system('netscape -remote "openURL(%s)" &' % url) if rc: os.system('netscape "%s" &' % url)
af4215be4e43ddf4f8775f622d9db3233f712894 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/af4215be4e43ddf4f8775f622d9db3233f712894/pydoc.py
Pop up a graphical interface for serving and finding documentation.
Pop up a graphical interface for finding and serving documentation.
def ready(server): print 'server ready at %s' % server.url
af4215be4e43ddf4f8775f622d9db3233f712894 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/af4215be4e43ddf4f8775f622d9db3233f712894/pydoc.py
directory. If <name> contains a '%s', it is treated as a filename.
directory. If <name> contains a '%s', it is treated as a filename; if it names a directory, documentation is written for all the contents.
def ready(server): print 'server ready at %s' % server.url
af4215be4e43ddf4f8775f622d9db3233f712894 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/af4215be4e43ddf4f8775f622d9db3233f712894/pydoc.py
self.saved_clear() self.hrefstack.append(href) def anchor_end(self): if self.proc: title = cgi.escape(self.saved_get(), True) path = self.path + '/' + self.hrefstack.pop()
def anchor_bgn(self, href, name, type): if self.proc: self.saved_clear() self.hrefstack.append(href)
7d574e3a453e66a884e6bac844a159c9fca0df26 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/7d574e3a453e66a884e6bac844a159c9fca0df26/prechm.py
def anchor_end(self): if self.proc: title = cgi.escape(self.saved_get(), True) path = self.path + '/' + self.hrefstack.pop() # XXX See SF bug <http://www.python.org/sf/546579>. # XXX index.html for the 2.2 language reference manual contains # XXX nested <a></a> tags in the entry for the section on blank # XXX lines. We want to ignore the nested part completely. if len(self.hrefstack) == 0: self.tab(object_sitemap % (title, path))
7d574e3a453e66a884e6bac844a159c9fca0df26 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/7d574e3a453e66a884e6bac844a159c9fca0df26/prechm.py
self.checkequal(('http://www.python.org', '', ''), S, 'rpartition', '?')
self.checkequal(('', '', 'http://www.python.org'), S, 'rpartition', '?')
def test_rpartition(self):
5ef499c037d6aae25158d7222955353c982e7717 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/5ef499c037d6aae25158d7222955353c982e7717/string_tests.py
test_classes = (TestBasicOps, TestVariousIteratorArgs, TestGC)
test_classes = (TestBasicOps, TestVariousIteratorArgs, TestGC, RegressionTests)
def test_main(verbose=None): test_classes = (TestBasicOps, TestVariousIteratorArgs, TestGC) test_support.run_unittest(*test_classes) # verify reference counting if verbose and hasattr(sys, "gettotalrefcount"): import gc counts = [None] * 5 for i in xrange(len(counts)): test_support.run_unittest(*test_classes) gc.collect() counts[i] = sys.gettotalrefcount() print counts # doctest the examples in the library reference test_support.run_doctest(sys.modules[__name__], verbose)
d9f808f3d66789fefbfa99ee0020c8cdcd28a6fb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d9f808f3d66789fefbfa99ee0020c8cdcd28a6fb/test_itertools.py
self.bytecompile(outfiles)
if outfiles is not None: self.bytecompile(outfiles)
def run (self):
652511cab75ca48fcd1299198ba2fdf3d7ed0536 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/652511cab75ca48fcd1299198ba2fdf3d7ed0536/install_lib.py
del Popen3, Popen4, _active, _cleanup
del Popen3, Popen4
def __init__(self, cmd, bufsize=-1): _cleanup() p2cread, p2cwrite = os.pipe() c2pread, c2pwrite = os.pipe() self.pid = os.fork() if self.pid == 0: # Child os.dup2(p2cread, 0) os.dup2(c2pwrite, 1) os.dup2(c2pwrite, 2) self._run_child(cmd) os.close(p2cread) self.tochild = os.fdopen(p2cwrite, 'w', bufsize) os.close(c2pwrite) self.fromchild = os.fdopen(c2pread, 'r', bufsize) _active.append(self)
d6e049ff1a17b7dc5e9c7ed8c13baea3f977d224 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d6e049ff1a17b7dc5e9c7ed8c13baea3f977d224/popen2.py
dir = os.path.join(*paths) return os.path.normcase(os.path.abspath(dir)) L = sys.modules.values() for m in L:
dir = os.path.abspath(os.path.join(*paths)) return dir, os.path.normcase(dir) for m in sys.modules.values():
def makepath(*paths): dir = os.path.join(*paths) return os.path.normcase(os.path.abspath(dir))
8611ea685d3b98759c521191bcdd35fa431bb9ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8611ea685d3b98759c521191bcdd35fa431bb9ca/site.py
m.__file__ = makepath(m.__file__) del m, L
m.__file__ = os.path.abspath(m.__file__) del m
def makepath(*paths): dir = os.path.join(*paths) return os.path.normcase(os.path.abspath(dir))
8611ea685d3b98759c521191bcdd35fa431bb9ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8611ea685d3b98759c521191bcdd35fa431bb9ca/site.py
dir = makepath(dir) if dir not in L:
dir, dircase = makepath(dir) if not dirs_in_sys_path.has_key(dircase):
def makepath(*paths): dir = os.path.join(*paths) return os.path.normcase(os.path.abspath(dir))
8611ea685d3b98759c521191bcdd35fa431bb9ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8611ea685d3b98759c521191bcdd35fa431bb9ca/site.py
sitedir = makepath(sitedir) if sitedir not in sys.path:
sitedir, sitedircase = makepath(sitedir) if not dirs_in_sys_path.has_key(sitedircase):
def addsitedir(sitedir): sitedir = makepath(sitedir) if sitedir not in sys.path: sys.path.append(sitedir) # Add path component try: names = os.listdir(sitedir) except os.error: return names = map(os.path.normcase, names) names.sort() for name in names: if name[-4:] == endsep + "pth": addpackage(sitedir, name)
8611ea685d3b98759c521191bcdd35fa431bb9ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8611ea685d3b98759c521191bcdd35fa431bb9ca/site.py
names = map(os.path.normcase, names)
def addsitedir(sitedir): sitedir = makepath(sitedir) if sitedir not in sys.path: sys.path.append(sitedir) # Add path component try: names = os.listdir(sitedir) except os.error: return names = map(os.path.normcase, names) names.sort() for name in names: if name[-4:] == endsep + "pth": addpackage(sitedir, name)
8611ea685d3b98759c521191bcdd35fa431bb9ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8611ea685d3b98759c521191bcdd35fa431bb9ca/site.py
dir = makepath(sitedir, dir) if dir not in sys.path and os.path.exists(dir):
dir, dircase = makepath(sitedir, dir) if not dirs_in_sys_path.has_key(dircase) and os.path.exists(dir):
def addpackage(sitedir, name): fullname = os.path.join(sitedir, name) try: f = open(fullname) except IOError: return while 1: dir = f.readline() if not dir: break if dir[0] == '#': continue if dir.startswith("import"): exec dir continue if dir[-1] == '\n': dir = dir[:-1] dir = makepath(sitedir, dir) if dir not in sys.path and os.path.exists(dir): sys.path.append(dir)
8611ea685d3b98759c521191bcdd35fa431bb9ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8611ea685d3b98759c521191bcdd35fa431bb9ca/site.py
sitedirs = [makepath(prefix, "lib", "python" + sys.version[:3], "site-packages"), makepath(prefix, "lib", "site-python")]
sitedirs = [os.path.join(prefix, "lib", "python" + sys.version[:3], "site-packages"), os.path.join(prefix, "lib", "site-python")]
def addpackage(sitedir, name): fullname = os.path.join(sitedir, name) try: f = open(fullname) except IOError: return while 1: dir = f.readline() if not dir: break if dir[0] == '#': continue if dir.startswith("import"): exec dir continue if dir[-1] == '\n': dir = dir[:-1] dir = makepath(sitedir, dir) if dir not in sys.path and os.path.exists(dir): sys.path.append(dir)
8611ea685d3b98759c521191bcdd35fa431bb9ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8611ea685d3b98759c521191bcdd35fa431bb9ca/site.py
sitedirs = [makepath(prefix, "lib", "site-packages")]
sitedirs = [os.path.join(prefix, "lib", "site-packages")]
def addpackage(sitedir, name): fullname = os.path.join(sitedir, name) try: f = open(fullname) except IOError: return while 1: dir = f.readline() if not dir: break if dir[0] == '#': continue if dir.startswith("import"): exec dir continue if dir[-1] == '\n': dir = dir[:-1] dir = makepath(sitedir, dir) if dir not in sys.path and os.path.exists(dir): sys.path.append(dir)
8611ea685d3b98759c521191bcdd35fa431bb9ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8611ea685d3b98759c521191bcdd35fa431bb9ca/site.py
testf.write(data)
if DEBUG: testf.write(data)
def write(self, data):
0fc14771c0c0be4db25ab4f7abd742618289c23f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/0fc14771c0c0be4db25ab4f7abd742618289c23f/binhex.py
fss, ok = macfs.StandardGetFile()
fss, ok = macfs.PromptGetFile('File to convert:')
def _test(): if os.name == 'mac': fss, ok = macfs.StandardGetFile() if not ok: sys.exit(0) fname = fss.as_pathname() else: fname = sys.argv[1] #binhex(fname, fname+'.hqx') #hexbin(fname+'.hqx', fname+'.viahqx') hexbin(fname, fname+'.unpacked') sys.exit(1)
0fc14771c0c0be4db25ab4f7abd742618289c23f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/0fc14771c0c0be4db25ab4f7abd742618289c23f/binhex.py
rc = os.system("%s %s" % (self.name, url))
rc = os.system(cmd)
def _remote(self, url, action, autoraise): autoraise = int(bool(autoraise)) # always 0/1 raise_opt = self.raise_opts and self.raise_opts[autoraise] or '' cmd = "%s %s %s '%s' >/dev/null 2>&1" % (self.name, raise_opt, self.remote_cmd, action) if self.remote_background: cmd += ' &' rc = os.system(cmd) if rc: # bad return status, try again with simpler command rc = os.system("%s %s" % (self.name, url)) return not rc
cfb444dff0197da83f7e7bab75b57f2c7044c0be /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/cfb444dff0197da83f7e7bab75b57f2c7044c0be/webbrowser.py
rc = os.system(self.name + " -d '%s'" % url)
rc = os.system(self.name + " -d '%s' &" % url)
def _remote(self, url, action): # kfmclient is the new KDE way of opening URLs. cmd = "kfmclient %s >/dev/null 2>&1" % action rc = os.system(cmd) # Fall back to other variants. if rc: if _iscommand("konqueror"): rc = os.system(self.name + " --silent '%s' &" % url) elif _iscommand("kfm"): rc = os.system(self.name + " -d '%s'" % url) return not rc
cfb444dff0197da83f7e7bab75b57f2c7044c0be /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/cfb444dff0197da83f7e7bab75b57f2c7044c0be/webbrowser.py
script = _safequote('open location "%s"', url)
script = 'open location "%s"' % url.replace('"', '%22')
def open(self, url, new=0, autoraise=1): assert "'" not in url # new must be 0 or 1 new = int(bool(new)) if self.name == "default": # User called open, open_new or get without a browser parameter script = _safequote('open location "%s"', url) # opens in default browser else: # User called get and chose a browser if self.name == "OmniWeb": toWindow = "" else: # Include toWindow parameter of OpenURL command for browsers # that support it. 0 == new window; -1 == existing toWindow = "toWindow %d" % (new - 1) cmd = _safequote('OpenURL "%s"', url) script = '''tell application "%s" activate %s %s end tell''' % (self.name, cmd, toWindow) # Open pipe to AppleScript through osascript command osapipe = os.popen("osascript", "w") if osapipe is None: return False # Write script to osascript's stdin osapipe.write(script) rc = osapipe.close() return not rc
cfb444dff0197da83f7e7bab75b57f2c7044c0be /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/cfb444dff0197da83f7e7bab75b57f2c7044c0be/webbrowser.py
cmd = _safequote('OpenURL "%s"', url)
cmd = 'OpenURL "%s"' % url.replace('"', '%22')
def open(self, url, new=0, autoraise=1): assert "'" not in url # new must be 0 or 1 new = int(bool(new)) if self.name == "default": # User called open, open_new or get without a browser parameter script = _safequote('open location "%s"', url) # opens in default browser else: # User called get and chose a browser if self.name == "OmniWeb": toWindow = "" else: # Include toWindow parameter of OpenURL command for browsers # that support it. 0 == new window; -1 == existing toWindow = "toWindow %d" % (new - 1) cmd = _safequote('OpenURL "%s"', url) script = '''tell application "%s" activate %s %s end tell''' % (self.name, cmd, toWindow) # Open pipe to AppleScript through osascript command osapipe = os.popen("osascript", "w") if osapipe is None: return False # Write script to osascript's stdin osapipe.write(script) rc = osapipe.close() return not rc
cfb444dff0197da83f7e7bab75b57f2c7044c0be /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/cfb444dff0197da83f7e7bab75b57f2c7044c0be/webbrowser.py
if r.status in (200, 206): resp = addinfourl(r.fp, r.msg, req.get_full_url()) resp.code = r.status resp.msg = r.reason return resp else: return self.parent.error("http", req, r.fp, r.status, r.msg, r.msg.dict)
resp = addinfourl(r.fp, r.msg, req.get_full_url()) resp.code = r.status resp.msg = r.reason return resp
def do_open(self, http_class, req): """Return an addinfourl object for the request, using http_class.
297e9c02959d08188d4a797a8f0314e0ea5e94a8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/297e9c02959d08188d4a797a8f0314e0ea5e94a8/urllib2.py
self.__messages.setdefault(msg, []).append(entry)
self.__messages.setdefault(msg, {})[entry] = 1
def __addentry(self, msg, lineno=None): if lineno is None: lineno = self.__lineno if not msg in self.__options.toexclude: entry = (self.__curfile, lineno) self.__messages.setdefault(msg, []).append(entry)
a9d8d69b67996254705aac34cd306812abf1c8c6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a9d8d69b67996254705aac34cd306812abf1c8c6/pygettext.py
sys.stderr.write(_("Can't read --exclude-file: %s") % options.excludefilename)
print >> sys.stderr, _( "Can't read --exclude-file: %s") % options.excludefilename
def main(): global default_keywords try: opts, args = getopt.getopt( sys.argv[1:], 'ad:DEhk:Kno:p:S:Vvw:x:', ['extract-all', 'default-domain', 'escape', 'help', 'keyword=', 'no-default-keywords', 'add-location', 'no-location', 'output=', 'output-dir=', 'style=', 'verbose', 'version', 'width=', 'exclude-file=', 'docstrings', ]) except getopt.error, msg: usage(1, msg) # for holding option values class Options: # constants GNU = 1 SOLARIS = 2 # defaults extractall = 0 # FIXME: currently this option has no effect at all. escape = 0 keywords = [] outpath = '' outfile = 'messages.pot' writelocations = 1 locationstyle = GNU verbose = 0 width = 78 excludefilename = '' docstrings = 0 options = Options() locations = {'gnu' : options.GNU, 'solaris' : options.SOLARIS, } # parse options for opt, arg in opts: if opt in ('-h', '--help'): usage(0) elif opt in ('-a', '--extract-all'): options.extractall = 1 elif opt in ('-d', '--default-domain'): options.outfile = arg + '.pot' elif opt in ('-E', '--escape'): options.escape = 1 elif opt in ('-D', '--docstrings'): options.docstrings = 1 elif opt in ('-k', '--keyword'): options.keywords.append(arg) elif opt in ('-K', '--no-default-keywords'): default_keywords = [] elif opt in ('-n', '--add-location'): options.writelocations = 1 elif opt in ('--no-location',): options.writelocations = 0 elif opt in ('-S', '--style'): options.locationstyle = locations.get(arg.lower()) if options.locationstyle is None: usage(1, _('Invalid value for --style: %s') % arg) elif opt in ('-o', '--output'): options.outfile = arg elif opt in ('-p', '--output-dir'): options.outpath = arg elif opt in ('-v', '--verbose'): options.verbose = 1 elif opt in ('-V', '--version'): print _('pygettext.py (xgettext for Python) %s') % __version__ sys.exit(0) elif opt in ('-w', '--width'): try: options.width = int(arg) except ValueError: usage(1, _('--width argument must be an integer: %s') % arg) elif opt in ('-x', '--exclude-file'): options.excludefilename = arg # calculate escapes make_escapes(options.escape) # calculate all keywords options.keywords.extend(default_keywords) # initialize list of strings to exclude if options.excludefilename: try: fp = open(options.excludefilename) options.toexclude = fp.readlines() fp.close() except IOError: sys.stderr.write(_("Can't read --exclude-file: %s") % options.excludefilename) sys.exit(1) else: options.toexclude = [] # slurp through all the files eater = TokenEater(options) for filename in args: if filename == '-': if options.verbose: print _('Reading standard input') fp = sys.stdin closep = 0 else: if options.verbose: print _('Working on %s') % filename fp = open(filename) closep = 1 try: eater.set_filename(filename) try: tokenize.tokenize(fp.readline, eater) except tokenize.TokenError, e: sys.stderr.write('%s: %s, line %d, column %d\n' % (e[0], filename, e[1][0], e[1][1])) finally: if closep: fp.close() # write the output if options.outfile == '-': fp = sys.stdout closep = 0 else: if options.outpath: options.outfile = os.path.join(options.outpath, options.outfile) fp = open(options.outfile, 'w') closep = 1 try: eater.write(fp) finally: if closep: fp.close()
a9d8d69b67996254705aac34cd306812abf1c8c6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a9d8d69b67996254705aac34cd306812abf1c8c6/pygettext.py
sys.stderr.write('%s: %s, line %d, column %d\n' % (e[0], filename, e[1][0], e[1][1]))
print >> sys.stderr, '%s: %s, line %d, column %d' % ( e[0], filename, e[1][0], e[1][1])
def main(): global default_keywords try: opts, args = getopt.getopt( sys.argv[1:], 'ad:DEhk:Kno:p:S:Vvw:x:', ['extract-all', 'default-domain', 'escape', 'help', 'keyword=', 'no-default-keywords', 'add-location', 'no-location', 'output=', 'output-dir=', 'style=', 'verbose', 'version', 'width=', 'exclude-file=', 'docstrings', ]) except getopt.error, msg: usage(1, msg) # for holding option values class Options: # constants GNU = 1 SOLARIS = 2 # defaults extractall = 0 # FIXME: currently this option has no effect at all. escape = 0 keywords = [] outpath = '' outfile = 'messages.pot' writelocations = 1 locationstyle = GNU verbose = 0 width = 78 excludefilename = '' docstrings = 0 options = Options() locations = {'gnu' : options.GNU, 'solaris' : options.SOLARIS, } # parse options for opt, arg in opts: if opt in ('-h', '--help'): usage(0) elif opt in ('-a', '--extract-all'): options.extractall = 1 elif opt in ('-d', '--default-domain'): options.outfile = arg + '.pot' elif opt in ('-E', '--escape'): options.escape = 1 elif opt in ('-D', '--docstrings'): options.docstrings = 1 elif opt in ('-k', '--keyword'): options.keywords.append(arg) elif opt in ('-K', '--no-default-keywords'): default_keywords = [] elif opt in ('-n', '--add-location'): options.writelocations = 1 elif opt in ('--no-location',): options.writelocations = 0 elif opt in ('-S', '--style'): options.locationstyle = locations.get(arg.lower()) if options.locationstyle is None: usage(1, _('Invalid value for --style: %s') % arg) elif opt in ('-o', '--output'): options.outfile = arg elif opt in ('-p', '--output-dir'): options.outpath = arg elif opt in ('-v', '--verbose'): options.verbose = 1 elif opt in ('-V', '--version'): print _('pygettext.py (xgettext for Python) %s') % __version__ sys.exit(0) elif opt in ('-w', '--width'): try: options.width = int(arg) except ValueError: usage(1, _('--width argument must be an integer: %s') % arg) elif opt in ('-x', '--exclude-file'): options.excludefilename = arg # calculate escapes make_escapes(options.escape) # calculate all keywords options.keywords.extend(default_keywords) # initialize list of strings to exclude if options.excludefilename: try: fp = open(options.excludefilename) options.toexclude = fp.readlines() fp.close() except IOError: sys.stderr.write(_("Can't read --exclude-file: %s") % options.excludefilename) sys.exit(1) else: options.toexclude = [] # slurp through all the files eater = TokenEater(options) for filename in args: if filename == '-': if options.verbose: print _('Reading standard input') fp = sys.stdin closep = 0 else: if options.verbose: print _('Working on %s') % filename fp = open(filename) closep = 1 try: eater.set_filename(filename) try: tokenize.tokenize(fp.readline, eater) except tokenize.TokenError, e: sys.stderr.write('%s: %s, line %d, column %d\n' % (e[0], filename, e[1][0], e[1][1])) finally: if closep: fp.close() # write the output if options.outfile == '-': fp = sys.stdout closep = 0 else: if options.outpath: options.outfile = os.path.join(options.outpath, options.outfile) fp = open(options.outfile, 'w') closep = 1 try: eater.write(fp) finally: if closep: fp.close()
a9d8d69b67996254705aac34cd306812abf1c8c6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a9d8d69b67996254705aac34cd306812abf1c8c6/pygettext.py
def _(s): return s
try: import fintl _ = fintl.gettext except ImportError: def _(s): return s
def _(s): return s
b748a44903fd0395aa03a8c8e6f42748f50d37f5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b748a44903fd0395aa03a8c8e6f42748f50d37f5/pygettext.py
for i in range(256): if i < 32 or i > 127: escapes.append("\\%03o" % i) else: escapes.append(chr(i)) escapes[ord('\\')] = '\\\\' escapes[ord('\t')] = '\\t' escapes[ord('\r')] = '\\r' escapes[ord('\n')] = '\\n' escapes[ord('\"')] = '\\"'
def make_escapes(pass_iso8859): global escapes for i in range(256): if pass_iso8859: i = i % 128 if 32 <= i <= 126: escapes.append(chr(i)) else: escapes.append("\\%03o" % i) escapes[ord('\\')] = '\\\\' escapes[ord('\t')] = '\\t' escapes[ord('\r')] = '\\r' escapes[ord('\n')] = '\\n' escapes[ord('\"')] = '\\"'
def usage(code, msg=''): print __doc__ % globals() if msg: print msg sys.exit(code)
b748a44903fd0395aa03a8c8e6f42748f50d37f5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b748a44903fd0395aa03a8c8e6f42748f50d37f5/pygettext.py
entry = (self.__curfile, self.__lineno) linenos = self.__messages.get(msg) if linenos is None: self.__messages[msg] = [entry] else: linenos.append(entry)
if not msg in self.__options.toexclude: entry = (self.__curfile, self.__lineno) linenos = self.__messages.get(msg) if linenos is None: self.__messages[msg] = [entry] else: linenos.append(entry)
def __openseen(self, ttype, tstring, lineno): if ttype == tokenize.OP and tstring == ')': # We've seen the last of the translatable strings. Record the # line number of the first line of the strings and update the list # of messages seen. Reset state for the next batch. If there # were no strings inside _(), then just ignore this entry. if self.__data: msg = string.join(self.__data, '') entry = (self.__curfile, self.__lineno) linenos = self.__messages.get(msg) if linenos is None: self.__messages[msg] = [entry] else: linenos.append(entry) self.__state = self.__waiting elif ttype == tokenize.STRING: self.__data.append(safe_eval(tstring)) # TBD: should we warn if we seen anything else?
b748a44903fd0395aa03a8c8e6f42748f50d37f5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b748a44903fd0395aa03a8c8e6f42748f50d37f5/pygettext.py
print pot_header % {'time': timestamp, 'version':__version__}
print pot_header % {'time': timestamp, 'version': __version__}
def write(self, fp): options = self.__options timestamp = time.ctime(time.time()) # common header try: sys.stdout = fp # The time stamp in the header doesn't have the same format # as that generated by xgettext... print pot_header % {'time': timestamp, 'version':__version__} for k, v in self.__messages.items(): for filename, lineno in v: # location comments are different b/w Solaris and GNU d = {'filename': filename, 'lineno': lineno} if options.location == options.SOLARIS: print _('# File: %(filename)s, line: %(lineno)d') % d elif options.location == options.GNU: print _('#: %(filename)s:%(lineno)d') % d # TBD: sorting, normalizing print 'msgid', normalize(k) print 'msgstr ""' print finally: sys.stdout = sys.__stdout__
b748a44903fd0395aa03a8c8e6f42748f50d37f5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b748a44903fd0395aa03a8c8e6f42748f50d37f5/pygettext.py
for filename, lineno in v: d = {'filename': filename, 'lineno': lineno} if options.location == options.SOLARIS:
if options.location == options.SOLARIS: for filename, lineno in v: d = {'filename': filename, 'lineno': lineno}
def write(self, fp): options = self.__options timestamp = time.ctime(time.time()) # common header try: sys.stdout = fp # The time stamp in the header doesn't have the same format # as that generated by xgettext... print pot_header % {'time': timestamp, 'version':__version__} for k, v in self.__messages.items(): for filename, lineno in v: # location comments are different b/w Solaris and GNU d = {'filename': filename, 'lineno': lineno} if options.location == options.SOLARIS: print _('# File: %(filename)s, line: %(lineno)d') % d elif options.location == options.GNU: print _('#: %(filename)s:%(lineno)d') % d # TBD: sorting, normalizing print 'msgid', normalize(k) print 'msgstr ""' print finally: sys.stdout = sys.__stdout__
b748a44903fd0395aa03a8c8e6f42748f50d37f5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b748a44903fd0395aa03a8c8e6f42748f50d37f5/pygettext.py
elif options.location == options.GNU: print _('
elif options.location == options.GNU: locline = ' for filename, lineno in v: d = {'filename': filename, 'lineno': lineno} s = _(' %(filename)s:%(lineno)d') % d if len(locline) + len(s) <= options.width: locline = locline + s else: print locline locline = " if len(locline) > 2: print locline
def write(self, fp): options = self.__options timestamp = time.ctime(time.time()) # common header try: sys.stdout = fp # The time stamp in the header doesn't have the same format # as that generated by xgettext... print pot_header % {'time': timestamp, 'version':__version__} for k, v in self.__messages.items(): for filename, lineno in v: # location comments are different b/w Solaris and GNU d = {'filename': filename, 'lineno': lineno} if options.location == options.SOLARIS: print _('# File: %(filename)s, line: %(lineno)d') % d elif options.location == options.GNU: print _('#: %(filename)s:%(lineno)d') % d # TBD: sorting, normalizing print 'msgid', normalize(k) print 'msgstr ""' print finally: sys.stdout = sys.__stdout__
b748a44903fd0395aa03a8c8e6f42748f50d37f5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b748a44903fd0395aa03a8c8e6f42748f50d37f5/pygettext.py
print 'msgstr ""' print
print 'msgstr ""\n'
def write(self, fp): options = self.__options timestamp = time.ctime(time.time()) # common header try: sys.stdout = fp # The time stamp in the header doesn't have the same format # as that generated by xgettext... print pot_header % {'time': timestamp, 'version':__version__} for k, v in self.__messages.items(): for filename, lineno in v: # location comments are different b/w Solaris and GNU d = {'filename': filename, 'lineno': lineno} if options.location == options.SOLARIS: print _('# File: %(filename)s, line: %(lineno)d') % d elif options.location == options.GNU: print _('#: %(filename)s:%(lineno)d') % d # TBD: sorting, normalizing print 'msgid', normalize(k) print 'msgstr ""' print finally: sys.stdout = sys.__stdout__
b748a44903fd0395aa03a8c8e6f42748f50d37f5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b748a44903fd0395aa03a8c8e6f42748f50d37f5/pygettext.py
'k:d:n:hv', ['keyword', 'default-domain', 'help', 'add-location=', 'no-location', 'verbose'])
'ad:Ehk:n:o:p:Vvw:x:', ['extract-all', 'default-domain', 'escape', 'help', 'keyword', 'add-location', 'no-location', 'output=', 'output-dir=', 'verbose', 'version', 'width=', 'exclude-file=', ])
def main(): default_keywords = ['_'] try: opts, args = getopt.getopt( sys.argv[1:], 'k:d:n:hv', ['keyword', 'default-domain', 'help', 'add-location=', 'no-location', 'verbose']) except getopt.error, msg: usage(1, msg) # for holding option values class Options: # constants GNU = 1 SOLARIS = 2 # defaults keywords = [] outfile = 'messages.pot' location = GNU verbose = 0 options = Options() locations = {'gnu' : options.GNU, 'solaris' : options.SOLARIS, } # parse options for opt, arg in opts: if opt in ('-h', '--help'): usage(0) elif opt in ('-k', '--keyword'): if arg is None: default_keywords = [] options.keywords.append(arg) elif opt in ('-d', '--default-domain'): options.outfile = arg + '.pot' elif opt in ('-n', '--add-location'): if arg is None: arg = 'gnu' try: options.location = locations[string.lower(arg)] except KeyError: d = {'arg':arg} usage(1, _('Invalid value for --add-location: %(arg)s') % d) elif opt in ('--no-location',): options.location = 0 elif opt in ('-v', '--verbose'): options.verbose = 1 # calculate all keywords options.keywords.extend(default_keywords) # slurp through all the files eater = TokenEater(options) for filename in args: if options.verbose: print _('Working on %(filename)s') % {'filename':filename} fp = open(filename) eater.set_filename(filename) tokenize.tokenize(fp.readline, eater) fp.close() fp = open(options.outfile, 'w') eater.write(fp) fp.close()
b748a44903fd0395aa03a8c8e6f42748f50d37f5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b748a44903fd0395aa03a8c8e6f42748f50d37f5/pygettext.py
elif opt in ('-d', '--default-domain'): options.outfile = arg + '.pot'
def main(): default_keywords = ['_'] try: opts, args = getopt.getopt( sys.argv[1:], 'k:d:n:hv', ['keyword', 'default-domain', 'help', 'add-location=', 'no-location', 'verbose']) except getopt.error, msg: usage(1, msg) # for holding option values class Options: # constants GNU = 1 SOLARIS = 2 # defaults keywords = [] outfile = 'messages.pot' location = GNU verbose = 0 options = Options() locations = {'gnu' : options.GNU, 'solaris' : options.SOLARIS, } # parse options for opt, arg in opts: if opt in ('-h', '--help'): usage(0) elif opt in ('-k', '--keyword'): if arg is None: default_keywords = [] options.keywords.append(arg) elif opt in ('-d', '--default-domain'): options.outfile = arg + '.pot' elif opt in ('-n', '--add-location'): if arg is None: arg = 'gnu' try: options.location = locations[string.lower(arg)] except KeyError: d = {'arg':arg} usage(1, _('Invalid value for --add-location: %(arg)s') % d) elif opt in ('--no-location',): options.location = 0 elif opt in ('-v', '--verbose'): options.verbose = 1 # calculate all keywords options.keywords.extend(default_keywords) # slurp through all the files eater = TokenEater(options) for filename in args: if options.verbose: print _('Working on %(filename)s') % {'filename':filename} fp = open(filename) eater.set_filename(filename) tokenize.tokenize(fp.readline, eater) fp.close() fp = open(options.outfile, 'w') eater.write(fp) fp.close()
b748a44903fd0395aa03a8c8e6f42748f50d37f5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b748a44903fd0395aa03a8c8e6f42748f50d37f5/pygettext.py
def deepcopyrecursive(): if verbose: print "Testing deepcopy of recursive objects..." class Node: pass a = Node() b = Node() a.b = b b.a = a z = deepcopy(a)
def strops(): try: 'a' + 5 except TypeError: pass else: raise TestFailed, "'' + 5 doesn't raise TypeError" try: ''.split('') except ValueError: pass else: raise TestFailed, "''.split('') doesn't raise ValueError" try: ''.join([0]) except TypeError: pass else: raise TestFailed, "''.join([0]) doesn't raise TypeError" try: ''.rindex('5') except ValueError: pass else: raise TestFailed, "''.rindex('5') doesn't raise ValueError" try: ''.replace('', '') except ValueError: pass else: raise TestFailed, "''.replace('', '') doesn't raise ValueError" try: '%(n)s' % None except TypeError: pass else: raise TestFailed, "'%(n)s' % None doesn't raise TypeError" try: '%(n' % {} except ValueError: pass else: raise TestFailed, "'%(n' % {} '' doesn't raise ValueError" try: '%*s' % ('abc') except TypeError: pass else: raise TestFailed, "'%*s' % ('abc') doesn't raise TypeError" try: '%*.*s' % ('abc', 5) except TypeError: pass else: raise TestFailed, "'%*.*s' % ('abc', 5) doesn't raise TypeError" try: '%s' % (1, 2) except TypeError: pass else: raise TestFailed, "'%s' % (1, 2) doesn't raise TypeError" try: '%' % None except ValueError: pass else: raise TestFailed, "'%' % None doesn't raise ValueError" vereq('534253'.isdigit(), 1) vereq('534253x'.isdigit(), 0) vereq('%c' % 5, '\x05') vereq('%c' % '5', '5')
956c39424aee8fac526a33307bb7315425f25817 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/956c39424aee8fac526a33307bb7315425f25817/test_descr.py
effective = (effective / tabwidth + 1) * tabwidth
effective = (int(effective / tabwidth) + 1) * tabwidth
def classifyws(s, tabwidth): raw = effective = 0 for ch in s: if ch == ' ': raw = raw + 1 effective = effective + 1 elif ch == '\t': raw = raw + 1 effective = (effective / tabwidth + 1) * tabwidth else: break return raw, effective
abb8bde536623ba9f3caa44026e3dfd812d79c71 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/abb8bde536623ba9f3caa44026e3dfd812d79c71/AutoIndent.py
"Please save first!")
"The buffer for %s is not saved.\n" % name + "Please save it first!")
def getfilename(self): # Logic to make sure we have a saved filename # XXX Better logic would offer to save! if not self.editwin.get_saved(): self.errorbox("Not saved", "Please save first!") self.editwin.text.focus_set() return filename = self.editwin.io.filename if not filename: self.errorbox("No file name", "This window has no file name") return return filename
d95cc35059608ccfb8afe130c5870b7a437ca828 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d95cc35059608ccfb8afe130c5870b7a437ca828/ScriptBinding.py
self.fail("expected TypeError")
def test_union_update(self): try: self.set |= self.other self.fail("expected TypeError") except TypeError: pass
2521aa2cec6a3f785b321b2d7ad810b04f8aeefd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2521aa2cec6a3f785b321b2d7ad810b04f8aeefd/test_sets.py
try: self.other | self.set self.fail("expected TypeError") except TypeError: pass try: self.set | self.other self.fail("expected TypeError") except TypeError: pass
self.assertRaises(TypeError, lambda: self.set | self.other) self.assertRaises(TypeError, lambda: self.other | self.set)
def test_union(self): try: self.other | self.set self.fail("expected TypeError") except TypeError: pass try: self.set | self.other self.fail("expected TypeError") except TypeError: pass
2521aa2cec6a3f785b321b2d7ad810b04f8aeefd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2521aa2cec6a3f785b321b2d7ad810b04f8aeefd/test_sets.py
self.fail("expected TypeError")
def test_intersection_update(self): try: self.set &= self.other self.fail("expected TypeError") except TypeError: pass
2521aa2cec6a3f785b321b2d7ad810b04f8aeefd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2521aa2cec6a3f785b321b2d7ad810b04f8aeefd/test_sets.py
try: self.other & self.set self.fail("expected TypeError") except TypeError: pass try: self.set & self.other self.fail("expected TypeError") except TypeError: pass
self.assertRaises(TypeError, lambda: self.set & self.other) self.assertRaises(TypeError, lambda: self.other & self.set)
def test_intersection(self): try: self.other & self.set self.fail("expected TypeError") except TypeError: pass try: self.set & self.other self.fail("expected TypeError") except TypeError: pass
2521aa2cec6a3f785b321b2d7ad810b04f8aeefd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2521aa2cec6a3f785b321b2d7ad810b04f8aeefd/test_sets.py
self.fail("expected TypeError")
def test_sym_difference_update(self): try: self.set ^= self.other self.fail("expected TypeError") except TypeError: pass
2521aa2cec6a3f785b321b2d7ad810b04f8aeefd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2521aa2cec6a3f785b321b2d7ad810b04f8aeefd/test_sets.py
try: self.other ^ self.set self.fail("expected TypeError") except TypeError: pass try: self.set ^ self.other self.fail("expected TypeError") except TypeError: pass
self.assertRaises(TypeError, lambda: self.set ^ self.other) self.assertRaises(TypeError, lambda: self.other ^ self.set)
def test_sym_difference(self): try: self.other ^ self.set self.fail("expected TypeError") except TypeError: pass try: self.set ^ self.other self.fail("expected TypeError") except TypeError: pass
2521aa2cec6a3f785b321b2d7ad810b04f8aeefd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2521aa2cec6a3f785b321b2d7ad810b04f8aeefd/test_sets.py
self.fail("expected TypeError")
def test_difference_update(self): try: self.set -= self.other self.fail("expected TypeError") except TypeError: pass
2521aa2cec6a3f785b321b2d7ad810b04f8aeefd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2521aa2cec6a3f785b321b2d7ad810b04f8aeefd/test_sets.py
try: self.other - self.set self.fail("expected TypeError") except TypeError: pass try: self.set - self.other self.fail("expected TypeError") except TypeError: pass
self.assertRaises(TypeError, lambda: self.set - self.other) self.assertRaises(TypeError, lambda: self.other - self.set)
def test_difference(self): try: self.other - self.set self.fail("expected TypeError") except TypeError: pass try: self.set - self.other self.fail("expected TypeError") except TypeError: pass
2521aa2cec6a3f785b321b2d7ad810b04f8aeefd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2521aa2cec6a3f785b321b2d7ad810b04f8aeefd/test_sets.py
if not args: usage('hostname missing') host = args[0]
def main(): global verbose, interactive, mac, rmok, nologin try: opts, args = getopt.getopt(sys.argv[1:], 'a:bil:mnp:qrs:v') except getopt.error, msg: usage(msg) login = '' passwd = '' account = '' for o, a in opts: if o == '-l': login = a if o == '-p': passwd = a if o == '-a': account = a if o == '-v': verbose = verbose + 1 if o == '-q': verbose = 0 if o == '-i': interactive = 1 if o == '-m': mac = 1; nologin = 1; skippats.append('*.o') if o == '-n': nologin = 1 if o == '-r': rmok = 1 if o == '-s': skippats.append(a) if not args: usage('hostname missing') host = args[0] remotedir = '' localdir = '' if args[1:]: remotedir = args[1] if args[2:]: localdir = args[2] if args[3:]: usage('too many arguments') # f = ftplib.FTP() if verbose: print 'Connecting to %s...' % `host` f.connect(host) if not nologin: if verbose: print 'Logging in as %s...' % `login or 'anonymous'` f.login(login, passwd, account) if verbose: print 'OK.' pwd = f.pwd() if verbose > 1: print 'PWD =', `pwd` if remotedir: if verbose > 1: print 'cwd(%s)' % `remotedir` f.cwd(remotedir) if verbose > 1: print 'OK.' pwd = f.pwd() if verbose > 1: print 'PWD =', `pwd` # mirrorsubdir(f, localdir)
54b871f51c1b9d2d2a9a816b7172b868377b7989 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/54b871f51c1b9d2d2a9a816b7172b868377b7989/ftpmirror.py
exts.append( Extension('errno', ['errnomodule.c']) )
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')
beadc82f527ea8617c228e6b4cb98592a9514a77 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/beadc82f527ea8617c228e6b4cb98592a9514a77/setup.py
print set
def __init__(self, set):
b2202eddd973943cab19b3439da4266d52557ad9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b2202eddd973943cab19b3439da4266d52557ad9/re.py
if pattern[index] == 'iI':
if pattern[index] in 'iI':
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].register > 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)
b2202eddd973943cab19b3439da4266d52557ad9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b2202eddd973943cab19b3439da4266d52557ad9/re.py
elif pattern[index] == 'mM':
elif pattern[index] in 'mM':
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].register > 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)
b2202eddd973943cab19b3439da4266d52557ad9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b2202eddd973943cab19b3439da4266d52557ad9/re.py
elif pattern[index] == 'sS':
elif pattern[index] in 'sS':
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].register > 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)
b2202eddd973943cab19b3439da4266d52557ad9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b2202eddd973943cab19b3439da4266d52557ad9/re.py
if err[0] == socket.SSL_ERROR_ZERO_RETURN:
if (err[0] == socket.SSL_ERROR_ZERO_RETURN or err[0] == socket.SSL_ERROR_EOF):
def makefile(self, mode, bufsize=None): """Return a readable file-like object with data from socket.
cd6f7dca2bce97bbaa6dd9d3efd28eb0f4a4399d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/cd6f7dca2bce97bbaa6dd9d3efd28eb0f4a4399d/httplib.py
if sys.platform == 'Darwin1.2':
if platform == 'Darwin1.2':
def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.append('/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.append( '/usr/local/include' )
1fc6b0d7db91d541a72639988978bef873a18f5f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1fc6b0d7db91d541a72639988978bef873a18f5f/setup.py
if (self.compiler.find_library_file(lib_dirs, 'ndbm')): exts.append( Extension('dbm', ['dbmmodule.c'], libraries = ['ndbm'] ) ) else: exts.append( Extension('dbm', ['dbmmodule.c']) )
if platform not in ['cygwin']: if (self.compiler.find_library_file(lib_dirs, 'ndbm')): exts.append( Extension('dbm', ['dbmmodule.c'], libraries = ['ndbm'] ) ) else: exts.append( Extension('dbm', ['dbmmodule.c']) )
def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.append('/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.append( '/usr/local/include' )
1fc6b0d7db91d541a72639988978bef873a18f5f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1fc6b0d7db91d541a72639988978bef873a18f5f/setup.py
if sys.platform not in ['mac', 'win32']:
if platform not in ['mac', 'win32']:
def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.append('/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.append( '/usr/local/include' )
1fc6b0d7db91d541a72639988978bef873a18f5f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1fc6b0d7db91d541a72639988978bef873a18f5f/setup.py
exts.append( Extension('resource', ['resource.c']) )
if platform not in ['cygwin']: exts.append( Extension('resource', ['resource.c']) )
def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.append('/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.append( '/usr/local/include' )
1fc6b0d7db91d541a72639988978bef873a18f5f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1fc6b0d7db91d541a72639988978bef873a18f5f/setup.py
if sys.platform == 'sunos4':
if platform == 'sunos4':
def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.append('/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.append( '/usr/local/include' )
1fc6b0d7db91d541a72639988978bef873a18f5f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1fc6b0d7db91d541a72639988978bef873a18f5f/setup.py
if sys.platform == 'irix5':
if platform == 'irix5':
def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.append('/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.append( '/usr/local/include' )
1fc6b0d7db91d541a72639988978bef873a18f5f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1fc6b0d7db91d541a72639988978bef873a18f5f/setup.py
plat = sys.platform if plat == 'linux2':
if platform == 'linux2':
def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.append('/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.append( '/usr/local/include' )
1fc6b0d7db91d541a72639988978bef873a18f5f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1fc6b0d7db91d541a72639988978bef873a18f5f/setup.py
if plat == 'sunos5':
if platform == 'sunos5':
def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.append('/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.append( '/usr/local/include' )
1fc6b0d7db91d541a72639988978bef873a18f5f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1fc6b0d7db91d541a72639988978bef873a18f5f/setup.py
if sys.platform == 'sunos5':
platform = self.get_platform() if platform == 'sunos5':
def detect_tkinter(self, inc_dirs, lib_dirs): # The _tkinter module. # # The command for _tkinter is long and site specific. Please # uncomment and/or edit those parts as indicated. If you don't have a # specific extension (e.g. Tix or BLT), leave the corresponding line # commented out. (Leave the trailing backslashes in! If you # experience strange errors, you may want to join all uncommented # lines and remove the backslashes -- the backslash interpretation is # done by the shell's "read" command and it may not be implemented on # every system.
1fc6b0d7db91d541a72639988978bef873a18f5f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1fc6b0d7db91d541a72639988978bef873a18f5f/setup.py
if sys.platform in ['aix3', 'aix4']:
if platform in ['aix3', 'aix4']:
def detect_tkinter(self, inc_dirs, lib_dirs): # The _tkinter module. # # The command for _tkinter is long and site specific. Please # uncomment and/or edit those parts as indicated. If you don't have a # specific extension (e.g. Tix or BLT), leave the corresponding line # commented out. (Leave the trailing backslashes in! If you # experience strange errors, you may want to join all uncommented # lines and remove the backslashes -- the backslash interpretation is # done by the shell's "read" command and it may not be implemented on # every system.
1fc6b0d7db91d541a72639988978bef873a18f5f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1fc6b0d7db91d541a72639988978bef873a18f5f/setup.py
self.previous_importer = namespace['__import__'] self.namespace = namespace
def install(self, namespace=vars(__builtin__)): "Install this ImportManager into the specified namespace."
497cbb445621297b48535033c85648fc81d4a16b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/497cbb445621297b48535033c85648fc81d4a16b/imputil.py