rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
for item in walk_packages(path, name+'.'):
for item in walk_packages(path, name+'.', onerror):
def seen(p, m={}): if p in m: return True m[p] = True
69b9b677b091fe770d73a22e0d4a11a15364bc4a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/69b9b677b091fe770d73a22e0d4a11a15364bc4a/pkgutil.py
"""Yield submodule names+loaders for path or sys.path"""
"""Yields (module_loader, name, ispkg) for all submodules on path, or, if path is None, all top-level modules on sys.path. 'path' should be either None or a list of paths to look for modules in. 'prefix' is a string to output on the front of every module name on output. """
def iter_modules(path=None, prefix=''): """Yield submodule names+loaders for path or sys.path""" if path is None: importers = iter_importers() else: importers = map(get_importer, path) yielded = {} for i in importers: for name, ispkg in iter_importer_modules(i, prefix): if name not in yielded: yielded[name] = 1 yield i, name, ispkg
69b9b677b091fe770d73a22e0d4a11a15364bc4a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/69b9b677b091fe770d73a22e0d4a11a15364bc4a/pkgutil.py
self.__buf = self.__buf + \ (chr(int(x>>24 & 0xff)) + chr(int(x>>16 & 0xff)) + \ chr(int(x>>8 & 0xff)) + chr(int(x & 0xff))) if _USE_MACHINE_REP: def pack_uint(self, x): if type(x) == LongType: x = int((x + 0x80000000L) % 0x100000000L - 0x80000000L) self.__buf = self.__buf + struct.pack('l', x)
self.__buf = self.__buf + struct.pack('>L', x)
def pack_uint(self, x):
6083f0e9ce84de9f8b3aa0531a833b9de285438d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6083f0e9ce84de9f8b3aa0531a833b9de285438d/xdrlib.py
raise ConversionError('Not supported')
try: self.__buf = self.__buf + struct.pack('>f', x) except struct.error, msg: raise ConversionError(msg)
def pack_float(self, x):
6083f0e9ce84de9f8b3aa0531a833b9de285438d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6083f0e9ce84de9f8b3aa0531a833b9de285438d/xdrlib.py
raise ConversionError('Not supported') if _xdr: def pack_float(self, x): try: self.__buf = self.__buf + _xdr.pack_float(x) except _xdr.error, msg: raise ConversionError(msg) def pack_double(self, x): try: self.__buf = self.__buf + _xdr.pack_double(x) except _xdr.error, msg: raise ConversionError(msg)
try: self.__buf = self.__buf + struct.pack('>d', x) except struct.error, msg: raise ConversionError(msg)
def pack_double(self, x):
6083f0e9ce84de9f8b3aa0531a833b9de285438d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6083f0e9ce84de9f8b3aa0531a833b9de285438d/xdrlib.py
x = long(ord(data[0]))<<24 | ord(data[1])<<16 | \ ord(data[2])<<8 | ord(data[3]) if x < 0x80000000L: x = int(x) return x if _USE_MACHINE_REP: def unpack_uint(self): i = self.__pos self.__pos = j = i+4 data = self.__buf[i:j] if len(data) < 4: raise EOFError return struct.unpack('l', data)[0]
x = struct.unpack('>L', data)[0] try: return int(x) except OverflowError: return x
def unpack_uint(self):
6083f0e9ce84de9f8b3aa0531a833b9de285438d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6083f0e9ce84de9f8b3aa0531a833b9de285438d/xdrlib.py
x = self.unpack_uint() if x >= 0x80000000L: x = x - 0x100000000L return int(x)
i = self.__pos self.__pos = j = i+4 data = self.__buf[i:j] if len(data) < 4: raise EOFError return struct.unpack('>l', data)[0]
def unpack_int(self):
6083f0e9ce84de9f8b3aa0531a833b9de285438d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6083f0e9ce84de9f8b3aa0531a833b9de285438d/xdrlib.py
raise ConversionError('Not supported')
i = self.__pos self.__pos = j = i+4 data = self.__buf[i:j] if len(data) < 4: raise EOFError return struct.unpack('>f', data)[0]
def unpack_float(self):
6083f0e9ce84de9f8b3aa0531a833b9de285438d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6083f0e9ce84de9f8b3aa0531a833b9de285438d/xdrlib.py
raise ConversionError('Not supported') if _xdr: def unpack_float(self): i = self.__pos self.__pos = j = i+4 data = self.__buf[i:j] if len(data) < 4: raise EOFError try: return _xdr.unpack_float(data) except _xdr.error, msg: raise ConversionError(msg) def unpack_double(self): i = self.__pos self.__pos = j = i+8 data = self.__buf[i:j] if len(data) < 8: raise EOFError try: return _xdr.unpack_double(data) except _xdr.error, msg: raise ConversionError(msg)
i = self.__pos self.__pos = j = i+8 data = self.__buf[i:j] if len(data) < 8: raise EOFError return struct.unpack('>d', data)[0]
def unpack_double(self):
6083f0e9ce84de9f8b3aa0531a833b9de285438d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6083f0e9ce84de9f8b3aa0531a833b9de285438d/xdrlib.py
k, v = item.split(':', 1) k = k.strip().lower() v = v.strip() self._info[k] = v
if ':' in item: k, v = item.split(':', 1) k = k.strip().lower() v = v.strip() self._info[k] = v lastk = k elif lastk: self._info[lastk] += '\n' + item
def _parse(self, fp): """Override this method to support alternative .mo formats.""" unpack = struct.unpack filename = getattr(fp, 'name', '') # Parse the .mo file header, which consists of 5 little endian 32 # bit words. self._catalog = catalog = {} self.plural = lambda n: int(n != 1) # germanic plural by default buf = fp.read() buflen = len(buf) # Are we big endian or little endian? magic = unpack('<I', buf[:4])[0] if magic == self.LE_MAGIC: version, msgcount, masteridx, transidx = unpack('<4I', buf[4:20]) ii = '<II' elif magic == self.BE_MAGIC: version, msgcount, masteridx, transidx = unpack('>4I', buf[4:20]) ii = '>II' else: raise IOError(0, 'Bad magic number', filename) # Now put all messages from the .mo file buffer into the catalog # dictionary. for i in xrange(0, msgcount): mlen, moff = unpack(ii, buf[masteridx:masteridx+8]) mend = moff + mlen tlen, toff = unpack(ii, buf[transidx:transidx+8]) tend = toff + tlen if mend < buflen and tend < buflen: msg = buf[moff:mend] tmsg = buf[toff:tend] else: raise IOError(0, 'File is corrupt', filename) # See if we're looking at GNU .mo conventions for metadata if mlen == 0: # Catalog description for item in tmsg.splitlines(): item = item.strip() if not item: continue k, v = item.split(':', 1) k = k.strip().lower() v = v.strip() self._info[k] = v if k == 'content-type': self._charset = v.split('charset=')[1] elif k == 'plural-forms': v = v.split(';') plural = v[1].split('plural=')[1] self.plural = c2py(plural) # Note: we unconditionally convert both msgids and msgstrs to # Unicode using the character encoding specified in the charset # parameter of the Content-Type header. The gettext documentation # strongly encourages msgids to be us-ascii, but some appliations # require alternative encodings (e.g. Zope's ZCML and ZPT). For # traditional gettext applications, the msgid conversion will # cause no problems since us-ascii should always be a subset of # the charset encoding. We may want to fall back to 8-bit msgids # if the Unicode conversion fails. if msg.find('\x00') >= 0: # Plural forms msgid1, msgid2 = msg.split('\x00') tmsg = tmsg.split('\x00') if self._charset: msgid1 = unicode(msgid1, self._charset) tmsg = [unicode(x, self._charset) for x in tmsg] for i in range(len(tmsg)): catalog[(msgid1, i)] = tmsg[i] else: if self._charset: msg = unicode(msg, self._charset) tmsg = unicode(tmsg, self._charset) catalog[msg] = tmsg # advance to next entry in the seek tables masteridx += 8 transidx += 8
7de63f57c881cb94ba89c2a1dfaf79af1bba52bb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7de63f57c881cb94ba89c2a1dfaf79af1bba52bb/gettext.py
import pdb ; pdb.set_trace()
def extractarg(self, part): mode = "InMode" if self.asplit.match(part) < 0: self.error("Indecipherable argument: %s", `part`) import pdb ; pdb.set_trace() return ("unknown", part, mode) type, name, array = self.asplit.group('type', 'name', 'array') if array: # array matches an optional [] after the argument name type = type + " ptr " type = regsub.gsub("\*", " ptr ", type) type = string.strip(type) type = regsub.gsub("[ \t]+", "_", type) return self.modifyarg(type, name, mode)
3d3a91c18854aabb4f32cfd4a894de5099d4832a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3d3a91c18854aabb4f32cfd4a894de5099d4832a/scantools.py
if name in ('os2', ):
if name in ('os2', 'nt', 'dos'):
def _execvpe(file, args, env = None): if env: func = execve argrest = (args, env) else: func = execv argrest = (args,) env = environ global _notfound head, tail = path.split(file) if head: apply(func, (file,) + argrest) return if env.has_key('PATH'): envpath = env['PATH'] else: envpath = defpath import string PATH = string.splitfields(envpath, pathsep) if not _notfound: import tempfile # Exec a file that is guaranteed not to exist try: execv(tempfile.mktemp(), ()) except error, _notfound: pass exc, arg = error, _notfound for dir in PATH: fullname = path.join(dir, file) try: apply(func, (fullname,) + argrest) except error, (errno, msg): if errno != arg[0]: exc, arg = error, (errno, msg) raise exc, arg
da4d6daa4a4a95f7031f9b8c3e76222ec4fd509e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/da4d6daa4a4a95f7031f9b8c3e76222ec4fd509e/os.py
key = string.upper(key)
def __setitem__(self, key, item): key = string.upper(key) putenv(key, item) self.data[key] = item
da4d6daa4a4a95f7031f9b8c3e76222ec4fd509e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/da4d6daa4a4a95f7031f9b8c3e76222ec4fd509e/os.py
def __getitem__(self, key): return self.data[string.upper(key)] else: class _Environ(UserDict.UserDict): def __init__(self, environ): UserDict.UserDict.__init__(self) self.data = environ def __getinitargs__(self): import copy return (copy.copy(self.data),) def __setitem__(self, key, item): putenv(key, item) self.data[key] = item def __copy__(self): return _Environ(self.data.copy())
def __getitem__(self, key): return self.data[string.upper(key)]
da4d6daa4a4a95f7031f9b8c3e76222ec4fd509e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/da4d6daa4a4a95f7031f9b8c3e76222ec4fd509e/os.py
path = [module.__filename__]
head, tail = os.path.split(module.__filename__) path = [head]
def reload(self, module, path=None): if path is None and hasattr(module, '__filename__'): path = [module.__filename__] return ihooks.ModuleImporter.reload(self, module, path)
18596003572b715d57ecb6d357cebc4257c0bb31 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/18596003572b715d57ecb6d357cebc4257c0bb31/rexec.py
def readline(self): if not self._file: if not self._files: return "" self._filename = self._files[0] self._files = self._files[1:] self._filelineno = 0 self._file = None self._isstdin = 0 self._backupfilename = 0 if self._filename == '-': self._filename = '<stdin>' self._file = sys.stdin self._isstdin = 1 else: if self._inplace: self._backupfilename = ( self._filename + (self._backup or ".bak")) try: os.unlink(self._backupfilename) except os.error: pass # The next three lines may raise IOError os.rename(self._filename, self._backupfilename) self._file = open(self._backupfilename, "r") self._output = open(self._filename, "w") self._savestdout = sys.stdout sys.stdout = self._output else: # This may raise IOError self._file = open(self._filename, "r") line = self._file.readline() if line: self._lineno = self._lineno + 1 self._filelineno = self._filelineno + 1 return line self.nextfile() # Recursive call return self.readline()
dcb8583c180bc9c477f58f77166dc2abbccadc11 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/dcb8583c180bc9c477f58f77166dc2abbccadc11/fileinput.py
self._output = open(self._filename, "w")
try: perm = os.fstat(self._file.fileno())[stat.ST_MODE] except: self._output = open(self._filename, "w") else: fd = os.open(self._filename, os.O_CREAT | os.O_WRONLY | os.O_TRUNC, perm) self._output = os.fdopen(fd, "w") try: os.chmod(self._filename, perm) except: pass
def readline(self): if not self._file: if not self._files: return "" self._filename = self._files[0] self._files = self._files[1:] self._filelineno = 0 self._file = None self._isstdin = 0 self._backupfilename = 0 if self._filename == '-': self._filename = '<stdin>' self._file = sys.stdin self._isstdin = 1 else: if self._inplace: self._backupfilename = ( self._filename + (self._backup or ".bak")) try: os.unlink(self._backupfilename) except os.error: pass # The next three lines may raise IOError os.rename(self._filename, self._backupfilename) self._file = open(self._backupfilename, "r") self._output = open(self._filename, "w") self._savestdout = sys.stdout sys.stdout = self._output else: # This may raise IOError self._file = open(self._filename, "r") line = self._file.readline() if line: self._lineno = self._lineno + 1 self._filelineno = self._filelineno + 1 return line self.nextfile() # Recursive call return self.readline()
dcb8583c180bc9c477f58f77166dc2abbccadc11 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/dcb8583c180bc9c477f58f77166dc2abbccadc11/fileinput.py
self.file.write('\n' + '\n'*blankline)
self.file.write('\n'*blankline)
def send_paragraph(self, blankline): self.file.write('\n' + '\n'*blankline) self.col = 0 self.atbreak = 0
f4bb656a4ff1b06c0af4e340edd60159a3d4522a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f4bb656a4ff1b06c0af4e340edd60159a3d4522a/formatter.py
return getattr(self, self.err)
return getattr(self.err, attr)
def __getattr__(self, attr): return getattr(self, self.err)
846d6dbbe6b5663dc2437c46815fda98eb24a934 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/846d6dbbe6b5663dc2437c46815fda98eb24a934/test_cgi.py
self.assertEqual(rem, 0) self.assertEqual(r1, r2)
self.assertEqual(rem, 0, '%s != 0 for %s' % (rem, i)) self.assertEqual(r1, r2, '%s != %s for %s' % (r1, r2, i))
def test_count(self): self.checkequal(3, 'aaa', 'count', 'a') self.checkequal(0, 'aaa', 'count', 'b') self.checkequal(3, 'aaa', 'count', 'a') self.checkequal(0, 'aaa', 'count', 'b') self.checkequal(3, 'aaa', 'count', 'a') self.checkequal(0, 'aaa', 'count', 'b') self.checkequal(0, 'aaa', 'count', 'b') self.checkequal(2, 'aaa', 'count', 'a', 1) self.checkequal(0, 'aaa', 'count', 'a', 10) self.checkequal(1, 'aaa', 'count', 'a', -1) self.checkequal(3, 'aaa', 'count', 'a', -10) self.checkequal(1, 'aaa', 'count', 'a', 0, 1) self.checkequal(3, 'aaa', 'count', 'a', 0, 10) self.checkequal(2, 'aaa', 'count', 'a', 0, -1) self.checkequal(0, 'aaa', 'count', 'a', 0, -10) self.checkequal(3, 'aaa', 'count', '', 1) self.checkequal(1, 'aaa', 'count', '', 3) self.checkequal(0, 'aaa', 'count', '', 10) self.checkequal(2, 'aaa', 'count', '', -1) self.checkequal(4, 'aaa', 'count', '', -10)
f71ec5a0acbf606abd8a19519829db8de20352ec /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f71ec5a0acbf606abd8a19519829db8de20352ec/string_tests.py
>>> print a.__dict__ {'default': -1000, 'x2': 200, 'x1': 100}
>>> print sortdict(a.__dict__) {'default': -1000, 'x1': 100, 'x2': 200}
>>> def sorted(seq):
e2052ab82aad273fa547fb91e09d63a15b3be305 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e2052ab82aad273fa547fb91e09d63a15b3be305/test_descrtut.py
"""Configure resources of an item.
"""Configure resources of an ITEM.
def itemconfigure(self, index, cnf=None, **kw): """Configure resources of an item.
09f1ad854237542315ec86151aa56b143e54d1d2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/09f1ad854237542315ec86151aa56b143e54d1d2/Tkinter.py
self.file = self.sock.makefile('rb')
if self.file is None: self.file = self.sock.makefile('rb')
def getreply(self): """Get a reply from the server. Returns a tuple consisting of:
f123f84f66bded5a5554f7130cf823d53d3304cd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f123f84f66bded5a5554f7130cf823d53d3304cd/smtplib.py
try: errcode = string.atoi(code) except ValueError: errcode = -1 break
def getreply(self): """Get a reply from the server. Returns a tuple consisting of:
f123f84f66bded5a5554f7130cf823d53d3304cd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f123f84f66bded5a5554f7130cf823d53d3304cd/smtplib.py
try: errcode = string.atoi(code) except(ValueError): errcode = -1
def getreply(self): """Get a reply from the server. Returns a tuple consisting of:
f123f84f66bded5a5554f7130cf823d53d3304cd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f123f84f66bded5a5554f7130cf823d53d3304cd/smtplib.py
for (extension_name, build_info) in extensions:
for (extension_name, build_info) in self.extensions:
def get_source_files (self):
48697d931bb86ddd114a42ccb89adb6374aef4ff /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/48697d931bb86ddd114a42ccb89adb6374aef4ff/build_ext.py
if sources is None or type (sources) is not ListType:
if sources is None or type (sources) not in (ListType, TupleType):
def build_extensions (self, extensions):
48697d931bb86ddd114a42ccb89adb6374aef4ff /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/48697d931bb86ddd114a42ccb89adb6374aef4ff/build_ext.py
includes=include_dirs)
include_dirs=include_dirs)
def build_extensions (self, extensions):
48697d931bb86ddd114a42ccb89adb6374aef4ff /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/48697d931bb86ddd114a42ccb89adb6374aef4ff/build_ext.py
import sys
def __init__(self, indent=1, width=80, depth=None, stream=None): """Handle pretty printing operations onto a stream using a set of configured parameters.
1ef106c94d7ec70f6f4ca756fa47852404556b6d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1ef106c94d7ec70f6f4ca756fa47852404556b6d/pprint.py
if not (typ in (DictType, ListType, TupleType) and object):
if not (typ in (DictType, ListType, TupleType, StringType) and object):
def _safe_repr(object, context, maxlevels=None, level=0): level += 1 typ = type(object) if not (typ in (DictType, ListType, TupleType) and object): rep = `object` return rep, (rep and (rep[0] != '<')), 0 if context.has_key(id(object)): return `_Recursion(object)`, 0, 1 objid = id(object) context[objid] = 1 readable = 1 recursive = 0 startchar, endchar = {ListType: "[]", TupleType: "()", DictType: "{}"}[typ] if maxlevels and level > maxlevels: with_commas = "..." readable = 0 elif typ is DictType: components = [] for k, v in object.iteritems(): krepr, kreadable, krecur = _safe_repr(k, context, maxlevels, level) vrepr, vreadable, vrecur = _safe_repr(v, context, maxlevels, level) components.append("%s: %s" % (krepr, vrepr)) readable = readable and kreadable and vreadable recursive = recursive or krecur or vrecur with_commas = ", ".join(components) else: # list or tuple assert typ in (ListType, TupleType) components = [] for element in object: subrepr, subreadable, subrecur = _safe_repr( element, context, maxlevels, level) components.append(subrepr) readable = readable and subreadable recursive = recursive or subrecur if len(components) == 1 and typ is TupleType: components[0] += "," with_commas = ", ".join(components) s = "%s%s%s" % (startchar, with_commas, endchar) del context[objid] return s, readable and not recursive, recursive
1ef106c94d7ec70f6f4ca756fa47852404556b6d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1ef106c94d7ec70f6f4ca756fa47852404556b6d/pprint.py
for base in cls.__bases__: if hasattr(base, "_getDefaults"): defaults.update(base._getDefaults())
def _getDefaults(cls): defaults = {} for name, value in cls.__dict__.items(): if name[0] != "_" and not isinstance(value, (function, classmethod)): defaults[name] = deepcopy(value) for base in cls.__bases__: if hasattr(base, "_getDefaults"): defaults.update(base._getDefaults()) return defaults
ed8bfce0028ecd7e7c3b778f70b24d8d03809a05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ed8bfce0028ecd7e7c3b778f70b24d8d03809a05/bundlebuilder.py
self.ofp.write(struct.pack('>h', self.crc))
if self.crc < 0: fmt = '>h' else: fmt = '>H' self.ofp.write(struct.pack(fmt, self.crc))
def _writecrc(self): # XXXX Should this be here?? # self.crc = binascii.crc_hqx('\0\0', self.crc) self.ofp.write(struct.pack('>h', self.crc)) self.crc = 0
910a08f6da226b892b8bfdb69c61b80386627fd2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/910a08f6da226b892b8bfdb69c61b80386627fd2/binhex.py
copier = x.__deepcopy__ except AttributeError:
issc = issubclass(type(x), type) except TypeError: issc = 0 if issc: y = _deepcopy_dispatch[type](x, memo) else:
def deepcopy(x, memo = None): """Deep copy operation on arbitrary Python objects. See the module's __doc__ string for more info. """ if memo is None: memo = {} d = id(x) if d in memo: return memo[d] try: copierfunction = _deepcopy_dispatch[type(x)] except KeyError: try: copier = x.__deepcopy__ except AttributeError: try: reductor = x.__reduce__ except AttributeError: raise error, \ "un-deep-copyable object of type %s" % type(x) else: y = _reconstruct(x, reductor(), 1, memo) else: y = copier(memo) else: y = copierfunction(x, memo) memo[d] = y return y
11ade1ddc053dcec884e2431b55fb1c1727c65d7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/11ade1ddc053dcec884e2431b55fb1c1727c65d7/copy.py
reductor = x.__reduce__
copier = x.__deepcopy__
def deepcopy(x, memo = None): """Deep copy operation on arbitrary Python objects. See the module's __doc__ string for more info. """ if memo is None: memo = {} d = id(x) if d in memo: return memo[d] try: copierfunction = _deepcopy_dispatch[type(x)] except KeyError: try: copier = x.__deepcopy__ except AttributeError: try: reductor = x.__reduce__ except AttributeError: raise error, \ "un-deep-copyable object of type %s" % type(x) else: y = _reconstruct(x, reductor(), 1, memo) else: y = copier(memo) else: y = copierfunction(x, memo) memo[d] = y return y
11ade1ddc053dcec884e2431b55fb1c1727c65d7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/11ade1ddc053dcec884e2431b55fb1c1727c65d7/copy.py
raise error, \ "un-deep-copyable object of type %s" % type(x)
try: reductor = x.__reduce__ except AttributeError: raise error, \ "un-deep-copyable object of type %s" % type(x) else: y = _reconstruct(x, reductor(), 1, memo)
def deepcopy(x, memo = None): """Deep copy operation on arbitrary Python objects. See the module's __doc__ string for more info. """ if memo is None: memo = {} d = id(x) if d in memo: return memo[d] try: copierfunction = _deepcopy_dispatch[type(x)] except KeyError: try: copier = x.__deepcopy__ except AttributeError: try: reductor = x.__reduce__ except AttributeError: raise error, \ "un-deep-copyable object of type %s" % type(x) else: y = _reconstruct(x, reductor(), 1, memo) else: y = copier(memo) else: y = copierfunction(x, memo) memo[d] = y return y
11ade1ddc053dcec884e2431b55fb1c1727c65d7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/11ade1ddc053dcec884e2431b55fb1c1727c65d7/copy.py
y = _reconstruct(x, reductor(), 1, memo) else: y = copier(memo)
y = copier(memo)
def deepcopy(x, memo = None): """Deep copy operation on arbitrary Python objects. See the module's __doc__ string for more info. """ if memo is None: memo = {} d = id(x) if d in memo: return memo[d] try: copierfunction = _deepcopy_dispatch[type(x)] except KeyError: try: copier = x.__deepcopy__ except AttributeError: try: reductor = x.__reduce__ except AttributeError: raise error, \ "un-deep-copyable object of type %s" % type(x) else: y = _reconstruct(x, reductor(), 1, memo) else: y = copier(memo) else: y = copierfunction(x, memo) memo[d] = y return y
11ade1ddc053dcec884e2431b55fb1c1727c65d7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/11ade1ddc053dcec884e2431b55fb1c1727c65d7/copy.py
result.addError(self,self.__exc_info())
result.addError(self,sys.exc_info())
def __call__(self, result=None): if result is None: result = self.defaultTestResult() result.startTest(self) testMethod = getattr(self, self.__testMethodName) try: try: self.setUp() except: result.addError(self,self.__exc_info()) return
17a781bc69d73326455ca7f129bdf57528f4ad8b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/17a781bc69d73326455ca7f129bdf57528f4ad8b/unittest.py
result.addFailure(self,self.__exc_info())
result.addFailure(self,sys.exc_info())
def __call__(self, result=None): if result is None: result = self.defaultTestResult() result.startTest(self) testMethod = getattr(self, self.__testMethodName) try: try: self.setUp() except: result.addError(self,self.__exc_info()) return
17a781bc69d73326455ca7f129bdf57528f4ad8b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/17a781bc69d73326455ca7f129bdf57528f4ad8b/unittest.py
result.addError(self,self.__exc_info())
result.addError(self,sys.exc_info())
def __call__(self, result=None): if result is None: result = self.defaultTestResult() result.startTest(self) testMethod = getattr(self, self.__testMethodName) try: try: self.setUp() except: result.addError(self,self.__exc_info()) return
17a781bc69d73326455ca7f129bdf57528f4ad8b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/17a781bc69d73326455ca7f129bdf57528f4ad8b/unittest.py
result.addError(self,self.__exc_info())
result.addError(self,sys.exc_info())
def __call__(self, result=None): if result is None: result = self.defaultTestResult() result.startTest(self) testMethod = getattr(self, self.__testMethodName) try: try: self.setUp() except: result.addError(self,self.__exc_info()) return
17a781bc69d73326455ca7f129bdf57528f4ad8b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/17a781bc69d73326455ca7f129bdf57528f4ad8b/unittest.py
def __exc_info(self): """Return a version of sys.exc_info() with the traceback frame minimised; usually the top level of the traceback frame is not needed. """ exctype, excvalue, tb = sys.exc_info() newtb = tb.tb_next if newtb is None: return (exctype, excvalue, tb) return (exctype, excvalue, newtb)
def __exc_info(self): """Return a version of sys.exc_info() with the traceback frame minimised; usually the top level of the traceback frame is not needed. """ exctype, excvalue, tb = sys.exc_info() newtb = tb.tb_next if newtb is None: return (exctype, excvalue, tb) return (exctype, excvalue, newtb)
17a781bc69d73326455ca7f129bdf57528f4ad8b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/17a781bc69d73326455ca7f129bdf57528f4ad8b/unittest.py
module = __import__(parts)
parts_copy = parts[:] while parts_copy: try: module = __import__(string.join(parts_copy,'.')) break except ImportError: del parts_copy[-1] if not parts_copy: raise
def loadTestsFromName(self, name, module=None): parts = string.split(name, '.') if module is None: if not parts: raise ValueError, "incomplete test name: %s" % name else: module = __import__(parts) parts = parts[1:] obj = module for part in parts: obj = getattr(obj, part)
17a781bc69d73326455ca7f129bdf57528f4ad8b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/17a781bc69d73326455ca7f129bdf57528f4ad8b/unittest.py
Usage: %(progName)s [options] [test[:(casename|prefix-)]] [...]
Usage: %(progName)s [options] [test] [...]
def run(self, test): "Run the given test case or test suite." result = self._makeResult() startTime = time.time() test(result) stopTime = time.time() timeTaken = float(stopTime - startTime) result.printErrors() self.stream.writeln(result.separator2) run = result.testsRun self.stream.writeln("Ran %d test%s in %.3fs" % (run, run == 1 and "" or "s", timeTaken)) self.stream.writeln() if not result.wasSuccessful(): self.stream.write("FAILED (") failed, errored = map(len, (result.failures, result.errors)) if failed: self.stream.write("failures=%d" % failed) if errored: if failed: self.stream.write(", ") self.stream.write("errors=%d" % errored) self.stream.writeln(")") else: self.stream.writeln("OK") return result
17a781bc69d73326455ca7f129bdf57528f4ad8b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/17a781bc69d73326455ca7f129bdf57528f4ad8b/unittest.py
screenbounds = Qd.qd.screenBits.bounds screenbounds = screenbounds[0]+4, screenbounds[1]+4, \ screenbounds[2]-4, screenbounds[3]-4
def AskYesNoCancel(question, default = 0):
1d63d8c8290e801f8a1d9041a8073e0ca79be56e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1d63d8c8290e801f8a1d9041a8073e0ca79be56e/EasyDialogs.py
def __init__(self, label="Working...", maxval=100): self.label = label
def __init__(self, title="Working...", maxval=100, label=""):
def __init__(self, label="Working...", maxval=100): self.label = label self.maxval = maxval self.curval = -1 self.d = GetNewDialog(259, -1) tp, text_h, rect = self.d.GetDialogItem(2) SetDialogItemText(text_h, label) self._update(0)
1d63d8c8290e801f8a1d9041a8073e0ca79be56e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1d63d8c8290e801f8a1d9041a8073e0ca79be56e/EasyDialogs.py
SetDialogItemText(text_h, label) self._update(0)
SetDialogItemText(text_h, self._label)
def __init__(self, label="Working...", maxval=100): self.label = label self.maxval = maxval self.curval = -1 self.d = GetNewDialog(259, -1) tp, text_h, rect = self.d.GetDialogItem(2) SetDialogItemText(text_h, label) self._update(0)
1d63d8c8290e801f8a1d9041a8073e0ca79be56e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1d63d8c8290e801f8a1d9041a8073e0ca79be56e/EasyDialogs.py
if ModalDialog(_ProgressBar_filterfunc) == 1: raise KeyboardInterrupt
ready, ev = Evt.WaitNextEvent( Events.mDownMask, 1 ) if ready : what,msg,when,where,mod = ev part = Win.FindWindow(where)[0] if Dlg.IsDialogEvent(ev): ds = Dlg.DialogSelect(ev) if ds[0] and ds[1] == self.d and ds[-1] == 1: raise KeyboardInterrupt, ev else: if part == 4: self.d.DragWindow(where, screenbounds) else: MacOS.HandleEvent(ev)
def _update(self, value): tp, h, bar_rect = self.d.GetDialogItem(3) Qd.SetPort(self.d) Qd.FrameRect(bar_rect) # Draw outline inner_rect = Qd.InsetRect(bar_rect, 1, 1) l, t, r, b = inner_rect
1d63d8c8290e801f8a1d9041a8073e0ca79be56e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1d63d8c8290e801f8a1d9041a8073e0ca79be56e/EasyDialogs.py
def _ProgressBar_filterfunc(*args): return 2
def inc(self, n=1): """inc(amt) - Increment progress bar position""" self.set(self.curval + n)
def set(self, value): if value < 0: value = 0 if value > self.maxval: value = self.maxval self._update(value)
1d63d8c8290e801f8a1d9041a8073e0ca79be56e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1d63d8c8290e801f8a1d9041a8073e0ca79be56e/EasyDialogs.py
bar = ProgressBar("Counting...", 100) for i in range(100): bar.set(i) del bar
text = ( "Working Hard...", "Hardly Working..." , "So far, so good!", "Keep on truckin'" ) bar = ProgressBar("Progress, progress...", 100) try: appsw = MacOS.EnableAppswitch(0) for i in range(100): bar.set(i) time.sleep(0.1) if i % 10 == 0: bar.label(text[(i/10) % 4]) bar.label("Done.") time.sleep(0.3) finally: del bar MacOS.EnableAppswitch(appsw)
def test(): Message("Testing EasyDialogs.") ok = AskYesNoCancel("Do you want to proceed?") if ok > 0: s = AskString("Enter your first name") Message("Thank you,\015%s" % `s`) bar = ProgressBar("Counting...", 100) for i in range(100): bar.set(i) del bar
1d63d8c8290e801f8a1d9041a8073e0ca79be56e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1d63d8c8290e801f8a1d9041a8073e0ca79be56e/EasyDialogs.py
test()
try: test() except KeyboardInterrupt: Message("Operation Canceled.")
def test(): Message("Testing EasyDialogs.") ok = AskYesNoCancel("Do you want to proceed?") if ok > 0: s = AskString("Enter your first name") Message("Thank you,\015%s" % `s`) bar = ProgressBar("Counting...", 100) for i in range(100): bar.set(i) del bar
1d63d8c8290e801f8a1d9041a8073e0ca79be56e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1d63d8c8290e801f8a1d9041a8073e0ca79be56e/EasyDialogs.py
self.rpcpid = os.spawnv(os.P_NOWAIT, args[0], args)
self.rpcpid = os.spawnv(os.P_NOWAIT, sys.executable, args)
def spawn_subprocess(self): args = self.subprocess_arglist self.rpcpid = os.spawnv(os.P_NOWAIT, args[0], args)
b785518d051dab322feafaed0fc79d7218ce6cb0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b785518d051dab322feafaed0fc79d7218ce6cb0/PyShell.py
return [sys.executable] + w + ["-c", command, str(self.port)]
if sys.platform[:3] == 'win' and ' ' in sys.executable: decorated_exec = '"%s"' % sys.executable else: decorated_exec = sys.executable return [decorated_exec] + w + ["-c", command, str(self.port)]
def build_subprocess_arglist(self): w = ['-W' + s for s in sys.warnoptions] # Maybe IDLE is installed and is being accessed via sys.path, # or maybe it's not installed and the idle.py script is being # run from the IDLE source directory. del_exitf = idleConf.GetOption('main', 'General', 'delete-exitfunc', default=False, type='bool') if __name__ == 'idlelib.PyShell': command = "__import__('idlelib.run').run.main(" + `del_exitf` +")" else: command = "__import__('run').main(" + `del_exitf` + ")" return [sys.executable] + w + ["-c", command, str(self.port)]
b785518d051dab322feafaed0fc79d7218ce6cb0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b785518d051dab322feafaed0fc79d7218ce6cb0/PyShell.py
fp.write("\tif hasattr(v, '_superclassnames') and v._superclassnames:\n")
fp.write("\tif hasattr(v, '_superclassnames') and not hasattr(v, '_propdict'):\n")
fp.write("def getbaseclasses(v):\n")
7ff034b65b85265989b8fd256febc88ae9e8947d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7ff034b65b85265989b8fd256febc88ae9e8947d/gensuitemodule.py
fp.write("\t\tv._superclassnames = None\n")
fp.write("def getbaseclasses(v):\n")
7ff034b65b85265989b8fd256febc88ae9e8947d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7ff034b65b85265989b8fd256febc88ae9e8947d/gensuitemodule.py
def _cmp(a, b):
def _cmp(a, b, sh, st):
def _cmp(a, b): try: return not abs(cmp(a, b)) except os.error: return 2
afb17fc7b2782bddd74ffcf4f5b51efc9a9b4545 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/afb17fc7b2782bddd74ffcf4f5b51efc9a9b4545/filecmp.py
return not abs(cmp(a, b))
return not abs(cmp(a, b, sh, st))
def _cmp(a, b): try: return not abs(cmp(a, b)) except os.error: return 2
afb17fc7b2782bddd74ffcf4f5b51efc9a9b4545 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/afb17fc7b2782bddd74ffcf4f5b51efc9a9b4545/filecmp.py
sys.stderr.write('MH error: %\n' % (msg % args))
sys.stderr.write('MH error: %s\n' % (msg % args))
def error(self, msg, *args): sys.stderr.write('MH error: %\n' % (msg % args))
508a092e2e44332c2f1ac381bdb956e3b94e0cc2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/508a092e2e44332c2f1ac381bdb956e3b94e0cc2/mhlib.py
mode = eval('0' + protect)
mode = string.atoi(protect, 8)
def makefolder(self, name): protect = pickline(self.profile, 'Folder-Protect') if protect and isnumeric(protect): mode = eval('0' + protect) else: mode = FOLDER_PROTECT os.mkdir(os.path.join(self.getpath(), name), mode)
508a092e2e44332c2f1ac381bdb956e3b94e0cc2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/508a092e2e44332c2f1ac381bdb956e3b94e0cc2/mhlib.py
if isnumeric(name): messages.append(eval(name))
if name[0] != "," and \ numericprog.match(name) == len(name): messages.append(string.atoi(name))
def listmessages(self): messages = [] for name in os.listdir(self.getfullname()): if isnumeric(name): messages.append(eval(name)) messages.sort() if messages: self.last = max(messages) else: self.last = 0 return messages
508a092e2e44332c2f1ac381bdb956e3b94e0cc2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/508a092e2e44332c2f1ac381bdb956e3b94e0cc2/mhlib.py
path = self.getmessagefilename(n)
def openmessage(self, n): path = self.getmessagefilename(n) return Message(self, n)
508a092e2e44332c2f1ac381bdb956e3b94e0cc2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/508a092e2e44332c2f1ac381bdb956e3b94e0cc2/mhlib.py
newline = '%s: %s' % (key, value)
newline = '%s: %s\n' % (key, value)
def updateline(file, key, value, casefold = 1): try: f = open(file, 'r') lines = f.readlines() f.close() except IOError: lines = [] pat = key + ':\(.*\)\n' if casefold: prog = regex.compile(pat, regex.casefold) else: prog = regex.compile(pat) if value is None: newline = None else: newline = '%s: %s' % (key, value) for i in range(len(lines)): line = lines[i] if prog.match(line) == len(line): if newline is None: del lines[i] else: lines[i] = newline break else: if newline is not None: lines.append(newline) f = open(tempfile, 'w') for line in lines: f.write(line) f.close()
508a092e2e44332c2f1ac381bdb956e3b94e0cc2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/508a092e2e44332c2f1ac381bdb956e3b94e0cc2/mhlib.py
specialsre = re.compile(r'[][\()<>@,:;".]') escapesre = re.compile(r'[][\()"]')
specialsre = re.compile(r'[][\\()<>@,:;".]') escapesre = re.compile(r'[][\\()"]')
def _qdecode(s): import quopri as _quopri
a2369928b52ddcbadb5709cfa5df0b502d861090 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a2369928b52ddcbadb5709cfa5df0b502d861090/Utils.py
if msilib.msi_type=="Intel64;1033": sqlite_arch = "/ia64" elif msilib.msi_type=="x64;1033": sqlite_arch = "/amd64" else: sqlite_arch = "" lib.add_file(srcdir+"/"+sqlite_dir+sqlite_arch+"/sqlite3.dll")
def add_files(db): cab = CAB("python") tmpfiles = [] # Add all executables, icons, text files into the TARGETDIR component root = PyDirectory(db, cab, None, srcdir, "TARGETDIR", "SourceDir") default_feature.set_current() if not msilib.Win64: root.add_file("PCBuild/w9xpopen.exe") root.add_file("README.txt", src="README") root.add_file("NEWS.txt", src="Misc/NEWS") root.add_file("LICENSE.txt", src="LICENSE") root.start_component("python.exe", keyfile="python.exe") root.add_file("PCBuild/python.exe") root.start_component("pythonw.exe", keyfile="pythonw.exe") root.add_file("PCBuild/pythonw.exe") # msidbComponentAttributesSharedDllRefCount = 8, see "Component Table" dlldir = PyDirectory(db, cab, root, srcdir, "DLLDIR", ".") pydll = "python%s%s.dll" % (major, minor) pydllsrc = srcdir + "/PCBuild/" + pydll dlldir.start_component("DLLDIR", flags = 8, keyfile = pydll, uuid = pythondll_uuid) installer = msilib.MakeInstaller() pyversion = installer.FileVersion(pydllsrc, 0) if not snapshot: # For releases, the Python DLL has the same version as the # installer package. assert pyversion.split(".")[:3] == current_version.split(".") dlldir.add_file("PCBuild/python%s%s.dll" % (major, minor), version=pyversion, language=installer.FileVersion(pydllsrc, 1)) # XXX determine dependencies version, lang = extract_msvcr71() dlldir.start_component("msvcr71", flags=8, keyfile="msvcr71.dll", uuid=msvcr71_uuid) dlldir.add_file("msvcr71.dll", src=os.path.abspath("msvcr71.dll"), version=version, language=lang) tmpfiles.append("msvcr71.dll") # Add all .py files in Lib, except lib-tk, test dirs={} pydirs = [(root,"Lib")] while pydirs: parent, dir = pydirs.pop() if dir == ".svn" or dir.startswith("plat-"): continue elif dir in ["lib-tk", "idlelib", "Icons"]: if not have_tcl: continue tcltk.set_current() elif dir in ['test', 'tests', 'data', 'output']: # test: Lib, Lib/email, Lib/bsddb, Lib/ctypes, Lib/sqlite3 # tests: Lib/distutils # data: Lib/email/test # output: Lib/test testsuite.set_current() else: default_feature.set_current() lib = PyDirectory(db, cab, parent, dir, dir, "%s|%s" % (parent.make_short(dir), dir)) # Add additional files dirs[dir]=lib lib.glob("*.txt") if dir=='site-packages': lib.add_file("README.txt", src="README") continue files = lib.glob("*.py") files += lib.glob("*.pyw") if files: # Add an entry to the RemoveFile table to remove bytecode files. lib.remove_pyc() if dir.endswith('.egg-info'): lib.add_file('entry_points.txt') lib.add_file('PKG-INFO') lib.add_file('top_level.txt') lib.add_file('zip-safe') continue if dir=='test' and parent.physical=='Lib': lib.add_file("185test.db") lib.add_file("audiotest.au") lib.add_file("cfgparser.1") lib.add_file("test.xml") lib.add_file("test.xml.out") lib.add_file("testtar.tar") lib.add_file("test_difflib_expect.html") lib.add_file("check_soundcard.vbs") lib.add_file("empty.vbs") lib.glob("*.uue") lib.add_file("readme.txt", src="README") if dir=='decimaltestdata': lib.glob("*.decTest") if dir=='output': lib.glob("test_*") if dir=='idlelib': lib.glob("*.def") lib.add_file("idle.bat") if dir=="Icons": lib.glob("*.gif") lib.add_file("idle.icns") if dir=="command" and parent.physical=="distutils": lib.add_file("wininst-6.exe") lib.add_file("wininst-7.1.exe") if dir=="setuptools": lib.add_file("cli.exe") lib.add_file("gui.exe") if dir=="data" and parent.physical=="test" and parent.basedir.physical=="email": # This should contain all non-.svn files listed in subversion for f in os.listdir(lib.absolute): if f.endswith(".txt") or f==".svn":continue if f.endswith(".au") or f.endswith(".gif"): lib.add_file(f) else: print "WARNING: New file %s in email/test/data" % f for f in os.listdir(lib.absolute): if os.path.isdir(os.path.join(lib.absolute, f)): pydirs.append((lib, f)) # Add DLLs default_feature.set_current() lib = PyDirectory(db, cab, root, srcdir+"/PCBuild", "DLLs", "DLLS|DLLs") lib.add_file("py.ico", src="../PC/py.ico") lib.add_file("pyc.ico", src="../PC/pyc.ico") dlls = [] tclfiles = [] for f in extensions: if f=="_tkinter.pyd": continue if not os.path.exists(srcdir+"/PCBuild/"+f): print "WARNING: Missing extension", f continue dlls.append(f) lib.add_file(f) if have_tcl: if not os.path.exists(srcdir+"/PCBuild/_tkinter.pyd"): print "WARNING: Missing _tkinter.pyd" else: lib.start_component("TkDLLs", tcltk) lib.add_file("_tkinter.pyd") dlls.append("_tkinter.pyd") tcldir = os.path.normpath(srcdir+"/../tcltk/bin") for f in glob.glob1(tcldir, "*.dll"): lib.add_file(f, src=os.path.join(tcldir, f)) # Add sqlite if msilib.msi_type=="Intel64;1033": sqlite_arch = "/ia64" elif msilib.msi_type=="x64;1033": sqlite_arch = "/amd64" else: sqlite_arch = "" lib.add_file(srcdir+"/"+sqlite_dir+sqlite_arch+"/sqlite3.dll") # check whether there are any unknown extensions for f in glob.glob1(srcdir+"/PCBuild", "*.pyd"): if f.endswith("_d.pyd"): continue # debug version if f in dlls: continue print "WARNING: Unknown extension", f # Add headers default_feature.set_current() lib = PyDirectory(db, cab, root, "include", "include", "INCLUDE|include") lib.glob("*.h") lib.add_file("pyconfig.h", src="../PC/pyconfig.h") # Add import libraries lib = PyDirectory(db, cab, root, "PCBuild", "libs", "LIBS|libs") for f in dlls: lib.add_file(f.replace('pyd','lib')) lib.add_file('python%s%s.lib' % (major, minor)) # Add the mingw-format library if have_mingw: lib.add_file('libpython%s%s.a' % (major, minor)) if have_tcl: # Add Tcl/Tk tcldirs = [(root, '../tcltk/lib', 'tcl')] tcltk.set_current() while tcldirs: parent, phys, dir = tcldirs.pop() lib = PyDirectory(db, cab, parent, phys, dir, "%s|%s" % (parent.make_short(dir), dir)) if not os.path.exists(lib.absolute): continue for f in os.listdir(lib.absolute): if os.path.isdir(os.path.join(lib.absolute, f)): tcldirs.append((lib, f, f)) else: lib.add_file(f) # Add tools tools.set_current() tooldir = PyDirectory(db, cab, root, "Tools", "Tools", "TOOLS|Tools") for f in ['i18n', 'pynche', 'Scripts', 'versioncheck', 'webchecker']: lib = PyDirectory(db, cab, tooldir, f, f, "%s|%s" % (tooldir.make_short(f), f)) lib.glob("*.py") lib.glob("*.pyw", exclude=['pydocgui.pyw']) lib.remove_pyc() lib.glob("*.txt") if f == "pynche": x = PyDirectory(db, cab, lib, "X", "X", "X|X") x.glob("*.txt") if os.path.exists(os.path.join(lib.absolute, "README")): lib.add_file("README.txt", src="README") if f == 'Scripts': if have_tcl: lib.start_component("pydocgui.pyw", tcltk, keyfile="pydocgui.pyw") lib.add_file("pydocgui.pyw") # Add documentation htmlfiles.set_current() lib = PyDirectory(db, cab, root, "Doc", "Doc", "DOC|Doc") lib.start_component("documentation", keyfile="Python%s%s.chm" % (major,minor)) lib.add_file("Python%s%s.chm" % (major, minor)) cab.commit(db) for f in tmpfiles: os.unlink(f)
88ef6377773b9bafdec0c7d85d3eefccf8209c61 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/88ef6377773b9bafdec0c7d85d3eefccf8209c61/msi.py
raise error, "flags should be one of 'r', 'w', 'c' or 'n' or use the bsddb.db.DB_* flags"
raise db.DBError, "flags should be one of 'r', 'w', 'c' or 'n' or use the bsddb.db.DB_* flags"
def open(filename, flags=db.DB_CREATE, mode=0660, filetype=db.DB_HASH, dbenv=None, dbname=None): """ A simple factory function for compatibility with the standard shleve.py module. It can be used like this, where key is a string and data is a pickleable object: from bsddb import dbshelve db = dbshelve.open(filename) db[key] = data db.close() """ if type(flags) == type(''): sflag = flags if sflag == 'r': flags = db.DB_RDONLY elif sflag == 'rw': flags = 0 elif sflag == 'w': flags = db.DB_CREATE elif sflag == 'c': flags = db.DB_CREATE elif sflag == 'n': flags = db.DB_TRUNCATE | db.DB_CREATE else: raise error, "flags should be one of 'r', 'w', 'c' or 'n' or use the bsddb.db.DB_* flags" d = DBShelf(dbenv) d.open(filename, dbname, filetype, flags, mode) return d
1281f76606cc4195f57d3446b42b97063c3adc1d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1281f76606cc4195f57d3446b42b97063c3adc1d/dbshelve.py
data = cPickle.dumps(value, self.binary) return self.db.append(data, txn)
if self.get_type() != db.DB_RECNO: self.append = self.__append return self.append(value, txn=txn) raise db.DBError, "append() only supported when dbshelve opened with filetype=dbshelve.db.DB_RECNO"
def append(self, value, txn=None): data = cPickle.dumps(value, self.binary) return self.db.append(data, txn)
1281f76606cc4195f57d3446b42b97063c3adc1d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1281f76606cc4195f57d3446b42b97063c3adc1d/dbshelve.py
if os.sep != '/' and os.sep in pathname: raise ValueError, \ "path '%s' cannot contain '%c' character" % \ (pathname, os.sep) paths = string.split (pathname, '/') return apply (os.path.join, paths)
if os.sep != '/': if os.sep in pathname: raise ValueError, \ "path '%s' cannot contain '%c' character" % (pathname, os.sep) else: paths = string.split (pathname, '/') return apply (os.path.join, paths)
def native_path (pathname): """Return 'pathname' as a name that will work on the native filesystem, i.e. split it on '/' and put it back together again using the current directory separator. Needed because filenames in the setup script are always supplied in Unix style, and have to be converted to the local convention before we can actually use them in the filesystem. Raises ValueError if 'pathname' is absolute (starts with '/') or contains local directory separators (unless the local separator is '/', of course).""" if pathname[0] == '/': raise ValueError, "path '%s' cannot be absolute" % pathname if pathname[-1] == '/': raise ValueError, "path '%s' cannot end with '/'" % pathname if os.sep != '/' and os.sep in pathname: raise ValueError, \ "path '%s' cannot contain '%c' character" % \ (pathname, os.sep) paths = string.split (pathname, '/') return apply (os.path.join, paths) else: return pathname
464023fb64dd590b91cab7059dffdf0756eecbce /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/464023fb64dd590b91cab7059dffdf0756eecbce/util.py
s = "\\pdfoutline goto name{page.%d}" % pageno
s = "\\pdfoutline goto name{page.%dx}" % pageno
def write_toc_entry(entry, fp, layer): stype, snum, title, pageno, toc = entry s = "\\pdfoutline goto name{page.%d}" % pageno if toc: s = "%s count -%d" % (s, len(toc)) if snum: title = "%s %s" % (snum, title) s = "%s {%s}\n" % (s, title) fp.write(s) for entry in toc: write_toc_entry(entry, fp, layer + 1)
a88d681255b8f4d5883e9ad245f00dae15c5c473 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a88d681255b8f4d5883e9ad245f00dae15c5c473/toc2bkm.py
try:
def __repr__ (self): try: status = [self.__class__.__module__+"."+self.__class__.__name__] if self.accepting and self.addr: status.append ('listening') elif self.connected: status.append ('connected') if self.addr: if type(self.addr) == types.TupleType: status.append ('%s:%d' % self.addr) else: status.append (self.addr) return '<%s at %#x>' % (' '.join (status), id (self)) except: pass
eee80ee2efa5288b3e30d3336a9fce0ebdde68eb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/eee80ee2efa5288b3e30d3336a9fce0ebdde68eb/asyncore.py
if self.addr: if type(self.addr) == types.TupleType:
if self.addr is not None: try:
def __repr__ (self): try: status = [self.__class__.__module__+"."+self.__class__.__name__] if self.accepting and self.addr: status.append ('listening') elif self.connected: status.append ('connected') if self.addr: if type(self.addr) == types.TupleType: status.append ('%s:%d' % self.addr) else: status.append (self.addr) return '<%s at %#x>' % (' '.join (status), id (self)) except: pass
eee80ee2efa5288b3e30d3336a9fce0ebdde68eb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/eee80ee2efa5288b3e30d3336a9fce0ebdde68eb/asyncore.py
else: status.append (self.addr)
except TypeError: status.append (repr(self.addr))
def __repr__ (self): try: status = [self.__class__.__module__+"."+self.__class__.__name__] if self.accepting and self.addr: status.append ('listening') elif self.connected: status.append ('connected') if self.addr: if type(self.addr) == types.TupleType: status.append ('%s:%d' % self.addr) else: status.append (self.addr) return '<%s at %#x>' % (' '.join (status), id (self)) except: pass
eee80ee2efa5288b3e30d3336a9fce0ebdde68eb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/eee80ee2efa5288b3e30d3336a9fce0ebdde68eb/asyncore.py
except: pass try: ar = repr (self.addr) except AttributeError: ar = 'no self.addr!' return '<__repr__() failed for %s instance at %x (addr=%s)>' % \ (self.__class__.__name__, id (self), ar)
def __repr__ (self): try: status = [self.__class__.__module__+"."+self.__class__.__name__] if self.accepting and self.addr: status.append ('listening') elif self.connected: status.append ('connected') if self.addr: if type(self.addr) == types.TupleType: status.append ('%s:%d' % self.addr) else: status.append (self.addr) return '<%s at %#x>' % (' '.join (status), id (self)) except: pass
eee80ee2efa5288b3e30d3336a9fce0ebdde68eb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/eee80ee2efa5288b3e30d3336a9fce0ebdde68eb/asyncore.py
"verify we can open a file known to be a hash v2 file"
def test_open_existing_hash(self): "verify we can open a file known to be a hash v2 file" db = bsddb185.hashopen(findfile("185test.db")) self.assertEqual(db["1"], "1") db.close()
065f7b8626ac2cc7be26a3cc1bd5d9ba51b5125d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/065f7b8626ac2cc7be26a3cc1bd5d9ba51b5125d/test_bsddb185.py
"verify that whichdb correctly sniffs the known hash v2 file"
def test_whichdb(self): "verify that whichdb correctly sniffs the known hash v2 file" self.assertEqual(whichdb.whichdb(findfile("185test.db")), "bsddb185")
065f7b8626ac2cc7be26a3cc1bd5d9ba51b5125d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/065f7b8626ac2cc7be26a3cc1bd5d9ba51b5125d/test_bsddb185.py
"verify that anydbm.open does *not* create a bsddb185 file"
def test_anydbm_create(self): "verify that anydbm.open does *not* create a bsddb185 file" tmpdir = tempfile.mkdtemp() try: try: dbfile = os.path.join(tmpdir, "foo.db") anydbm.open(dbfile, "c").close() ftype = whichdb.whichdb(findfile("foo.db")) self.assertNotEqual(ftype, "bsddb185") finally: os.unlink(dbfile) finally: os.rmdir(tmpdir)
065f7b8626ac2cc7be26a3cc1bd5d9ba51b5125d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/065f7b8626ac2cc7be26a3cc1bd5d9ba51b5125d/test_bsddb185.py
anydbm.open(dbfile, "c").close() ftype = whichdb.whichdb(findfile("foo.db"))
anydbm.open(os.path.splitext(dbfile)[0], "c").close() ftype = whichdb.whichdb(dbfile)
def test_anydbm_create(self): "verify that anydbm.open does *not* create a bsddb185 file" tmpdir = tempfile.mkdtemp() try: try: dbfile = os.path.join(tmpdir, "foo.db") anydbm.open(dbfile, "c").close() ftype = whichdb.whichdb(findfile("foo.db")) self.assertNotEqual(ftype, "bsddb185") finally: os.unlink(dbfile) finally: os.rmdir(tmpdir)
065f7b8626ac2cc7be26a3cc1bd5d9ba51b5125d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/065f7b8626ac2cc7be26a3cc1bd5d9ba51b5125d/test_bsddb185.py
while not os.path.isdir(":Mac:Plugins"):
while not os.path.isdir(":Mac:PlugIns"):
def gotopluginfolder(): """Go to the plugin folder, assuming we are somewhere in the Python tree""" import os while not os.path.isdir(":Mac:Plugins"): os.chdir("::") os.chdir(":Mac:Plugins") if verbose: print "current directory is", os.getcwd()
786cb11e51ecc5b2cf402badcb3e5f056a65341d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/786cb11e51ecc5b2cf402badcb3e5f056a65341d/ConfigurePython.py
os.chdir(":Mac:Plugins")
os.chdir(":Mac:PlugIns")
def gotopluginfolder(): """Go to the plugin folder, assuming we are somewhere in the Python tree""" import os while not os.path.isdir(":Mac:Plugins"): os.chdir("::") os.chdir(":Mac:Plugins") if verbose: print "current directory is", os.getcwd()
786cb11e51ecc5b2cf402badcb3e5f056a65341d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/786cb11e51ecc5b2cf402badcb3e5f056a65341d/ConfigurePython.py
if not os.path.exists(src): if not os.path.exists(altsrc):
if not os.path.exists(os.path.join(sys.exec_prefix, src)): if not os.path.exists(os.path.join(sys.exec_prefix, altsrc)):
def mkcorealias(src, altsrc): import string import macostools version = string.split(sys.version)[0] dst = getextensiondirfile(src+ ' ' + version) if not os.path.exists(src): if not os.path.exists(altsrc): if verbose: print '*', src, 'not found' return 0 src = altsrc try: os.unlink(dst) except os.error: pass macostools.mkalias(src, dst) if verbose: print ' ', dst, '->', src return 1
786cb11e51ecc5b2cf402badcb3e5f056a65341d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/786cb11e51ecc5b2cf402badcb3e5f056a65341d/ConfigurePython.py
macostools.mkalias(src, dst)
macostools.mkalias(os.path.join(sys.exec_prefix, src), dst)
def mkcorealias(src, altsrc): import string import macostools version = string.split(sys.version)[0] dst = getextensiondirfile(src+ ' ' + version) if not os.path.exists(src): if not os.path.exists(altsrc): if verbose: print '*', src, 'not found' return 0 src = altsrc try: os.unlink(dst) except os.error: pass macostools.mkalias(src, dst) if verbose: print ' ', dst, '->', src return 1
786cb11e51ecc5b2cf402badcb3e5f056a65341d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/786cb11e51ecc5b2cf402badcb3e5f056a65341d/ConfigurePython.py
from distutils.core import DEBUG
def parse_config_files (self, filenames=None):
7146073850f16465b1888ad46e7dd4072f0a31cd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7146073850f16465b1888ad46e7dd4072f0a31cd/dist.py
from distutils.core import DEBUG
def get_command_obj (self, command, create=1): """Return the command object for 'command'. Normally this object is cached on a previous call to 'get_command_obj()'; if no command object for 'command' is in the cache, then we either create and return it (if 'create' is true) or return None. """ from distutils.core import DEBUG cmd_obj = self.command_obj.get(command) if not cmd_obj and create: if DEBUG: print "Distribution.get_command_obj(): " \ "creating '%s' command object" % command
7146073850f16465b1888ad46e7dd4072f0a31cd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7146073850f16465b1888ad46e7dd4072f0a31cd/dist.py
from distutils.core import DEBUG
def _set_command_options (self, command_obj, option_dict=None): """Set the options for 'command_obj' from 'option_dict'. Basically this means copying elements of a dictionary ('option_dict') to attributes of an instance ('command').
7146073850f16465b1888ad46e7dd4072f0a31cd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7146073850f16465b1888ad46e7dd4072f0a31cd/dist.py
def small(text): return '<small>' + text + '</small>' def strong(text): return '<strong>' + text + '</strong>' def grey(text): return '<font color="
def small(text): if text: return '<small>' + text + '</small>' else: return '' def strong(text): if text: return '<strong>' + text + '</strong>' else: return '' def grey(text): if text: return '<font color=" else: return ''
def small(text): return '<small>' + text + '</small>'
5fcefdb32600fa64d3160f031d48fb033150fdb3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5fcefdb32600fa64d3160f031d48fb033150fdb3/cgitb.py
'<big><big><strong>%s</strong></big></big>' % str(etype),
'<big><big>%s</big></big>' % strong(pydoc.html.escape(str(etype))),
def html((etype, evalue, etb), context=5): """Return a nice HTML document describing a given traceback.""" import os, types, time, traceback, linecache, inspect, pydoc if type(etype) is types.ClassType: etype = etype.__name__ pyver = 'Python ' + sys.version.split()[0] + ': ' + sys.executable date = time.ctime(time.time()) head = '<body bgcolor="#f0f0f8">' + pydoc.html.heading( '<big><big><strong>%s</strong></big></big>' % str(etype), '#ffffff', '#6622aa', pyver + '<br>' + date) + '''
5fcefdb32600fa64d3160f031d48fb033150fdb3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5fcefdb32600fa64d3160f031d48fb033150fdb3/cgitb.py
function calls leading up to the error, in the order they occurred.'''
function calls leading up to the error, in the order they occurred.</p>'''
def html((etype, evalue, etb), context=5): """Return a nice HTML document describing a given traceback.""" import os, types, time, traceback, linecache, inspect, pydoc if type(etype) is types.ClassType: etype = etype.__name__ pyver = 'Python ' + sys.version.split()[0] + ': ' + sys.executable date = time.ctime(time.time()) head = '<body bgcolor="#f0f0f8">' + pydoc.html.heading( '<big><big><strong>%s</strong></big></big>' % str(etype), '#ffffff', '#6622aa', pyver + '<br>' + date) + '''
5fcefdb32600fa64d3160f031d48fb033150fdb3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5fcefdb32600fa64d3160f031d48fb033150fdb3/cgitb.py
frames.append('''<p>
frames.append('''
def reader(lnum=[lnum]): highlight[lnum[0]] = 1 try: return linecache.getline(file, lnum[0]) finally: lnum[0] += 1
5fcefdb32600fa64d3160f031d48fb033150fdb3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5fcefdb32600fa64d3160f031d48fb033150fdb3/cgitb.py
register("gnome", None, BackgroundBrowser(commd))
register("gnome", None, BackgroundBrowser(commd.split()))
def register_X_browsers(): # The default Gnome browser if _iscommand("gconftool-2"): # get the web browser string from gconftool gc = 'gconftool-2 -g /desktop/gnome/url-handlers/http/command 2>/dev/null' out = os.popen(gc) commd = out.read().strip() retncode = out.close() # if successful, register it if retncode is None and commd: register("gnome", None, BackgroundBrowser(commd)) # First, the Mozilla/Netscape browsers for browser in ("mozilla-firefox", "firefox", "mozilla-firebird", "firebird", "seamonkey", "mozilla", "netscape"): if _iscommand(browser): register(browser, None, Mozilla(browser)) # Konqueror/kfm, the KDE browser. if _iscommand("kfm"): register("kfm", Konqueror, Konqueror("kfm")) elif _iscommand("konqueror"): register("konqueror", Konqueror, Konqueror("konqueror")) # Gnome's Galeon and Epiphany for browser in ("galeon", "epiphany"): if _iscommand(browser): register(browser, None, Galeon(browser)) # Skipstone, another Gtk/Mozilla based browser if _iscommand("skipstone"): register("skipstone", None, BackgroundBrowser("skipstone")) # Opera, quite popular if _iscommand("opera"): register("opera", None, Opera("opera")) # Next, Mosaic -- old but still in use. if _iscommand("mosaic"): register("mosaic", None, BackgroundBrowser("mosaic")) # Grail, the Python browser. Does anybody still use it? if _iscommand("grail"): register("grail", Grail, None)
bbcb2814f2745ddd652480c3a932911680881544 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/bbcb2814f2745ddd652480c3a932911680881544/webbrowser.py
def user_line(self, frame): # get the currently executing function ##print>>sys.__stderr__, "*function: ", frame.f_code.co_name ##print>>sys.__stderr__, "*file: ", frame.f_code.co_filename ##print>>sys.__stderr__, "*line number: ", frame.f_code.co_firstlineno co_filename = frame.f_code.co_filename co_name = frame.f_code.co_name try: func = frame.f_locals[co_name] if getattr(func, "DebuggerStepThrough", 0): print "XXXX DEBUGGER STEPPING THROUGH" self.set_step() return except: pass if co_filename in ('rpc.py', '<string>'): self.set_step() return if co_filename.endswith('threading.py'): self.set_step() return message = self.__frame2message(frame) self.gui.interaction(message, frame)
067d734f9e54fa7685ab9bd44e2221c04a52f292 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/067d734f9e54fa7685ab9bd44e2221c04a52f292/Debugger.py
if co_filename in ('rpc.py', '<string>'):
if co_filename in (r'.\rpc.py', 'rpc.py','<string>'):
def user_line(self, frame): # get the currently executing function ##print>>sys.__stderr__, "*function: ", frame.f_code.co_name ##print>>sys.__stderr__, "*file: ", frame.f_code.co_filename ##print>>sys.__stderr__, "*line number: ", frame.f_code.co_firstlineno co_filename = frame.f_code.co_filename co_name = frame.f_code.co_name try: func = frame.f_locals[co_name] if getattr(func, "DebuggerStepThrough", 0): print "XXXX DEBUGGER STEPPING THROUGH" self.set_step() return except: pass if co_filename in ('rpc.py', '<string>'): self.set_step() return if co_filename.endswith('threading.py'): self.set_step() return message = self.__frame2message(frame) self.gui.interaction(message, frame)
067d734f9e54fa7685ab9bd44e2221c04a52f292 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/067d734f9e54fa7685ab9bd44e2221c04a52f292/Debugger.py
lines = f.readlines()
lines = [] line = f.readline() while line: lines.append(line.strip()) line = f.readline()
def read(self): opener = URLopener() f = opener.open(self.url) lines = f.readlines() self.errcode = opener.errcode if self.errcode == 401 or self.errcode == 403: self.disallow_all = 1 _debug("disallow all") elif self.errcode >= 400: self.allow_all = 1 _debug("allow all") elif self.errcode == 200 and lines: _debug("parse lines") self.parse(lines)
d22368ffb368198320d29518264a64a87b4f9b03 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d22368ffb368198320d29518264a64a87b4f9b03/robotparser.py
line = line.strip()
def parse(self, lines): """parse the input lines from a robot.txt file. We allow that a user-agent: line is not preceded by one or more blank lines.""" state = 0 linenumber = 0 entry = Entry()
d22368ffb368198320d29518264a64a87b4f9b03 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d22368ffb368198320d29518264a64a87b4f9b03/robotparser.py
self.tries = 0 self.maxtries = 10
def __init__(self, *args): apply(urllib.FancyURLopener.__init__, (self,) + args) self.errcode = 200 self.tries = 0 self.maxtries = 10
d22368ffb368198320d29518264a64a87b4f9b03 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d22368ffb368198320d29518264a64a87b4f9b03/robotparser.py
def http_error_302(self, url, fp, errcode, errmsg, headers, data=None): self.tries += 1 if self.tries >= self.maxtries: return self.http_error_default(url, fp, 500, "Internal Server Error: Redirect Recursion", headers) result = urllib.FancyURLopener.http_error_302(self, url, fp, errcode, errmsg, headers, data) self.tries = 0 return result
def http_error_default(self, url, fp, errcode, errmsg, headers): self.errcode = errcode return urllib.FancyURLopener.http_error_default(self, url, fp, errcode, errmsg, headers)
d22368ffb368198320d29518264a64a87b4f9b03 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d22368ffb368198320d29518264a64a87b4f9b03/robotparser.py
frozendllmain_c, extensions_c] + files
frozendllmain_c, os.path.basename(extensions_c)] + files
def main(): # overridable context prefix = None # settable with -p option exec_prefix = None # settable with -P option extensions = [] exclude = [] # settable with -x option addn_link = [] # settable with -l, but only honored under Windows. path = sys.path[:] modargs = 0 debug = 1 odir = '' win = sys.platform[:3] == 'win' # default the exclude list for each platform if win: exclude = exclude + [ 'dos', 'dospath', 'mac', 'macpath', 'macfs', 'MACFS', 'posix', 'os2'] # modules that are imported by the Python runtime implicits = ["site", "exceptions"] # output files frozen_c = 'frozen.c' config_c = 'config.c' target = 'a.out' # normally derived from script name makefile = 'Makefile' subsystem = 'console' # parse command line by first replacing any "-i" options with the file contents. pos = 1 while pos < len(sys.argv)-1: # last option can not be "-i", so this ensures "pos+1" is in range! if sys.argv[pos] == '-i': try: options = string.split(open(sys.argv[pos+1]).read()) except IOError, why: usage("File name '%s' specified with the -i option can not be read - %s" % (sys.argv[pos+1], why) ) # Replace the '-i' and the filename with the read params. sys.argv[pos:pos+2] = options pos = pos + len(options) - 1 # Skip the name and the included args. pos = pos + 1 # Now parse the command line with the extras inserted. try: opts, args = getopt.getopt(sys.argv[1:], 'a:de:hmo:p:P:qs:wx:l:') except getopt.error, msg: usage('getopt error: ' + str(msg)) # proces option arguments for o, a in opts: if o == '-h': print __doc__ return if o == '-d': debug = debug + 1 if o == '-e': extensions.append(a) if o == '-m': modargs = 1 if o == '-o': odir = a if o == '-p': prefix = a if o == '-P': exec_prefix = a if o == '-q': debug = 0 if o == '-w': win = not win if o == '-s': if not win: usage("-s subsystem option only on Windows") subsystem = a if o == '-x': exclude.append(a) if o == '-l': addn_link.append(a) if o == '-a': apply(modulefinder.AddPackagePath, tuple(string.split(a,"=", 2))) # default prefix and exec_prefix if not exec_prefix: if prefix: exec_prefix = prefix else: exec_prefix = sys.exec_prefix if not prefix: prefix = sys.prefix # determine whether -p points to the Python source tree ishome = os.path.exists(os.path.join(prefix, 'Python', 'ceval.c')) # locations derived from options version = sys.version[:3] if win: extensions_c = 'frozen_extensions.c' if ishome: print "(Using Python source directory)" binlib = exec_prefix incldir = os.path.join(prefix, 'Include') config_h_dir = exec_prefix config_c_in = os.path.join(prefix, 'Modules', 'config.c.in') frozenmain_c = os.path.join(prefix, 'Python', 'frozenmain.c') makefile_in = os.path.join(exec_prefix, 'Modules', 'Makefile') if win: frozendllmain_c = os.path.join(exec_prefix, 'Pc\\frozen_dllmain.c') else: binlib = os.path.join(exec_prefix, 'lib', 'python%s' % version, 'config') incldir = os.path.join(prefix, 'include', 'python%s' % version) config_h_dir = os.path.join(exec_prefix, 'include', 'python%s' % version) config_c_in = os.path.join(binlib, 'config.c.in') frozenmain_c = os.path.join(binlib, 'frozenmain.c') makefile_in = os.path.join(binlib, 'Makefile') frozendllmain_c = os.path.join(binlib, 'frozen_dllmain.c') supp_sources = [] defines = [] includes = ['-I' + incldir, '-I' + config_h_dir] # sanity check of directories and files check_dirs = [prefix, exec_prefix, binlib, incldir] if not win: check_dirs = check_dirs + extensions # These are not directories on Windows. for dir in check_dirs: if not os.path.exists(dir): usage('needed directory %s not found' % dir) if not os.path.isdir(dir): usage('%s: not a directory' % dir) if win: files = supp_sources + extensions # extensions are files on Windows. else: files = [config_c_in, makefile_in] + supp_sources for file in supp_sources: if not os.path.exists(file): usage('needed file %s not found' % file) if not os.path.isfile(file): usage('%s: not a plain file' % file) if not win: for dir in extensions: setup = os.path.join(dir, 'Setup') if not os.path.exists(setup): usage('needed file %s not found' % setup) if not os.path.isfile(setup): usage('%s: not a plain file' % setup) # check that enough arguments are passed if not args: usage('at least one filename argument required') # check that file arguments exist for arg in args: if arg == '-m': break # if user specified -m on the command line before _any_ # file names, then nothing should be checked (as the # very first file should be a module name) if modargs: break if not os.path.exists(arg): usage('argument %s not found' % arg) if not os.path.isfile(arg): usage('%s: not a plain file' % arg) # process non-option arguments scriptfile = args[0] modules = args[1:] # derive target name from script name base = os.path.basename(scriptfile) base, ext = os.path.splitext(base) if base: if base != scriptfile: target = base else: target = base + '.bin' # handle -o option base_frozen_c = frozen_c base_config_c = config_c base_target = target if odir and not os.path.isdir(odir): try: os.mkdir(odir) print "Created output directory", odir except os.error, msg: usage('%s: mkdir failed (%s)' % (odir, str(msg))) base = '' if odir: base = os.path.join(odir, '') frozen_c = os.path.join(odir, frozen_c) config_c = os.path.join(odir, config_c) target = os.path.join(odir, target) makefile = os.path.join(odir, makefile) if win: extensions_c = os.path.join(odir, extensions_c) # Handle special entry point requirements # (on Windows, some frozen programs do not use __main__, but # import the module directly. Eg, DLLs, Services, etc custom_entry_point = None # Currently only used on Windows python_entry_is_main = 1 # Is the entry point called __main__? # handle -s option on Windows if win: import winmakemakefile try: custom_entry_point, python_entry_is_main = \ winmakemakefile.get_custom_entry_point(subsystem) except ValueError, why: usage(why) # Actual work starts here... # collect all modules of the program dir = os.path.dirname(scriptfile) path[0] = dir mf = modulefinder.ModuleFinder(path, debug, exclude) if win and subsystem=='service': # If a Windows service, then add the "built-in" module. mod = mf.add_module("servicemanager") mod.__file__="dummy.pyd" # really built-in to the resulting EXE for mod in implicits: mf.import_hook(mod) for mod in modules: if mod == '-m': modargs = 1 continue if modargs: if mod[-2:] == '.*': mf.import_hook(mod[:-2], None, ["*"]) else: mf.import_hook(mod) else: mf.load_file(mod) # Add the main script as either __main__, or the actual module name. if python_entry_is_main: mf.run_script(scriptfile) else: if modargs: mf.import_hook(scriptfile) else: mf.load_file(scriptfile) if debug > 0: mf.report() print dict = mf.modules # generate output for frozen modules files = makefreeze.makefreeze(base, dict, debug, custom_entry_point) # look for unfrozen modules (builtin and of unknown origin) builtins = [] unknown = [] mods = dict.keys() mods.sort() for mod in mods: if dict[mod].__code__: continue if not dict[mod].__file__: builtins.append(mod) else: unknown.append(mod) # search for unknown modules in extensions directories (not on Windows) addfiles = [] frozen_extensions = [] # Windows list of modules. if unknown or (not win and builtins): if not win: addfiles, addmods = \ checkextensions.checkextensions(unknown+builtins, extensions) for mod in addmods: if mod in unknown: unknown.remove(mod) builtins.append(mod) else: # Do the windows thang... import checkextensions_win32 # Get a list of CExtension instances, each describing a module # (including its source files) frozen_extensions = checkextensions_win32.checkextensions( unknown, extensions) for mod in frozen_extensions: unknown.remove(mod.name) # report unknown modules if unknown: sys.stderr.write('Warning: unknown modules remain: %s\n' % string.join(unknown)) # windows gets different treatment if win: # Taking a shortcut here... import winmakemakefile, checkextensions_win32 checkextensions_win32.write_extension_table(extensions_c, frozen_extensions) # Create a module definition for the bootstrap C code. xtras = [frozenmain_c, os.path.basename(frozen_c), frozendllmain_c, extensions_c] + files maindefn = checkextensions_win32.CExtension( '__main__', xtras ) frozen_extensions.append( maindefn ) outfp = open(makefile, 'w') try: winmakemakefile.makemakefile(outfp, locals(), frozen_extensions, os.path.basename(target)) finally: outfp.close() return # generate config.c and Makefile builtins.sort() infp = open(config_c_in) outfp = bkfile.open(config_c, 'w') try: makeconfig.makeconfig(infp, outfp, builtins) finally: outfp.close() infp.close() cflags = defines + includes + ['$(OPT)'] libs = [os.path.join(binlib, 'libpython$(VERSION).a')] somevars = {} if os.path.exists(makefile_in): makevars = parsesetup.getmakevars(makefile_in) for key in makevars.keys(): somevars[key] = makevars[key] somevars['CFLAGS'] = string.join(cflags) # override files = ['$(OPT)', '$(LDFLAGS)', base_config_c, base_frozen_c] + \ files + supp_sources + addfiles + libs + \ ['$(MODLIBS)', '$(LIBS)', '$(SYSLIBS)'] outfp = bkfile.open(makefile, 'w') try: makemakefile.makemakefile(outfp, somevars, files, base_target) finally: outfp.close() # Done! if odir: print 'Now run "make" in', odir, print 'to build the target:', base_target else: print 'Now run "make" to build the target:', base_target
7039f50828473a030123d2bc2990532bcac9b5d9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7039f50828473a030123d2bc2990532bcac9b5d9/freeze.py
def split(p): d, p = splitdrive(p) slashes = '' while p and p[-1:] in '/\\': slashes = slashes + p[-1] p = p[:-1] if p == '': p = p + slashes head, tail = '', '' for c in p: tail = tail + c if c in '/\\': head, tail = head + tail, '' slashes = '' while head and head[-1:] in '/\\': slashes = slashes + head[-1] head = head[:-1] if head == '': head = head + slashes return d + head, tail
73e122f56383e15dc8045caeb5cc853430dd96e9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/73e122f56383e15dc8045caeb5cc853430dd96e9/ntpath.py
if c in '/\\':
if c in ['/','\\']:
def splitext(p): root, ext = '', '' for c in p: if c in '/\\': root, ext = root + ext + c, '' elif c == '.' or ext: ext = ext + c else: root = root + c return root, ext
73e122f56383e15dc8045caeb5cc853430dd96e9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/73e122f56383e15dc8045caeb5cc853430dd96e9/ntpath.py
elif c == '.' or ext:
elif c == '.': if ext: root, ext = root + ext, c else: ext = c elif ext:
def splitext(p): root, ext = '', '' for c in p: if c in '/\\': root, ext = root + ext + c, '' elif c == '.' or ext: ext = ext + c else: root = root + c return root, ext
73e122f56383e15dc8045caeb5cc853430dd96e9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/73e122f56383e15dc8045caeb5cc853430dd96e9/ntpath.py
save_warnings_filters = warnings.filters[:] globals = func.func_globals if '__warningregistry__' in globals: del globals['__warningregistry__'] warnings.filterwarnings("error", r"""^struct.*""", DeprecationWarning) warnings.filterwarnings("error", r""".*format requires.*""", DeprecationWarning)
def deprecated_err(func, *args): # The `warnings` module doesn't have an advertised way to restore # its filter list. Cheat. save_warnings_filters = warnings.filters[:] # Grrr, we need this function to warn every time. Without removing # the warningregistry, running test_tarfile then test_struct would fail # on 64-bit platforms. globals = func.func_globals if '__warningregistry__' in globals: del globals['__warningregistry__'] warnings.filterwarnings("error", r"""^struct.*""", DeprecationWarning) warnings.filterwarnings("error", r""".*format requires.*""", DeprecationWarning) try: try: func(*args) except (struct.error, TypeError): pass except DeprecationWarning: if not PY_STRUCT_OVERFLOW_MASKING: raise TestFailed, "%s%s expected to raise struct.error" % ( func.__name__, args) else: raise TestFailed, "%s%s did not raise error" % ( func.__name__, args) finally: warnings.filters[:] = save_warnings_filters[:]
e6c9f982a057208e15f884384ba389778b8518c0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e6c9f982a057208e15f884384ba389778b8518c0/test_struct.py
try: func(*args) except (struct.error, TypeError): pass except DeprecationWarning: if not PY_STRUCT_OVERFLOW_MASKING: raise TestFailed, "%s%s expected to raise struct.error" % ( func.__name__, args) else: raise TestFailed, "%s%s did not raise error" % (
func(*args) except (struct.error, TypeError): pass except DeprecationWarning: if not PY_STRUCT_OVERFLOW_MASKING: raise TestFailed, "%s%s expected to raise struct.error" % (
def deprecated_err(func, *args): # The `warnings` module doesn't have an advertised way to restore # its filter list. Cheat. save_warnings_filters = warnings.filters[:] # Grrr, we need this function to warn every time. Without removing # the warningregistry, running test_tarfile then test_struct would fail # on 64-bit platforms. globals = func.func_globals if '__warningregistry__' in globals: del globals['__warningregistry__'] warnings.filterwarnings("error", r"""^struct.*""", DeprecationWarning) warnings.filterwarnings("error", r""".*format requires.*""", DeprecationWarning) try: try: func(*args) except (struct.error, TypeError): pass except DeprecationWarning: if not PY_STRUCT_OVERFLOW_MASKING: raise TestFailed, "%s%s expected to raise struct.error" % ( func.__name__, args) else: raise TestFailed, "%s%s did not raise error" % ( func.__name__, args) finally: warnings.filters[:] = save_warnings_filters[:]
e6c9f982a057208e15f884384ba389778b8518c0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e6c9f982a057208e15f884384ba389778b8518c0/test_struct.py
finally: warnings.filters[:] = save_warnings_filters[:]
else: raise TestFailed, "%s%s did not raise error" % ( func.__name__, args) deprecated_err = with_warning_restore(deprecated_err)
def deprecated_err(func, *args): # The `warnings` module doesn't have an advertised way to restore # its filter list. Cheat. save_warnings_filters = warnings.filters[:] # Grrr, we need this function to warn every time. Without removing # the warningregistry, running test_tarfile then test_struct would fail # on 64-bit platforms. globals = func.func_globals if '__warningregistry__' in globals: del globals['__warningregistry__'] warnings.filterwarnings("error", r"""^struct.*""", DeprecationWarning) warnings.filterwarnings("error", r""".*format requires.*""", DeprecationWarning) try: try: func(*args) except (struct.error, TypeError): pass except DeprecationWarning: if not PY_STRUCT_OVERFLOW_MASKING: raise TestFailed, "%s%s expected to raise struct.error" % ( func.__name__, args) else: raise TestFailed, "%s%s did not raise error" % ( func.__name__, args) finally: warnings.filters[:] = save_warnings_filters[:]
e6c9f982a057208e15f884384ba389778b8518c0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e6c9f982a057208e15f884384ba389778b8518c0/test_struct.py