rem
stringlengths 1
322k
| add
stringlengths 0
2.05M
| context
stringlengths 4
228k
| meta
stringlengths 156
215
|
---|---|---|---|
def test_both(): "Test mmap module on Unix systems and Windows" # Create an mmap'ed file f = open('foo', 'w+') # Write 2 pages worth of data to the file f.write('\0'* PAGESIZE) f.write('foo') f.write('\0'* (PAGESIZE-3) ) m = mmap.mmap(f.fileno(), 2 * PAGESIZE) f.close() # Simple sanity checks print ' Position of foo:', string.find(m, 'foo') / float(PAGESIZE), 'pages' assert string.find(m, 'foo') == PAGESIZE print ' Length of file:', len(m) / float(PAGESIZE), 'pages' assert len(m) == 2*PAGESIZE print ' Contents of byte 0:', repr(m[0]) assert m[0] == '\0' print ' Contents of first 3 bytes:', repr(m[0:3]) assert m[0:3] == '\0\0\0' # Modify the file's content print "\n Modifying file's content..." m[0] = '3' m[PAGESIZE +3: PAGESIZE +3+3]='bar' # Check that the modification worked print ' Contents of byte 0:', repr(m[0]) assert m[0] == '3' print ' Contents of first 3 bytes:', repr(m[0:3]) assert m[0:3] == '3\0\0' print ' Contents of second page:', m[PAGESIZE-1 : PAGESIZE + 7] assert m[PAGESIZE-1 : PAGESIZE + 7] == '\0foobar\0' m.flush() # Test doing a regular expression match in an mmap'ed file match=re.search('[A-Za-z]+', m) if match == None: print ' ERROR: regex match on mmap failed!' else: start, end = match.span(0) length = end - start print ' Regex match on mmap (page start, length of match):', print start / float(PAGESIZE), length assert start == PAGESIZE assert end == PAGESIZE + 6 # test seeking around (try to overflow the seek implementation) m.seek(0,0) print ' Seek to zeroth byte' assert m.tell() == 0 m.seek(42,1) print ' Seek to 42nd byte' assert m.tell() == 42 m.seek(0,2) print ' Seek to last byte' assert m.tell() == len(m) print ' Try to seek to negative position...' try: m.seek(-1) except ValueError: pass else: assert 0, 'expected a ValueError but did not get it' print ' Try to seek beyond end of mmap...' try: m.seek(1,2) except ValueError: pass else: assert 0, 'expected a ValueError but did not get it' print ' Try to seek to negative position...' try: m.seek(-len(m)-1,2) except ValueError: pass else: assert 0, 'expected a ValueError but did not get it' # Try resizing map print ' Attempting resize()' try: m.resize( 512 ) except SystemError: # resize() not supported # No messages are printed, since the output of this test suite # would then be different across platforms. pass else: # resize() is supported pass m.close() os.unlink("foo") print ' Test passed'
|
7a11671e8b61dcf653d70db714813fba23afc884 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7a11671e8b61dcf653d70db714813fba23afc884/test_mmap.py
|
||
m.resize( 512 )
|
m.resize( 512 )
|
def test_both(): "Test mmap module on Unix systems and Windows" # Create an mmap'ed file f = open('foo', 'w+') # Write 2 pages worth of data to the file f.write('\0'* PAGESIZE) f.write('foo') f.write('\0'* (PAGESIZE-3) ) m = mmap.mmap(f.fileno(), 2 * PAGESIZE) f.close() # Simple sanity checks print ' Position of foo:', string.find(m, 'foo') / float(PAGESIZE), 'pages' assert string.find(m, 'foo') == PAGESIZE print ' Length of file:', len(m) / float(PAGESIZE), 'pages' assert len(m) == 2*PAGESIZE print ' Contents of byte 0:', repr(m[0]) assert m[0] == '\0' print ' Contents of first 3 bytes:', repr(m[0:3]) assert m[0:3] == '\0\0\0' # Modify the file's content print "\n Modifying file's content..." m[0] = '3' m[PAGESIZE +3: PAGESIZE +3+3]='bar' # Check that the modification worked print ' Contents of byte 0:', repr(m[0]) assert m[0] == '3' print ' Contents of first 3 bytes:', repr(m[0:3]) assert m[0:3] == '3\0\0' print ' Contents of second page:', m[PAGESIZE-1 : PAGESIZE + 7] assert m[PAGESIZE-1 : PAGESIZE + 7] == '\0foobar\0' m.flush() # Test doing a regular expression match in an mmap'ed file match=re.search('[A-Za-z]+', m) if match == None: print ' ERROR: regex match on mmap failed!' else: start, end = match.span(0) length = end - start print ' Regex match on mmap (page start, length of match):', print start / float(PAGESIZE), length assert start == PAGESIZE assert end == PAGESIZE + 6 # test seeking around (try to overflow the seek implementation) m.seek(0,0) print ' Seek to zeroth byte' assert m.tell() == 0 m.seek(42,1) print ' Seek to 42nd byte' assert m.tell() == 42 m.seek(0,2) print ' Seek to last byte' assert m.tell() == len(m) print ' Try to seek to negative position...' try: m.seek(-1) except ValueError: pass else: assert 0, 'expected a ValueError but did not get it' print ' Try to seek beyond end of mmap...' try: m.seek(1,2) except ValueError: pass else: assert 0, 'expected a ValueError but did not get it' print ' Try to seek to negative position...' try: m.seek(-len(m)-1,2) except ValueError: pass else: assert 0, 'expected a ValueError but did not get it' # Try resizing map print ' Attempting resize()' try: m.resize( 512 ) except SystemError: # resize() not supported # No messages are printed, since the output of this test suite # would then be different across platforms. pass else: # resize() is supported pass m.close() os.unlink("foo") print ' Test passed'
|
7a11671e8b61dcf653d70db714813fba23afc884 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7a11671e8b61dcf653d70db714813fba23afc884/test_mmap.py
|
def test_both(): "Test mmap module on Unix systems and Windows" # Create an mmap'ed file f = open('foo', 'w+') # Write 2 pages worth of data to the file f.write('\0'* PAGESIZE) f.write('foo') f.write('\0'* (PAGESIZE-3) ) m = mmap.mmap(f.fileno(), 2 * PAGESIZE) f.close() # Simple sanity checks print ' Position of foo:', string.find(m, 'foo') / float(PAGESIZE), 'pages' assert string.find(m, 'foo') == PAGESIZE print ' Length of file:', len(m) / float(PAGESIZE), 'pages' assert len(m) == 2*PAGESIZE print ' Contents of byte 0:', repr(m[0]) assert m[0] == '\0' print ' Contents of first 3 bytes:', repr(m[0:3]) assert m[0:3] == '\0\0\0' # Modify the file's content print "\n Modifying file's content..." m[0] = '3' m[PAGESIZE +3: PAGESIZE +3+3]='bar' # Check that the modification worked print ' Contents of byte 0:', repr(m[0]) assert m[0] == '3' print ' Contents of first 3 bytes:', repr(m[0:3]) assert m[0:3] == '3\0\0' print ' Contents of second page:', m[PAGESIZE-1 : PAGESIZE + 7] assert m[PAGESIZE-1 : PAGESIZE + 7] == '\0foobar\0' m.flush() # Test doing a regular expression match in an mmap'ed file match=re.search('[A-Za-z]+', m) if match == None: print ' ERROR: regex match on mmap failed!' else: start, end = match.span(0) length = end - start print ' Regex match on mmap (page start, length of match):', print start / float(PAGESIZE), length assert start == PAGESIZE assert end == PAGESIZE + 6 # test seeking around (try to overflow the seek implementation) m.seek(0,0) print ' Seek to zeroth byte' assert m.tell() == 0 m.seek(42,1) print ' Seek to 42nd byte' assert m.tell() == 42 m.seek(0,2) print ' Seek to last byte' assert m.tell() == len(m) print ' Try to seek to negative position...' try: m.seek(-1) except ValueError: pass else: assert 0, 'expected a ValueError but did not get it' print ' Try to seek beyond end of mmap...' try: m.seek(1,2) except ValueError: pass else: assert 0, 'expected a ValueError but did not get it' print ' Try to seek to negative position...' try: m.seek(-len(m)-1,2) except ValueError: pass else: assert 0, 'expected a ValueError but did not get it' # Try resizing map print ' Attempting resize()' try: m.resize( 512 ) except SystemError: # resize() not supported # No messages are printed, since the output of this test suite # would then be different across platforms. pass else: # resize() is supported pass m.close() os.unlink("foo") print ' Test passed'
|
7a11671e8b61dcf653d70db714813fba23afc884 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7a11671e8b61dcf653d70db714813fba23afc884/test_mmap.py
|
||
if v == "1": g[n] = 1 else: g[n] = v
|
try: v = string.atoi(v) except ValueError: pass g[n] = v
|
undef_rx = re.compile("/[*] #undef ([A-Z][A-Z0-9_]+) [*]/\n")
|
3c8e54bf6220cd89ec80839161926db9a92e00ba /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3c8e54bf6220cd89ec80839161926db9a92e00ba/sysconfig.py
|
done[name] = value
|
try: value = string.atoi(value) except ValueError: pass done[name] = string.strip(value)
|
undef_rx = re.compile("/[*] #undef ([A-Z][A-Z0-9_]+) [*]/\n")
|
3c8e54bf6220cd89ec80839161926db9a92e00ba /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3c8e54bf6220cd89ec80839161926db9a92e00ba/sysconfig.py
|
done[name] = value
|
try: value = string.atoi(value) except ValueError: pass done[name] = string.strip(value)
|
undef_rx = re.compile("/[*] #undef ([A-Z][A-Z0-9_]+) [*]/\n")
|
3c8e54bf6220cd89ec80839161926db9a92e00ba /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3c8e54bf6220cd89ec80839161926db9a92e00ba/sysconfig.py
|
"calling %s returned %s, not a test" % obj,test
|
"calling %s returned %s, not a test" % (obj,test)
|
def loadTestsFromName(self, name, module=None): """Return a suite of all tests cases given a string specifier.
|
4bc808533f6f2d57c31493f6bb8f18594413fb5c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4bc808533f6f2d57c31493f6bb8f18594413fb5c/unittest.py
|
_header_parser = email.Parser.HeaderParser()
|
def nolog(*allargs): """Dummy function, assigned to log when logging is disabled.""" pass
|
3a703b60593e2bc2ddde232eaad365e4c126ff42 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3a703b60593e2bc2ddde232eaad365e4c126ff42/cgi.py
|
|
headers = _header_parser.parse(fp)
|
headers = mimetools.Message(fp)
|
def parse_multipart(fp, pdict): """Parse multipart input. Arguments: fp : input file pdict: dictionary containing other parameters of content-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 = _header_parser.parse(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
|
3a703b60593e2bc2ddde232eaad365e4c126ff42 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3a703b60593e2bc2ddde232eaad365e4c126ff42/cgi.py
|
headers: a dictionary(-like) object (sometimes email.Message.Message or a subclass thereof) containing *all* headers
|
headers: a dictionary(-like) object (sometimes rfc822.Message or a subclass thereof) containing *all* headers
|
def __repr__(self): """Return printable representation.""" return "MiniFieldStorage(%r, %r)" % (self.name, self.value)
|
3a703b60593e2bc2ddde232eaad365e4c126ff42 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3a703b60593e2bc2ddde232eaad365e4c126ff42/cgi.py
|
headers = _header_parser.parse(self.fp)
|
headers = rfc822.Message(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 = _header_parser.parse(self.fp) part = klass(self.fp, headers, ib, environ, keep_blank_values, strict_parsing) self.list.append(part) self.skip_lines()
|
3a703b60593e2bc2ddde232eaad365e4c126ff42 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3a703b60593e2bc2ddde232eaad365e4c126ff42/cgi.py
|
ExistingwasteObj_New, &we) ) return NULL;
|
WEOObj_Convert, &we) ) return NULL;
|
def outputCheckNewArg(self): Output("""if (itself == NULL) { Py_INCREF(Py_None); return Py_None; }""")
|
9f2ff9124c79ee1dba64967d594bb2a760922da2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9f2ff9124c79ee1dba64967d594bb2a760922da2/wastesupport.py
|
verify(float(a).__class__ is float)
|
def __repr__(self): return "%.*g" % (self.prec, self)
|
7a50f2536e59762897a05b1d3996e51f3f1a9686 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7a50f2536e59762897a05b1d3996e51f3f1a9686/test_descr.py
|
|
data += self.sslobj.read(len(data)-size)
|
data += self.sslobj.read(size-len(data))
|
def read(self, size): """Read 'size' bytes from remote.""" # sslobj.read() sometimes returns < size bytes data = self.sslobj.read(size) while len(data) < size: data += self.sslobj.read(len(data)-size)
|
17031bf421b21ae8b792d2b04c0ad5f997244865 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/17031bf421b21ae8b792d2b04c0ad5f997244865/imaplib.py
|
self.fp.write(struct.pack("<lll", zinfo.CRC, zinfo.compress_size,
|
self.fp.write(struct.pack("<lLL", zinfo.CRC, zinfo.compress_size,
|
def write(self, filename, arcname=None, compress_type=None): """Put the bytes from filename into the archive under the name arcname.""" st = os.stat(filename) mtime = time.localtime(st.st_mtime) date_time = mtime[0:6] # Create ZipInfo instance to store file information if arcname is None: zinfo = ZipInfo(filename, date_time) else: zinfo = ZipInfo(arcname, date_time) zinfo.external_attr = (st[0] & 0xFFFF) << 16L # Unix attributes if compress_type is None: zinfo.compress_type = self.compression else: zinfo.compress_type = compress_type self._writecheck(zinfo) fp = open(filename, "rb") zinfo.flag_bits = 0x00 zinfo.header_offset = self.fp.tell() # Start of header bytes # Must overwrite CRC and sizes with correct data later zinfo.CRC = CRC = 0 zinfo.compress_size = compress_size = 0 zinfo.file_size = file_size = 0 self.fp.write(zinfo.FileHeader()) zinfo.file_offset = self.fp.tell() # Start of file bytes if zinfo.compress_type == ZIP_DEFLATED: cmpr = zlib.compressobj(zlib.Z_DEFAULT_COMPRESSION, zlib.DEFLATED, -15) else: cmpr = None while 1: buf = fp.read(1024 * 8) if not buf: break file_size = file_size + len(buf) CRC = binascii.crc32(buf, CRC) if cmpr: buf = cmpr.compress(buf) compress_size = compress_size + len(buf) self.fp.write(buf) fp.close() if cmpr: buf = cmpr.flush() compress_size = compress_size + len(buf) self.fp.write(buf) zinfo.compress_size = compress_size else: zinfo.compress_size = file_size zinfo.CRC = CRC zinfo.file_size = file_size # Seek backwards and write CRC and file sizes position = self.fp.tell() # Preserve current position in file self.fp.seek(zinfo.header_offset + 14, 0) self.fp.write(struct.pack("<lll", zinfo.CRC, zinfo.compress_size, zinfo.file_size)) self.fp.seek(position, 0) self.filelist.append(zinfo) self.NameToInfo[zinfo.filename] = zinfo
|
ff450f7512900eb883576109b53f0aa3ebc76a0a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ff450f7512900eb883576109b53f0aa3ebc76a0a/zipfile.py
|
self.fp.write(struct.pack("<lll", zinfo.CRC, zinfo.compress_size,
|
self.fp.write(struct.pack("<lLL", zinfo.CRC, zinfo.compress_size,
|
def writestr(self, zinfo_or_arcname, bytes): """Write a file into the archive. The contents is the string 'bytes'. 'zinfo_or_arcname' is either a ZipInfo instance or the name of the file in the archive.""" if not isinstance(zinfo_or_arcname, ZipInfo): zinfo = ZipInfo(filename=zinfo_or_arcname, date_time=time.localtime(time.time())) zinfo.compress_type = self.compression else: zinfo = zinfo_or_arcname self._writecheck(zinfo) zinfo.file_size = len(bytes) # Uncompressed size zinfo.CRC = binascii.crc32(bytes) # CRC-32 checksum if zinfo.compress_type == ZIP_DEFLATED: co = zlib.compressobj(zlib.Z_DEFAULT_COMPRESSION, zlib.DEFLATED, -15) bytes = co.compress(bytes) + co.flush() zinfo.compress_size = len(bytes) # Compressed size else: zinfo.compress_size = zinfo.file_size zinfo.header_offset = self.fp.tell() # Start of header bytes self.fp.write(zinfo.FileHeader()) zinfo.file_offset = self.fp.tell() # Start of file bytes self.fp.write(bytes) if zinfo.flag_bits & 0x08: # Write CRC and file sizes after the file data self.fp.write(struct.pack("<lll", zinfo.CRC, zinfo.compress_size, zinfo.file_size)) self.filelist.append(zinfo) self.NameToInfo[zinfo.filename] = zinfo
|
ff450f7512900eb883576109b53f0aa3ebc76a0a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ff450f7512900eb883576109b53f0aa3ebc76a0a/zipfile.py
|
if self.inc.match(fullname) == None:
|
if DEBUG: print 'checkpath', fullname matchvalue = self.inc.match(fullname) if matchvalue == None:
|
def checkdir(self, path, istop): files = os.listdir(path) rv = [] todo = [] for f in files: if self.exc.match(f): continue fullname = os.path.join(path, f) if self.inc.match(fullname) == None: if os.path.isdir(fullname): todo.append(fullname) else: rv.append(fullname) for d in todo: if len(rv) > 500: if istop: rv.append('... and more ...') return rv rv = rv + self.checkdir(d, 0) return rv
|
73c804a3cd864cdb0ae2f2cff816848633f454f2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/73c804a3cd864cdb0ae2f2cff816848633f454f2/MkDistr.py
|
macostools.copy(fullname, os.path.join(destprefix, dest), 1)
|
try: macostools.copy(fullname, os.path.join(destprefix, dest), 1) except: print 'cwd', os.path.getcwd() print 'fsspec', macfs.FSSpec(fullname) sys.exit(1)
|
def rundir(self, path, destprefix, doit): files = os.listdir(path) todo = [] rv = 1 for f in files: if self.exc.match(f): continue fullname = os.path.join(path, f) if os.path.isdir(fullname): todo.append(fullname) else: dest = self.inc.match(fullname) if dest == None: print 'Not yet resolved:', fullname rv = 0 if dest: if doit: print 'COPY ', fullname print ' -> ', os.path.join(destprefix, dest) macostools.copy(fullname, os.path.join(destprefix, dest), 1) for d in todo: if not self.rundir(d, destprefix, doit): rv = 0 return rv
|
73c804a3cd864cdb0ae2f2cff816848633f454f2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/73c804a3cd864cdb0ae2f2cff816848633f454f2/MkDistr.py
|
def test_strptime(self): tt = time.gmtime(self.t) for directive in ('a', 'A', 'b', 'B', 'c', 'd', 'H', 'I', 'j', 'm', 'M', 'p', 'S', 'U', 'w', 'W', 'x', 'X', 'y', 'Y', 'Z', '%'): format = ' %' + directive try: time.strptime(time.strftime(format, tt), format) except ValueError: self.fail('conversion specifier: %r failed.' % format)
|
d11b62edd077428935f93b36ae8d65ebaa684cca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d11b62edd077428935f93b36ae8d65ebaa684cca/test_time.py
|
||
if sys.platform == 'Darwin1.2':
|
if platform == 'Darwin1.2':
|
def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.append('/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.append( '/usr/local/include' )
|
34febf5e9273cf7715b46286ff28fb41fa413231 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/34febf5e9273cf7715b46286ff28fb41fa413231/setup.py
|
if (self.compiler.find_library_file(lib_dirs, 'ndbm')): exts.append( Extension('dbm', ['dbmmodule.c'], libraries = ['ndbm'] ) ) else: exts.append( Extension('dbm', ['dbmmodule.c']) )
|
if platform not in ['cygwin']: if (self.compiler.find_library_file(lib_dirs, 'ndbm')): exts.append( Extension('dbm', ['dbmmodule.c'], libraries = ['ndbm'] ) ) else: exts.append( Extension('dbm', ['dbmmodule.c']) )
|
def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.append('/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.append( '/usr/local/include' )
|
34febf5e9273cf7715b46286ff28fb41fa413231 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/34febf5e9273cf7715b46286ff28fb41fa413231/setup.py
|
if sys.platform not in ['mac', 'win32']:
|
if platform not in ['mac', 'win32']:
|
def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.append('/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.append( '/usr/local/include' )
|
34febf5e9273cf7715b46286ff28fb41fa413231 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/34febf5e9273cf7715b46286ff28fb41fa413231/setup.py
|
exts.append( Extension('resource', ['resource.c']) )
|
if platform not in ['cygwin']: exts.append( Extension('resource', ['resource.c']) )
|
def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.append('/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.append( '/usr/local/include' )
|
34febf5e9273cf7715b46286ff28fb41fa413231 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/34febf5e9273cf7715b46286ff28fb41fa413231/setup.py
|
if sys.platform == 'sunos4':
|
if platform == 'sunos4':
|
def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.append('/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.append( '/usr/local/include' )
|
34febf5e9273cf7715b46286ff28fb41fa413231 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/34febf5e9273cf7715b46286ff28fb41fa413231/setup.py
|
if sys.platform == 'irix5':
|
if platform == 'irix5':
|
def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.append('/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.append( '/usr/local/include' )
|
34febf5e9273cf7715b46286ff28fb41fa413231 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/34febf5e9273cf7715b46286ff28fb41fa413231/setup.py
|
plat = sys.platform if plat == 'linux2':
|
if platform == 'linux2':
|
def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.append('/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.append( '/usr/local/include' )
|
34febf5e9273cf7715b46286ff28fb41fa413231 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/34febf5e9273cf7715b46286ff28fb41fa413231/setup.py
|
if plat == 'sunos5':
|
if platform == 'sunos5':
|
def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.append('/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.append( '/usr/local/include' )
|
34febf5e9273cf7715b46286ff28fb41fa413231 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/34febf5e9273cf7715b46286ff28fb41fa413231/setup.py
|
if sys.platform == 'sunos5':
|
platform = self.get_platform() if platform == 'sunos5':
|
def detect_tkinter(self, inc_dirs, lib_dirs): # The _tkinter module. # # The command for _tkinter is long and site specific. Please # uncomment and/or edit those parts as indicated. If you don't have a # specific extension (e.g. Tix or BLT), leave the corresponding line # commented out. (Leave the trailing backslashes in! If you # experience strange errors, you may want to join all uncommented # lines and remove the backslashes -- the backslash interpretation is # done by the shell's "read" command and it may not be implemented on # every system.
|
34febf5e9273cf7715b46286ff28fb41fa413231 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/34febf5e9273cf7715b46286ff28fb41fa413231/setup.py
|
if sys.platform in ['aix3', 'aix4']:
|
if platform in ['aix3', 'aix4']:
|
def detect_tkinter(self, inc_dirs, lib_dirs): # The _tkinter module. # # The command for _tkinter is long and site specific. Please # uncomment and/or edit those parts as indicated. If you don't have a # specific extension (e.g. Tix or BLT), leave the corresponding line # commented out. (Leave the trailing backslashes in! If you # experience strange errors, you may want to join all uncommented # lines and remove the backslashes -- the backslash interpretation is # done by the shell's "read" command and it may not be implemented on # every system.
|
34febf5e9273cf7715b46286ff28fb41fa413231 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/34febf5e9273cf7715b46286ff28fb41fa413231/setup.py
|
self.warn ("file %s (for module %s) not found" % module_file, module)
|
self.warn ("file %s (for module %s) not found" % (module_file, module))
|
def check_module (self, module, module_file): if not os.path.isfile (module_file): self.warn ("file %s (for module %s) not found" % module_file, module) return 0 else: return 1
|
113e70efa2b932a3ad2662875114133a1edb600c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/113e70efa2b932a3ad2662875114133a1edb600c/build_py.py
|
__contains__ = has_key
|
def __contains__(self, key): return self.has_key(key)
|
def has_key(self, key): try: value = self[key] except KeyError: return False return True
|
51f3f1b7dce6d054891faf9959fc493e66e9f684 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/51f3f1b7dce6d054891faf9959fc493e66e9f684/UserDict.py
|
iterkeys = __iter__
|
def iterkeys(self): return self.__iter__()
|
def iteritems(self): for k in self: yield (k, self[k])
|
51f3f1b7dce6d054891faf9959fc493e66e9f684 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/51f3f1b7dce6d054891faf9959fc493e66e9f684/UserDict.py
|
addinfourl.__init__(self, fp, hdrs, url)
|
self.__super_init(fp, hdrs, url)
|
def __init__(self, url, code, msg, hdrs, fp): addinfourl.__init__(self, fp, hdrs, url) self.code = code self.msg = msg self.hdrs = hdrs self.fp = fp # XXX self.filename = url
|
73574eefe56334fb7cf052cf89f5d7fbe4d1e0a6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/73574eefe56334fb7cf052cf89f5d7fbe4d1e0a6/urllib2.py
|
self.fp.close()
|
if self.fp: self.fp.close()
|
def __del__(self): # XXX is this safe? what if user catches exception, then # extracts fp and discards exception? self.fp.close()
|
73574eefe56334fb7cf052cf89f5d7fbe4d1e0a6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/73574eefe56334fb7cf052cf89f5d7fbe4d1e0a6/urllib2.py
|
result = apply(func, args)
|
result = func(*args)
|
def _call_chain(self, chain, kind, meth_name, *args): # XXX raise an exception if no one else should try to handle # this url. return None if you can't but someone else could. handlers = chain.get(kind, ()) for handler in handlers: func = getattr(handler, meth_name) result = apply(func, args) if result is not None: return result
|
73574eefe56334fb7cf052cf89f5d7fbe4d1e0a6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/73574eefe56334fb7cf052cf89f5d7fbe4d1e0a6/urllib2.py
|
'_open', req)
|
'_open', req)
|
def open(self, fullurl, data=None): # accept a URL or a Request object if type(fullurl) == types.StringType: req = Request(fullurl, data) else: req = fullurl if data is not None: req.add_data(data) assert isinstance(req, Request) # really only care about interface result = self._call_chain(self.handle_open, 'default', 'default_open', req) if result: return result
|
73574eefe56334fb7cf052cf89f5d7fbe4d1e0a6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/73574eefe56334fb7cf052cf89f5d7fbe4d1e0a6/urllib2.py
|
result = apply(self._call_chain, args)
|
result = self._call_chain(*args)
|
def error(self, proto, *args): if proto == 'http': # XXX http protocol is special cased dict = self.handle_error[proto] proto = args[2] # YUCK! meth_name = 'http_error_%d' % proto http_err = 1 orig_args = args else: dict = self.handle_error meth_name = proto + '_error' http_err = 0 args = (dict, proto, meth_name) + args result = apply(self._call_chain, args) if result: return result
|
73574eefe56334fb7cf052cf89f5d7fbe4d1e0a6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/73574eefe56334fb7cf052cf89f5d7fbe4d1e0a6/urllib2.py
|
return apply(self._call_chain, args)
|
return self._call_chain(*args)
|
def error(self, proto, *args): if proto == 'http': # XXX http protocol is special cased dict = self.handle_error[proto] proto = args[2] # YUCK! meth_name = 'http_error_%d' % proto http_err = 1 orig_args = args else: dict = self.handle_error meth_name = proto + '_error' http_err = 0 args = (dict, proto, meth_name) + args result = apply(self._call_chain, args) if result: return result
|
73574eefe56334fb7cf052cf89f5d7fbe4d1e0a6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/73574eefe56334fb7cf052cf89f5d7fbe4d1e0a6/urllib2.py
|
h = httplib.HTTP(host) if req.has_data(): data = req.get_data() h.putrequest('POST', req.get_selector()) h.putheader('Content-type', 'application/x-www-form-urlencoded') h.putheader('Content-length', '%d' % len(data)) else: h.putrequest('GET', req.get_selector())
|
try: h = httplib.HTTP(host) if req.has_data(): data = req.get_data() h.putrequest('POST', req.get_selector()) h.putheader('Content-type', 'application/x-www-form-urlencoded') h.putheader('Content-length', '%d' % len(data)) else: h.putrequest('GET', req.get_selector()) except socket.error, err: raise URLError(err)
|
def http_open(self, req): # XXX devise a new mechanism to specify user/password host = req.get_host() if not host: raise URLError('no host given')
|
73574eefe56334fb7cf052cf89f5d7fbe4d1e0a6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/73574eefe56334fb7cf052cf89f5d7fbe4d1e0a6/urllib2.py
|
apply(h.putheader, args)
|
h.putheader(*args)
|
def http_open(self, req): # XXX devise a new mechanism to specify user/password host = req.get_host() if not host: raise URLError('no host given')
|
73574eefe56334fb7cf052cf89f5d7fbe4d1e0a6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/73574eefe56334fb7cf052cf89f5d7fbe4d1e0a6/urllib2.py
|
if h.sock: h.sock.close() h.sock = None
|
def http_open(self, req): # XXX devise a new mechanism to specify user/password host = req.get_host() if not host: raise URLError('no host given')
|
73574eefe56334fb7cf052cf89f5d7fbe4d1e0a6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/73574eefe56334fb7cf052cf89f5d7fbe4d1e0a6/urllib2.py
|
|
host = socket.gethostbyname(host)
|
try: host = socket.gethostbyname(host) except socket.error, msg: raise URLError(msg)
|
def ftp_open(self, req): host = req.get_host() if not host: raise IOError, ('ftp error', 'no host given') # XXX handle custom username & password host = socket.gethostbyname(host) host, port = splitport(host) if port is None: port = ftplib.FTP_PORT path, attrs = splitattr(req.get_selector()) path = unquote(path) dirs = string.splitfields(path, '/') dirs, file = dirs[:-1], dirs[-1] if dirs and not dirs[0]: dirs = dirs[1:] user = passwd = '' # XXX try: fw = self.connect_ftp(user, passwd, host, port, dirs) type = file and 'I' or 'D' for attr in attrs: attr, value = splitattr(attr) if string.lower(attr) == 'type' and \ value in ('a', 'A', 'i', 'I', 'd', 'D'): type = string.upper(value) fp, retrlen = fw.retrfile(file, type) if retrlen is not None and retrlen >= 0: sf = StringIO('Content-Length: %d\n' % retrlen) headers = mimetools.Message(sf) else: headers = noheaders() return addinfourl(fp, headers, req.get_full_url()) except ftplib.all_errors, msg: raise IOError, ('ftp error', msg), sys.exc_info()[2]
|
73574eefe56334fb7cf052cf89f5d7fbe4d1e0a6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/73574eefe56334fb7cf052cf89f5d7fbe4d1e0a6/urllib2.py
|
elif socket.gethostname() == 'walden':
|
elif socket.gethostname() == 'bitdiddle.concentric.net':
|
def build_opener(self): opener = OpenerDirectory() for ph in self.proxy_handlers: if type(ph) == types.ClassType: ph = ph() opener.add_handler(ph)
|
73574eefe56334fb7cf052cf89f5d7fbe4d1e0a6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/73574eefe56334fb7cf052cf89f5d7fbe4d1e0a6/urllib2.py
|
def create_inifile (self):
|
def get_inidata (self): lines = []
|
def create_inifile (self): # Create an inifile containing data describing the installation. # This could be done without creating a real file, but # a file is (at least) useful for debugging bdist_wininst.
|
1ac9802748c26e716685f8ba19277d1a4dc0bcf1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1ac9802748c26e716685f8ba19277d1a4dc0bcf1/bdist_wininst.py
|
ini_name = "%s.ini" % metadata.get_fullname() self.announce ("creating %s" % ini_name) inifile = open (ini_name, "w")
|
def create_inifile (self): # Create an inifile containing data describing the installation. # This could be done without creating a real file, but # a file is (at least) useful for debugging bdist_wininst.
|
1ac9802748c26e716685f8ba19277d1a4dc0bcf1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1ac9802748c26e716685f8ba19277d1a4dc0bcf1/bdist_wininst.py
|
|
inifile.write ("[metadata]\n")
|
lines.append ("[metadata]")
|
def create_inifile (self): # Create an inifile containing data describing the installation. # This could be done without creating a real file, but # a file is (at least) useful for debugging bdist_wininst.
|
1ac9802748c26e716685f8ba19277d1a4dc0bcf1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1ac9802748c26e716685f8ba19277d1a4dc0bcf1/bdist_wininst.py
|
inifile.write ("%s=%s\n" % (name, repr (data)[1:-1]))
|
lines.append ("%s=%s" % (name, repr (data)[1:-1]))
|
def create_inifile (self): # Create an inifile containing data describing the installation. # This could be done without creating a real file, but # a file is (at least) useful for debugging bdist_wininst.
|
1ac9802748c26e716685f8ba19277d1a4dc0bcf1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1ac9802748c26e716685f8ba19277d1a4dc0bcf1/bdist_wininst.py
|
inifile.write ("\n[Setup]\n") inifile.write ("info=%s\n" % repr (info)[1:-1]) inifile.write ("pthname=%s.%s\n" % (metadata.name, metadata.version))
|
lines.append ("\n[Setup]") lines.append ("info=%s" % repr (info)[1:-1]) lines.append ("pthname=%s.%s" % (metadata.name, metadata.version))
|
def create_inifile (self): # Create an inifile containing data describing the installation. # This could be done without creating a real file, but # a file is (at least) useful for debugging bdist_wininst.
|
1ac9802748c26e716685f8ba19277d1a4dc0bcf1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1ac9802748c26e716685f8ba19277d1a4dc0bcf1/bdist_wininst.py
|
inifile.write ("target_version=%s\n" % self.target_version)
|
lines.append ("target_version=%s" % self.target_version)
|
def create_inifile (self): # Create an inifile containing data describing the installation. # This could be done without creating a real file, but # a file is (at least) useful for debugging bdist_wininst.
|
1ac9802748c26e716685f8ba19277d1a4dc0bcf1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1ac9802748c26e716685f8ba19277d1a4dc0bcf1/bdist_wininst.py
|
inifile.write ("title=%s\n" % repr (title)[1:-1]) inifile.close() return ini_name
|
lines.append ("title=%s" % repr (title)[1:-1]) return string.join (lines, "\n")
|
def create_inifile (self): # Create an inifile containing data describing the installation. # This could be done without creating a real file, but # a file is (at least) useful for debugging bdist_wininst.
|
1ac9802748c26e716685f8ba19277d1a4dc0bcf1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1ac9802748c26e716685f8ba19277d1a4dc0bcf1/bdist_wininst.py
|
import struct cfgdata = open (self.create_inifile()).read()
|
import struct self.mkpath(self.dist_dir) cfgdata = self.get_inidata()
|
def create_exe (self, arcname, fullname): import struct#, zlib
|
1ac9802748c26e716685f8ba19277d1a4dc0bcf1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1ac9802748c26e716685f8ba19277d1a4dc0bcf1/bdist_wininst.py
|
if (PyArg_Parse(v, "(O&l)", PyMac_GetOSType, &(out->eventClass), &(out->eventKind)))
|
if (PyArg_Parse(v, "(O&l)", PyMac_GetOSType, &(out->eventClass), &(out->eventKind)))
|
#ifdef WITHOUT_FRAMEWORKS
|
820867662bf35a2d8d2234f8cd4c8ce316ebfd37 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/820867662bf35a2d8d2234f8cd4c8ce316ebfd37/CarbonEvtsupport.py
|
retValue = PyObject_CallFunction((PyObject *)outPyObject, "O&O&", EventHandlerCallRef_New, handlerRef, EventRef_New, event);
|
retValue = PyObject_CallFunction((PyObject *)outPyObject, "O&O&", EventHandlerCallRef_New, handlerRef, EventRef_New, event);
|
#ifdef WITHOUT_FRAMEWORKS
|
820867662bf35a2d8d2234f8cd4c8ce316ebfd37 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/820867662bf35a2d8d2234f8cd4c8ce316ebfd37/CarbonEvtsupport.py
|
toaddrs = ','.split(prompt("To"))
|
toaddrs = prompt("To").split(',')
|
def prompt(prompt): sys.stdout.write(prompt + ": ") return sys.stdin.readline().strip()
|
38151ed6b895f5a9a2234eb962bac16c417dd1f4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/38151ed6b895f5a9a2234eb962bac16c417dd1f4/smtplib.py
|
info = metadata.long_description or '' + '\n'
|
info = (metadata.long_description or '') + '\n'
|
def create_inifile (self): # Create an inifile containing data describing the installation. # This could be done without creating a real file, but # a file is (at least) useful for debugging bdist_wininst.
|
6f9320b9d12649d084ed54671960d8387a856282 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6f9320b9d12649d084ed54671960d8387a856282/bdist_wininst.py
|
curses.pair_content(curses.COLOR_PAIRS)
|
curses.pair_content(curses.COLOR_PAIRS - 1)
|
def module_funcs(stdscr): "Test module-level functions" for func in [curses.baudrate, curses.beep, curses.can_change_color, curses.cbreak, curses.def_prog_mode, curses.doupdate, curses.filter, curses.flash, curses.flushinp, curses.has_colors, curses.has_ic, curses.has_il, curses.isendwin, curses.killchar, curses.longname, curses.nocbreak, curses.noecho, curses.nonl, curses.noqiflush, curses.noraw, curses.reset_prog_mode, curses.termattrs, curses.termname, curses.erasechar, curses.getsyx]: func() # Functions that actually need arguments if curses.tigetstr("cnorm"): curses.curs_set(1) curses.delay_output(1) curses.echo() ; curses.echo(1) f = tempfile.TemporaryFile() stdscr.putwin(f) f.seek(0) curses.getwin(f) f.close() curses.halfdelay(1) curses.intrflush(1) curses.meta(1) curses.napms(100) curses.newpad(50,50) win = curses.newwin(5,5) win = curses.newwin(5,5, 1,1) curses.nl() ; curses.nl(1) curses.putp('abc') curses.qiflush() curses.raw() ; curses.raw(1) curses.setsyx(5,5) curses.setupterm(fd=sys.__stdout__.fileno()) curses.tigetflag('hc') curses.tigetnum('co') curses.tigetstr('cr') curses.tparm('cr') curses.typeahead(sys.__stdin__.fileno()) curses.unctrl('a') curses.ungetch('a') curses.use_env(1) # Functions only available on a few platforms if curses.has_colors(): curses.start_color() curses.init_pair(2, 1,1) curses.color_content(1) curses.color_pair(2) curses.pair_content(curses.COLOR_PAIRS) curses.pair_number(0) if hasattr(curses, 'use_default_colors'): curses.use_default_colors() if hasattr(curses, 'keyname'): curses.keyname(13) if hasattr(curses, 'has_key'): curses.has_key(13) if hasattr(curses, 'getmouse'): curses.mousemask(curses.BUTTON1_PRESSED) curses.mouseinterval(10)
|
d1badac99c01aeb15a261d262fff1c402c4f24e9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d1badac99c01aeb15a261d262fff1c402c4f24e9/test_curses.py
|
tester('ntpath.splitdrive("\\\\conky\\mountpoint\\foo\\bar")', ('\\\\conky\\mountpoint', '\\foo\\bar'))
|
tester('ntpath.splitunc("\\\\conky\\mountpoint\\foo\\bar")', ('\\\\conky\\mountpoint', '\\foo\\bar'))
|
def tester(fn, wantResult): fn = string.replace(fn, "\\", "\\\\") gotResult = eval(fn) if wantResult != gotResult: print "error!" print "evaluated: " + str(fn) print "should be: " + str(wantResult) print " returned: " + str(gotResult) print "" global errors errors = errors + 1
|
630a9a68941205a7ebb8428fe4faeef82429d77d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/630a9a68941205a7ebb8428fe4faeef82429d77d/test_ntpath.py
|
tester('ntpath.splitdrive("//conky/mountpoint/foo/bar")', ('//conky/mountpoint', '/foo/bar'))
|
tester('ntpath.splitunc("//conky/mountpoint/foo/bar")', ('//conky/mountpoint', '/foo/bar'))
|
def tester(fn, wantResult): fn = string.replace(fn, "\\", "\\\\") gotResult = eval(fn) if wantResult != gotResult: print "error!" print "evaluated: " + str(fn) print "should be: " + str(wantResult) print " returned: " + str(gotResult) print "" global errors errors = errors + 1
|
630a9a68941205a7ebb8428fe4faeef82429d77d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/630a9a68941205a7ebb8428fe4faeef82429d77d/test_ntpath.py
|
tester('ntpath.split("\\\\conky\\mountpoint\\")', ('\\\\conky\\mountpoint\\', ''))
|
tester('ntpath.split("\\\\conky\\mountpoint\\")', ('\\\\conky\\mountpoint', ''))
|
def tester(fn, wantResult): fn = string.replace(fn, "\\", "\\\\") gotResult = eval(fn) if wantResult != gotResult: print "error!" print "evaluated: " + str(fn) print "should be: " + str(wantResult) print " returned: " + str(gotResult) print "" global errors errors = errors + 1
|
630a9a68941205a7ebb8428fe4faeef82429d77d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/630a9a68941205a7ebb8428fe4faeef82429d77d/test_ntpath.py
|
tester('ntpath.split("//conky/mountpoint/")', ('//conky/mountpoint/', ''))
|
tester('ntpath.split("//conky/mountpoint/")', ('//conky/mountpoint', ''))
|
def tester(fn, wantResult): fn = string.replace(fn, "\\", "\\\\") gotResult = eval(fn) if wantResult != gotResult: print "error!" print "evaluated: " + str(fn) print "should be: " + str(wantResult) print " returned: " + str(gotResult) print "" global errors errors = errors + 1
|
630a9a68941205a7ebb8428fe4faeef82429d77d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/630a9a68941205a7ebb8428fe4faeef82429d77d/test_ntpath.py
|
def test_close_fds(self): os.pipe() p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' \ 'sys.stdout.write(str(os.dup(0)))'], stdout=subprocess.PIPE, close_fds=1) self.assertEqual(p.stdout.read(), "3")
|
def test_preexec(self): # preexec function p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' \ 'sys.stdout.write(os.getenv("FRUIT"))'], stdout=subprocess.PIPE, preexec_fn=lambda: os.putenv("FRUIT", "apple")) self.assertEqual(p.stdout.read(), "apple")
|
c19ccc9f1137bceb830a635a199b0798cc6d3932 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c19ccc9f1137bceb830a635a199b0798cc6d3932/test_subprocess.py
|
|
raise ValueError("truncated header")
|
raise HeaderError("truncated header")
|
def frombuf(cls, buf): """Construct a TarInfo object from a 512 byte string buffer. """ if len(buf) != BLOCKSIZE: raise ValueError("truncated header") if buf.count(NUL) == BLOCKSIZE: raise ValueError("empty header")
|
ebbeed781d923494f782f0750e76ad4aac8e29f5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ebbeed781d923494f782f0750e76ad4aac8e29f5/tarfile.py
|
raise ValueError("empty header")
|
raise HeaderError("empty header") try: chksum = nti(buf[148:156]) except ValueError: raise HeaderError("invalid header") if chksum not in calc_chksums(buf): raise HeaderError("bad checksum")
|
def frombuf(cls, buf): """Construct a TarInfo object from a 512 byte string buffer. """ if len(buf) != BLOCKSIZE: raise ValueError("truncated header") if buf.count(NUL) == BLOCKSIZE: raise ValueError("empty header")
|
ebbeed781d923494f782f0750e76ad4aac8e29f5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ebbeed781d923494f782f0750e76ad4aac8e29f5/tarfile.py
|
tarinfo.chksum = nti(buf[148:156])
|
tarinfo.chksum = chksum
|
def frombuf(cls, buf): """Construct a TarInfo object from a 512 byte string buffer. """ if len(buf) != BLOCKSIZE: raise ValueError("truncated header") if buf.count(NUL) == BLOCKSIZE: raise ValueError("empty header")
|
ebbeed781d923494f782f0750e76ad4aac8e29f5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ebbeed781d923494f782f0750e76ad4aac8e29f5/tarfile.py
|
if tarinfo.chksum not in calc_chksums(buf): raise ValueError("invalid header")
|
def frombuf(cls, buf): """Construct a TarInfo object from a 512 byte string buffer. """ if len(buf) != BLOCKSIZE: raise ValueError("truncated header") if buf.count(NUL) == BLOCKSIZE: raise ValueError("empty header")
|
ebbeed781d923494f782f0750e76ad4aac8e29f5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ebbeed781d923494f782f0750e76ad4aac8e29f5/tarfile.py
|
|
except ValueError, e:
|
except HeaderError, e:
|
def next(self): """Return the next member of the archive as a TarInfo object, when TarFile is opened for reading. Return None if there is no more available. """ self._check("ra") if self.firstmember is not None: m = self.firstmember self.firstmember = None return m
|
ebbeed781d923494f782f0750e76ad4aac8e29f5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ebbeed781d923494f782f0750e76ad4aac8e29f5/tarfile.py
|
self._dbg(2, "0x%X: empty or invalid block: %s" % (self.offset, e))
|
self._dbg(2, "0x%X: %s" % (self.offset, e))
|
def next(self): """Return the next member of the archive as a TarInfo object, when TarFile is opened for reading. Return None if there is no more available. """ self._check("ra") if self.firstmember is not None: m = self.firstmember self.firstmember = None return m
|
ebbeed781d923494f782f0750e76ad4aac8e29f5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ebbeed781d923494f782f0750e76ad4aac8e29f5/tarfile.py
|
raise ReadError("empty, unreadable or compressed " "file: %s" % e)
|
raise ReadError(str(e))
|
def next(self): """Return the next member of the archive as a TarInfo object, when TarFile is opened for reading. Return None if there is no more available. """ self._check("ra") if self.firstmember is not None: m = self.firstmember self.firstmember = None return m
|
ebbeed781d923494f782f0750e76ad4aac8e29f5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ebbeed781d923494f782f0750e76ad4aac8e29f5/tarfile.py
|
ignores.append(regex.compile(a))
|
ignores.append(re.compile(a))
|
def main(): global filedict opts, args = getopt.getopt(sys.argv[1:], 'i:') for o, a in opts: if o == '-i': ignores.append(regex.compile(a)) if not args: args = ['-'] for filename in args: if filename == '-': sys.stdout.write('# Generated by h2py from stdin\n') process(sys.stdin, sys.stdout) else: fp = open(filename, 'r') outfile = os.path.basename(filename) i = string.rfind(outfile, '.') if i > 0: outfile = outfile[:i] outfile = string.upper(outfile) outfile = outfile + '.py' outfp = open(outfile, 'w') outfp.write('# Generated by h2py from %s\n' % filename) filedict = {} for dir in searchdirs: if filename[:len(dir)] == dir: filedict[filename[len(dir)+1:]] = None # no '/' trailing break process(fp, outfp) outfp.close() fp.close()
|
4f85bf3311e9ac09ec64e74f1ce9cf3e2d223543 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4f85bf3311e9ac09ec64e74f1ce9cf3e2d223543/h2py.py
|
i = string.rfind(outfile, '.')
|
i = outfile.rfind('.')
|
def main(): global filedict opts, args = getopt.getopt(sys.argv[1:], 'i:') for o, a in opts: if o == '-i': ignores.append(regex.compile(a)) if not args: args = ['-'] for filename in args: if filename == '-': sys.stdout.write('# Generated by h2py from stdin\n') process(sys.stdin, sys.stdout) else: fp = open(filename, 'r') outfile = os.path.basename(filename) i = string.rfind(outfile, '.') if i > 0: outfile = outfile[:i] outfile = string.upper(outfile) outfile = outfile + '.py' outfp = open(outfile, 'w') outfp.write('# Generated by h2py from %s\n' % filename) filedict = {} for dir in searchdirs: if filename[:len(dir)] == dir: filedict[filename[len(dir)+1:]] = None # no '/' trailing break process(fp, outfp) outfp.close() fp.close()
|
4f85bf3311e9ac09ec64e74f1ce9cf3e2d223543 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4f85bf3311e9ac09ec64e74f1ce9cf3e2d223543/h2py.py
|
outfile = string.upper(outfile) outfile = outfile + '.py'
|
modname = outfile.upper() outfile = modname + '.py'
|
def main(): global filedict opts, args = getopt.getopt(sys.argv[1:], 'i:') for o, a in opts: if o == '-i': ignores.append(regex.compile(a)) if not args: args = ['-'] for filename in args: if filename == '-': sys.stdout.write('# Generated by h2py from stdin\n') process(sys.stdin, sys.stdout) else: fp = open(filename, 'r') outfile = os.path.basename(filename) i = string.rfind(outfile, '.') if i > 0: outfile = outfile[:i] outfile = string.upper(outfile) outfile = outfile + '.py' outfp = open(outfile, 'w') outfp.write('# Generated by h2py from %s\n' % filename) filedict = {} for dir in searchdirs: if filename[:len(dir)] == dir: filedict[filename[len(dir)+1:]] = None # no '/' trailing break process(fp, outfp) outfp.close() fp.close()
|
4f85bf3311e9ac09ec64e74f1ce9cf3e2d223543 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4f85bf3311e9ac09ec64e74f1ce9cf3e2d223543/h2py.py
|
if p_include.match(line) >= 0: regs = p_include.regs
|
match = p_include.match(line) if match: regs = match.regs
|
stmt = 'def %s(%s): return %s\n' % (macro, arg, body)
|
4f85bf3311e9ac09ec64e74f1ce9cf3e2d223543 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4f85bf3311e9ac09ec64e74f1ce9cf3e2d223543/h2py.py
|
if not filedict.has_key(filename):
|
if importable.has_key(filename): outfp.write('import %s\n' % importable[filename]) elif not filedict.has_key(filename):
|
stmt = 'def %s(%s): return %s\n' % (macro, arg, body)
|
4f85bf3311e9ac09ec64e74f1ce9cf3e2d223543 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4f85bf3311e9ac09ec64e74f1ce9cf3e2d223543/h2py.py
|
inclfp = open(dir + '/' + filename, 'r')
|
inclfp = open(dir + '/' + filename)
|
stmt = 'def %s(%s): return %s\n' % (macro, arg, body)
|
4f85bf3311e9ac09ec64e74f1ce9cf3e2d223543 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4f85bf3311e9ac09ec64e74f1ce9cf3e2d223543/h2py.py
|
file(foo_path, 'w').close() file(bar_path, 'w').close()
|
f = open(foo_path, 'w') f.write("@") f.close() f = open(bar_path, 'w') f.write("@") f.close()
|
def test_clean(self): # Remove old files from 'tmp' foo_path = os.path.join(self._path, 'tmp', 'foo') bar_path = os.path.join(self._path, 'tmp', 'bar') file(foo_path, 'w').close() file(bar_path, 'w').close() self._box.clean() self.assert_(os.path.exists(foo_path)) self.assert_(os.path.exists(bar_path)) foo_stat = os.stat(foo_path) os.utime(os.path.join(foo_path), (time.time() - 129600 - 2, foo_stat.st_mtime)) self._box.clean() self.assert_(not os.path.exists(foo_path)) self.assert_(os.path.exists(bar_path))
|
b2045837b69992d054aa12849b07a3b0c8b2bd09 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b2045837b69992d054aa12849b07a3b0c8b2bd09/test_mailbox.py
|
os.utime(os.path.join(foo_path), (time.time() - 129600 - 2, foo_stat.st_mtime))
|
os.utime(foo_path, (time.time() - 129600 - 2, foo_stat.st_mtime))
|
def test_clean(self): # Remove old files from 'tmp' foo_path = os.path.join(self._path, 'tmp', 'foo') bar_path = os.path.join(self._path, 'tmp', 'bar') file(foo_path, 'w').close() file(bar_path, 'w').close() self._box.clean() self.assert_(os.path.exists(foo_path)) self.assert_(os.path.exists(bar_path)) foo_stat = os.stat(foo_path) os.utime(os.path.join(foo_path), (time.time() - 129600 - 2, foo_stat.st_mtime)) self._box.clean() self.assert_(not os.path.exists(foo_path)) self.assert_(os.path.exists(bar_path))
|
b2045837b69992d054aa12849b07a3b0c8b2bd09 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b2045837b69992d054aa12849b07a3b0c8b2bd09/test_mailbox.py
|
sys.stdout.flush() os.system("/depot/gnu/plat/bin/rlog -r %s </dev/null 2>&1" % self.name)
|
p = os.popen("/depot/gnu/plat/bin/rlog -r %s </dev/null 2>&1" % self.name) output = p.read() p.close() print cgi.escape(output)
|
def do_info(self):
|
1dcc24404bd0414d44ae6e0d216f003d7b6c7af5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1dcc24404bd0414d44ae6e0d216f003d7b6c7af5/faqmain.py
|
sys.stdout.flush() os.system("/depot/gnu/plat/bin/rlog %s </dev/null 2>&1" % self.name)
|
p = os.popen("/depot/gnu/plat/bin/rlog %s </dev/null 2>&1" % self.name) output = p.read() p.close() print cgi.escape(output)
|
def do_rlog(self):
|
1dcc24404bd0414d44ae6e0d216f003d7b6c7af5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1dcc24404bd0414d44ae6e0d216f003d7b6c7af5/faqmain.py
|
print "domain=%s;" % os.environ['HTTP_HOST'],
|
print "domain=%s;" % hostname,
|
def set_cookie(self, author, email):
|
1dcc24404bd0414d44ae6e0d216f003d7b6c7af5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1dcc24404bd0414d44ae6e0d216f003d7b6c7af5/faqmain.py
|
<TEXTAREA COLS=80 ROWS=20 NAME=text>""" % title
|
<TEXTAREA COLS=80 ROWS=20 NAME=text>""" % self.escape(title)
|
def showedit(self, name, title, text):
|
1dcc24404bd0414d44ae6e0d216f003d7b6c7af5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1dcc24404bd0414d44ae6e0d216f003d7b6c7af5/faqmain.py
|
""" % (author, email, self.log)
|
""" % (self.escape(author), self.escape(email), self.escape(self.log)) def escape(self, s): import regsub if '&' in s: s = regsub.gsub("&", "&", s) if '<' in s: s = regsub.gsub("<", "<", s) if '>' in s: s = regsub.gsub(">", ">", s) if '"' in s: s = regsub.gsub('"', """, s) return s
|
def showedit(self, name, title, text):
|
1dcc24404bd0414d44ae6e0d216f003d7b6c7af5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1dcc24404bd0414d44ae6e0d216f003d7b6c7af5/faqmain.py
|
while url[-1] in ");:,.?":
|
while url[-1] in ");:,.?'\"":
|
def translate(self, text):
|
1dcc24404bd0414d44ae6e0d216f003d7b6c7af5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1dcc24404bd0414d44ae6e0d216f003d7b6c7af5/faqmain.py
|
url = cgi.escape(url)
|
url = self.escape(url)
|
def translate(self, text):
|
1dcc24404bd0414d44ae6e0d216f003d7b6c7af5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1dcc24404bd0414d44ae6e0d216f003d7b6c7af5/faqmain.py
|
if hasattr(self.db, 'close'): self.db.close() self.db = None
|
if hasattr(self.dict, 'close'): self.dict.close() self.dict = None
|
def close(self): if hasattr(self.db, 'close'): self.db.close() self.db = None
|
cebfa70a794ba3d4aeda681b3164123d934d1c28 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/cebfa70a794ba3d4aeda681b3164123d934d1c28/shelve.py
|
elif compiler == "gcc" or compiler == "g++":
|
elif compiler[:3] == "gcc" or compiler[:3] == "g++":
|
def runtime_library_dir_option(self, dir): # XXX Hackish, at the very least. See Python bug #445902: # http://sourceforge.net/tracker/index.php # ?func=detail&aid=445902&group_id=5470&atid=105470 # Linkers on different platforms need different options to # specify that directories need to be added to the list of # directories searched for dependencies when a dynamic library # is sought. GCC has to be told to pass the -R option through # to the linker, whereas other compilers just know this. # Other compilers may need something slightly different. At # this time, there's no way to determine this information from # the configuration data stored in the Python installation, so # we use this hack. compiler = os.path.basename(sysconfig.get_config_var("CC")) if sys.platform[:6] == "darwin": # MacOSX's linker doesn't understand the -R flag at all return "-L" + dir elif compiler == "gcc" or compiler == "g++": return "-Wl,-R" + dir else: return "-R" + dir
|
69ceb33baccb85d7d215733c14861c1b3548aba5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/69ceb33baccb85d7d215733c14861c1b3548aba5/unixccompiler.py
|
UserDict.UserDict.__init__(self, *args, **kw)
|
def __init__(self, *args, **kw): UserDict.UserDict.__init__(self, *args, **kw) def remove(wr, selfref=ref(self)): self = selfref() if self is not None: del self.data[wr.key] self._remove = remove
|
9166e1a24ac7b15776ffd38e436fa51a9b002674 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9166e1a24ac7b15776ffd38e436fa51a9b002674/weakref.py
|
|
'marshal', 'math', 'md5', 'operator',
|
'math', 'md5', 'operator',
|
def reload(self, module, path=None): if path is None and hasattr(module, '__filename__'): head, tail = os.path.split(module.__filename__) path = [os.path.join(head, '')] return ihooks.ModuleImporter.reload(self, module, path)
|
3ee6b195bbe8272b5901f3f97c0966ddd4bb72fa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3ee6b195bbe8272b5901f3f97c0966ddd4bb72fa/rexec.py
|
LE_MAGIC = 0x950412de BE_MAGIC = 0xde120495
|
LE_MAGIC = 0x950412deL BE_MAGIC = 0xde120495L
|
def install(self, unicode=0): import __builtin__ __builtin__.__dict__['_'] = unicode and self.ugettext or self.gettext
|
09707e363723fa24ba53e4e5d77cc26d4dea724f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/09707e363723fa24ba53e4e5d77cc26d4dea724f/gettext.py
|
MASK = 0xffffffff
|
def _parse(self, fp): """Override this method to support alternative .mo formats.""" # We need to & all 32 bit unsigned integers with 0xffffffff for # portability to 64 bit machines. MASK = 0xffffffff unpack = struct.unpack filename = getattr(fp, 'name', '') # Parse the .mo file header, which consists of 5 little endian 32 # bit words. self._catalog = catalog = {} buf = fp.read() buflen = len(buf) # Are we big endian or little endian? magic = unpack('<i', buf[:4])[0] & MASK 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) # more unsigned ints msgcount &= MASK masteridx &= MASK transidx &= MASK # 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]) moff &= MASK mend = moff + (mlen & MASK) tlen, toff = unpack(ii, buf[transidx:transidx+8]) toff &= MASK tend = toff + (tlen & MASK) if mend < buflen and tend < buflen: tmsg = buf[toff:tend] catalog[buf[moff:mend]] = tmsg else: raise IOError(0, 'File is corrupt', filename) # See if we're looking at GNU .mo conventions for metadata if mlen == 0 and tmsg.lower().startswith('project-id-version:'): # Catalog description for item in tmsg.split('\n'): 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] # advance to next entry in the seek tables masteridx += 8 transidx += 8
|
09707e363723fa24ba53e4e5d77cc26d4dea724f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/09707e363723fa24ba53e4e5d77cc26d4dea724f/gettext.py
|
|
magic = unpack('<i', buf[:4])[0] & MASK
|
magic = unpack('<I', buf[:4])[0]
|
def _parse(self, fp): """Override this method to support alternative .mo formats.""" # We need to & all 32 bit unsigned integers with 0xffffffff for # portability to 64 bit machines. MASK = 0xffffffff unpack = struct.unpack filename = getattr(fp, 'name', '') # Parse the .mo file header, which consists of 5 little endian 32 # bit words. self._catalog = catalog = {} buf = fp.read() buflen = len(buf) # Are we big endian or little endian? magic = unpack('<i', buf[:4])[0] & MASK 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) # more unsigned ints msgcount &= MASK masteridx &= MASK transidx &= MASK # 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]) moff &= MASK mend = moff + (mlen & MASK) tlen, toff = unpack(ii, buf[transidx:transidx+8]) toff &= MASK tend = toff + (tlen & MASK) if mend < buflen and tend < buflen: tmsg = buf[toff:tend] catalog[buf[moff:mend]] = tmsg else: raise IOError(0, 'File is corrupt', filename) # See if we're looking at GNU .mo conventions for metadata if mlen == 0 and tmsg.lower().startswith('project-id-version:'): # Catalog description for item in tmsg.split('\n'): 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] # advance to next entry in the seek tables masteridx += 8 transidx += 8
|
09707e363723fa24ba53e4e5d77cc26d4dea724f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/09707e363723fa24ba53e4e5d77cc26d4dea724f/gettext.py
|
version, msgcount, masteridx, transidx = unpack('<4i', buf[4:20]) ii = '<ii'
|
version, msgcount, masteridx, transidx = unpack('<4I', buf[4:20]) ii = '<II'
|
def _parse(self, fp): """Override this method to support alternative .mo formats.""" # We need to & all 32 bit unsigned integers with 0xffffffff for # portability to 64 bit machines. MASK = 0xffffffff unpack = struct.unpack filename = getattr(fp, 'name', '') # Parse the .mo file header, which consists of 5 little endian 32 # bit words. self._catalog = catalog = {} buf = fp.read() buflen = len(buf) # Are we big endian or little endian? magic = unpack('<i', buf[:4])[0] & MASK 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) # more unsigned ints msgcount &= MASK masteridx &= MASK transidx &= MASK # 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]) moff &= MASK mend = moff + (mlen & MASK) tlen, toff = unpack(ii, buf[transidx:transidx+8]) toff &= MASK tend = toff + (tlen & MASK) if mend < buflen and tend < buflen: tmsg = buf[toff:tend] catalog[buf[moff:mend]] = tmsg else: raise IOError(0, 'File is corrupt', filename) # See if we're looking at GNU .mo conventions for metadata if mlen == 0 and tmsg.lower().startswith('project-id-version:'): # Catalog description for item in tmsg.split('\n'): 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] # advance to next entry in the seek tables masteridx += 8 transidx += 8
|
09707e363723fa24ba53e4e5d77cc26d4dea724f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/09707e363723fa24ba53e4e5d77cc26d4dea724f/gettext.py
|
version, msgcount, masteridx, transidx = unpack('>4i', buf[4:20]) ii = '>ii'
|
version, msgcount, masteridx, transidx = unpack('>4I', buf[4:20]) ii = '>II'
|
def _parse(self, fp): """Override this method to support alternative .mo formats.""" # We need to & all 32 bit unsigned integers with 0xffffffff for # portability to 64 bit machines. MASK = 0xffffffff unpack = struct.unpack filename = getattr(fp, 'name', '') # Parse the .mo file header, which consists of 5 little endian 32 # bit words. self._catalog = catalog = {} buf = fp.read() buflen = len(buf) # Are we big endian or little endian? magic = unpack('<i', buf[:4])[0] & MASK 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) # more unsigned ints msgcount &= MASK masteridx &= MASK transidx &= MASK # 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]) moff &= MASK mend = moff + (mlen & MASK) tlen, toff = unpack(ii, buf[transidx:transidx+8]) toff &= MASK tend = toff + (tlen & MASK) if mend < buflen and tend < buflen: tmsg = buf[toff:tend] catalog[buf[moff:mend]] = tmsg else: raise IOError(0, 'File is corrupt', filename) # See if we're looking at GNU .mo conventions for metadata if mlen == 0 and tmsg.lower().startswith('project-id-version:'): # Catalog description for item in tmsg.split('\n'): 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] # advance to next entry in the seek tables masteridx += 8 transidx += 8
|
09707e363723fa24ba53e4e5d77cc26d4dea724f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/09707e363723fa24ba53e4e5d77cc26d4dea724f/gettext.py
|
msgcount &= MASK masteridx &= MASK transidx &= MASK
|
def _parse(self, fp): """Override this method to support alternative .mo formats.""" # We need to & all 32 bit unsigned integers with 0xffffffff for # portability to 64 bit machines. MASK = 0xffffffff unpack = struct.unpack filename = getattr(fp, 'name', '') # Parse the .mo file header, which consists of 5 little endian 32 # bit words. self._catalog = catalog = {} buf = fp.read() buflen = len(buf) # Are we big endian or little endian? magic = unpack('<i', buf[:4])[0] & MASK 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) # more unsigned ints msgcount &= MASK masteridx &= MASK transidx &= MASK # 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]) moff &= MASK mend = moff + (mlen & MASK) tlen, toff = unpack(ii, buf[transidx:transidx+8]) toff &= MASK tend = toff + (tlen & MASK) if mend < buflen and tend < buflen: tmsg = buf[toff:tend] catalog[buf[moff:mend]] = tmsg else: raise IOError(0, 'File is corrupt', filename) # See if we're looking at GNU .mo conventions for metadata if mlen == 0 and tmsg.lower().startswith('project-id-version:'): # Catalog description for item in tmsg.split('\n'): 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] # advance to next entry in the seek tables masteridx += 8 transidx += 8
|
09707e363723fa24ba53e4e5d77cc26d4dea724f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/09707e363723fa24ba53e4e5d77cc26d4dea724f/gettext.py
|
|
moff &= MASK mend = moff + (mlen & MASK)
|
mend = moff + mlen
|
def _parse(self, fp): """Override this method to support alternative .mo formats.""" # We need to & all 32 bit unsigned integers with 0xffffffff for # portability to 64 bit machines. MASK = 0xffffffff unpack = struct.unpack filename = getattr(fp, 'name', '') # Parse the .mo file header, which consists of 5 little endian 32 # bit words. self._catalog = catalog = {} buf = fp.read() buflen = len(buf) # Are we big endian or little endian? magic = unpack('<i', buf[:4])[0] & MASK 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) # more unsigned ints msgcount &= MASK masteridx &= MASK transidx &= MASK # 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]) moff &= MASK mend = moff + (mlen & MASK) tlen, toff = unpack(ii, buf[transidx:transidx+8]) toff &= MASK tend = toff + (tlen & MASK) if mend < buflen and tend < buflen: tmsg = buf[toff:tend] catalog[buf[moff:mend]] = tmsg else: raise IOError(0, 'File is corrupt', filename) # See if we're looking at GNU .mo conventions for metadata if mlen == 0 and tmsg.lower().startswith('project-id-version:'): # Catalog description for item in tmsg.split('\n'): 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] # advance to next entry in the seek tables masteridx += 8 transidx += 8
|
09707e363723fa24ba53e4e5d77cc26d4dea724f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/09707e363723fa24ba53e4e5d77cc26d4dea724f/gettext.py
|
toff &= MASK tend = toff + (tlen & MASK)
|
tend = toff + tlen
|
def _parse(self, fp): """Override this method to support alternative .mo formats.""" # We need to & all 32 bit unsigned integers with 0xffffffff for # portability to 64 bit machines. MASK = 0xffffffff unpack = struct.unpack filename = getattr(fp, 'name', '') # Parse the .mo file header, which consists of 5 little endian 32 # bit words. self._catalog = catalog = {} buf = fp.read() buflen = len(buf) # Are we big endian or little endian? magic = unpack('<i', buf[:4])[0] & MASK 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) # more unsigned ints msgcount &= MASK masteridx &= MASK transidx &= MASK # 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]) moff &= MASK mend = moff + (mlen & MASK) tlen, toff = unpack(ii, buf[transidx:transidx+8]) toff &= MASK tend = toff + (tlen & MASK) if mend < buflen and tend < buflen: tmsg = buf[toff:tend] catalog[buf[moff:mend]] = tmsg else: raise IOError(0, 'File is corrupt', filename) # See if we're looking at GNU .mo conventions for metadata if mlen == 0 and tmsg.lower().startswith('project-id-version:'): # Catalog description for item in tmsg.split('\n'): 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] # advance to next entry in the seek tables masteridx += 8 transidx += 8
|
09707e363723fa24ba53e4e5d77cc26d4dea724f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/09707e363723fa24ba53e4e5d77cc26d4dea724f/gettext.py
|
if len(segments) >= 2 and segments[-1] == '..':
|
if len(segments) == 2 and segments[1] == '..' and segments[0] == '': segments[-1] = '' elif len(segments) >= 2 and segments[-1] == '..':
|
def urljoin(base, url, allow_framents = 1): if not base: return url bscheme, bnetloc, bpath, bparams, bquery, bfragment = \ urlparse(base, '', allow_framents) scheme, netloc, path, params, query, fragment = \ urlparse(url, bscheme, allow_framents) # XXX Unofficial hack: default netloc to bnetloc even if # schemes differ if scheme != bscheme and not netloc and \ scheme in uses_relative and bscheme in uses_relative and \ scheme in uses_netloc and bscheme in uses_netloc: netloc = bnetloc # Strip the port number i = find(netloc, '@') if i < 0: i = 0 i = find(netloc, ':', i) if i >= 0: netloc = netloc[:i] if scheme != bscheme or scheme not in uses_relative: return urlunparse((scheme, netloc, path, params, query, fragment)) if scheme in uses_netloc: if netloc: return urlunparse((scheme, netloc, path, params, query, fragment)) netloc = bnetloc if path[:1] == '/': return urlunparse((scheme, netloc, path, params, query, fragment)) if not path: return urlunparse((scheme, netloc, bpath, params, query or bquery, fragment)) i = rfind(bpath, '/') if i >= 0: path = bpath[:i] + '/' + path segments = splitfields(path, '/') if segments[-1] == '.': segments[-1] = '' while '.' in segments: segments.remove('.') while 1: i = 1 n = len(segments) - 1 while i < n: if segments[i] == '..' and segments[i-1]: del segments[i-1:i+1] break i = i+1 else: break if len(segments) >= 2 and segments[-1] == '..': segments[-2:] = [''] return urlunparse((scheme, netloc, joinfields(segments, '/'), params, query, fragment))
|
e612be59263f9771f89c79a89843872ae1b8f667 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e612be59263f9771f89c79a89843872ae1b8f667/urlparse.py
|
from os.path import normpath, join, dirname for (name, value) in done.items(): if value[0:2] == "./": done[name] = normpath(join(dirname(fp.name), value))
|
def parse_makefile(fp, g=None): """Parse a Makefile-style file. A dictionary containing name/value pairs is returned. If an optional dictionary is passed in as the second argument, it is used instead of a new dictionary. """ if g is None: g = {} variable_rx = re.compile("([a-zA-Z][a-zA-Z0-9_]+)\s*=\s*(.*)\n") done = {} notdone = {} # while 1: line = fp.readline() if not line: break m = variable_rx.match(line) if m: n, v = m.group(1, 2) v = string.strip(v) if "$" in v: notdone[n] = v else: try: v = string.atoi(v) except ValueError: pass done[n] = v # do variable interpolation here findvar1_rx = re.compile(r"\$\(([A-Za-z][A-Za-z0-9_]*)\)") findvar2_rx = re.compile(r"\${([A-Za-z][A-Za-z0-9_]*)}") while notdone: for name in notdone.keys(): value = notdone[name] m = findvar1_rx.search(value) if not m: m = findvar2_rx.search(value) if m: n = m.group(1) if done.has_key(n): after = value[m.end():] value = value[:m.start()] + done[n] + after if "$" in after: notdone[name] = value else: try: value = string.atoi(value) except ValueError: pass done[name] = string.strip(value) del notdone[name] elif notdone.has_key(n): # get it on a subsequent round pass else: done[n] = "" after = value[m.end():] value = value[:m.start()] + after if "$" in after: notdone[name] = value else: try: value = string.atoi(value) except ValueError: pass done[name] = string.strip(value) del notdone[name] else: # bogus variable reference; just drop it since we can't deal del notdone[name] # "Fix" all pathnames in the Makefile that are explicitly relative, # ie. that start with "./". This is a kludge to fix the "./ld_so_aix" # problem, the nature of which is that Python's installed Makefile # refers to "./ld_so_aix", but when we are building extensions we are # far from the directory where Python's Makefile (and ld_so_aix, for # that matter) is installed. Unfortunately, there are several other # relative pathnames in the Makefile, and this fix doesn't fix them, # because the layout of Python's source tree -- which is what the # Makefile refers to -- is not fully preserved in the Python # installation. Grumble. from os.path import normpath, join, dirname for (name, value) in done.items(): if value[0:2] == "./": done[name] = normpath(join(dirname(fp.name), value)) # save the results in the global dictionary g.update(done) return g
|
4f880280c2b03ec08c17714f7023eeb9d89849e8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4f880280c2b03ec08c17714f7023eeb9d89849e8/sysconfig.py
|
|
while args and args[0][0] == '-' and args[0] <> '-':
|
while args and args[0][:1] == '-' and args[0] <> '-':
|
def getopt(args, options): list = [] while args and args[0][0] == '-' and args[0] <> '-': if args[0] == '--': args = args[1:] break optstring, args = args[0][1:], args[1:] while optstring <> '': opt, optstring = optstring[0], optstring[1:] if classify(opt, options): # May raise exception as well if optstring == '': if not args: raise error, 'option -' + opt + ' requires argument' optstring, args = args[0], args[1:] optarg, optstring = optstring, '' else: optarg = '' list.append('-' + opt, optarg) return list, args
|
70083dee1203992fff93c0d659df51c6286c3e19 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/70083dee1203992fff93c0d659df51c6286c3e19/getopt.py
|
def _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite): """Execute program (MS Windows version)"""
|
51ee66e611ca16e51bea158e09db663fe0cdff22 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/51ee66e611ca16e51bea158e09db663fe0cdff22/subprocess.py
|
||
BasicStrTest
|
BasicStrTest, CharmapTest
|
def test_main(): test_support.run_unittest( UTF16Test, UTF16LETest, UTF16BETest, UTF8Test, EscapeDecodeTest, RecodingTest, PunycodeTest, UnicodeInternalTest, NameprepTest, CodecTest, CodecsModuleTest, StreamReaderTest, Str2StrTest, BasicUnicodeTest, BasicStrTest )
|
d1c1e10f70212464415fdf2ab0bed4b5d32fdf32 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d1c1e10f70212464415fdf2ab0bed4b5d32fdf32/test_codecs.py
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.