rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
_platform_cache = platform
_platform_cache[bool(terse)] = platform
def platform(aliased=0, terse=0): """ Returns a single string identifying the underlying platform with as much useful information as possible (but no more :). The output is intended to be human readable rather than machine parseable. It may look different on different platforms and this is intended. If "aliased" is true, the function will use aliases for various platforms that report system names which differ from their common names, e.g. SunOS will be reported as Solaris. The system_alias() function is used to implement this. Setting terse to true causes the function to return only the absolute minimum information needed to identify the platform. """ global _platform_cache,_platform_aliased_cache if not aliased and (_platform_cache is not None): return _platform_cache elif _platform_aliased_cache is not None: return _platform_aliased_cache # Get uname information and then apply platform specific cosmetics # to it... system,node,release,version,machine,processor = uname() if machine == processor: processor = '' if aliased: system,release,version = system_alias(system,release,version) if system == 'Windows': # MS platforms rel,vers,csd,ptype = win32_ver(version) if terse: platform = _platform(system,release) else: platform = _platform(system,release,version,csd) elif system in ('Linux',): # Linux based systems distname,distversion,distid = dist('') if distname and not terse: platform = _platform(system,release,machine,processor, 'with', distname,distversion,distid) else: # If the distribution name is unknown check for libc vs. glibc libcname,libcversion = libc_ver(sys.executable) platform = _platform(system,release,machine,processor, 'with', libcname+libcversion) elif system == 'Java': # Java platforms r,v,vminfo,(os_name,os_version,os_arch) = java_ver() if terse: platform = _platform(system,release,version) else: platform = _platform(system,release,version, 'on', os_name,os_version,os_arch) elif system == 'MacOS': # MacOS platforms if terse: platform = _platform(system,release) else: platform = _platform(system,release,machine) else: # Generic handler if terse: platform = _platform(system,release) else: bits,linkage = architecture(sys.executable) platform = _platform(system,release,machine,processor,bits,linkage) if aliased: _platform_aliased_cache = platform elif terse: pass else: _platform_cache = platform return platform
21beb4c2ceb5238a6a3ab83156db55f678ed01ec /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/21beb4c2ceb5238a6a3ab83156db55f678ed01ec/platform.py
e.append(fd) if obj.readable():
is_r = obj.readable() is_w = obj.writable() if is_r:
def poll(timeout=0.0, map=None): if map is None: map = socket_map if map: r = []; w = []; e = [] for fd, obj in map.items(): e.append(fd) if obj.readable(): r.append(fd) if obj.writable(): w.append(fd) if [] == r == w == e: time.sleep(timeout) else: try: r, w, e = select.select(r, w, e, timeout) except select.error, err: if err[0] != EINTR: raise else: return for fd in r: obj = map.get(fd) if obj is None: continue read(obj) for fd in w: obj = map.get(fd) if obj is None: continue write(obj) for fd in e: obj = map.get(fd) if obj is None: continue _exception(obj)
e47c381c62091d5d8583438b70632eecb96ad29e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e47c381c62091d5d8583438b70632eecb96ad29e/asyncore.py
if obj.writable():
if is_w:
def poll(timeout=0.0, map=None): if map is None: map = socket_map if map: r = []; w = []; e = [] for fd, obj in map.items(): e.append(fd) if obj.readable(): r.append(fd) if obj.writable(): w.append(fd) if [] == r == w == e: time.sleep(timeout) else: try: r, w, e = select.select(r, w, e, timeout) except select.error, err: if err[0] != EINTR: raise else: return for fd in r: obj = map.get(fd) if obj is None: continue read(obj) for fd in w: obj = map.get(fd) if obj is None: continue write(obj) for fd in e: obj = map.get(fd) if obj is None: continue _exception(obj)
e47c381c62091d5d8583438b70632eecb96ad29e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e47c381c62091d5d8583438b70632eecb96ad29e/asyncore.py
flags = select.POLLERR | select.POLLHUP | select.POLLNVAL
flags = 0
def poll2(timeout=0.0, map=None): # Use the poll() support added to the select module in Python 2.0 if map is None: map = socket_map if timeout is not None: # timeout is in milliseconds timeout = int(timeout*1000) pollster = select.poll() if map: for fd, obj in map.items(): flags = select.POLLERR | select.POLLHUP | select.POLLNVAL if obj.readable(): flags |= select.POLLIN | select.POLLPRI if obj.writable(): flags |= select.POLLOUT if flags: pollster.register(fd, flags) try: r = pollster.poll(timeout) except select.error, err: if err[0] != EINTR: raise r = [] for fd, flags in r: obj = map.get(fd) if obj is None: continue readwrite(obj, flags)
e47c381c62091d5d8583438b70632eecb96ad29e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e47c381c62091d5d8583438b70632eecb96ad29e/asyncore.py
1 <= len(macros) <= 2):
1 <= len(macro) <= 2):
def check_extensions_list (self, extensions): """Ensure that the list of extensions (presumably provided as a command option 'extensions') is valid, i.e. it is a list of Extension objects. We also support the old-style list of 2-tuples, where the tuples are (ext_name, build_info), which are converted to Extension instances here.
53c1bc3f9bf4d83f01e5dc8c228379ae525a2cbb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/53c1bc3f9bf4d83f01e5dc8c228379ae525a2cbb/build_ext.py
if value < 0: value = value + 0x100000000L
def write32u(output, value): if value < 0: value = value + 0x100000000L output.write(struct.pack("<L", value))
fb0ea525d528153838586bf8ece15a45bbf5ddf3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fb0ea525d528153838586bf8ece15a45bbf5ddf3/gzip.py
xlen=ord(self.fileobj.read(1)) xlen=xlen+256*ord(self.fileobj.read(1))
xlen = ord(self.fileobj.read(1)) xlen = xlen + 256*ord(self.fileobj.read(1))
def _read_gzip_header(self): magic = self.fileobj.read(2) if magic != '\037\213': raise IOError, 'Not a gzipped file' method = ord( self.fileobj.read(1) ) if method != 8: raise IOError, 'Unknown compression method' flag = ord( self.fileobj.read(1) ) # modtime = self.fileobj.read(4) # extraflag = self.fileobj.read(1) # os = self.fileobj.read(1) self.fileobj.read(6)
fb0ea525d528153838586bf8ece15a45bbf5ddf3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fb0ea525d528153838586bf8ece15a45bbf5ddf3/gzip.py
s=self.fileobj.read(1) if not s or s=='\000': break
s = self.fileobj.read(1) if not s or s=='\000': break
def _read_gzip_header(self): magic = self.fileobj.read(2) if magic != '\037\213': raise IOError, 'Not a gzipped file' method = ord( self.fileobj.read(1) ) if method != 8: raise IOError, 'Unknown compression method' flag = ord( self.fileobj.read(1) ) # modtime = self.fileobj.read(4) # extraflag = self.fileobj.read(1) # os = self.fileobj.read(1) self.fileobj.read(6)
fb0ea525d528153838586bf8ece15a45bbf5ddf3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fb0ea525d528153838586bf8ece15a45bbf5ddf3/gzip.py
s=self.fileobj.read(1) if not s or s=='\000': break
s = self.fileobj.read(1) if not s or s=='\000': break
def _read_gzip_header(self): magic = self.fileobj.read(2) if magic != '\037\213': raise IOError, 'Not a gzipped file' method = ord( self.fileobj.read(1) ) if method != 8: raise IOError, 'Unknown compression method' flag = ord( self.fileobj.read(1) ) # modtime = self.fileobj.read(4) # extraflag = self.fileobj.read(1) # os = self.fileobj.read(1) self.fileobj.read(6)
fb0ea525d528153838586bf8ece15a45bbf5ddf3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fb0ea525d528153838586bf8ece15a45bbf5ddf3/gzip.py
if self.fileobj is None: raise EOFError, "Reached EOF"
if self.fileobj is None: raise EOFError, "Reached EOF"
def _read(self, size=1024): if self.fileobj is None: raise EOFError, "Reached EOF"
fb0ea525d528153838586bf8ece15a45bbf5ddf3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fb0ea525d528153838586bf8ece15a45bbf5ddf3/gzip.py
isize = read32(self.fileobj) if crc32%0x100000000L != self.crc%0x100000000L:
isize = U32(read32(self.fileobj)) if U32(crc32) != U32(self.crc):
def _read_eof(self): # We've read to the end of the file, so we have to rewind in order # to reread the 8 bytes containing the CRC and the file size. # We check the that the computed CRC and size of the # uncompressed data matches the stored values. self.fileobj.seek(-8, 1) crc32 = read32(self.fileobj) isize = read32(self.fileobj) if crc32%0x100000000L != self.crc%0x100000000L: raise ValueError, "CRC check failed" elif isize != self.size: raise ValueError, "Incorrect length of data produced"
fb0ea525d528153838586bf8ece15a45bbf5ddf3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fb0ea525d528153838586bf8ece15a45bbf5ddf3/gzip.py
write32(self.fileobj, self.size)
write32u(self.fileobj, self.size)
def close(self): if self.mode == WRITE: self.fileobj.write(self.compress.flush()) write32(self.fileobj, self.crc) write32(self.fileobj, self.size) self.fileobj = None elif self.mode == READ: self.fileobj = None if self.myfileobj: self.myfileobj.close() self.myfileobj = None
fb0ea525d528153838586bf8ece15a45bbf5ddf3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fb0ea525d528153838586bf8ece15a45bbf5ddf3/gzip.py
for i in range(count/1024): self.write(1024*'\0') self.write((count%1024)*'\0')
for i in range(count // 1024): self.write(1024 * '\0') self.write((count % 1024) * '\0')
def seek(self, offset): if self.mode == WRITE: if offset < self.offset: raise IOError('Negative seek in write mode') count = offset - self.offset for i in range(count/1024): self.write(1024*'\0') self.write((count%1024)*'\0') elif self.mode == READ: if offset < self.offset: # for negative seek, rewind and do positive seek self.rewind() count = offset - self.offset for i in range(count/1024): self.read(1024) self.read(count % 1024)
fb0ea525d528153838586bf8ece15a45bbf5ddf3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fb0ea525d528153838586bf8ece15a45bbf5ddf3/gzip.py
for i in range(count/1024): self.read(1024)
for i in range(count // 1024): self.read(1024)
def seek(self, offset): if self.mode == WRITE: if offset < self.offset: raise IOError('Negative seek in write mode') count = offset - self.offset for i in range(count/1024): self.write(1024*'\0') self.write((count%1024)*'\0') elif self.mode == READ: if offset < self.offset: # for negative seek, rewind and do positive seek self.rewind() count = offset - self.offset for i in range(count/1024): self.read(1024) self.read(count % 1024)
fb0ea525d528153838586bf8ece15a45bbf5ddf3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fb0ea525d528153838586bf8ece15a45bbf5ddf3/gzip.py
if sizehint <= 0: sizehint = sys.maxint
if sizehint <= 0: sizehint = sys.maxint
def readlines(self, sizehint=0): # Negative numbers result in reading all the lines if sizehint <= 0: sizehint = sys.maxint L = [] while sizehint > 0: line = self.readline() if line == "": break L.append(line) sizehint = sizehint - len(line)
fb0ea525d528153838586bf8ece15a45bbf5ddf3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fb0ea525d528153838586bf8ece15a45bbf5ddf3/gzip.py
if line == "": break
if line == "": break
def readlines(self, sizehint=0): # Negative numbers result in reading all the lines if sizehint <= 0: sizehint = sys.maxint L = [] while sizehint > 0: line = self.readline() if line == "": break L.append(line) sizehint = sizehint - len(line)
fb0ea525d528153838586bf8ece15a45bbf5ddf3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fb0ea525d528153838586bf8ece15a45bbf5ddf3/gzip.py
path = module.__path__
try: path = module.__path__ except AttributeError: raise ImportError, 'No source for module ' + module.__name__
def _find_module(fullname, path=None): """Version of imp.find_module() that handles hierarchical module names""" file = None for tgt in fullname.split('.'): if file is not None: file.close() # close intermediate files (file, filename, descr) = imp.find_module(tgt, path) if descr[2] == imp.PY_SOURCE: break # find but not load the source file module = imp.load_module(tgt, file, filename, descr) path = module.__path__ return file, filename, descr
69e8afcc9fcd8a41a1035893d60893d51fae62f1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/69e8afcc9fcd8a41a1035893d60893d51fae62f1/EditorWindow.py
print (garbage, path)
def retrieve(self, url, filename=None): url = unwrap(url) if self.tempcache and self.tempcache.has_key(url): return self.tempcache[url] type, url1 = splittype(url) if not filename and (not type or type == 'file'): try: fp = self.open_local_file(url1) hdrs = fp.info() del fp return url2pathname(splithost(url1)[1]), hdrs except IOError, msg: pass fp = self.open(url) headers = fp.info() if not filename: import tempfile garbage, path = splittype(url) print (garbage, path) garbage, path = splithost(path or "") print (garbage, path) path, garbage = splitquery(path or "") print (path, garbage) path, garbage = splitattr(path or "") print (path, garbage) suffix = os.path.splitext(path)[1] filename = tempfile.mktemp(suffix) self.__tempfiles.append(filename) result = filename, headers if self.tempcache is not None: self.tempcache[url] = result tfp = open(filename, 'wb') bs = 1024*8 block = fp.read(bs) while block: tfp.write(block) block = fp.read(bs) fp.close() tfp.close() del fp del tfp return result
c74521acc4d3d08fe557a8ac835c1f827d107e7c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c74521acc4d3d08fe557a8ac835c1f827d107e7c/urllib.py
print (garbage, path)
def retrieve(self, url, filename=None): url = unwrap(url) if self.tempcache and self.tempcache.has_key(url): return self.tempcache[url] type, url1 = splittype(url) if not filename and (not type or type == 'file'): try: fp = self.open_local_file(url1) hdrs = fp.info() del fp return url2pathname(splithost(url1)[1]), hdrs except IOError, msg: pass fp = self.open(url) headers = fp.info() if not filename: import tempfile garbage, path = splittype(url) print (garbage, path) garbage, path = splithost(path or "") print (garbage, path) path, garbage = splitquery(path or "") print (path, garbage) path, garbage = splitattr(path or "") print (path, garbage) suffix = os.path.splitext(path)[1] filename = tempfile.mktemp(suffix) self.__tempfiles.append(filename) result = filename, headers if self.tempcache is not None: self.tempcache[url] = result tfp = open(filename, 'wb') bs = 1024*8 block = fp.read(bs) while block: tfp.write(block) block = fp.read(bs) fp.close() tfp.close() del fp del tfp return result
c74521acc4d3d08fe557a8ac835c1f827d107e7c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c74521acc4d3d08fe557a8ac835c1f827d107e7c/urllib.py
print (path, garbage)
def retrieve(self, url, filename=None): url = unwrap(url) if self.tempcache and self.tempcache.has_key(url): return self.tempcache[url] type, url1 = splittype(url) if not filename and (not type or type == 'file'): try: fp = self.open_local_file(url1) hdrs = fp.info() del fp return url2pathname(splithost(url1)[1]), hdrs except IOError, msg: pass fp = self.open(url) headers = fp.info() if not filename: import tempfile garbage, path = splittype(url) print (garbage, path) garbage, path = splithost(path or "") print (garbage, path) path, garbage = splitquery(path or "") print (path, garbage) path, garbage = splitattr(path or "") print (path, garbage) suffix = os.path.splitext(path)[1] filename = tempfile.mktemp(suffix) self.__tempfiles.append(filename) result = filename, headers if self.tempcache is not None: self.tempcache[url] = result tfp = open(filename, 'wb') bs = 1024*8 block = fp.read(bs) while block: tfp.write(block) block = fp.read(bs) fp.close() tfp.close() del fp del tfp return result
c74521acc4d3d08fe557a8ac835c1f827d107e7c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c74521acc4d3d08fe557a8ac835c1f827d107e7c/urllib.py
print (path, garbage)
def retrieve(self, url, filename=None): url = unwrap(url) if self.tempcache and self.tempcache.has_key(url): return self.tempcache[url] type, url1 = splittype(url) if not filename and (not type or type == 'file'): try: fp = self.open_local_file(url1) hdrs = fp.info() del fp return url2pathname(splithost(url1)[1]), hdrs except IOError, msg: pass fp = self.open(url) headers = fp.info() if not filename: import tempfile garbage, path = splittype(url) print (garbage, path) garbage, path = splithost(path or "") print (garbage, path) path, garbage = splitquery(path or "") print (path, garbage) path, garbage = splitattr(path or "") print (path, garbage) suffix = os.path.splitext(path)[1] filename = tempfile.mktemp(suffix) self.__tempfiles.append(filename) result = filename, headers if self.tempcache is not None: self.tempcache[url] = result tfp = open(filename, 'wb') bs = 1024*8 block = fp.read(bs) while block: tfp.write(block) block = fp.read(bs) fp.close() tfp.close() del fp del tfp return result
c74521acc4d3d08fe557a8ac835c1f827d107e7c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c74521acc4d3d08fe557a8ac835c1f827d107e7c/urllib.py
if string.lower(filename[-3:]) == '.py' and os.path.exists(filename):
for suffix, mode, kind in imp.get_suffixes(): if 'b' in mode and string.lower(filename[-len(suffix):]) == suffix: return None if os.path.exists(filename):
def getsourcefile(object): """Return the Python source file an object was defined in, if it exists.""" filename = getfile(object) if string.lower(filename[-4:]) in ['.pyc', '.pyo']: filename = filename[:-4] + '.py' if string.lower(filename[-3:]) == '.py' and os.path.exists(filename): return filename
4eb0c003f8cd892800aa425fbde02ca9ecc76f34 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4eb0c003f8cd892800aa425fbde02ca9ecc76f34/inspect.py
"""Return an absolute path to the source file or compiled file for an object. The idea is for each object to have a unique origin, so this routine normalizes the result as much as possible.""" return os.path.normcase(os.path.abspath(getsourcefile(object) or getfile(object)))
"""Return an absolute path to the source or compiled file for an object. The idea is for each object to have a unique origin, so this routine normalizes the result as much as possible.""" return os.path.normcase( os.path.abspath(getsourcefile(object) or getfile(object)))
def getabsfile(object): """Return an absolute path to the source file or compiled file for an object. The idea is for each object to have a unique origin, so this routine normalizes the result as much as possible.""" return os.path.normcase(os.path.abspath(getsourcefile(object) or getfile(object)))
4eb0c003f8cd892800aa425fbde02ca9ecc76f34 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4eb0c003f8cd892800aa425fbde02ca9ecc76f34/inspect.py
"""Try to guess which module an object was defined in."""
"""Return the module an object was defined in, or None if not found."""
def getmodule(object): """Try to guess which module an object was defined in.""" if isclass(object): return sys.modules.get(object.__module__) try: file = getabsfile(object) except TypeError: return None if modulesbyfile.has_key(file): return sys.modules[modulesbyfile[file]] for module in sys.modules.values(): if hasattr(module, '__file__'): modulesbyfile[getabsfile(module)] = module.__name__ if modulesbyfile.has_key(file): return sys.modules[modulesbyfile[file]] main = sys.modules['__main__'] try: mainobject = getattr(main, object.__name__) if mainobject is object: return main except AttributeError: pass builtin = sys.modules['__builtin__'] try: builtinobject = getattr(builtin, object.__name__) if builtinobject is object: return builtin except AttributeError: pass
4eb0c003f8cd892800aa425fbde02ca9ecc76f34 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4eb0c003f8cd892800aa425fbde02ca9ecc76f34/inspect.py
try:
if hasattr(main, object.__name__):
def getmodule(object): """Try to guess which module an object was defined in.""" if isclass(object): return sys.modules.get(object.__module__) try: file = getabsfile(object) except TypeError: return None if modulesbyfile.has_key(file): return sys.modules[modulesbyfile[file]] for module in sys.modules.values(): if hasattr(module, '__file__'): modulesbyfile[getabsfile(module)] = module.__name__ if modulesbyfile.has_key(file): return sys.modules[modulesbyfile[file]] main = sys.modules['__main__'] try: mainobject = getattr(main, object.__name__) if mainobject is object: return main except AttributeError: pass builtin = sys.modules['__builtin__'] try: builtinobject = getattr(builtin, object.__name__) if builtinobject is object: return builtin except AttributeError: pass
4eb0c003f8cd892800aa425fbde02ca9ecc76f34 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4eb0c003f8cd892800aa425fbde02ca9ecc76f34/inspect.py
if mainobject is object: return main except AttributeError: pass
if mainobject is object: return main
def getmodule(object): """Try to guess which module an object was defined in.""" if isclass(object): return sys.modules.get(object.__module__) try: file = getabsfile(object) except TypeError: return None if modulesbyfile.has_key(file): return sys.modules[modulesbyfile[file]] for module in sys.modules.values(): if hasattr(module, '__file__'): modulesbyfile[getabsfile(module)] = module.__name__ if modulesbyfile.has_key(file): return sys.modules[modulesbyfile[file]] main = sys.modules['__main__'] try: mainobject = getattr(main, object.__name__) if mainobject is object: return main except AttributeError: pass builtin = sys.modules['__builtin__'] try: builtinobject = getattr(builtin, object.__name__) if builtinobject is object: return builtin except AttributeError: pass
4eb0c003f8cd892800aa425fbde02ca9ecc76f34 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4eb0c003f8cd892800aa425fbde02ca9ecc76f34/inspect.py
try:
if hasattr(builtin, object.__name__):
def getmodule(object): """Try to guess which module an object was defined in.""" if isclass(object): return sys.modules.get(object.__module__) try: file = getabsfile(object) except TypeError: return None if modulesbyfile.has_key(file): return sys.modules[modulesbyfile[file]] for module in sys.modules.values(): if hasattr(module, '__file__'): modulesbyfile[getabsfile(module)] = module.__name__ if modulesbyfile.has_key(file): return sys.modules[modulesbyfile[file]] main = sys.modules['__main__'] try: mainobject = getattr(main, object.__name__) if mainobject is object: return main except AttributeError: pass builtin = sys.modules['__builtin__'] try: builtinobject = getattr(builtin, object.__name__) if builtinobject is object: return builtin except AttributeError: pass
4eb0c003f8cd892800aa425fbde02ca9ecc76f34 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4eb0c003f8cd892800aa425fbde02ca9ecc76f34/inspect.py
if builtinobject is object: return builtin except AttributeError: pass
if builtinobject is object: return builtin
def getmodule(object): """Try to guess which module an object was defined in.""" if isclass(object): return sys.modules.get(object.__module__) try: file = getabsfile(object) except TypeError: return None if modulesbyfile.has_key(file): return sys.modules[modulesbyfile[file]] for module in sys.modules.values(): if hasattr(module, '__file__'): modulesbyfile[getabsfile(module)] = module.__name__ if modulesbyfile.has_key(file): return sys.modules[modulesbyfile[file]] main = sys.modules['__main__'] try: mainobject = getattr(main, object.__name__) if mainobject is object: return main except AttributeError: pass builtin = sys.modules['__builtin__'] try: builtinobject = getattr(builtin, object.__name__) if builtinobject is object: return builtin except AttributeError: pass
4eb0c003f8cd892800aa425fbde02ca9ecc76f34 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4eb0c003f8cd892800aa425fbde02ca9ecc76f34/inspect.py
lines = file.readlines() file.close()
def findsource(object): """Return the entire source file and starting line number for an object. The argument may be a module, class, method, function, traceback, frame, or code object. The source code is returned as a list of all the lines in the file and the line number indexes a line in that list. An IOError is raised if the source code cannot be retrieved.""" try: file = open(getsourcefile(object)) lines = file.readlines() file.close() except (TypeError, IOError): raise IOError, 'could not get source code' if ismodule(object): return lines, 0 if isclass(object): name = object.__name__ matches = (['class', name], ['class', name + ':']) for i in range(len(lines)): if string.split(lines[i])[:2] in matches: return lines, i else: raise IOError, 'could not find class definition' if ismethod(object): object = object.im_func if isfunction(object): object = object.func_code if istraceback(object): object = object.tb_frame if isframe(object): object = object.f_code if iscode(object): try: lnum = object.co_firstlineno - 1 except AttributeError: raise IOError, 'could not find function definition' else: while lnum > 0: if string.split(lines[lnum])[:1] == ['def']: break lnum = lnum - 1 return lines, lnum
4eb0c003f8cd892800aa425fbde02ca9ecc76f34 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4eb0c003f8cd892800aa425fbde02ca9ecc76f34/inspect.py
try: lnum = object.co_firstlineno - 1 except AttributeError:
if not hasattr(object, 'co_firstlineno'):
def findsource(object): """Return the entire source file and starting line number for an object. The argument may be a module, class, method, function, traceback, frame, or code object. The source code is returned as a list of all the lines in the file and the line number indexes a line in that list. An IOError is raised if the source code cannot be retrieved.""" try: file = open(getsourcefile(object)) lines = file.readlines() file.close() except (TypeError, IOError): raise IOError, 'could not get source code' if ismodule(object): return lines, 0 if isclass(object): name = object.__name__ matches = (['class', name], ['class', name + ':']) for i in range(len(lines)): if string.split(lines[i])[:2] in matches: return lines, i else: raise IOError, 'could not find class definition' if ismethod(object): object = object.im_func if isfunction(object): object = object.func_code if istraceback(object): object = object.tb_frame if isframe(object): object = object.f_code if iscode(object): try: lnum = object.co_firstlineno - 1 except AttributeError: raise IOError, 'could not find function definition' else: while lnum > 0: if string.split(lines[lnum])[:1] == ['def']: break lnum = lnum - 1 return lines, lnum
4eb0c003f8cd892800aa425fbde02ca9ecc76f34 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4eb0c003f8cd892800aa425fbde02ca9ecc76f34/inspect.py
else: while lnum > 0: if string.split(lines[lnum])[:1] == ['def']: break lnum = lnum - 1 return lines, lnum
lnum = object.co_firstlineno - 1 while lnum > 0: if string.split(lines[lnum])[:1] == ['def']: break lnum = lnum - 1 return lines, lnum
def findsource(object): """Return the entire source file and starting line number for an object. The argument may be a module, class, method, function, traceback, frame, or code object. The source code is returned as a list of all the lines in the file and the line number indexes a line in that list. An IOError is raised if the source code cannot be retrieved.""" try: file = open(getsourcefile(object)) lines = file.readlines() file.close() except (TypeError, IOError): raise IOError, 'could not get source code' if ismodule(object): return lines, 0 if isclass(object): name = object.__name__ matches = (['class', name], ['class', name + ':']) for i in range(len(lines)): if string.split(lines[i])[:2] in matches: return lines, i else: raise IOError, 'could not find class definition' if ismethod(object): object = object.im_func if isfunction(object): object = object.func_code if istraceback(object): object = object.tb_frame if isframe(object): object = object.f_code if iscode(object): try: lnum = object.co_firstlineno - 1 except AttributeError: raise IOError, 'could not find function definition' else: while lnum > 0: if string.split(lines[lnum])[:1] == ['def']: break lnum = lnum - 1 return lines, lnum
4eb0c003f8cd892800aa425fbde02ca9ecc76f34 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4eb0c003f8cd892800aa425fbde02ca9ecc76f34/inspect.py
except: return None
except IOError: return None
def getcomments(object): """Get lines of comments immediately preceding an object's source code.""" try: lines, lnum = findsource(object) except: return None if ismodule(object): # Look for a comment block at the top of the file. start = 0 if lines[0][:2] == '#!': start = 1 while start < len(lines) and string.strip(lines[start]) in ['', '#']: start = start + 1 if lines[start][:1] == '#': comments = [] end = start while end < len(lines) and lines[end][:1] == '#': comments.append(string.expandtabs(lines[end])) end = end + 1 return string.join(comments, '') # Look for a preceding block of comments at the same indentation. elif lnum > 0: indent = indentsize(lines[lnum]) end = lnum - 1 if end >= 0 and string.lstrip(lines[end])[:1] == '#' and \ indentsize(lines[end]) == indent: comments = [string.lstrip(string.expandtabs(lines[end]))] if end > 0: end = end - 1 comment = string.lstrip(string.expandtabs(lines[end])) while comment[:1] == '#' and indentsize(lines[end]) == indent: comments[:0] = [comment] end = end - 1 if end < 0: break comment = string.lstrip(string.expandtabs(lines[end])) while comments and string.strip(comments[0]) == '#': comments[:1] = [] while comments and string.strip(comments[-1]) == '#': comments[-1:] = [] return string.join(comments, '')
4eb0c003f8cd892800aa425fbde02ca9ecc76f34 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4eb0c003f8cd892800aa425fbde02ca9ecc76f34/inspect.py
except IOError: lines = index = None
def getframeinfo(frame, context=1): """Get information about a frame or traceback object. A tuple of five things is returned: the filename, the line number of the current line, the function name, a list of lines of context from the source code, and the index of the current line within that list. The optional second argument specifies the number of lines of context to return, which are centered around the current line.""" if istraceback(frame): frame = frame.tb_frame if not isframe(frame): raise TypeError, 'arg is not a frame or traceback object' filename = getsourcefile(frame) lineno = getlineno(frame) if context > 0: start = lineno - 1 - context/2 try: lines, lnum = findsource(frame) start = max(start, 1) start = min(start, len(lines) - context) lines = lines[start:start+context] index = lineno - 1 - start except IOError: lines = index = None else: lines = index = None return (filename, lineno, frame.f_code.co_name, lines, index)
4eb0c003f8cd892800aa425fbde02ca9ecc76f34 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4eb0c003f8cd892800aa425fbde02ca9ecc76f34/inspect.py
for stack in self.rows + self.suits:
for stack in self.openstacks:
def closeststack(self, card):
a0dc1c4a613f11e1b6e20fa25658823533ca201b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a0dc1c4a613f11e1b6e20fa25658823533ca201b/solitaire.py
for stack in [self.opendeck] + self.suits + self.rows:
for stack in self.openstacks:
def reset(self):
a0dc1c4a613f11e1b6e20fa25658823533ca201b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a0dc1c4a613f11e1b6e20fa25658823533ca201b/solitaire.py
ssl = socket.ssl(sock, self.key_file, self.cert_file)
realsock = sock if hasattr(sock, "_sock"): realsock = sock._sock ssl = socket.ssl(realsock, self.key_file, self.cert_file)
def connect(self): "Connect to a host on a given (SSL) port."
0aee7220db3354ef32b5d1ac92f2c5942bb8eaf8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0aee7220db3354ef32b5d1ac92f2c5942bb8eaf8/httplib.py
def test_main(): # Historically, these tests have sloppy about removing TESTFN. So get # rid of it no matter what. try: run_unittest(AutoFileTests, OtherFileTests) finally: if os.path.exists(TESTFN): os.unlink(TESTFN)
c9778a8951110e9781f51a10882397b1647a609e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c9778a8951110e9781f51a10882397b1647a609e/test_file.py
dir = os.path.join(self.root, dir[1:])
dir = change_root(self.root, dir)
def run (self): self.mkpath(self.install_dir) for f in self.data_files: if type(f) == StringType: # its a simple file, so copy it self.copy_file(f, self.install_dir) else: # its a tuple with path to install to and a list of files dir = f[0] if not os.path.isabs(dir): dir = os.path.join(self.install_dir, dir) elif self.root: dir = os.path.join(self.root, dir[1:]) self.mkpath(dir) for data in f[1]: self.copy_file(data, dir)
101de379070c3a7700a9f57bd6d24cab55f7848a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/101de379070c3a7700a9f57bd6d24cab55f7848a/install_data.py
return s[:1] == '/'
return s.startswith('/')
def isabs(s): """Test whether a path is absolute""" return s[:1] == '/'
77cdeaff556447a980fe8632e8cd010499ade2d0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/77cdeaff556447a980fe8632e8cd010499ade2d0/posixpath.py
if b[:1] == '/':
if b.startswith('/'):
def join(a, *p): """Join two or more pathname components, inserting '/' as needed""" path = a for b in p: if b[:1] == '/': path = b elif path == '' or path[-1:] == '/': path = path + b else: path = path + '/' + b return path
77cdeaff556447a980fe8632e8cd010499ade2d0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/77cdeaff556447a980fe8632e8cd010499ade2d0/posixpath.py
elif path == '' or path[-1:] == '/': path = path + b
elif path == '' or path.endswith('/'): path += b
def join(a, *p): """Join two or more pathname components, inserting '/' as needed""" path = a for b in p: if b[:1] == '/': path = b elif path == '' or path[-1:] == '/': path = path + b else: path = path + '/' + b return path
77cdeaff556447a980fe8632e8cd010499ade2d0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/77cdeaff556447a980fe8632e8cd010499ade2d0/posixpath.py
path = path + '/' + b
path += '/' + b
def join(a, *p): """Join two or more pathname components, inserting '/' as needed""" path = a for b in p: if b[:1] == '/': path = b elif path == '' or path[-1:] == '/': path = path + b else: path = path + '/' + b return path
77cdeaff556447a980fe8632e8cd010499ade2d0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/77cdeaff556447a980fe8632e8cd010499ade2d0/posixpath.py
while head[-1] == '/': head = head[:-1]
head = head.rstrip('/')
def split(p): """Split a pathname. Returns tuple "(head, tail)" where "tail" is everything after the final slash. Either part may be empty.""" i = p.rfind('/') + 1 head, tail = p[:i], p[i:] if head and head != '/'*len(head): while head[-1] == '/': head = head[:-1] return head, tail
77cdeaff556447a980fe8632e8cd010499ade2d0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/77cdeaff556447a980fe8632e8cd010499ade2d0/posixpath.py
if i == 0: return ''
if i == 0: return ''
def commonprefix(m): "Given a list of pathnames, returns the longest common leading component" if not m: return '' prefix = m[0] for item in m: for i in range(len(prefix)): if prefix[:i+1] != item[:i+1]: prefix = prefix[:i] if i == 0: return '' break return prefix
77cdeaff556447a980fe8632e8cd010499ade2d0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/77cdeaff556447a980fe8632e8cd010499ade2d0/posixpath.py
if path[:1] != '~':
if not path.startswith('~'):
def expanduser(path): """Expand ~ and ~user constructions. If user or $HOME is unknown, do nothing.""" if path[:1] != '~': return path i, n = 1, len(path) while i < n and path[i] != '/': i = i + 1 if i == 1: if not 'HOME' in os.environ: import pwd userhome = pwd.getpwuid(os.getuid())[5] else: userhome = os.environ['HOME'] else: import pwd try: pwent = pwd.getpwnam(path[1:i]) except KeyError: return path userhome = pwent[5] if userhome[-1:] == '/': i = i + 1 return userhome + path[i:]
77cdeaff556447a980fe8632e8cd010499ade2d0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/77cdeaff556447a980fe8632e8cd010499ade2d0/posixpath.py
i = i + 1
i += 1
def expanduser(path): """Expand ~ and ~user constructions. If user or $HOME is unknown, do nothing.""" if path[:1] != '~': return path i, n = 1, len(path) while i < n and path[i] != '/': i = i + 1 if i == 1: if not 'HOME' in os.environ: import pwd userhome = pwd.getpwuid(os.getuid())[5] else: userhome = os.environ['HOME'] else: import pwd try: pwent = pwd.getpwnam(path[1:i]) except KeyError: return path userhome = pwent[5] if userhome[-1:] == '/': i = i + 1 return userhome + path[i:]
77cdeaff556447a980fe8632e8cd010499ade2d0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/77cdeaff556447a980fe8632e8cd010499ade2d0/posixpath.py
userhome = pwd.getpwuid(os.getuid())[5]
userhome = pwd.getpwuid(os.getuid()).pw_dir
def expanduser(path): """Expand ~ and ~user constructions. If user or $HOME is unknown, do nothing.""" if path[:1] != '~': return path i, n = 1, len(path) while i < n and path[i] != '/': i = i + 1 if i == 1: if not 'HOME' in os.environ: import pwd userhome = pwd.getpwuid(os.getuid())[5] else: userhome = os.environ['HOME'] else: import pwd try: pwent = pwd.getpwnam(path[1:i]) except KeyError: return path userhome = pwent[5] if userhome[-1:] == '/': i = i + 1 return userhome + path[i:]
77cdeaff556447a980fe8632e8cd010499ade2d0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/77cdeaff556447a980fe8632e8cd010499ade2d0/posixpath.py
userhome = pwent[5] if userhome[-1:] == '/': i = i + 1
userhome = pwent.pw_dir if userhome.endswith('/'): i += 1
def expanduser(path): """Expand ~ and ~user constructions. If user or $HOME is unknown, do nothing.""" if path[:1] != '~': return path i, n = 1, len(path) while i < n and path[i] != '/': i = i + 1 if i == 1: if not 'HOME' in os.environ: import pwd userhome = pwd.getpwuid(os.getuid())[5] else: userhome = os.environ['HOME'] else: import pwd try: pwent = pwd.getpwnam(path[1:i]) except KeyError: return path userhome = pwent[5] if userhome[-1:] == '/': i = i + 1 return userhome + path[i:]
77cdeaff556447a980fe8632e8cd010499ade2d0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/77cdeaff556447a980fe8632e8cd010499ade2d0/posixpath.py
if name[:1] == '{' and name[-1:] == '}':
if name.startswith('{') and name.endswith('}'):
def expandvars(path): """Expand shell variables of form $var and ${var}. Unknown variables are left unchanged.""" global _varprog if '$' not in path: return path if not _varprog: import re _varprog = re.compile(r'\$(\w+|\{[^}]*\})') i = 0 while True: m = _varprog.search(path, i) if not m: break i, j = m.span(0) name = m.group(1) if name[:1] == '{' and name[-1:] == '}': name = name[1:-1] if name in os.environ: tail = path[j:] path = path[:i] + os.environ[name] i = len(path) path = path + tail else: i = j return path
77cdeaff556447a980fe8632e8cd010499ade2d0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/77cdeaff556447a980fe8632e8cd010499ade2d0/posixpath.py
path = path + tail
path += tail
def expandvars(path): """Expand shell variables of form $var and ${var}. Unknown variables are left unchanged.""" global _varprog if '$' not in path: return path if not _varprog: import re _varprog = re.compile(r'\$(\w+|\{[^}]*\})') i = 0 while True: m = _varprog.search(path, i) if not m: break i, j = m.span(0) name = m.group(1) if name[:1] == '{' and name[-1:] == '}': name = name[1:-1] if name in os.environ: tail = path[j:] path = path[:i] + os.environ[name] i = len(path) path = path + tail else: i = j return path
77cdeaff556447a980fe8632e8cd010499ade2d0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/77cdeaff556447a980fe8632e8cd010499ade2d0/posixpath.py
filename = EasyDialogs.AskFileForOpen(message='Select file with aeut/aete resource:')
filename = EasyDialogs.AskFileForOpen( message='Select scriptable application', dialogOptionFlags=0x1056)
def main(): if len(sys.argv) > 1: for filename in sys.argv[1:]: processfile(filename) else: filename = EasyDialogs.AskFileForOpen(message='Select file with aeut/aete resource:') if not filename: sys.exit(0) processfile(filename)
fa1bf1c518528ae8ec9b24ce452edc930ec80a7d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fa1bf1c518528ae8ec9b24ce452edc930ec80a7d/gensuitemodule.py
processfile(filename) def processfile(fullname):
try: processfile(filename) except MacOS.Error, arg: print "Error getting terminology:", arg print "Retry, manually parsing resources" processfile_fromresource(filename) def processfile_fromresource(fullname):
def main(): if len(sys.argv) > 1: for filename in sys.argv[1:]: processfile(filename) else: filename = EasyDialogs.AskFileForOpen(message='Select file with aeut/aete resource:') if not filename: sys.exit(0) processfile(filename)
fa1bf1c518528ae8ec9b24ce452edc930ec80a7d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fa1bf1c518528ae8ec9b24ce452edc930ec80a7d/gensuitemodule.py
defaultLocation=DEFAULT_PACKAGEFOLDER)
defaultLocation=DEFAULT_USER_PACKAGEFOLDER)
def compileaete(aete, resinfo, fname): """Generate code for a full aete resource. fname passed for doc purposes""" [version, language, script, suites] = aete major, minor = divmod(version, 256) creatorsignature, dummy = MacOS.GetCreatorAndType(fname) packagename = identify(os.path.splitext(os.path.basename(fname))[0]) if language: packagename = packagename+'_lang%d'%language if script: packagename = packagename+'_script%d'%script if len(packagename) > 27: packagename = packagename[:27] pathname = EasyDialogs.AskFolder(message='Create and select package folder for %s'%packagename, defaultLocation=DEFAULT_PACKAGEFOLDER) if not pathname: return packagename = os.path.split(os.path.normpath(pathname))[1] basepkgname = EasyDialogs.AskFolder(message='Package folder for base suite (usually StdSuites)', defaultLocation=DEFAULT_PACKAGEFOLDER) if basepkgname: dirname, basepkgname = os.path.split(os.path.normpath(basepkgname)) if not dirname in sys.path: sys.path.insert(0, dirname) basepackage = __import__(basepkgname) else: basepackage = None suitelist = [] allprecompinfo = [] allsuites = [] for suite in suites: code, suite, pathname, modname, precompinfo = precompilesuite(suite, basepackage) if not code: continue allprecompinfo = allprecompinfo + precompinfo suiteinfo = suite, pathname, modname suitelist.append((code, modname)) allsuites.append(suiteinfo) for suiteinfo in allsuites: compilesuite(suiteinfo, major, minor, language, script, fname, basepackage, allprecompinfo) initfilename = EasyDialogs.AskFileForSave(message='Package module', savedFileName='__init__.py') if not initfilename: return fp = open(initfilename, 'w') MacOS.SetCreatorAndType(initfilename, 'Pyth', 'TEXT') fp.write('"""\n') fp.write("Package generated from %s\n"%fname) if resinfo: fp.write("Resource %s resid %d %s\n"%(ascii(resinfo[1]), resinfo[0], ascii(resinfo[2]))) fp.write('"""\n') fp.write('import aetools\n') fp.write('Error = aetools.Error\n') for code, modname in suitelist: fp.write("import %s\n" % modname) fp.write("\n\n_code_to_module = {\n") for code, modname in suitelist: fp.write("\t'%s' : %s,\n"%(ascii(code), modname)) fp.write("}\n\n") fp.write("\n\n_code_to_fullname = {\n") for code, modname in suitelist: fp.write("\t'%s' : ('%s.%s', '%s'),\n"%(ascii(code), packagename, modname, modname)) fp.write("}\n\n") for code, modname in suitelist: fp.write("from %s import *\n"%modname) # Generate property dicts and element dicts for all types declared in this module fp.write("def getbaseclasses(v):\n") fp.write("\tif hasattr(v, '_superclassnames') and not hasattr(v, '_propdict'):\n") fp.write("\t\tv._propdict = {}\n") fp.write("\t\tv._elemdict = {}\n") fp.write("\t\tfor superclass in v._superclassnames:\n")
fa1bf1c518528ae8ec9b24ce452edc930ec80a7d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fa1bf1c518528ae8ec9b24ce452edc930ec80a7d/gensuitemodule.py
defaultLocation=DEFAULT_PACKAGEFOLDER)
defaultLocation=DEFAULT_STANDARD_PACKAGEFOLDER)
def compileaete(aete, resinfo, fname): """Generate code for a full aete resource. fname passed for doc purposes""" [version, language, script, suites] = aete major, minor = divmod(version, 256) creatorsignature, dummy = MacOS.GetCreatorAndType(fname) packagename = identify(os.path.splitext(os.path.basename(fname))[0]) if language: packagename = packagename+'_lang%d'%language if script: packagename = packagename+'_script%d'%script if len(packagename) > 27: packagename = packagename[:27] pathname = EasyDialogs.AskFolder(message='Create and select package folder for %s'%packagename, defaultLocation=DEFAULT_PACKAGEFOLDER) if not pathname: return packagename = os.path.split(os.path.normpath(pathname))[1] basepkgname = EasyDialogs.AskFolder(message='Package folder for base suite (usually StdSuites)', defaultLocation=DEFAULT_PACKAGEFOLDER) if basepkgname: dirname, basepkgname = os.path.split(os.path.normpath(basepkgname)) if not dirname in sys.path: sys.path.insert(0, dirname) basepackage = __import__(basepkgname) else: basepackage = None suitelist = [] allprecompinfo = [] allsuites = [] for suite in suites: code, suite, pathname, modname, precompinfo = precompilesuite(suite, basepackage) if not code: continue allprecompinfo = allprecompinfo + precompinfo suiteinfo = suite, pathname, modname suitelist.append((code, modname)) allsuites.append(suiteinfo) for suiteinfo in allsuites: compilesuite(suiteinfo, major, minor, language, script, fname, basepackage, allprecompinfo) initfilename = EasyDialogs.AskFileForSave(message='Package module', savedFileName='__init__.py') if not initfilename: return fp = open(initfilename, 'w') MacOS.SetCreatorAndType(initfilename, 'Pyth', 'TEXT') fp.write('"""\n') fp.write("Package generated from %s\n"%fname) if resinfo: fp.write("Resource %s resid %d %s\n"%(ascii(resinfo[1]), resinfo[0], ascii(resinfo[2]))) fp.write('"""\n') fp.write('import aetools\n') fp.write('Error = aetools.Error\n') for code, modname in suitelist: fp.write("import %s\n" % modname) fp.write("\n\n_code_to_module = {\n") for code, modname in suitelist: fp.write("\t'%s' : %s,\n"%(ascii(code), modname)) fp.write("}\n\n") fp.write("\n\n_code_to_fullname = {\n") for code, modname in suitelist: fp.write("\t'%s' : ('%s.%s', '%s'),\n"%(ascii(code), packagename, modname, modname)) fp.write("}\n\n") for code, modname in suitelist: fp.write("from %s import *\n"%modname) # Generate property dicts and element dicts for all types declared in this module fp.write("def getbaseclasses(v):\n") fp.write("\tif hasattr(v, '_superclassnames') and not hasattr(v, '_propdict'):\n") fp.write("\t\tv._propdict = {}\n") fp.write("\t\tv._elemdict = {}\n") fp.write("\t\tfor superclass in v._superclassnames:\n")
fa1bf1c518528ae8ec9b24ce452edc930ec80a7d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fa1bf1c518528ae8ec9b24ce452edc930ec80a7d/gensuitemodule.py
print identify('for')
def identify(str): """Turn any string into an identifier: - replace space by _ - replace other illegal chars by _xx_ (hex code) - prepend _ if the result is a python keyword """ if not str: return "empty_ae_name_" rv = '' ok = string.ascii_letters + '_' ok2 = ok + string.digits for c in str: if c in ok: rv = rv + c elif c == ' ': rv = rv + '_' else: rv = rv + '_%02.2x_'%ord(c) ok = ok2 if keyword.iskeyword(rv): rv = rv + '_' return rv
fa1bf1c518528ae8ec9b24ce452edc930ec80a7d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fa1bf1c518528ae8ec9b24ce452edc930ec80a7d/gensuitemodule.py
cre = re.compile(r'def\s+%s\s*[(]' % funcname)
cre = re.compile(r'def\s+%s\s*[(]' % re.escape(funcname))
def find_function(funcname, filename): cre = re.compile(r'def\s+%s\s*[(]' % funcname) try: fp = open(filename) except IOError: return None # consumer of this info expects the first line to be 1 lineno = 1 answer = None while 1: line = fp.readline() if line == '': break if cre.match(line): answer = funcname, filename, lineno break lineno = lineno + 1 fp.close() return answer
e6728252a3598527bbda15c7ee17e03bf2c448f1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e6728252a3598527bbda15c7ee17e03bf2c448f1/pdb.py
def __init__(self, host, port=None, **x509): keys = x509.keys() try: keys.remove('key_file') except ValueError: pass try: keys.remove('cert_file') except ValueError: pass if keys: raise IllegalKeywordArgument()
def __init__(self, host, port=None, key_file=None, cert_file=None):
def __init__(self, host, port=None, **x509): keys = x509.keys() try: keys.remove('key_file') except ValueError: pass try: keys.remove('cert_file') except ValueError: pass if keys: raise IllegalKeywordArgument() HTTPConnection.__init__(self, host, port) self.key_file = x509.get('key_file') self.cert_file = x509.get('cert_file')
7c75c99a10691998b7e1506ede4f98eec28bd226 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7c75c99a10691998b7e1506ede4f98eec28bd226/httplib.py
self.key_file = x509.get('key_file') self.cert_file = x509.get('cert_file')
self.key_file = key_file self.cert_file = cert_file
def __init__(self, host, port=None, **x509): keys = x509.keys() try: keys.remove('key_file') except ValueError: pass try: keys.remove('cert_file') except ValueError: pass if keys: raise IllegalKeywordArgument() HTTPConnection.__init__(self, host, port) self.key_file = x509.get('key_file') self.cert_file = x509.get('cert_file')
7c75c99a10691998b7e1506ede4f98eec28bd226 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7c75c99a10691998b7e1506ede4f98eec28bd226/httplib.py
pass class IllegalKeywordArgument(HTTPException):
def __init__(self, version): self.version = version
7c75c99a10691998b7e1506ede4f98eec28bd226 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7c75c99a10691998b7e1506ede4f98eec28bd226/httplib.py
lookup = getattr(self, "handle_"+condition) elif condition in ["response", "request"]:
lookup = self.handle_open elif condition == "response":
def add_handler(self, handler): added = False for meth in dir(handler): i = meth.find("_") protocol = meth[:i] condition = meth[i+1:]
f7bf02ded533421a0e231c425ac7ff08b8efc589 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f7bf02ded533421a0e231c425ac7ff08b8efc589/urllib2.py
lookup = getattr(self, "process_"+condition)
lookup = self.process_response elif condition == "request": kind = protocol lookup = self.process_request
def add_handler(self, handler): added = False for meth in dir(handler): i = meth.find("_") protocol = meth[:i] condition = meth[i+1:]
f7bf02ded533421a0e231c425ac7ff08b8efc589 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f7bf02ded533421a0e231c425ac7ff08b8efc589/urllib2.py
str = in_file.readline() while str and str != 'end\n': out_file.write(binascii.a2b_uu(str)) str = in_file.readline()
s = in_file.readline() while s and s != 'end\n': try: data = binascii.a2b_uu(s) except binascii.Error, v: nbytes = (((ord(s[0])-32) & 63) * 4 + 5) / 3 data = binascii.a2b_uu(s[:nbytes]) sys.stderr.write("Warning: %s\n" % str(v)) out_file.write(data) s = in_file.readline()
def decode(in_file, out_file=None, mode=None): """Decode uuencoded file""" # # Open the input file, if needed. # if in_file == '-': in_file = sys.stdin elif type(in_file) == type(''): in_file = open(in_file) # # Read until a begin is encountered or we've exhausted the file # while 1: hdr = in_file.readline() if not hdr: raise Error, 'No valid begin line found in input file' if hdr[:5] != 'begin': continue hdrfields = string.split(hdr) if len(hdrfields) == 3 and hdrfields[0] == 'begin': try: string.atoi(hdrfields[1], 8) break except ValueError: pass if out_file == None: out_file = hdrfields[2] if mode == None: mode = string.atoi(hdrfields[1], 8) # # Open the output file # if out_file == '-': out_file = sys.stdout elif type(out_file) == type(''): fp = open(out_file, 'wb') try: os.path.chmod(out_file, mode) except AttributeError: pass out_file = fp # # Main decoding loop # str = in_file.readline() while str and str != 'end\n': out_file.write(binascii.a2b_uu(str)) str = in_file.readline() if not str: raise Error, 'Truncated input file'
4494101858cdcc489281c1e22c3172b99ae2cb20 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4494101858cdcc489281c1e22c3172b99ae2cb20/uu.py
params, method = xmlrpclib.loads(data)
def _marshaled_dispatch(self, data, dispatch_method = None): """Dispatches an XML-RPC method from marshalled (XML) data.
b9120e772be65492e02beced8b344e98cf5f85d2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b9120e772be65492e02beced8b344e98cf5f85d2/SimpleXMLRPCServer.py
print socket.getservbyname('telnet', 'tcp') try: socket.getservbyname('telnet', 'udp') except socket.error: pass
if hasattr(socket, 'getservbyname'): print socket.getservbyname('telnet', 'tcp') try: socket.getservbyname('telnet', 'udp') except socket.error: pass
def missing_ok(str): try: getattr(socket, str) except AttributeError: pass
6870bba459a7c30908c8640b20023e9817e8ac53 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6870bba459a7c30908c8640b20023e9817e8ac53/test_socket.py
self._cont_handler = handler.ContentHandler() self._err_handler = handler.ErrorHandler()
self._cont_handler = handler.ContentHandler() self._err_handler = handler.ErrorHandler()
def __init__(self):
f9059ebede7acc7d498d0703dd97adede37c5016 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f9059ebede7acc7d498d0703dd97adede37c5016/xmlreader.py
"Parse an XML document from a system identifier or an InputSource."
"Parse an XML document from a system identifier or an InputSource."
def parse(self, source):
f9059ebede7acc7d498d0703dd97adede37c5016 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f9059ebede7acc7d498d0703dd97adede37c5016/xmlreader.py
"Register an object to receive basic DTD-related events." self._dtd_handler = handler
"Register an object to receive basic DTD-related events." self._dtd_handler = handler
def setDTDHandler(self, handler):
f9059ebede7acc7d498d0703dd97adede37c5016 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f9059ebede7acc7d498d0703dd97adede37c5016/xmlreader.py
"Register an object to resolve external entities." self._ent_handler = resolver
"Register an object to resolve external entities." self._ent_handler = resolver
def setEntityResolver(self, resolver):
f9059ebede7acc7d498d0703dd97adede37c5016 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f9059ebede7acc7d498d0703dd97adede37c5016/xmlreader.py
"Register an object to receive error-message events." self._err_handler = handler
"Register an object to receive error-message events." self._err_handler = handler
def setErrorHandler(self, handler):
f9059ebede7acc7d498d0703dd97adede37c5016 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f9059ebede7acc7d498d0703dd97adede37c5016/xmlreader.py
"Return the column number where the current event ends." return -1
"Return the column number where the current event ends." return -1
def getColumnNumber(self):
f9059ebede7acc7d498d0703dd97adede37c5016 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f9059ebede7acc7d498d0703dd97adede37c5016/xmlreader.py
"Return the line number where the current event ends." return -1
"Return the line number where the current event ends." return -1
def getLineNumber(self):
f9059ebede7acc7d498d0703dd97adede37c5016 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f9059ebede7acc7d498d0703dd97adede37c5016/xmlreader.py
"Return the public identifier for the current event." return None
"Return the public identifier for the current event." return None
def getPublicId(self):
f9059ebede7acc7d498d0703dd97adede37c5016 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f9059ebede7acc7d498d0703dd97adede37c5016/xmlreader.py
"Return the system identifier for the current event." return None
"Return the system identifier for the current event." return None
def getSystemId(self):
f9059ebede7acc7d498d0703dd97adede37c5016 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f9059ebede7acc7d498d0703dd97adede37c5016/xmlreader.py
if not self._dict['MD5Sum']:
if not self._dict.get('MD5Sum'):
def _archiveOK(self): """Test an archive. It should exist and the MD5 checksum should be correct.""" if not os.path.exists(self.archiveFilename): return 0 if not self._dict['MD5Sum']: sys.stderr.write("Warning: no MD5Sum for %s\n" % self.fullname()) return 1 data = open(self.archiveFilename, 'rb').read() checksum = md5.new(data).hexdigest() return checksum == self._dict['MD5Sum']
e71b9f830b0a3829de799c6b826ea2b4450762c4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e71b9f830b0a3829de799c6b826ea2b4450762c4/pimp.py
if type(value) != type([]):
if type(value) not in (type([]), type( () )):
def post_to_server(self, data, auth=None): ''' Post a query to the server, and return a string response. '''
0037300f153cb0a84238c5fbe2eafde3102001b6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0037300f153cb0a84238c5fbe2eafde3102001b6/register.py
self.doc.append(readme)
self.doc_files.append(readme)
def finalize_package_data (self): self.ensure_string('group', "Development/Libraries") self.ensure_string('vendor', "%s <%s>" % (self.distribution.get_contact(), self.distribution.get_contact_email())) self.ensure_string('packager') self.ensure_string_list('doc_files') if type(self.doc_files) is ListType: for readme in ('README', 'README.txt'): if os.path.exists(readme) and readme not in self.doc_files: self.doc.append(readme)
0152fbdc7f90b3dc6fed167ebda2392cbb47954b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0152fbdc7f90b3dc6fed167ebda2392cbb47954b/bdist_rpm.py
def getresponse(self): "Get the response from the server."
ca2e79000b869861540015468e1b4873241ec984 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ca2e79000b869861540015468e1b4873241ec984/httplib.py
outputs[-1:] = \
outputs.extend (
def copy_tree (src, dst, preserve_mode=1, preserve_times=1, preserve_symlinks=0, update=0, verbose=0, dry_run=0): """Copy an entire directory tree 'src' to a new location 'dst'. Both 'src' and 'dst' must be directory names. If 'src' is not a directory, raise DistutilsFileError. If 'dst' does not exist, it is created with 'mkpath()'. The end result of the copy is that every file in 'src' is copied to 'dst', and directories under 'src' are recursively copied to 'dst'. Return the list of files copied (under their output names) -- note that if 'update' is true, this might be less than the list of files considered. Return value is not affected by 'dry_run'. 'preserve_mode' and 'preserve_times' are the same as for 'copy_file'; note that they only apply to regular files, not to directories. If 'preserve_symlinks' is true, symlinks will be copied as symlinks (on platforms that support them!); otherwise (the default), the destination of the symlink will be copied. 'update' and 'verbose' are the same as for 'copy_file'.""" if not dry_run and not os.path.isdir (src): raise DistutilsFileError, \ "cannot copy tree %s: not a directory" % src try: names = os.listdir (src) except os.error, (errno, errstr): if dry_run: names = [] else: raise DistutilsFileError, \ "error listing files in %s: %s" % (src, errstr) if not dry_run: mkpath (dst, verbose=verbose) outputs = [] for n in names: src_name = os.path.join (src, n) dst_name = os.path.join (dst, n) if preserve_symlinks and os.path.islink (src_name): link_dest = os.readlink (src_name) if verbose: print "linking %s -> %s" % (dst_name, link_dest) if not dry_run: os.symlink (link_dest, dst_name) outputs.append (dst_name) elif os.path.isdir (src_name): outputs[-1:] = \ copy_tree (src_name, dst_name, preserve_mode, preserve_times, preserve_symlinks, update, verbose, dry_run) else: if (copy_file (src_name, dst_name, preserve_mode, preserve_times, update, verbose, dry_run)): outputs.append (dst_name) return outputs
a002edc85b25160cfffe610df9ab7337efc8f0c0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a002edc85b25160cfffe610df9ab7337efc8f0c0/util.py
update, verbose, dry_run)
update, verbose, dry_run))
def copy_tree (src, dst, preserve_mode=1, preserve_times=1, preserve_symlinks=0, update=0, verbose=0, dry_run=0): """Copy an entire directory tree 'src' to a new location 'dst'. Both 'src' and 'dst' must be directory names. If 'src' is not a directory, raise DistutilsFileError. If 'dst' does not exist, it is created with 'mkpath()'. The end result of the copy is that every file in 'src' is copied to 'dst', and directories under 'src' are recursively copied to 'dst'. Return the list of files copied (under their output names) -- note that if 'update' is true, this might be less than the list of files considered. Return value is not affected by 'dry_run'. 'preserve_mode' and 'preserve_times' are the same as for 'copy_file'; note that they only apply to regular files, not to directories. If 'preserve_symlinks' is true, symlinks will be copied as symlinks (on platforms that support them!); otherwise (the default), the destination of the symlink will be copied. 'update' and 'verbose' are the same as for 'copy_file'.""" if not dry_run and not os.path.isdir (src): raise DistutilsFileError, \ "cannot copy tree %s: not a directory" % src try: names = os.listdir (src) except os.error, (errno, errstr): if dry_run: names = [] else: raise DistutilsFileError, \ "error listing files in %s: %s" % (src, errstr) if not dry_run: mkpath (dst, verbose=verbose) outputs = [] for n in names: src_name = os.path.join (src, n) dst_name = os.path.join (dst, n) if preserve_symlinks and os.path.islink (src_name): link_dest = os.readlink (src_name) if verbose: print "linking %s -> %s" % (dst_name, link_dest) if not dry_run: os.symlink (link_dest, dst_name) outputs.append (dst_name) elif os.path.isdir (src_name): outputs[-1:] = \ copy_tree (src_name, dst_name, preserve_mode, preserve_times, preserve_symlinks, update, verbose, dry_run) else: if (copy_file (src_name, dst_name, preserve_mode, preserve_times, update, verbose, dry_run)): outputs.append (dst_name) return outputs
a002edc85b25160cfffe610df9ab7337efc8f0c0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a002edc85b25160cfffe610df9ab7337efc8f0c0/util.py
if not uthread2:
if uthread2:
def execstring(pytext, globals, locals, filename="<string>", debugging=0, modname="__main__", profiling=0): if debugging: import PyDebugger, bdb BdbQuit = bdb.BdbQuit else: BdbQuit = 'BdbQuitDummyException' pytext = string.split(pytext, '\r') pytext = string.join(pytext, '\n') + '\n' W.SetCursor("watch") globals['__name__'] = modname globals['__file__'] = filename sys.argv = [filename] try: code = compile(pytext, filename, "exec") except: # XXXX BAAAADDD.... We let tracebackwindow decide to treat SyntaxError # special. That's wrong because THIS case is special (could be literal # overflow!) and SyntaxError could mean we need a traceback (syntax error # in imported module!!! tracebackwindow.traceback(1, filename) return try: if debugging: if uthread2: uthread2.globalLock() PyDebugger.startfromhere() uthread2.globalUnlock() else: PyDebugger.startfromhere() elif not uthread2: MacOS.EnableAppswitch(0) try: if profiling: import profile, ProfileBrowser p = profile.Profile() p.set_cmd(filename) try: p.runctx(code, globals, locals) finally: import pstats stats = pstats.Stats(p) ProfileBrowser.ProfileBrowser(stats) else: exec code in globals, locals finally: if not uthread2: MacOS.EnableAppswitch(-1) except W.AlertError, detail: raise W.AlertError, detail except (KeyboardInterrupt, BdbQuit): pass except: if uthread2: uthread2.globalLock() if debugging: sys.settrace(None) PyDebugger.postmortem(sys.exc_type, sys.exc_value, sys.exc_traceback) return else: tracebackwindow.traceback(1, filename) if not uthread2: uthread2.globalUnlock() if debugging: sys.settrace(None) PyDebugger.stop()
1c0fceeaa78c1cef7b4ed9eded85310135fa3bad /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1c0fceeaa78c1cef7b4ed9eded85310135fa3bad/PyEdit.py
code = co.co_code n = len(code) i = 0 lastname = None while i < n: c = code[i] i = i+1 op = ord(c) if op >= dis.HAVE_ARGUMENT: oparg = ord(code[i]) + ord(code[i+1])*256 i = i+2 if op == IMPORT_NAME: name = lastname = co.co_names[oparg] if not self.badmodules.has_key(lastname): try: self.import_hook(name, m) except ImportError, msg: self.msg(2, "ImportError:", str(msg)) self.badmodules[name] = None elif op == IMPORT_FROM: name = co.co_names[oparg] assert lastname is not None if not self.badmodules.has_key(lastname): try: self.import_hook(lastname, m, [name]) except ImportError, msg: self.msg(2, "ImportError:", str(msg)) fullname = lastname + "." + name self.badmodules[fullname] = None else: lastname = None
self.scan_code(co, m)
def load_module(self, fqname, fp, pathname, (suffix, mode, type)): self.msgin(2, "load_module", fqname, fp and "fp", pathname) if type == imp.PKG_DIRECTORY: m = self.load_package(fqname, pathname) self.msgout(2, "load_module ->", m) return m if type == imp.PY_SOURCE: co = compile(fp.read(), pathname, 'exec') elif type == imp.PY_COMPILED: if fp.read(4) != imp.get_magic(): self.msgout(2, "raise ImportError: Bad magic number", pathname) raise ImportError, "Bad magic number in %s", pathname fp.read(4) co = marshal.load(fp) else: co = None m = self.add_module(fqname) if co: m.__file__ = pathname m.__code__ = co code = co.co_code n = len(code) i = 0 lastname = None while i < n: c = code[i] i = i+1 op = ord(c) if op >= dis.HAVE_ARGUMENT: oparg = ord(code[i]) + ord(code[i+1])*256 i = i+2 if op == IMPORT_NAME: name = lastname = co.co_names[oparg] if not self.badmodules.has_key(lastname): try: self.import_hook(name, m) except ImportError, msg: self.msg(2, "ImportError:", str(msg)) self.badmodules[name] = None elif op == IMPORT_FROM: name = co.co_names[oparg] assert lastname is not None if not self.badmodules.has_key(lastname): try: self.import_hook(lastname, m, [name]) except ImportError, msg: self.msg(2, "ImportError:", str(msg)) fullname = lastname + "." + name self.badmodules[fullname] = None else: lastname = None self.msgout(2, "load_module ->", m) return m
3c51cf2b6995995fc02771eceb41683fb194c932 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3c51cf2b6995995fc02771eceb41683fb194c932/modulefinder.py
def askopenfilenames(**options): """Ask for multiple filenames to open Returns a list of filenames or empty list if cancel button selected """ options["multiple"]=1 files=Open(**options).show() return files.split()
def asksaveasfilename(**options): "Ask for a filename to save as" return SaveAs(**options).show()
b24e3477dc0f9895573a37b8fcedcf65dc99ef2c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b24e3477dc0f9895573a37b8fcedcf65dc99ef2c/tkFileDialog.py
except BClass, v: raise TestFailed except AClass, v:
except BClass, v:
def __init__(self, ignore):
ae631f7f4588adb3f0077ae80c2ccd530fb5ccc5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ae631f7f4588adb3f0077ae80c2ccd530fb5ccc5/test_opcodes.py
else: raise TestFailed
def __init__(self, ignore):
ae631f7f4588adb3f0077ae80c2ccd530fb5ccc5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ae631f7f4588adb3f0077ae80c2ccd530fb5ccc5/test_opcodes.py
libraries, extradirs, extraexportsymbols, outputdir)
libraries, extradirs, extraexportsymbols, outputdir, libraryflags, stdlibraryflags, prefixname)
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) genpluginproject("carbon", module, project, projectdir, sources, sourcedirs, libraries, extradirs, extraexportsymbols, outputdir) 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)
9051e0e5775b0d0d9f6b4d09a15ef262dd936e76 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9051e0e5775b0d0d9f6b4d09a15ef262dd936e76/genpluginprojects.py
libraries, extradirs, extraexportsymbols, outputdir)
libraries, extradirs, extraexportsymbols, outputdir, libraryflags, stdlibraryflags, prefixname)
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) genpluginproject("carbon", module, project, projectdir, sources, sourcedirs, libraries, extradirs, extraexportsymbols, outputdir) 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)
9051e0e5775b0d0d9f6b4d09a15ef262dd936e76 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9051e0e5775b0d0d9f6b4d09a15ef262dd936e76/genpluginprojects.py
genpluginproject("all", "_Res", outputdir="::Lib:Carbon")
genpluginproject("all", "_Res", 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) genpluginproject("carbon", module, project, projectdir, sources, sourcedirs, libraries, extradirs, extraexportsymbols, outputdir) 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)
9051e0e5775b0d0d9f6b4d09a15ef262dd936e76 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9051e0e5775b0d0d9f6b4d09a15ef262dd936e76/genpluginprojects.py
self.preffilepath = ":Python:PythonIDE preferences"
self.preffilepath = os.path.join("Python", "PythonIDE preferences")
def __init__(self): self.preffilepath = ":Python:PythonIDE preferences" Wapplication.Application.__init__(self, 'Pide') from Carbon import AE from Carbon import AppleEvents AE.AEInstallEventHandler(AppleEvents.kCoreEventClass, AppleEvents.kAEOpenApplication, self.ignoreevent) AE.AEInstallEventHandler(AppleEvents.kCoreEventClass, AppleEvents.kAEReopenApplication, self.ignoreevent) AE.AEInstallEventHandler(AppleEvents.kCoreEventClass, AppleEvents.kAEPrintDocuments, self.ignoreevent) AE.AEInstallEventHandler(AppleEvents.kCoreEventClass, AppleEvents.kAEOpenDocuments, self.opendocsevent) AE.AEInstallEventHandler(AppleEvents.kCoreEventClass, AppleEvents.kAEQuitApplication, self.quitevent) import PyConsole, PyEdit Splash.wait() # With -D option (OSX command line only) keep stderr, for debugging the IDE # itself. debug_stderr = None if len(sys.argv) >= 2 and sys.argv[1] == '-D': debug_stderr = sys.stderr del sys.argv[1] PyConsole.installoutput() PyConsole.installconsole() if debug_stderr: sys.stderr = debug_stderr for path in sys.argv[1:]: self.opendoc(path) try: import Wthreading except ImportError: self.mainloop() else: if Wthreading.haveThreading: self.mainthread = Wthreading.Thread("IDE event loop", self.mainloop) self.mainthread.start() #self.mainthread.setResistant(1) Wthreading.run() else: self.mainloop()
979c53757b5a555725bfab5ee65cfb00b763b46b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/979c53757b5a555725bfab5ee65cfb00b763b46b/PythonIDEMain.py
self.compile = 0
self.compile = None
def initialize_options (self):
b26ca9db2e1efdac62893799c49e3db2c127d56b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b26ca9db2e1efdac62893799c49e3db2c127d56b/install.py
13 0 LOAD_FAST 0 (a)
%-4d 0 LOAD_FAST 0 (a)
def _f(a): print a return 1
26848a34d100f5ff9c3f2710d321d68f73204005 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/26848a34d100f5ff9c3f2710d321d68f73204005/test_dis.py
14 5 LOAD_CONST 1 (1)
%-4d 5 LOAD_CONST 1 (1)
def _f(a): print a return 1
26848a34d100f5ff9c3f2710d321d68f73204005 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/26848a34d100f5ff9c3f2710d321d68f73204005/test_dis.py
"""
"""%(_f.func_code.co_firstlineno + 1, _f.func_code.co_firstlineno + 2) def bug708901(): for res in range(1, 10): pass dis_bug708901 = """\ %-4d 0 SETUP_LOOP 23 (to 26) 3 LOAD_GLOBAL 0 (range) 6 LOAD_CONST 1 (1) %-4d 9 LOAD_CONST 2 (10) 12 CALL_FUNCTION 2 15 GET_ITER >> 16 FOR_ITER 6 (to 25) 19 STORE_FAST 0 (res) %-4d 22 JUMP_ABSOLUTE 16 >> 25 POP_BLOCK >> 26 LOAD_CONST 0 (None) 29 RETURN_VALUE """%(bug708901.func_code.co_firstlineno + 1, bug708901.func_code.co_firstlineno + 2, bug708901.func_code.co_firstlineno + 3)
def _f(a): print a return 1
26848a34d100f5ff9c3f2710d321d68f73204005 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/26848a34d100f5ff9c3f2710d321d68f73204005/test_dis.py
s = StringIO.StringIO() save_stdout = sys.stdout sys.stdout = s dis.dis(_f) sys.stdout = save_stdout got = s.getvalue() lines = got.split('\n') lines = [line.rstrip() for line in lines] got = '\n'.join(lines) self.assertEqual(dis_f, got)
self.do_disassembly_test(_f, dis_f) def test_bug_708901(self): self.do_disassembly_test(bug708901, dis_bug708901)
def test_dis(self): s = StringIO.StringIO() save_stdout = sys.stdout sys.stdout = s dis.dis(_f) sys.stdout = save_stdout got = s.getvalue() # Trim trailing blanks (if any). lines = got.split('\n') lines = [line.rstrip() for line in lines] got = '\n'.join(lines) self.assertEqual(dis_f, got)
26848a34d100f5ff9c3f2710d321d68f73204005 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/26848a34d100f5ff9c3f2710d321d68f73204005/test_dis.py
"""comment: get or set the Finder-comment of the item, displayed in the Get Info window."""
"""comment: get or set the Finder-comment of the item, displayed in the 'Get Info' window."""
def comment(object, comment=None): """comment: get or set the Finder-comment of the item, displayed in the Get Info window.""" object = macfs.FSSpec(object) fss = macfs.FSSpec(object) object_alias = fss.NewAlias() if comment == None: return _getcomment(object_alias) else: return _setcomment(object_alias, comment)
cb100d16e3e7c368179a8b507afd5534c5681eb6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/cb100d16e3e7c368179a8b507afd5534c5681eb6/findertools.py
print '\nmorefindertools version %s\nTests coming up' %__version__
print '\nmorefindertools version %s\nTests coming up...' %__version__
def _test2(): print '\nmorefindertools version %s\nTests coming up' %__version__ import os import random # miscellaneous print '\tfilesharing on?', filesharing() # is file sharing on, off, starting up? print '\tOS version', OSversion() # the version of the system software # set the soundvolume in a simple way print '\tSystem beep volume' for i in range(0, 7): volumelevel(i) MacOS.SysBeep() # Finder's windows, file location, file attributes open("@findertoolstest", "w") f = macfs.FSSpec("@findertoolstest").as_pathname() reveal(f) # reveal this file in a Finder window select(f) # select this file base, file = os.path.split(f) closewindow(base) # close the window this file is in (opened by reveal) openwindow(base) # open it again windowview(base, 1) # set the view by list label(f, 2) # set the label of this file to something orange print '\tlabel', label(f) # get the label of this file # the file location only works in a window with icon view! print 'Random locations for an icon' windowview(base, 0) # set the view by icon windowsize(base, (600, 600)) for i in range(50): location(f, (random.randint(10, 590), random.randint(10, 590))) windowsize(base, (200, 400)) windowview(base, 1) # set the view by icon orgpos = windowposition(base) print 'Animated window location' for i in range(10): pos = (100+i*10, 100+i*10) windowposition(base, pos) print '\twindow position', pos windowposition(base, orgpos) # park it where it was before print 'Put a comment in file', f, ':' print '\t', comment(f) # print the Finder comment this file has s = 'This is a comment no one reads!' comment(f, s) # set the Finder comment
cb100d16e3e7c368179a8b507afd5534c5681eb6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/cb100d16e3e7c368179a8b507afd5534c5681eb6/findertools.py
pdict: dictionary containing other parameters of conten-type header
pdict: dictionary containing other parameters of content-type header
def parse_multipart(fp, pdict): """Parse multipart input. Arguments: fp : input file pdict: dictionary containing other parameters of conten-type header Returns a dictionary just like parse_qs(): keys are the field names, each value is a list of values for that field. This is easy to use but not much good if you are expecting megabytes to be uploaded -- in that case, use the FieldStorage class instead which is much more flexible. Note that content-type is the raw, unparsed contents of the content-type header. XXX This does not parse nested multipart parts -- use FieldStorage for that. XXX This should really be subsumed by FieldStorage altogether -- no point in having two implementations of the same parsing algorithm. """ boundary = "" if 'boundary' in pdict: boundary = pdict['boundary'] if not valid_boundary(boundary): raise ValueError, ('Invalid boundary in multipart form: %r' % (boundary,)) nextpart = "--" + boundary lastpart = "--" + boundary + "--" partdict = {} terminator = "" while terminator != lastpart: bytes = -1 data = None if terminator: # At start of next part. Read headers first. headers = mimetools.Message(fp) clength = headers.getheader('content-length') if clength: try: bytes = int(clength) except ValueError: pass if bytes > 0: if maxlen and bytes > maxlen: raise ValueError, 'Maximum content length exceeded' data = fp.read(bytes) else: data = "" # Read lines until end of part. lines = [] while 1: line = fp.readline() if not line: terminator = lastpart # End outer loop break if line[:2] == "--": terminator = line.strip() if terminator in (nextpart, lastpart): break lines.append(line) # Done with part. if data is None: continue if bytes < 0: if lines: # Strip final line terminator line = lines[-1] if line[-2:] == "\r\n": line = line[:-2] elif line[-1:] == "\n": line = line[:-1] lines[-1] = line data = "".join(lines) line = headers['content-disposition'] if not line: continue key, params = parse_header(line) if key != 'form-data': continue if 'name' in params: name = params['name'] else: continue if name in partdict: partdict[name].append(data) else: partdict[name] = [data] return partdict
c7fc10a41873df6dc40055e62385c1dd198e18b6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c7fc10a41873df6dc40055e62385c1dd198e18b6/cgi.py
headers = mimetools.Message(fp)
headers = _header_parser.parse(fp)
def parse_multipart(fp, pdict): """Parse multipart input. Arguments: fp : input file pdict: dictionary containing other parameters of conten-type header Returns a dictionary just like parse_qs(): keys are the field names, each value is a list of values for that field. This is easy to use but not much good if you are expecting megabytes to be uploaded -- in that case, use the FieldStorage class instead which is much more flexible. Note that content-type is the raw, unparsed contents of the content-type header. XXX This does not parse nested multipart parts -- use FieldStorage for that. XXX This should really be subsumed by FieldStorage altogether -- no point in having two implementations of the same parsing algorithm. """ boundary = "" if 'boundary' in pdict: boundary = pdict['boundary'] if not valid_boundary(boundary): raise ValueError, ('Invalid boundary in multipart form: %r' % (boundary,)) nextpart = "--" + boundary lastpart = "--" + boundary + "--" partdict = {} terminator = "" while terminator != lastpart: bytes = -1 data = None if terminator: # At start of next part. Read headers first. headers = mimetools.Message(fp) clength = headers.getheader('content-length') if clength: try: bytes = int(clength) except ValueError: pass if bytes > 0: if maxlen and bytes > maxlen: raise ValueError, 'Maximum content length exceeded' data = fp.read(bytes) else: data = "" # Read lines until end of part. lines = [] while 1: line = fp.readline() if not line: terminator = lastpart # End outer loop break if line[:2] == "--": terminator = line.strip() if terminator in (nextpart, lastpart): break lines.append(line) # Done with part. if data is None: continue if bytes < 0: if lines: # Strip final line terminator line = lines[-1] if line[-2:] == "\r\n": line = line[:-2] elif line[-1:] == "\n": line = line[:-1] lines[-1] = line data = "".join(lines) line = headers['content-disposition'] if not line: continue key, params = parse_header(line) if key != 'form-data': continue if 'name' in params: name = params['name'] else: continue if name in partdict: partdict[name].append(data) else: partdict[name] = [data] return partdict
c7fc10a41873df6dc40055e62385c1dd198e18b6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c7fc10a41873df6dc40055e62385c1dd198e18b6/cgi.py
headers: a dictionary(-like) object (sometimes rfc822.Message or a subclass thereof) containing *all* headers
headers: a dictionary(-like) object (sometimes email.Message.Message or a subclass thereof) containing *all* headers
def __repr__(self): """Return printable representation.""" return "MiniFieldStorage(%r, %r)" % (self.name, self.value)
c7fc10a41873df6dc40055e62385c1dd198e18b6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c7fc10a41873df6dc40055e62385c1dd198e18b6/cgi.py
headers = rfc822.Message(self.fp)
headers = _header_parser.parse(self.fp)
def read_multi(self, environ, keep_blank_values, strict_parsing): """Internal: read a part that is itself multipart.""" ib = self.innerboundary if not valid_boundary(ib): raise ValueError, 'Invalid boundary in multipart form: %r' % (ib,) self.list = [] klass = self.FieldStorageClass or self.__class__ part = klass(self.fp, {}, ib, environ, keep_blank_values, strict_parsing) # Throw first part away while not part.done: headers = rfc822.Message(self.fp) part = klass(self.fp, headers, ib, environ, keep_blank_values, strict_parsing) self.list.append(part) self.skip_lines()
c7fc10a41873df6dc40055e62385c1dd198e18b6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c7fc10a41873df6dc40055e62385c1dd198e18b6/cgi.py
print>>sys.__stderr__, "** __file__: ", __file__
def view_readme(self, event=None): print>>sys.__stderr__, "** __file__: ", __file__ fn=os.path.join(os.path.abspath(os.path.dirname(__file__)),'README.txt') textView.TextViewer(self.top,'IDLEfork - README',fn)
4ba6067d6bdc2a535e0f691418c1fbb4b4189039 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4ba6067d6bdc2a535e0f691418c1fbb4b4189039/EditorWindow.py