rem
stringlengths 1
322k
| add
stringlengths 0
2.05M
| context
stringlengths 4
228k
| meta
stringlengths 156
215
|
---|---|---|---|
socketDataProcessed.acquire() | def test_main(): rootLogger = logging.getLogger("") rootLogger.setLevel(logging.DEBUG) hdlr = logging.StreamHandler(sys.stdout) fmt = logging.Formatter(logging.BASIC_FORMAT) hdlr.setFormatter(fmt) rootLogger.addHandler(hdlr) #Set up a handler such that all events are sent via a socket to the log #receiver (logrecv). #The handler will only be added to the rootLogger for some of the tests hdlr = logging.handlers.SocketHandler('localhost', logging.handlers.DEFAULT_TCP_LOGGING_PORT) #Configure the logger for logrecv so events do not propagate beyond it. #The sockLogger output is buffered in memory until the end of the test, #and printed at the end. sockOut = cStringIO.StringIO() sockLogger = logging.getLogger("logrecv") sockLogger.setLevel(logging.DEBUG) sockhdlr = logging.StreamHandler(sockOut) sockhdlr.setFormatter(logging.Formatter( "%(name)s -> %(levelname)s: %(message)s")) sockLogger.addHandler(sockhdlr) sockLogger.propagate = 0 #Set up servers threads = [] tcpserver = LogRecordSocketReceiver() #sys.stdout.write("About to start TCP server...\n") threads.append(threading.Thread(target=runTCP, args=(tcpserver,))) for thread in threads: thread.start() try: banner("log_test0", "begin") rootLogger.addHandler(hdlr) test0() hdlr.close() rootLogger.removeHandler(hdlr) banner("log_test0", "end") banner("log_test1", "begin") test1() banner("log_test1", "end") banner("log_test2", "begin") test2() banner("log_test2", "end") banner("log_test3", "begin") test3() banner("log_test3", "end") finally: #wait for TCP receiver to terminate socketDataProcessed.acquire() socketDataProcessed.wait() socketDataProcessed.release() for thread in threads: thread.join() banner("logrecv output", "begin") sys.stdout.write(sockOut.getvalue()) sockOut.close() banner("logrecv output", "end") sys.stdout.flush() | b12ca583a6d7086b0f656a4acc8ada68425877b6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b12ca583a6d7086b0f656a4acc8ada68425877b6/test_logging.py |
|
socketDataProcessed.release() | def test_main(): rootLogger = logging.getLogger("") rootLogger.setLevel(logging.DEBUG) hdlr = logging.StreamHandler(sys.stdout) fmt = logging.Formatter(logging.BASIC_FORMAT) hdlr.setFormatter(fmt) rootLogger.addHandler(hdlr) #Set up a handler such that all events are sent via a socket to the log #receiver (logrecv). #The handler will only be added to the rootLogger for some of the tests hdlr = logging.handlers.SocketHandler('localhost', logging.handlers.DEFAULT_TCP_LOGGING_PORT) #Configure the logger for logrecv so events do not propagate beyond it. #The sockLogger output is buffered in memory until the end of the test, #and printed at the end. sockOut = cStringIO.StringIO() sockLogger = logging.getLogger("logrecv") sockLogger.setLevel(logging.DEBUG) sockhdlr = logging.StreamHandler(sockOut) sockhdlr.setFormatter(logging.Formatter( "%(name)s -> %(levelname)s: %(message)s")) sockLogger.addHandler(sockhdlr) sockLogger.propagate = 0 #Set up servers threads = [] tcpserver = LogRecordSocketReceiver() #sys.stdout.write("About to start TCP server...\n") threads.append(threading.Thread(target=runTCP, args=(tcpserver,))) for thread in threads: thread.start() try: banner("log_test0", "begin") rootLogger.addHandler(hdlr) test0() hdlr.close() rootLogger.removeHandler(hdlr) banner("log_test0", "end") banner("log_test1", "begin") test1() banner("log_test1", "end") banner("log_test2", "begin") test2() banner("log_test2", "end") banner("log_test3", "begin") test3() banner("log_test3", "end") finally: #wait for TCP receiver to terminate socketDataProcessed.acquire() socketDataProcessed.wait() socketDataProcessed.release() for thread in threads: thread.join() banner("logrecv output", "begin") sys.stdout.write(sockOut.getvalue()) sockOut.close() banner("logrecv output", "end") sys.stdout.flush() | b12ca583a6d7086b0f656a4acc8ada68425877b6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b12ca583a6d7086b0f656a4acc8ada68425877b6/test_logging.py |
|
self.assertRaises(ValueError, u"%c".__mod__, (sys.maxunicode+1,)) | self.assertRaises(OverflowError, u"%c".__mod__, (sys.maxunicode+1,)) | def test_formatting(self): string_tests.MixinStrUnicodeUserStringTest.test_formatting(self) # Testing Unicode formatting strings... self.assertEqual(u"%s, %s" % (u"abc", "abc"), u'abc, abc') self.assertEqual(u"%s, %s, %i, %f, %5.2f" % (u"abc", "abc", 1, 2, 3), u'abc, abc, 1, 2.000000, 3.00') self.assertEqual(u"%s, %s, %i, %f, %5.2f" % (u"abc", "abc", 1, -2, 3), u'abc, abc, 1, -2.000000, 3.00') self.assertEqual(u"%s, %s, %i, %f, %5.2f" % (u"abc", "abc", -1, -2, 3.5), u'abc, abc, -1, -2.000000, 3.50') self.assertEqual(u"%s, %s, %i, %f, %5.2f" % (u"abc", "abc", -1, -2, 3.57), u'abc, abc, -1, -2.000000, 3.57') self.assertEqual(u"%s, %s, %i, %f, %5.2f" % (u"abc", "abc", -1, -2, 1003.57), u'abc, abc, -1, -2.000000, 1003.57') if not sys.platform.startswith('java'): self.assertEqual(u"%r, %r" % (u"abc", "abc"), u"u'abc', 'abc'") self.assertEqual(u"%(x)s, %(y)s" % {'x':u"abc", 'y':"def"}, u'abc, def') self.assertEqual(u"%(x)s, %(\xfc)s" % {'x':u"abc", u'\xfc':"def"}, u'abc, def') | af4d89be439790637af3f16f817c0df3594b297e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/af4d89be439790637af3f16f817c0df3594b297e/test_unicode.py |
raise error, "bogus escape" | raise error, "bogus escape (end of line)" | def __next(self): if self.index >= len(self.string): self.next = None return char = self.string[self.index] if char[0] == "\\": try: c = self.string[self.index + 1] except IndexError: raise error, "bogus escape" char = char + c self.index = self.index + len(char) self.next = char | 8cdf1d98cb8676d10b31e6eaa984064db5ec019d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8cdf1d98cb8676d10b31e6eaa984064db5ec019d/sre_parse.py |
"""Container for the properties of an event. | """Container for the properties of an event. | def _cnfmerge(cnfs): """Internal function.""" if type(cnfs) is DictionaryType: return cnfs elif type(cnfs) in (NoneType, StringType): return cnfs else: cnf = {} for c in _flatten(cnfs): try: cnf.update(c) except (AttributeError, TypeError), msg: print "_cnfmerge: fallback due to:", msg for k, v in c.items(): cnf[k] = v return cnf | c2bfd9409912b5d4eb3e4b97641fc6321393918f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/c2bfd9409912b5d4eb3e4b97641fc6321393918f/Tkinter.py |
"""Return a tupel of x and y coordinates of the pointer on the root window.""" | """Return a tuple of x and y coordinates of the pointer on the root window.""" | def winfo_pointerxy(self): """Return a tupel of x and y coordinates of the pointer on the root window.""" return self._getints( self.tk.call('winfo', 'pointerxy', self._w)) | c2bfd9409912b5d4eb3e4b97641fc6321393918f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/c2bfd9409912b5d4eb3e4b97641fc6321393918f/Tkinter.py |
return getint( | return getint( | def winfo_pointery(self): """Return the y coordinate of the pointer on the root window.""" return getint( self.tk.call('winfo', 'pointery', self._w)) | c2bfd9409912b5d4eb3e4b97641fc6321393918f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/c2bfd9409912b5d4eb3e4b97641fc6321393918f/Tkinter.py |
"""Return tupel of decimal values for red, green, blue for | """Return tuple of decimal values for red, green, blue for | def winfo_rgb(self, color): """Return tupel of decimal values for red, green, blue for COLOR in this widget.""" return self._getints( self.tk.call('winfo', 'rgb', self._w, color)) | c2bfd9409912b5d4eb3e4b97641fc6321393918f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/c2bfd9409912b5d4eb3e4b97641fc6321393918f/Tkinter.py |
def __init__(self, name=""): """Construct a TarInfo object. name is the optional name of the member. """ | a5d321590b6fbeded04d879956891c67090e606f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a5d321590b6fbeded04d879956891c67090e606f/tarfile.py |
||
self.prefix = "" | def __init__(self, name=""): """Construct a TarInfo object. name is the optional name of the member. """ | a5d321590b6fbeded04d879956891c67090e606f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a5d321590b6fbeded04d879956891c67090e606f/tarfile.py |
|
tarinfo.prefix = buf[345:500] | prefix = buf[345:500].rstrip(NUL) if prefix and not tarinfo.issparse(): tarinfo.name = prefix + "/" + tarinfo.name | 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") | a5d321590b6fbeded04d879956891c67090e606f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a5d321590b6fbeded04d879956891c67090e606f/tarfile.py |
"""Return a tar header block as a 512 byte string. """ | """Return a tar header as a string of 512 byte blocks. """ buf = "" type = self.type prefix = "" if self.name.endswith("/"): type = DIRTYPE name = normpath(self.name) if type == DIRTYPE: name += "/" linkname = self.linkname if linkname: linkname = normpath(linkname) if posix: if self.size > MAXSIZE_MEMBER: raise ValueError("file is too large (>= 8 GB)") if len(self.linkname) > LENGTH_LINK: raise ValueError("linkname is too long (>%d)" % (LENGTH_LINK)) if len(name) > LENGTH_NAME: prefix = name[:LENGTH_PREFIX + 1] while prefix and prefix[-1] != "/": prefix = prefix[:-1] name = name[len(prefix):] prefix = prefix[:-1] if not prefix or len(name) > LENGTH_NAME: raise ValueError("name is too long") else: if len(self.linkname) > LENGTH_LINK: buf += self._create_gnulong(self.linkname, GNUTYPE_LONGLINK) if len(name) > LENGTH_NAME: buf += self._create_gnulong(name, GNUTYPE_LONGNAME) | def tobuf(self, posix=False): """Return a tar header block as a 512 byte string. """ parts = [ stn(self.name, 100), itn(self.mode & 07777, 8, posix), itn(self.uid, 8, posix), itn(self.gid, 8, posix), itn(self.size, 12, posix), itn(self.mtime, 12, posix), " ", # checksum field self.type, stn(self.linkname, 100), stn(MAGIC, 6), stn(VERSION, 2), stn(self.uname, 32), stn(self.gname, 32), itn(self.devmajor, 8, posix), itn(self.devminor, 8, posix), stn(self.prefix, 155) ] | a5d321590b6fbeded04d879956891c67090e606f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a5d321590b6fbeded04d879956891c67090e606f/tarfile.py |
stn(self.name, 100), | stn(name, 100), | def tobuf(self, posix=False): """Return a tar header block as a 512 byte string. """ parts = [ stn(self.name, 100), itn(self.mode & 07777, 8, posix), itn(self.uid, 8, posix), itn(self.gid, 8, posix), itn(self.size, 12, posix), itn(self.mtime, 12, posix), " ", # checksum field self.type, stn(self.linkname, 100), stn(MAGIC, 6), stn(VERSION, 2), stn(self.uname, 32), stn(self.gname, 32), itn(self.devmajor, 8, posix), itn(self.devminor, 8, posix), stn(self.prefix, 155) ] | a5d321590b6fbeded04d879956891c67090e606f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a5d321590b6fbeded04d879956891c67090e606f/tarfile.py |
self.type, | type, | def tobuf(self, posix=False): """Return a tar header block as a 512 byte string. """ parts = [ stn(self.name, 100), itn(self.mode & 07777, 8, posix), itn(self.uid, 8, posix), itn(self.gid, 8, posix), itn(self.size, 12, posix), itn(self.mtime, 12, posix), " ", # checksum field self.type, stn(self.linkname, 100), stn(MAGIC, 6), stn(VERSION, 2), stn(self.uname, 32), stn(self.gname, 32), itn(self.devmajor, 8, posix), itn(self.devminor, 8, posix), stn(self.prefix, 155) ] | a5d321590b6fbeded04d879956891c67090e606f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a5d321590b6fbeded04d879956891c67090e606f/tarfile.py |
stn(self.prefix, 155) | stn(prefix, 155) | def tobuf(self, posix=False): """Return a tar header block as a 512 byte string. """ parts = [ stn(self.name, 100), itn(self.mode & 07777, 8, posix), itn(self.uid, 8, posix), itn(self.gid, 8, posix), itn(self.size, 12, posix), itn(self.mtime, 12, posix), " ", # checksum field self.type, stn(self.linkname, 100), stn(MAGIC, 6), stn(VERSION, 2), stn(self.uname, 32), stn(self.gname, 32), itn(self.devmajor, 8, posix), itn(self.devminor, 8, posix), stn(self.prefix, 155) ] | a5d321590b6fbeded04d879956891c67090e606f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a5d321590b6fbeded04d879956891c67090e606f/tarfile.py |
buf = struct.pack("%ds" % BLOCKSIZE, "".join(parts)) | buf += struct.pack("%ds" % BLOCKSIZE, "".join(parts)) | def tobuf(self, posix=False): """Return a tar header block as a 512 byte string. """ parts = [ stn(self.name, 100), itn(self.mode & 07777, 8, posix), itn(self.uid, 8, posix), itn(self.gid, 8, posix), itn(self.size, 12, posix), itn(self.mtime, 12, posix), " ", # checksum field self.type, stn(self.linkname, 100), stn(MAGIC, 6), stn(VERSION, 2), stn(self.uname, 32), stn(self.gname, 32), itn(self.devmajor, 8, posix), itn(self.devminor, 8, posix), stn(self.prefix, 155) ] | a5d321590b6fbeded04d879956891c67090e606f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a5d321590b6fbeded04d879956891c67090e606f/tarfile.py |
buf = buf[:148] + "%06o\0" % chksum + buf[155:] | buf = buf[:-364] + "%06o\0" % chksum + buf[-357:] | def tobuf(self, posix=False): """Return a tar header block as a 512 byte string. """ parts = [ stn(self.name, 100), itn(self.mode & 07777, 8, posix), itn(self.uid, 8, posix), itn(self.gid, 8, posix), itn(self.size, 12, posix), itn(self.mtime, 12, posix), " ", # checksum field self.type, stn(self.linkname, 100), stn(MAGIC, 6), stn(VERSION, 2), stn(self.uname, 32), stn(self.gname, 32), itn(self.devmajor, 8, posix), itn(self.devminor, 8, posix), stn(self.prefix, 155) ] | a5d321590b6fbeded04d879956891c67090e606f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a5d321590b6fbeded04d879956891c67090e606f/tarfile.py |
tarinfo.name = normpath(tarinfo.name) if tarinfo.isdir(): tarinfo.name += "/" if tarinfo.linkname: tarinfo.linkname = normpath(tarinfo.linkname) if tarinfo.size > MAXSIZE_MEMBER: if self.posix: raise ValueError("file is too large (>= 8 GB)") else: self._dbg(2, "tarfile: Created GNU tar largefile header") if len(tarinfo.linkname) > LENGTH_LINK: if self.posix: raise ValueError("linkname is too long (>%d)" % (LENGTH_LINK)) else: self._create_gnulong(tarinfo.linkname, GNUTYPE_LONGLINK) tarinfo.linkname = tarinfo.linkname[:LENGTH_LINK -1] self._dbg(2, "tarfile: Created GNU tar extension LONGLINK") if len(tarinfo.name) > LENGTH_NAME: if self.posix: prefix = tarinfo.name[:LENGTH_PREFIX + 1] while prefix and prefix[-1] != "/": prefix = prefix[:-1] name = tarinfo.name[len(prefix):] prefix = prefix[:-1] if not prefix or len(name) > LENGTH_NAME: raise ValueError("name is too long (>%d)" % (LENGTH_NAME)) tarinfo.name = name tarinfo.prefix = prefix else: self._create_gnulong(tarinfo.name, GNUTYPE_LONGNAME) tarinfo.name = tarinfo.name[:LENGTH_NAME - 1] self._dbg(2, "tarfile: Created GNU tar extension LONGNAME") self.fileobj.write(tarinfo.tobuf(self.posix)) self.offset += BLOCKSIZE | tarinfo = copy.copy(tarinfo) buf = tarinfo.tobuf(self.posix) self.fileobj.write(buf) self.offset += len(buf) | def addfile(self, tarinfo, fileobj=None): """Add the TarInfo object `tarinfo' to the archive. If `fileobj' is given, tarinfo.size bytes are read from it and added to the archive. You can create TarInfo objects using gettarinfo(). On Windows platforms, `fileobj' should always be opened with mode 'rb' to avoid irritation about the file size. """ self._check("aw") | a5d321590b6fbeded04d879956891c67090e606f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a5d321590b6fbeded04d879956891c67090e606f/tarfile.py |
tarinfo.name = normpath(os.path.join(tarinfo.prefix.rstrip(NUL), tarinfo.name)) | 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 | a5d321590b6fbeded04d879956891c67090e606f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a5d321590b6fbeded04d879956891c67090e606f/tarfile.py |
|
tarinfo.prefix = "" | def proc_sparse(self, tarinfo): """Process a GNU sparse header plus extra headers. """ buf = tarinfo.buf sp = _ringbuffer() pos = 386 lastpos = 0L realpos = 0L # There are 4 possible sparse structs in the # first header. for i in xrange(4): try: offset = nti(buf[pos:pos + 12]) numbytes = nti(buf[pos + 12:pos + 24]) except ValueError: break if offset > lastpos: sp.append(_hole(lastpos, offset - lastpos)) sp.append(_data(offset, numbytes, realpos)) realpos += numbytes lastpos = offset + numbytes pos += 24 | a5d321590b6fbeded04d879956891c67090e606f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a5d321590b6fbeded04d879956891c67090e606f/tarfile.py |
|
def _create_gnulong(self, name, type): """Write a GNU longname/longlink member to the TarFile. It consists of an extended tar header, with the length of the longname as size, followed by data blocks, which contain the longname as a null terminated string. """ name += NUL tarinfo = TarInfo() tarinfo.name = "././@LongLink" tarinfo.type = type tarinfo.mode = 0 tarinfo.size = len(name) self.fileobj.write(tarinfo.tobuf()) self.offset += BLOCKSIZE self.fileobj.write(name) blocks, remainder = divmod(tarinfo.size, BLOCKSIZE) if remainder > 0: self.fileobj.write(NUL * (BLOCKSIZE - remainder)) blocks += 1 self.offset += blocks * BLOCKSIZE | def __iter__(self): """Provide an iterator object. """ if self._loaded: return iter(self.members) else: return TarIter(self) | a5d321590b6fbeded04d879956891c67090e606f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a5d321590b6fbeded04d879956891c67090e606f/tarfile.py |
|
except: | except NameError: | def _init_categories(categories=categories): for k,v in globals().items(): if k[:3] == 'LC_': categories[k] = v | 326fc0c070ceed2a8a465b214cb3a3c65bce272f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/326fc0c070ceed2a8a465b214cb3a3c65bce272f/locale.py |
This is called by the http_error_30x methods when a redirection response is received. If a redirection should take place, return a new Request to allow http_error_30x to perform the redirect. Otherwise, raise HTTPError if no-one else should try to handle this url. Return None if you can't but another Handler might. | This is called by the http_error_30x methods when a redirection response is received. If a redirection should take place, return a new Request to allow http_error_30x to perform the redirect. Otherwise, raise HTTPError if no-one else should try to handle this url. Return None if you can't but another Handler might. | def redirect_request(self, req, fp, code, msg, headers, newurl): """Return a Request or None in response to a redirect. | 20de815e627877d604ee88b5781bf5b64b2edb18 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/20de815e627877d604ee88b5781bf5b64b2edb18/urllib2.py |
user, password = HTTPPasswordMgr.find_user_password(self,realm,authuri) | user, password = HTTPPasswordMgr.find_user_password(self, realm, authuri) | def find_user_password(self, realm, authuri): user, password = HTTPPasswordMgr.find_user_password(self,realm,authuri) if user is not None: return user, password return HTTPPasswordMgr.find_user_password(self, None, authuri) | 20de815e627877d604ee88b5781bf5b64b2edb18 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/20de815e627877d604ee88b5781bf5b64b2edb18/urllib2.py |
header = 'Authorization' | auth_header = 'Authorization' | def get_entity_digest(self, data, chal): # XXX not implemented yet return None | 20de815e627877d604ee88b5781bf5b64b2edb18 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/20de815e627877d604ee88b5781bf5b64b2edb18/urllib2.py |
header = 'Proxy-Authorization' | auth_header = 'Proxy-Authorization' | def http_error_401(self, req, fp, code, msg, headers): host = urlparse.urlparse(req.get_full_url())[1] self.http_error_auth_reqed('www-authenticate', host, req, headers) | 20de815e627877d604ee88b5781bf5b64b2edb18 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/20de815e627877d604ee88b5781bf5b64b2edb18/urllib2.py |
if path.startswith(dir) and path[len(dir)] == os.path.sep: | dir = os.path.normcase(dir) if comparepath.startswith(dir) and comparepath[len(dir)] == os.sep: | def fullmodname(path): """Return a plausible module name for the path.""" # If the file 'path' is part of a package, then the filename isn't # enough to uniquely identify it. Try to do the right thing by # looking in sys.path for the longest matching prefix. We'll # assume that the rest is the package name. longest = "" for dir in sys.path: if path.startswith(dir) and path[len(dir)] == os.path.sep: if len(dir) > len(longest): longest = dir if longest: base = path[len(longest) + 1:] else: base = path base = base.replace(os.sep, ".") if os.altsep: base = base.replace(os.altsep, ".") filename, ext = os.path.splitext(base) return filename | 7e47ee1f260b297b5c11015bbcdb53dbe10da90a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/7e47ee1f260b297b5c11015bbcdb53dbe10da90a/trace.py |
FILE = open(self.file_path, 'wU') | FILE = open(self.file_path, 'w') | def create(self): """Create a .pth file with a comment, blank lines, an ``import <self.imported>``, a line with self.good_dirname, and a line with self.bad_dirname. | 936bc6091d116f5ac4135118d15148b7cbf231b7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/936bc6091d116f5ac4135118d15148b7cbf231b7/test_site.py |
return os.path.join(prefix, "Mac", "Plugins") | return os.path.join(prefix, "Lib", "lib-dynload") | def get_python_lib(plat_specific=0, standard_lib=0, prefix=None): """Return the directory containing the Python library (standard or site additions). If 'plat_specific' is true, return the directory containing platform-specific modules, i.e. any module from a non-pure-Python module distribution; otherwise, return the platform-shared library directory. If 'standard_lib' is true, return the directory containing standard Python library modules; otherwise, return the directory for site-specific modules. If 'prefix' is supplied, use it instead of sys.prefix or sys.exec_prefix -- i.e., ignore 'plat_specific'. """ if prefix is None: prefix = plat_specific and EXEC_PREFIX or PREFIX if os.name == "posix": libpython = os.path.join(prefix, "lib", "python" + sys.version[:3]) if standard_lib: return libpython else: return os.path.join(libpython, "site-packages") elif os.name == "nt": if standard_lib: return os.path.join(prefix, "Lib") else: if sys.version < "2.2": return prefix else: return os.path.join(PREFIX, "Lib", "site-packages") elif os.name == "mac": if plat_specific: if standard_lib: return os.path.join(prefix, "Mac", "Plugins") else: raise DistutilsPlatformError( "OK, where DO site-specific extensions go on the Mac?") else: if standard_lib: return os.path.join(prefix, "Lib") else: raise DistutilsPlatformError( "OK, where DO site-specific modules go on the Mac?") else: raise DistutilsPlatformError( "I don't know where Python installs its library " "on platform '%s'" % os.name) | e02d632ecbf922864b83cc707f4ea1e36509501a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/e02d632ecbf922864b83cc707f4ea1e36509501a/sysconfig.py |
raise DistutilsPlatformError( "OK, where DO site-specific extensions go on the Mac?") | return os.path.join(prefix, "Lib", "site-packages") | def get_python_lib(plat_specific=0, standard_lib=0, prefix=None): """Return the directory containing the Python library (standard or site additions). If 'plat_specific' is true, return the directory containing platform-specific modules, i.e. any module from a non-pure-Python module distribution; otherwise, return the platform-shared library directory. If 'standard_lib' is true, return the directory containing standard Python library modules; otherwise, return the directory for site-specific modules. If 'prefix' is supplied, use it instead of sys.prefix or sys.exec_prefix -- i.e., ignore 'plat_specific'. """ if prefix is None: prefix = plat_specific and EXEC_PREFIX or PREFIX if os.name == "posix": libpython = os.path.join(prefix, "lib", "python" + sys.version[:3]) if standard_lib: return libpython else: return os.path.join(libpython, "site-packages") elif os.name == "nt": if standard_lib: return os.path.join(prefix, "Lib") else: if sys.version < "2.2": return prefix else: return os.path.join(PREFIX, "Lib", "site-packages") elif os.name == "mac": if plat_specific: if standard_lib: return os.path.join(prefix, "Mac", "Plugins") else: raise DistutilsPlatformError( "OK, where DO site-specific extensions go on the Mac?") else: if standard_lib: return os.path.join(prefix, "Lib") else: raise DistutilsPlatformError( "OK, where DO site-specific modules go on the Mac?") else: raise DistutilsPlatformError( "I don't know where Python installs its library " "on platform '%s'" % os.name) | e02d632ecbf922864b83cc707f4ea1e36509501a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/e02d632ecbf922864b83cc707f4ea1e36509501a/sysconfig.py |
raise DistutilsPlatformError( "OK, where DO site-specific modules go on the Mac?") | return os.path.join(prefix, "Lib", "site-packages") | def get_python_lib(plat_specific=0, standard_lib=0, prefix=None): """Return the directory containing the Python library (standard or site additions). If 'plat_specific' is true, return the directory containing platform-specific modules, i.e. any module from a non-pure-Python module distribution; otherwise, return the platform-shared library directory. If 'standard_lib' is true, return the directory containing standard Python library modules; otherwise, return the directory for site-specific modules. If 'prefix' is supplied, use it instead of sys.prefix or sys.exec_prefix -- i.e., ignore 'plat_specific'. """ if prefix is None: prefix = plat_specific and EXEC_PREFIX or PREFIX if os.name == "posix": libpython = os.path.join(prefix, "lib", "python" + sys.version[:3]) if standard_lib: return libpython else: return os.path.join(libpython, "site-packages") elif os.name == "nt": if standard_lib: return os.path.join(prefix, "Lib") else: if sys.version < "2.2": return prefix else: return os.path.join(PREFIX, "Lib", "site-packages") elif os.name == "mac": if plat_specific: if standard_lib: return os.path.join(prefix, "Mac", "Plugins") else: raise DistutilsPlatformError( "OK, where DO site-specific extensions go on the Mac?") else: if standard_lib: return os.path.join(prefix, "Lib") else: raise DistutilsPlatformError( "OK, where DO site-specific modules go on the Mac?") else: raise DistutilsPlatformError( "I don't know where Python installs its library " "on platform '%s'" % os.name) | e02d632ecbf922864b83cc707f4ea1e36509501a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/e02d632ecbf922864b83cc707f4ea1e36509501a/sysconfig.py |
import macfs | import macfs | def islink(s): """Return true if the pathname refers to a symbolic link.""" try: import macfs return macfs.ResolveAliasFile(s)[2] except: return False | d79ca7d394cfa8387460f121d73f6147718acfc0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d79ca7d394cfa8387460f121d73f6147718acfc0/macpath.py |
path = os.path.join(host, path) if path[-1] == "/": path = path + "index.html" | if not path or path[-1] == "/": path = path + "index.html" | def savefilename(self, url): type, rest = urllib.splittype(url) host, path = urllib.splithost(rest) while path[:1] == "/": path = path[1:] user, host = urllib.splituser(host) host, port = urllib.splitnport(host) host = string.lower(host) path = os.path.join(host, path) if path[-1] == "/": path = path + "index.html" if os.sep != "/": path = string.join(string.split(path, "/"), os.sep) return path | 6b4dae1604cc214f5125fc888e72dfd12c7afc67 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/6b4dae1604cc214f5125fc888e72dfd12c7afc67/websucker.py |
l.append (fd, flags) | l.append ((fd, flags)) | def poll2 (timeout=0.0): import poll # timeout is in milliseconds timeout = int(timeout*1000) if socket_map: fd_map = {} for s in socket_map.keys(): fd_map[s.fileno()] = s l = [] for fd, s in fd_map.items(): flags = 0 if s.readable(): flags = poll.POLLIN if s.writable(): flags = flags | poll.POLLOUT if flags: l.append (fd, flags) r = poll.poll (l, timeout) for fd, flags in r: s = fd_map[fd] try: if (flags & poll.POLLIN): s.handle_read_event() if (flags & poll.POLLOUT): s.handle_write_event() if (flags & poll.POLLERR): s.handle_expt_event() except: s.handle_error() | 1a2db408820053542eb9c09530d1c00e5cd61f75 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1a2db408820053542eb9c09530d1c00e5cd61f75/asyncore.py |
tbinfo.append ( | tbinfo.append (( | def compact_traceback (): t,v,tb = sys.exc_info() tbinfo = [] while 1: tbinfo.append ( tb.tb_frame.f_code.co_filename, tb.tb_frame.f_code.co_name, str(tb.tb_lineno) ) tb = tb.tb_next if not tb: break # just to be safe del tb file, function, line = tbinfo[-1] info = '[' + string.join ( map ( lambda x: string.join (x, '|'), tbinfo ), '] [' ) + ']' return (file, function, line), t, v, info | 1a2db408820053542eb9c09530d1c00e5cd61f75 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1a2db408820053542eb9c09530d1c00e5cd61f75/asyncore.py |
tb.tb_frame.f_code.co_name, | tb.tb_frame.f_code.co_name, | def compact_traceback (): t,v,tb = sys.exc_info() tbinfo = [] while 1: tbinfo.append ( tb.tb_frame.f_code.co_filename, tb.tb_frame.f_code.co_name, str(tb.tb_lineno) ) tb = tb.tb_next if not tb: break # just to be safe del tb file, function, line = tbinfo[-1] info = '[' + string.join ( map ( lambda x: string.join (x, '|'), tbinfo ), '] [' ) + ']' return (file, function, line), t, v, info | 1a2db408820053542eb9c09530d1c00e5cd61f75 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1a2db408820053542eb9c09530d1c00e5cd61f75/asyncore.py |
) | )) | def compact_traceback (): t,v,tb = sys.exc_info() tbinfo = [] while 1: tbinfo.append ( tb.tb_frame.f_code.co_filename, tb.tb_frame.f_code.co_name, str(tb.tb_lineno) ) tb = tb.tb_next if not tb: break # just to be safe del tb file, function, line = tbinfo[-1] info = '[' + string.join ( map ( lambda x: string.join (x, '|'), tbinfo ), '] [' ) + ']' return (file, function, line), t, v, info | 1a2db408820053542eb9c09530d1c00e5cd61f75 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1a2db408820053542eb9c09530d1c00e5cd61f75/asyncore.py |
'ext_modules': ('build_ext', 'modules'), | 'ext_modules': ('build_ext', 'extensions'), | def setup (**attrs): """The gateway to the Distutils: do everything your setup script needs to do, in a highly flexible and user-driven way. Briefly: create a Distribution instance; parse the command-line, creating and customizing instances of the command class for each command found on the command-line; run each of those commands. The Distribution instance might be an instance of a class supplied via the 'distclass' keyword argument to 'setup'; if no such class is supplied, then the 'Distribution' class (also in this module) is instantiated. All other arguments to 'setup' (except for 'cmdclass') are used to set attributes of the Distribution instance. The 'cmdclass' argument, if supplied, is a dictionary mapping command names to command classes. Each command encountered on the command line will be turned into a command class, which is in turn instantiated; any class found in 'cmdclass' is used in place of the default, which is (for command 'foo_bar') class 'FooBar' in module 'distutils.command.foo_bar'. The command object must provide an 'options' attribute which is a list of option specifiers for 'distutils.fancy_getopt'. Any command-line options between the current and the next command are used to set attributes in the current command object. When the entire command-line has been successfully parsed, calls the 'run' method on each command object in turn. This method will be driven entirely by the Distribution object (which each command object has a reference to, thanks to its constructor), and the command-specific options that became attributes of each command object.""" # Determine the distribution class -- either caller-supplied or # our Distribution (see below). klass = attrs.get ('distclass') if klass: del attrs['distclass'] else: klass = Distribution # Create the Distribution instance, using the remaining arguments # (ie. everything except distclass) to initialize it dist = klass (attrs) # If we had a config file, this is where we would parse it: override # the client-supplied command options, but be overridden by the # command line. # Parse the command line; any command-line errors are the end-users # fault, so turn them into SystemExit to suppress tracebacks. try: dist.parse_command_line (sys.argv[1:]) except DistutilsArgError, msg: raise SystemExit, msg # And finally, run all the commands found on the command line. dist.run_commands () | 363e008b0984072a91bd94e893ad053fb115cf56 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/363e008b0984072a91bd94e893ad053fb115cf56/core.py |
"command %s: no such option %s" % \ | "command '%s': no such option '%s'" % \ | def set_option (self, option, value): """Set the value of a single option for this command. Raise DistutilsOptionError if 'option' is not known.""" | 363e008b0984072a91bd94e893ad053fb115cf56 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/363e008b0984072a91bd94e893ad053fb115cf56/core.py |
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') | 387f886616dbba17fb0cbf3f2ed160325117c2b8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/387f886616dbba17fb0cbf3f2ed160325117c2b8/setup.py |
||
env_val = os.getenv(env_var) | env_val = sysconfig.get_config_var(env_var) | def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') | 387f886616dbba17fb0cbf3f2ed160325117c2b8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/387f886616dbba17fb0cbf3f2ed160325117c2b8/setup.py |
output.write(input.read()) | return output.write(input.read()) | def decode(input, output, encoding): """Decode common content-transfer-encodings (base64, quopri, uuencode).""" if encoding == 'base64': import base64 return base64.decode(input, output) if encoding == 'quoted-printable': import quopri return quopri.decode(input, output) if encoding in ('uuencode', 'x-uuencode', 'uue', 'x-uue'): import uu return uu.decode(input, output) if encoding in ('7bit', '8bit'): output.write(input.read()) if decodetab.has_key(encoding): pipethrough(input, decodetab[encoding], output) else: raise ValueError, \ 'unknown Content-Transfer-Encoding: %s' % encoding | aa2aaa53f3cfd347bd8a4f3e9e4a036e3c8f41f8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/aa2aaa53f3cfd347bd8a4f3e9e4a036e3c8f41f8/mimetools.py |
output.write(input.read()) | return output.write(input.read()) | def encode(input, output, encoding): """Encode common content-transfer-encodings (base64, quopri, uuencode).""" if encoding == 'base64': import base64 return base64.encode(input, output) if encoding == 'quoted-printable': import quopri return quopri.encode(input, output, 0) if encoding in ('uuencode', 'x-uuencode', 'uue', 'x-uue'): import uu return uu.encode(input, output) if encoding in ('7bit', '8bit'): output.write(input.read()) if encodetab.has_key(encoding): pipethrough(input, encodetab[encoding], output) else: raise ValueError, \ 'unknown Content-Transfer-Encoding: %s' % encoding | aa2aaa53f3cfd347bd8a4f3e9e4a036e3c8f41f8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/aa2aaa53f3cfd347bd8a4f3e9e4a036e3c8f41f8/mimetools.py |
FILE = file(test_support.TESTFN, 'w') | FILE = file(test_support.TESTFN, 'wb') | def setUp(self): """Setup of a temp file to use for testing""" self.text = "test_urllib: %s\n" % self.__class__.__name__ FILE = file(test_support.TESTFN, 'w') try: FILE.write(self.text) finally: FILE.close() self.pathname = test_support.TESTFN self.returned_obj = urllib.urlopen("file:%s" % self.pathname) | 0244c7405d6d30653be5ec1be555809e876e451c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/0244c7405d6d30653be5ec1be555809e876e451c/test_urllib.py |
prefix = m[0] for item in m: for i in range(len(prefix)): if prefix[:i+1] != item[:i+1]: prefix = prefix[:i] if i == 0: return '' break return prefix | s1 = min(m) s2 = max(m) n = min(len(s1), len(s2)) for i in xrange(n): if s1[i] != s2[i]: return s1[:i] return s1[:n] | def commonprefix(m): "Given a list of pathnames, returns the longest common leading component" if not m: return '' prefix = m[0] for item in m: for i in range(len(prefix)): if prefix[:i+1] != item[:i+1]: prefix = prefix[:i] if i == 0: return '' break return prefix | d04bdebb06ff2c76629ecb030df623125ffd8954 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d04bdebb06ff2c76629ecb030df623125ffd8954/posixpath.py |
inc_dir = get_python_inc(plat_specific=1) | if python_build: inc_dir = '.' else: inc_dir = get_python_inc(plat_specific=1) | def get_config_h_filename(): """Return full pathname of installed config.h file.""" inc_dir = get_python_inc(plat_specific=1) return os.path.join(inc_dir, "config.h") | be596c4e7399c1d2d8df512cb5c7df1a15f9c315 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/be596c4e7399c1d2d8df512cb5c7df1a15f9c315/sysconfig.py |
if os.name == 'mac': def writable(self): return not self.accepting else: def writable(self): return True | def writable(self): return True | def readable(self): return True | 0f998027cc4f83e4bb8c052e65d620fe3d011a9f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/0f998027cc4f83e4bb8c052e65d620fe3d011a9f/asyncore.py |
typ, dat = self._simple_command('GETQUOTA', root) | typ, dat = self._simple_command('GETQUOTA', mailbox) | def getquotaroot(self, mailbox): """Get the list of quota roots for the named mailbox. | 857ee505440131ca1750d94966f51ba4b2fbd0ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/857ee505440131ca1750d94966f51ba4b2fbd0ca/imaplib.py |
self.disallow_all = 0 self.allow_all = 0 | self.disallow_all = False self.allow_all = False | def __init__(self, url=''): self.entries = [] self.default_entry = None self.disallow_all = 0 self.allow_all = 0 self.set_url(url) self.last_checked = 0 | cdc5dc13bf5601f11087fe93324730aef873843b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/cdc5dc13bf5601f11087fe93324730aef873843b/robotparser.py |
self.disallow_all = 1 | self.disallow_all = True | def read(self): """Reads the robots.txt URL and feeds it to the parser.""" opener = URLopener() f = opener.open(self.url) lines = [] line = f.readline() while line: lines.append(line.strip()) line = f.readline() 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) | cdc5dc13bf5601f11087fe93324730aef873843b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/cdc5dc13bf5601f11087fe93324730aef873843b/robotparser.py |
self.allow_all = 1 | self.allow_all = True | def read(self): """Reads the robots.txt URL and feeds it to the parser.""" opener = URLopener() f = opener.open(self.url) lines = [] line = f.readline() while line: lines.append(line.strip()) line = f.readline() 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) | cdc5dc13bf5601f11087fe93324730aef873843b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/cdc5dc13bf5601f11087fe93324730aef873843b/robotparser.py |
entry.rulelines.append(RuleLine(line[1], 0)) | entry.rulelines.append(RuleLine(line[1], False)) | def parse(self, lines): """parse the input lines from a robots.txt file. We allow that a user-agent: line is not preceded by one or more blank lines.""" state = 0 linenumber = 0 entry = Entry() | cdc5dc13bf5601f11087fe93324730aef873843b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/cdc5dc13bf5601f11087fe93324730aef873843b/robotparser.py |
entry.rulelines.append(RuleLine(line[1], 1)) | entry.rulelines.append(RuleLine(line[1], True)) | def parse(self, lines): """parse the input lines from a robots.txt file. We allow that a user-agent: line is not preceded by one or more blank lines.""" state = 0 linenumber = 0 entry = Entry() | cdc5dc13bf5601f11087fe93324730aef873843b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/cdc5dc13bf5601f11087fe93324730aef873843b/robotparser.py |
"""A rule line is a single "Allow:" (allowance==1) or "Disallow:" (allowance==0) followed by a path.""" | """A rule line is a single "Allow:" (allowance==True) or "Disallow:" (allowance==False) followed by a path.""" | def __str__(self): ret = "" for entry in self.entries: ret = ret + str(entry) + "\n" return ret | cdc5dc13bf5601f11087fe93324730aef873843b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/cdc5dc13bf5601f11087fe93324730aef873843b/robotparser.py |
allowance = 1 | allowance = True | def __init__(self, path, allowance): if path == '' and not allowance: # an empty value means allow all allowance = 1 self.path = urllib.quote(path) self.allowance = allowance | cdc5dc13bf5601f11087fe93324730aef873843b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/cdc5dc13bf5601f11087fe93324730aef873843b/robotparser.py |
return 1 | return True | def allowance(self, filename): """Preconditions: - our agent applies to this entry - filename is URL decoded""" for line in self.rulelines: _debug((filename, str(line), line.allowance)) if line.applies_to(filename): return line.allowance return 1 | cdc5dc13bf5601f11087fe93324730aef873843b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/cdc5dc13bf5601f11087fe93324730aef873843b/robotparser.py |
'$CC -Wl,-t -o /dev/null 2>&1 -l' + name | '$CC -Wl,-t -o ' + ccout + ' 2>&1 -l' + name | def _findLib_gcc(name): expr = '[^\(\)\s]*lib%s\.[^\(\)\s]*' % name cmd = 'if type gcc &>/dev/null; then CC=gcc; else CC=cc; fi;' \ '$CC -Wl,-t -o /dev/null 2>&1 -l' + name try: fdout, outfile = tempfile.mkstemp() fd = os.popen(cmd) trace = fd.read() err = fd.close() finally: try: os.unlink(outfile) except OSError, e: if e.errno != errno.ENOENT: raise res = re.search(expr, trace) if not res: return None return res.group(0) | 5ecd565a310c7efd0270382d27f395e78aae57ab /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/5ecd565a310c7efd0270382d27f395e78aae57ab/util.py |
def index(path, archivo, output): | def index(path, indexpage, output): | def index(path, archivo, output): f = formatter.AbstractFormatter(AlmostNullWriter()) parser = IdxHlpHtmlParser(f) parser.path = path parser.ft = output fil = path + '/' + archivo parser.feed(open(fil).read()) parser.close() | 8015dfc7a15e3f806424cf9b38ac0fd2916f7714 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8015dfc7a15e3f806424cf9b38ac0fd2916f7714/prechm.py |
fil = path + '/' + archivo parser.feed(open(fil).read()) | f = open(path + '/' + indexpage) parser.feed(f.read()) | def index(path, archivo, output): f = formatter.AbstractFormatter(AlmostNullWriter()) parser = IdxHlpHtmlParser(f) parser.path = path parser.ft = output fil = path + '/' + archivo parser.feed(open(fil).read()) parser.close() | 8015dfc7a15e3f806424cf9b38ac0fd2916f7714 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8015dfc7a15e3f806424cf9b38ac0fd2916f7714/prechm.py |
def content(path, archivo, output): | f.close() def content(path, contentpage, output): | def index(path, archivo, output): f = formatter.AbstractFormatter(AlmostNullWriter()) parser = IdxHlpHtmlParser(f) parser.path = path parser.ft = output fil = path + '/' + archivo parser.feed(open(fil).read()) parser.close() | 8015dfc7a15e3f806424cf9b38ac0fd2916f7714 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8015dfc7a15e3f806424cf9b38ac0fd2916f7714/prechm.py |
fil = path + '/' + archivo parser.feed(open(fil).read()) | f = open(path + '/' + contentpage) parser.feed(f.read()) | def content(path, archivo, output): f = formatter.AbstractFormatter(AlmostNullWriter()) parser = TocHlpHtmlParser(f) parser.path = path parser.ft = output fil = path + '/' + archivo parser.feed(open(fil).read()) parser.close() | 8015dfc7a15e3f806424cf9b38ac0fd2916f7714 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8015dfc7a15e3f806424cf9b38ac0fd2916f7714/prechm.py |
print '\t', book[2] if book[4]: index(book[0], book[4], output) | print '\t', book.title, '-', book.indexpage if book.indexpage: index(book.directory, book.indexpage, output) | def do_index(library, output): output.write('<UL>\n') for book in library: print '\t', book[2] if book[4]: index(book[0], book[4], output) output.write('</UL>\n') | 8015dfc7a15e3f806424cf9b38ac0fd2916f7714 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8015dfc7a15e3f806424cf9b38ac0fd2916f7714/prechm.py |
print '\t', book[2] output.write(object_sitemap % (book[0]+"/"+book[2], book[1])) if book[3]: content(book[0], book[3], output) | print '\t', book.title, '-', book.firstpage output.write(object_sitemap % (book.directory + "/" + book.firstpage, book.title)) if book.contentpage: content(book.directory, book.contentpage, output) | def do_content(library, version, output): output.write(contents_header % version) for book in library: print '\t', book[2] output.write(object_sitemap % (book[0]+"/"+book[2], book[1])) if book[3]: content(book[0], book[3], output) output.write(contents_footer) | 8015dfc7a15e3f806424cf9b38ac0fd2916f7714 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8015dfc7a15e3f806424cf9b38ac0fd2916f7714/prechm.py |
directory = book[0] | directory = book.directory | def do_project(library, output, arch, version): output.write(project_template % locals()) for book in library: directory = book[0] path = directory + '\\%s\n' for page in os.listdir(directory): if page.endswith('.html') or page.endswith('.css'): output.write(path % page) | 8015dfc7a15e3f806424cf9b38ac0fd2916f7714 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8015dfc7a15e3f806424cf9b38ac0fd2916f7714/prechm.py |
library = supported_libraries[ version ] | library = supported_libraries[version] | def do_it(args = None): if not args: args = sys.argv[1:] if not args: usage() try: optlist, args = getopt.getopt(args, 'ckpv:') except getopt.error, msg: print msg usage() if not args or len(args) > 1: usage() arch = args[0] version = None for opt in optlist: if opt[0] == '-v': version = opt[1] break if not version: usage() library = supported_libraries[ version ] if not (('-p','') in optlist): fname = arch + '.stp' f = openfile(fname) print "Building stoplist", fname, "..." words = stop_list.split() words.sort() for word in words: print >> f, word f.close() f = openfile(arch + '.hhp') print "Building Project..." do_project(library, f, arch, version) if version == '2.0.0': for image in os.listdir('icons'): f.write('icons'+ '\\' + image + '\n') f.close() if not (('-c','') in optlist): f = openfile(arch + '.hhc') print "Building Table of Content..." do_content(library, version, f) f.close() if not (('-k','') in optlist): f = openfile(arch + '.hhk') print "Building Index..." do_index(library, f) f.close() | 8015dfc7a15e3f806424cf9b38ac0fd2916f7714 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8015dfc7a15e3f806424cf9b38ac0fd2916f7714/prechm.py |
proxies[protocol] = '%s://%s' % (protocol, address) | type, address = splittype(address) if not type: address = '%s://%s' % (protocol, address) proxies[protocol] = address | def getproxies_registry(): """Return a dictionary of scheme -> proxy server URL mappings. | d597ca3d9862870f3cbf1c7881365128cb40f3c0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d597ca3d9862870f3cbf1c7881365128cb40f3c0/urllib.py |
fd = os.open(filename, os.O_RDWR|os.O_CREAT|os.O_EXCL, 0700) | fd = os.open(filename, os.O_RDWR | os.O_CREAT | os.O_EXCL, 0700) | def gettempdir(): """Function to calculate the directory to use.""" global tempdir if tempdir is not None: return tempdir try: pwd = os.getcwd() except (AttributeError, os.error): pwd = os.curdir attempdirs = ['/var/tmp', '/usr/tmp', '/tmp', pwd] if os.name == 'nt': attempdirs.insert(0, 'C:\\TEMP') attempdirs.insert(0, '\\TEMP') elif os.name == 'mac': import macfs, MACFS try: refnum, dirid = macfs.FindFolder(MACFS.kOnSystemDisk, MACFS.kTemporaryFolderType, 1) dirname = macfs.FSSpec((refnum, dirid, '')).as_pathname() attempdirs.insert(0, dirname) except macfs.error: pass for envname in 'TMPDIR', 'TEMP', 'TMP': if os.environ.has_key(envname): attempdirs.insert(0, os.environ[envname]) testfile = gettempprefix() + 'test' for dir in attempdirs: try: filename = os.path.join(dir, testfile) if os.name == 'posix': try: fd = os.open(filename, os.O_RDWR|os.O_CREAT|os.O_EXCL, 0700) except OSError: pass else: fp = os.fdopen(fd, 'w') fp.write('blat') fp.close() os.unlink(filename) del fp, fd tempdir = dir break else: fp = open(filename, 'w') fp.write('blat') fp.close() os.unlink(filename) tempdir = dir break except IOError: pass if tempdir is None: msg = "Can't find a usable temporary directory amongst " + `attempdirs` raise IOError, msg return tempdir | 6e01c4ab5ac2ed81ddd6c15179dfe1063910d3ed /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/6e01c4ab5ac2ed81ddd6c15179dfe1063910d3ed/tempfile.py |
doc = `doc` | doc = '"' + doc + '"' | def outputGetSetList(self): if self.getsetlist: for name, get, set, doc in self.getsetlist: if get: self.outputGetter(name, get) else: Output("#define %s_get_%s NULL", self.prefix, name) if set: self.outputSetter(name, set) else: Output("#define %s_set_%s NULL", self.prefix, name) Output("static PyGetSetDef %s_getsetlist[] = {", self.prefix) IndentLevel() for name, get, set, doc in self.getsetlist: if doc: doc = `doc` else: doc = "NULL" Output("{\"%s\", (getter)%s_get_%s, (setter)%s_set_%s, %s}", name, self.prefix, name, self.prefix, name, doc) DedentLevel() Output("};") else: Output("#define %s_getsetlist NULL", self.prefix) | 58f7c2f628fd21b0cd986c52e47bd7f98f844acd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/58f7c2f628fd21b0cd986c52e47bd7f98f844acd/bgenObjectDefinition.py |
Output("{\"%s\", (getter)%s_get_%s, (setter)%s_set_%s, %s}", | Output("{\"%s\", (getter)%s_get_%s, (setter)%s_set_%s, %s},", | def outputGetSetList(self): if self.getsetlist: for name, get, set, doc in self.getsetlist: if get: self.outputGetter(name, get) else: Output("#define %s_get_%s NULL", self.prefix, name) if set: self.outputSetter(name, set) else: Output("#define %s_set_%s NULL", self.prefix, name) Output("static PyGetSetDef %s_getsetlist[] = {", self.prefix) IndentLevel() for name, get, set, doc in self.getsetlist: if doc: doc = `doc` else: doc = "NULL" Output("{\"%s\", (getter)%s_get_%s, (setter)%s_set_%s, %s}", name, self.prefix, name, self.prefix, name, doc) DedentLevel() Output("};") else: Output("#define %s_getsetlist NULL", self.prefix) | 58f7c2f628fd21b0cd986c52e47bd7f98f844acd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/58f7c2f628fd21b0cd986c52e47bd7f98f844acd/bgenObjectDefinition.py |
Output("static int %s_get_%s(%s *self, PyObject *v, void *closure)", | Output("static int %s_set_%s(%s *self, PyObject *v, void *closure)", | def outputSetter(self, name, code): Output("static int %s_get_%s(%s *self, PyObject *v, void *closure)", self.prefix, name, self.objecttype) OutLbrace() Output(code) Output("return 0;") OutRbrace() | 58f7c2f628fd21b0cd986c52e47bd7f98f844acd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/58f7c2f628fd21b0cd986c52e47bd7f98f844acd/bgenObjectDefinition.py |
emit((av[0]-1)*2) | emit(av[0]-1) | def fixup(literal, flags=flags): return _sre.getlower(literal, flags) | 4466f55f524737416d8193ec960009dbea6180f1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/4466f55f524737416d8193ec960009dbea6180f1/sre_compile.py |
self.socket.setsockopt( socket.SOL_SOCKET, socket.SO_REUSEADDR, self.socket.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR) | 1) | self.set_reuse_addr() | def __init__(self, localaddr, remoteaddr): self._localaddr = localaddr self._remoteaddr = remoteaddr asyncore.dispatcher.__init__(self) self.create_socket(socket.AF_INET, socket.SOCK_STREAM) # try to re-use a server port if possible self.socket.setsockopt( socket.SOL_SOCKET, socket.SO_REUSEADDR, self.socket.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR) | 1) self.bind(localaddr) self.listen(5) print >> DEBUGSTREAM, \ '%s started at %s\n\tLocal addr: %s\n\tRemote addr:%s' % ( self.__class__.__name__, time.ctime(time.time()), localaddr, remoteaddr) | d936b8a52f7f33f8ebd7f76a39aabf0ae157083e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d936b8a52f7f33f8ebd7f76a39aabf0ae157083e/smtpd.py |
print """usage: basd64 [-d] [-e] [-u] [-t] [file|-] | print """usage: %s [-d|-e|-u|-t] [file|-] | def test(): """Small test program""" import sys, getopt try: opts, args = getopt.getopt(sys.argv[1:], 'deut') except getopt.error, msg: sys.stdout = sys.stderr print msg print """usage: basd64 [-d] [-e] [-u] [-t] [file|-] -d, -u: decode -e: encode (default) -t: decode string 'Aladdin:open sesame'""" sys.exit(2) func = encode for o, a in opts: if o == '-e': func = encode if o == '-d': func = decode if o == '-u': func = decode if o == '-t': test1(); return if args and args[0] != '-': func(open(args[0], 'rb'), sys.stdout) else: func(sys.stdin, sys.stdout) | 33f9f987fe46bfee692503cefaaae73700cd9f6f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/33f9f987fe46bfee692503cefaaae73700cd9f6f/base64.py |
-t: decode string 'Aladdin:open sesame'""" | -t: encode and decode string 'Aladdin:open sesame'"""%sys.argv[0] | def test(): """Small test program""" import sys, getopt try: opts, args = getopt.getopt(sys.argv[1:], 'deut') except getopt.error, msg: sys.stdout = sys.stderr print msg print """usage: basd64 [-d] [-e] [-u] [-t] [file|-] -d, -u: decode -e: encode (default) -t: decode string 'Aladdin:open sesame'""" sys.exit(2) func = encode for o, a in opts: if o == '-e': func = encode if o == '-d': func = decode if o == '-u': func = decode if o == '-t': test1(); return if args and args[0] != '-': func(open(args[0], 'rb'), sys.stdout) else: func(sys.stdin, sys.stdout) | 33f9f987fe46bfee692503cefaaae73700cd9f6f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/33f9f987fe46bfee692503cefaaae73700cd9f6f/base64.py |
class PyShell(MultiEditorWindow): | class PyShell(PyShellEditorWindow): | def write(self, s): # Override base class write self.tkconsole.console.write(s) | 6cc30cf0dd8dfcc402a00fc2e1e213407f2eac1f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/6cc30cf0dd8dfcc402a00fc2e1e213407f2eac1f/PyShell.py |
flist = FileList(root) MultiEditorWindow.__init__(self, flist, None, None) | flist = PyShellFileList(root) PyShellEditorWindow.__init__(self, flist, None, None) | def __init__(self, flist=None): self.interp = ModifiedInterpreter(self) if flist is None: root = Tk() fixwordbreaks(root) root.withdraw() flist = FileList(root) | 6cc30cf0dd8dfcc402a00fc2e1e213407f2eac1f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/6cc30cf0dd8dfcc402a00fc2e1e213407f2eac1f/PyShell.py |
reply = MultiEditorWindow.close(self) | reply = PyShellEditorWindow.close(self) | def close(self): # Extend base class method if self.executing: # XXX Need to ask a question here if not tkMessageBox.askokcancel( "Cancel?", "The program is still running; do you want to cancel it?", default="ok", master=self.text): return "cancel" self.canceled = 1 if self.reading: self.top.quit() return "cancel" reply = MultiEditorWindow.close(self) if reply != "cancel": # Restore std streams sys.stdout = sys.__stdout__ sys.stderr = sys.__stderr__ sys.stdin = sys.__stdin__ # Break cycles self.interp = None self.console = None return reply | 6cc30cf0dd8dfcc402a00fc2e1e213407f2eac1f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/6cc30cf0dd8dfcc402a00fc2e1e213407f2eac1f/PyShell.py |
def interact(self): | def begin(self): | def interact(self): self.resetoutput() self.write("Python %s on %s\n%s\n" % (sys.version, sys.platform, sys.copyright)) try: sys.ps1 except AttributeError: sys.ps1 = ">>> " self.showprompt() import Tkinter Tkinter._default_root = None self.top.mainloop() | 6cc30cf0dd8dfcc402a00fc2e1e213407f2eac1f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/6cc30cf0dd8dfcc402a00fc2e1e213407f2eac1f/PyShell.py |
flist = FileList(root) | flist = PyShellFileList(root) | def main(): global flist, root root = Tk() fixwordbreaks(root) root.withdraw() flist = FileList(root) if sys.argv[1:]: for filename in sys.argv[1:]: flist.open(filename) t = PyShell(flist) t.interact() | 6cc30cf0dd8dfcc402a00fc2e1e213407f2eac1f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/6cc30cf0dd8dfcc402a00fc2e1e213407f2eac1f/PyShell.py |
t.interact() | flist.pyshell = t t.begin() root.mainloop() | def main(): global flist, root root = Tk() fixwordbreaks(root) root.withdraw() flist = FileList(root) if sys.argv[1:]: for filename in sys.argv[1:]: flist.open(filename) t = PyShell(flist) t.interact() | 6cc30cf0dd8dfcc402a00fc2e1e213407f2eac1f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/6cc30cf0dd8dfcc402a00fc2e1e213407f2eac1f/PyShell.py |
os.close(r2w[rd]) | os.close(r2w[rd]) ; os.close( rd ) p.unregister( r2w[rd] ) p.unregister( rd ) | def test_poll1(): """Basic functional test of poll object Create a bunch of pipe and test that poll works with them. """ print 'Running poll test 1' p = select.poll() NUM_PIPES = 12 MSG = " This is a test." MSG_LEN = len(MSG) readers = [] writers = [] r2w = {} w2r = {} for i in range(NUM_PIPES): rd, wr = os.pipe() p.register(rd, select.POLLIN) p.register(wr, select.POLLOUT) readers.append(rd) writers.append(wr) r2w[rd] = wr w2r[wr] = rd while writers: ready = p.poll() ready_writers = find_ready_matching(ready, select.POLLOUT) if not ready_writers: raise RuntimeError, "no pipes ready for writing" wr = random.choice(ready_writers) os.write(wr, MSG) ready = p.poll() ready_readers = find_ready_matching(ready, select.POLLIN) if not ready_readers: raise RuntimeError, "no pipes ready for reading" rd = random.choice(ready_readers) buf = os.read(rd, MSG_LEN) assert len(buf) == MSG_LEN print buf os.close(r2w[rd]) writers.remove(r2w[rd]) poll_unit_tests() print 'Poll test 1 complete' | 7df471db89dc663b66037c656e758b99fba2d76d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/7df471db89dc663b66037c656e758b99fba2d76d/test_poll.py |
if fdlist[0] == (p.fileno(),select.POLLHUP): | fd, flags = fdlist[0] if flags & select.POLLHUP: | def test_poll2(): print 'Running poll test 2' cmd = 'for i in 0 1 2 3 4 5 6 7 8 9; do echo testing...; sleep 1; done' p = os.popen(cmd, 'r') pollster = select.poll() pollster.register( p, select.POLLIN ) for tout in (0, 1000, 2000, 4000, 8000, 16000) + (-1,)*10: if verbose: print 'timeout =', tout fdlist = pollster.poll(tout) if (fdlist == []): continue if fdlist[0] == (p.fileno(),select.POLLHUP): line = p.readline() if line != "": print 'error: pipe seems to be closed, but still returns data' continue elif fdlist[0] == (p.fileno(),select.POLLIN): line = p.readline() if verbose: print `line` if not line: if verbose: print 'EOF' break continue else: print 'Unexpected return value from select.poll:', fdlist p.close() print 'Poll test 2 complete' | 7df471db89dc663b66037c656e758b99fba2d76d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/7df471db89dc663b66037c656e758b99fba2d76d/test_poll.py |
elif fdlist[0] == (p.fileno(),select.POLLIN): | elif flags & select.POLLIN: | def test_poll2(): print 'Running poll test 2' cmd = 'for i in 0 1 2 3 4 5 6 7 8 9; do echo testing...; sleep 1; done' p = os.popen(cmd, 'r') pollster = select.poll() pollster.register( p, select.POLLIN ) for tout in (0, 1000, 2000, 4000, 8000, 16000) + (-1,)*10: if verbose: print 'timeout =', tout fdlist = pollster.poll(tout) if (fdlist == []): continue if fdlist[0] == (p.fileno(),select.POLLHUP): line = p.readline() if line != "": print 'error: pipe seems to be closed, but still returns data' continue elif fdlist[0] == (p.fileno(),select.POLLIN): line = p.readline() if verbose: print `line` if not line: if verbose: print 'EOF' break continue else: print 'Unexpected return value from select.poll:', fdlist p.close() print 'Poll test 2 complete' | 7df471db89dc663b66037c656e758b99fba2d76d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/7df471db89dc663b66037c656e758b99fba2d76d/test_poll.py |
verify (D().meth(4) == "D(4)C(4)B(4)A(4)") | vereq(D().meth(4), "D(4)C(4)B(4)A(4)") class mysuper(super): def __init__(self, *args): return super(mysuper, self).__init__(*args) class E(D): def meth(self, a): return "E(%r)" % a + mysuper(E, self).meth(a) vereq(E().meth(5), "E(5)D(5)C(5)B(5)A(5)") class F(E): def meth(self, a): s = self.__super return "F(%r)[%s]" % (a, s.__class__.__name__) + s.meth(a) F._F__super = mysuper(F) vereq(F().meth(6), "F(6)[mysuper]E(6)D(6)C(6)B(6)A(6)") try: super(D, 42) except TypeError: pass else: raise TestFailed, "shouldn't allow super(D, 42)" try: super(D, C()) except TypeError: pass else: raise TestFailed, "shouldn't allow super(D, C())" try: super(D).__get__(12) except TypeError: pass else: raise TestFailed, "shouldn't allow super(D).__get__(12)" try: super(D).__get__(C()) except TypeError: pass else: raise TestFailed, "shouldn't allow super(D).__get__(C())" | def meth(self, a): return "D(%r)" % a + super(D, self).meth(a) | 1e06da30efcdb24053590df2c44633dd7be69aeb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1e06da30efcdb24053590df2c44633dd7be69aeb/test_descr.py |
return self.sslobj.read(size) | data = self.sslobj.read(size) while len(data) < size: data += self.sslobj.read(len(data)-size) return data | def read(self, size): """Read 'size' bytes from remote.""" return self.sslobj.read(size) | 99825c88c11843fd85e8b70558f3acb6fc09c834 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/99825c88c11843fd85e8b70558f3acb6fc09c834/imaplib.py |
self.sslobj.write(data) | bytes = len(data) while bytes > 0: sent = self.sslobj.write(data) if sent == bytes: break data = data[sent:] bytes = bytes - sent | def send(self, data): """Send data to remote.""" self.sslobj.write(data) | 99825c88c11843fd85e8b70558f3acb6fc09c834 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/99825c88c11843fd85e8b70558f3acb6fc09c834/imaplib.py |
return | return command | def reinitialize_command (self, command): """Reinitializes a command to the state it was in when first returned by 'get_command_obj()': ie., initialized but not yet finalized. This gives provides the opportunity to sneak option values in programmatically, overriding or supplementing user-supplied values from the config files and command line. You'll have to re-finalize the command object (by calling 'finalize_options()' or 'ensure_finalized()') before using it for real. | e62772dd379287126a3774aacb60cd9a4073e7bd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/e62772dd379287126a3774aacb60cd9a4073e7bd/dist.py |
def write(self, arg, move=0): x, y = start = self._position | def write(self, text, move=False): """ Write text at the current pen position. If move is true, the pen is moved to the bottom-right corner of the text. By default, move is False. Example: >>> turtle.write('The race is on!') >>> turtle.write('Home = (0, 0)', True) """ x, y = self._position | def write(self, arg, move=0): x, y = start = self._position x = x-1 # correction -- calibrated for Windows item = self._canvas.create_text(x, y, text=str(arg), anchor="sw", fill=self._color) self._items.append(item) if move: x0, y0, x1, y1 = self._canvas.bbox(item) self._goto(x1, y1) self._draw_turtle() | 9221c22d6c6b431b17192173cf539900e3bec058 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9221c22d6c6b431b17192173cf539900e3bec058/turtle.py |
text=str(arg), anchor="sw", | text=str(text), anchor="sw", | def write(self, arg, move=0): x, y = start = self._position x = x-1 # correction -- calibrated for Windows item = self._canvas.create_text(x, y, text=str(arg), anchor="sw", fill=self._color) self._items.append(item) if move: x0, y0, x1, y1 = self._canvas.bbox(item) self._goto(x1, y1) self._draw_turtle() | 9221c22d6c6b431b17192173cf539900e3bec058 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9221c22d6c6b431b17192173cf539900e3bec058/turtle.py |
self._canvas.lower(item) | def fill(self, flag): if self._filling: path = tuple(self._path) smooth = self._filling < 0 if len(path) > 2: item = self._canvas._create('polygon', path, {'fill': self._color, 'smooth': smooth}) self._items.append(item) self._canvas.lower(item) if self._tofill: for item in self._tofill: self._canvas.itemconfigure(item, fill=self._color) self._items.append(item) self._path = [] self._tofill = [] self._filling = flag if flag: self._path.append(self._position) self.forward(0) | 9221c22d6c6b431b17192173cf539900e3bec058 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9221c22d6c6b431b17192173cf539900e3bec058/turtle.py |
|
start = self._angle - 90.0 | start = self._angle - (self._fullcircle / 4.0) | def circle(self, radius, extent=None): if extent is None: extent = self._fullcircle x0, y0 = self._position xc = x0 - radius * sin(self._angle * self._invradian) yc = y0 - radius * cos(self._angle * self._invradian) if radius >= 0.0: start = self._angle - 90.0 else: start = self._angle + 90.0 extent = -extent if self._filling: if abs(extent) >= self._fullcircle: item = self._canvas.create_oval(xc-radius, yc-radius, xc+radius, yc+radius, width=self._width, outline="") self._tofill.append(item) item = self._canvas.create_arc(xc-radius, yc-radius, xc+radius, yc+radius, style="chord", start=start, extent=extent, width=self._width, outline="") self._tofill.append(item) if self._drawing: if abs(extent) >= self._fullcircle: item = self._canvas.create_oval(xc-radius, yc-radius, xc+radius, yc+radius, width=self._width, outline=self._color) self._items.append(item) item = self._canvas.create_arc(xc-radius, yc-radius, xc+radius, yc+radius, style="arc", start=start, extent=extent, width=self._width, outline=self._color) self._items.append(item) angle = start + extent x1 = xc + abs(radius) * cos(angle * self._invradian) y1 = yc - abs(radius) * sin(angle * self._invradian) self._angle = (self._angle + extent) % self._fullcircle self._position = x1, y1 if self._filling: self._path.append(self._position) self._draw_turtle() | 9221c22d6c6b431b17192173cf539900e3bec058 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9221c22d6c6b431b17192173cf539900e3bec058/turtle.py |
start = self._angle + 90.0 | start = self._angle + (self._fullcircle / 4.0) | def circle(self, radius, extent=None): if extent is None: extent = self._fullcircle x0, y0 = self._position xc = x0 - radius * sin(self._angle * self._invradian) yc = y0 - radius * cos(self._angle * self._invradian) if radius >= 0.0: start = self._angle - 90.0 else: start = self._angle + 90.0 extent = -extent if self._filling: if abs(extent) >= self._fullcircle: item = self._canvas.create_oval(xc-radius, yc-radius, xc+radius, yc+radius, width=self._width, outline="") self._tofill.append(item) item = self._canvas.create_arc(xc-radius, yc-radius, xc+radius, yc+radius, style="chord", start=start, extent=extent, width=self._width, outline="") self._tofill.append(item) if self._drawing: if abs(extent) >= self._fullcircle: item = self._canvas.create_oval(xc-radius, yc-radius, xc+radius, yc+radius, width=self._width, outline=self._color) self._items.append(item) item = self._canvas.create_arc(xc-radius, yc-radius, xc+radius, yc+radius, style="arc", start=start, extent=extent, width=self._width, outline=self._color) self._items.append(item) angle = start + extent x1 = xc + abs(radius) * cos(angle * self._invradian) y1 = yc - abs(radius) * sin(angle * self._invradian) self._angle = (self._angle + extent) % self._fullcircle self._position = x1, y1 if self._filling: self._path.append(self._position) self._draw_turtle() | 9221c22d6c6b431b17192173cf539900e3bec058 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9221c22d6c6b431b17192173cf539900e3bec058/turtle.py |
x0, y0 = start = self._position | x0, y0 = self._position | def _goto(self, x1, y1): x0, y0 = start = self._position self._position = map(float, (x1, y1)) if self._filling: self._path.append(self._position) if self._drawing: if self._tracing: dx = float(x1 - x0) dy = float(y1 - y0) distance = hypot(dx, dy) nhops = int(distance) item = self._canvas.create_line(x0, y0, x0, y0, width=self._width, capstyle="round", fill=self._color) try: for i in range(1, 1+nhops): x, y = x0 + dx*i/nhops, y0 + dy*i/nhops self._canvas.coords(item, x0, y0, x, y) self._draw_turtle((x,y)) self._canvas.update() self._canvas.after(10) # in case nhops==0 self._canvas.coords(item, x0, y0, x1, y1) self._canvas.itemconfigure(item, arrow="none") except Tkinter.TclError: # Probably the window was closed! return else: item = self._canvas.create_line(x0, y0, x1, y1, width=self._width, capstyle="round", fill=self._color) self._items.append(item) self._draw_turtle() | 9221c22d6c6b431b17192173cf539900e3bec058 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9221c22d6c6b431b17192173cf539900e3bec058/turtle.py |
self._canvas.after(10) | self._canvas.after(self._delay) | def _goto(self, x1, y1): x0, y0 = start = self._position self._position = map(float, (x1, y1)) if self._filling: self._path.append(self._position) if self._drawing: if self._tracing: dx = float(x1 - x0) dy = float(y1 - y0) distance = hypot(dx, dy) nhops = int(distance) item = self._canvas.create_line(x0, y0, x0, y0, width=self._width, capstyle="round", fill=self._color) try: for i in range(1, 1+nhops): x, y = x0 + dx*i/nhops, y0 + dy*i/nhops self._canvas.coords(item, x0, y0, x, y) self._draw_turtle((x,y)) self._canvas.update() self._canvas.after(10) # in case nhops==0 self._canvas.coords(item, x0, y0, x1, y1) self._canvas.itemconfigure(item, arrow="none") except Tkinter.TclError: # Probably the window was closed! return else: item = self._canvas.create_line(x0, y0, x1, y1, width=self._width, capstyle="round", fill=self._color) self._items.append(item) self._draw_turtle() | 9221c22d6c6b431b17192173cf539900e3bec058 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9221c22d6c6b431b17192173cf539900e3bec058/turtle.py |
def _draw_turtle(self,position=[]): | def speed(self, speed): """ Set the turtle's speed. speed must one of these five strings: 'fastest' is a 0 ms delay 'fast' is a 5 ms delay 'normal' is a 10 ms delay 'slow' is a 15 ms delay 'slowest' is a 20 ms delay Example: >>> turtle.speed('slow') """ try: speed = speed.strip().lower() self._delay = speeds.index(speed) * 5 except: raise ValueError("%r is not a valid speed. speed must be " "one of %s" % (speed, speeds)) def delay(self, delay): """ Set the drawing delay in milliseconds. This is intended to allow finer control of the drawing speed than the speed() method Example: >>> turtle.delay(15) """ if int(delay) < 0: raise ValueError("delay must be greater than or equal to 0") self._delay = int(delay) def _draw_turtle(self, position=[]): | def _draw_turtle(self,position=[]): if not self._tracing: return if position == []: position = self._position x,y = position distance = 8 dx = distance * cos(self._angle*self._invradian) dy = distance * sin(self._angle*self._invradian) self._delete_turtle() self._arrow = self._canvas.create_line(x-dx,y+dy,x,y, width=self._width, arrow="last", capstyle="round", fill=self._color) self._canvas.update() | 9221c22d6c6b431b17192173cf539900e3bec058 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9221c22d6c6b431b17192173cf539900e3bec058/turtle.py |
self._arrow = 0 | self._arrow = 0 | def _delete_turtle(self): if self._arrow != 0: self._canvas.delete(self._arrow) self._arrow = 0 | 9221c22d6c6b431b17192173cf539900e3bec058 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9221c22d6c6b431b17192173cf539900e3bec058/turtle.py |
def _destroy(self): global _root, _canvas, _pen root = self._canvas._root() if root is _root: _pen = None _root = None _canvas = None root.destroy() | 9221c22d6c6b431b17192173cf539900e3bec058 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9221c22d6c6b431b17192173cf539900e3bec058/turtle.py |
||
pen = _pen if not pen: _pen = pen = Pen() return pen | if not _pen: _pen = Pen() return _pen class Turtle(Pen): pass """For documentation of the following functions see the RawPen methods with the same names """ | def _getpen(): global _pen pen = _pen if not pen: _pen = pen = Pen() return pen | 9221c22d6c6b431b17192173cf539900e3bec058 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9221c22d6c6b431b17192173cf539900e3bec058/turtle.py |
if __name__ == '__main__': _root.mainloop() | def demo2(): speed('fast') width(3) setheading(towards(0,0)) x,y = position() r = (x**2+y**2)**.5/2.0 right(90) pendown = True for i in range(18): if pendown: up() pendown = False else: down() pendown = True circle(r,10) sleep(2) reset() left(90) l = 10 color("green") width(3) left(180) sp = 5 for i in range(-2,16): if i > 0: color(1.0-0.05*i,0,0.05*i) fill(1) color("green") for j in range(3): forward(l) left(120) l += 10 left(15) if sp > 0: sp = sp-1 speed(speeds[sp]) color(0.25,0,0.75) fill(0) color("green") left(130) up() forward(90) color("red") speed('fastest') down(); turtle=Turtle() turtle.reset() turtle.left(90) turtle.speed('normal') turtle.up() turtle.goto(280,40) turtle.left(24) turtle.down() turtle.speed('fast') turtle.color("blue") turtle.width(2) speed('fastest') setheading(towards(turtle)) while ( abs(position()[0]-turtle.position()[0])>4 or abs(position()[1]-turtle.position()[1])>4): turtle.forward(3.5) turtle.left(0.6) setheading(towards(turtle)) forward(4) write("CAUGHT! ", move=True) | def demo(): reset() tracer(1) up() backward(100) down() # draw 3 squares; the last filled width(3) for i in range(3): if i == 2: fill(1) for j in range(4): forward(20) left(90) if i == 2: color("maroon") fill(0) up() forward(30) down() width(1) color("black") # move out of the way tracer(0) up() right(90) forward(100) right(90) forward(100) right(180) down() # some text write("startstart", 1) write("start", 1) color("red") # staircase for i in range(5): forward(20) left(90) forward(20) right(90) # filled staircase fill(1) for i in range(5): forward(20) left(90) forward(20) right(90) fill(0) # more text write("end") if __name__ == '__main__': _root.mainloop() | 9221c22d6c6b431b17192173cf539900e3bec058 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9221c22d6c6b431b17192173cf539900e3bec058/turtle.py |
print "*** skipping leakage tests ***" | if verbose: print "*** skipping leakage tests ***" | def test_lineterminator(self): class mydialect(csv.Dialect): delimiter = ";" escapechar = '\\' doublequote = False skipinitialspace = True lineterminator = '\r\n' quoting = csv.QUOTE_NONE d = mydialect() | bc64a907f00d08e8b583332c634d558059893102 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/bc64a907f00d08e8b583332c634d558059893102/test_csv.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.