rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
if issubclass(t, TypeType):
try: issc = issubclass(t, TypeType) except TypeError: issc = 0 if issc:
def save(self, object, pers_save = 0): memo = self.memo
85ee491b3af3e1c124522249a52443b4d8c34c88 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/85ee491b3af3e1c124522249a52443b4d8c34c88/pickle.py
match = mime_head.group(0, 1) newline = newline + line[:i] + mime_decode(match[1]) line = line[i + len(match[0]):]
match0, match1 = mime_head.group(0, 1) match1 = string.join(string.split(match1, '_'), ' ') newline = newline + line[:i] + mime_decode(match1) line = line[i + len(match0):]
def mime_decode_header(line): '''Decode a header line to 8bit.''' newline = '' while 1: i = mime_head.search(line) if i < 0: break match = mime_head.group(0, 1) newline = newline + line[:i] + mime_decode(match[1]) line = line[i + len(match[0]):] return newline + line
88bb808d7700307d37692f7e658d2d4b1582e0dc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/88bb808d7700307d37692f7e658d2d4b1582e0dc/mimify.py
emit(LOGHEADER, self.ui, os.environ, date=date, _file=tfn)
emit(LOGHEADER, self.ui, os.environ, date=date, _file=tf)
def commit(self, entry): file = entry.file # Normalize line endings in body if '\r' in self.ui.body: self.ui.body = re.sub('\r\n?', '\n', self.ui.body) # Normalize whitespace in title self.ui.title = ' '.join(self.ui.title.split()) # Check that there were any changes if self.ui.body == entry.body and self.ui.title == entry.title: self.error("You didn't make any changes!") return
e6e77e5fe74289af8afe653ea426bcf966afff89 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e6e77e5fe74289af8afe653ea426bcf966afff89/faqwiz.py
os.unlink(tfn)
os.unlink(tf.name)
def commit(self, entry): file = entry.file # Normalize line endings in body if '\r' in self.ui.body: self.ui.body = re.sub('\r\n?', '\n', self.ui.body) # Normalize whitespace in title self.ui.title = ' '.join(self.ui.title.split()) # Check that there were any changes if self.ui.body == entry.body and self.ui.title == entry.title: self.error("You didn't make any changes!") return
e6e77e5fe74289af8afe653ea426bcf966afff89 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e6e77e5fe74289af8afe653ea426bcf966afff89/faqwiz.py
if __name__ == "__main__": import glob f = glob.glob("command/*.py") byte_compile(f, optimize=0, prefix="command/", base_dir="/usr/lib/python")
def byte_compile (py_files, optimize=0, force=0, prefix=None, base_dir=None, verbose=1, dry_run=0, direct=None): """Byte-compile a collection of Python source files to either .pyc or .pyo files in the same directory. 'py_files' is a list of files to compile; any files that don't end in ".py" are silently skipped. 'optimize' must be one of the following: 0 - don't optimize (generate .pyc) 1 - normal optimization (like "python -O") 2 - extra optimization (like "python -OO") If 'force' is true, all files are recompiled regardless of timestamps. The source filename encoded in each bytecode file defaults to the filenames listed in 'py_files'; you can modify these with 'prefix' and 'basedir'. 'prefix' is a string that will be stripped off of each source filename, and 'base_dir' is a directory name that will be prepended (after 'prefix' is stripped). You can supply either or both (or neither) of 'prefix' and 'base_dir', as you wish. If 'verbose' is true, prints out a report of each file. If 'dry_run' is true, doesn't actually do anything that would affect the filesystem. Byte-compilation is either done directly in this interpreter process with the standard py_compile module, or indirectly by writing a temporary script and executing it. Normally, you should let 'byte_compile()' figure out to use direct compilation or not (see the source for details). The 'direct' flag is used by the script generated in indirect mode; unless you know what you're doing, leave it set to None. """ # First, if the caller didn't force us into direct or indirect mode, # figure out which mode we should be in. We take a conservative # approach: choose direct mode *only* if the current interpreter is # in debug mode and optimize is 0. If we're not in debug mode (-O # or -OO), we don't know which level of optimization this # interpreter is running with, so we can't do direct # byte-compilation and be certain that it's the right thing. Thus, # always compile indirectly if the current interpreter is in either # optimize mode, or if either optimization level was requested by # the caller. if direct is None: direct = (__debug__ and optimize == 0) # "Indirect" byte-compilation: write a temporary script and then # run it with the appropriate flags. if not direct: from tempfile import mktemp script_name = mktemp(".py") if verbose: print "writing byte-compilation script '%s'" % script_name if not dry_run: script = open(script_name, "w") script.write("""\
047c3723d02e691578724271a536ee27ad1b2fc2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/047c3723d02e691578724271a536ee27ad1b2fc2/util.py
self._dkeys = self._dict.keys() self._dkeys.sort()
def __init__(self, *args): unittest.TestCase.__init__(self, *args) self._dkeys = self._dict.keys() self._dkeys.sort()
c08fe82b32386d2621f4c6c17cc334c7a3a924b9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c08fe82b32386d2621f4c6c17cc334c7a3a924b9/test_dumbdbm.py
_delete_files()
def test_dumbdbm_creation(self): _delete_files() f = dumbdbm.open(_fname, 'c') self.assertEqual(f.keys(), []) for key in self._dict: f[key] = self._dict[key] self.read_helper(f) f.close()
c08fe82b32386d2621f4c6c17cc334c7a3a924b9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c08fe82b32386d2621f4c6c17cc334c7a3a924b9/test_dumbdbm.py
self.assertEqual(keys, self._dkeys)
dkeys = self._dict.keys() dkeys.sort() self.assertEqual(keys, dkeys)
def keys_helper(self, f): keys = f.keys() keys.sort() self.assertEqual(keys, self._dkeys) return keys
c08fe82b32386d2621f4c6c17cc334c7a3a924b9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c08fe82b32386d2621f4c6c17cc334c7a3a924b9/test_dumbdbm.py
socketDataProcessed = threading.Condition()
socketDataProcessed = threading.Event()
def handleLogRecord(self, record): logname = "logrecv.tcp." + record.name #If the end-of-messages sentinel is seen, tell the server to terminate if record.msg == FINISH_UP: self.server.abort = 1 record.msg = record.msg + " (via " + logname + ")" logger = logging.getLogger(logname) logger.handle(record)
f9addb676d7ef864c6685a1ac8423b5b2663ec68 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f9addb676d7ef864c6685a1ac8423b5b2663ec68/test_logging.py
socketDataProcessed.acquire() socketDataProcessed.notify() socketDataProcessed.release()
socketDataProcessed.set()
def serve_until_stopped(self): abort = 0 while not abort: rd, wr, ex = select.select([self.socket.fileno()], [], [], self.timeout) if rd: self.handle_request() abort = self.abort #notify the main thread that we're about to exit socketDataProcessed.acquire() socketDataProcessed.notify() socketDataProcessed.release()
f9addb676d7ef864c6685a1ac8423b5b2663ec68 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f9addb676d7ef864c6685a1ac8423b5b2663ec68/test_logging.py
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()
f9addb676d7ef864c6685a1ac8423b5b2663ec68 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f9addb676d7ef864c6685a1ac8423b5b2663ec68/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()
f9addb676d7ef864c6685a1ac8423b5b2663ec68 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f9addb676d7ef864c6685a1ac8423b5b2663ec68/test_logging.py
parts = msg.split(" ", 2)
parts = msg.split(" ", 1)
def _decode_msg(self, msg): seqno = self.decode_seqno(msg[:self.SEQNO_ENC_LEN]) msg = msg[self.SEQNO_ENC_LEN:] parts = msg.split(" ", 2) if len(parts) == 1: cmd = msg arg = '' else: cmd = parts[0] arg = parts[1] return cmd, arg, seqno
55956c93615855b47cfc5bf9ddc2633a5f73044c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/55956c93615855b47cfc5bf9ddc2633a5f73044c/RemoteInterp.py
return sys.modules[fqname]
module = sys.modules[fqname] module.__name__ = fqname return module
def _process_result(self, (ispkg, code, values), fqname): # did get_code() return an actual module? (rather than a code object) is_module = isinstance(code, _ModuleType)
70195da3ff1cae7f4c6e76b0f2a19c3fe04bc1e4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/70195da3ff1cae7f4c6e76b0f2a19c3fe04bc1e4/imputil.py
return _urlopener.retrieve(url, filename)
return _urlopener.retrieve(url, filename)
def urlretrieve(url, filename=None): global _urlopener if not _urlopener: _urlopener = FancyURLopener() if filename: return _urlopener.retrieve(url, filename) else: return _urlopener.retrieve(url)
7e7ca0ba1753f9088a9b2afb3351a02127337974 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7e7ca0ba1753f9088a9b2afb3351a02127337974/urllib.py
return _urlopener.retrieve(url)
return _urlopener.retrieve(url)
def urlretrieve(url, filename=None): global _urlopener if not _urlopener: _urlopener = FancyURLopener() if filename: return _urlopener.retrieve(url, filename) else: return _urlopener.retrieve(url)
7e7ca0ba1753f9088a9b2afb3351a02127337974 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7e7ca0ba1753f9088a9b2afb3351a02127337974/urllib.py
self.tempcache.clear()
self.tempcache.clear()
def cleanup(self): # This code sometimes runs when the rest of this module # has already been deleted, so it can't use any globals # or import anything. if self.__tempfiles: for file in self.__tempfiles: try: self.__unlink(file) except: pass del self.__tempfiles[:] if self.tempcache: self.tempcache.clear()
7e7ca0ba1753f9088a9b2afb3351a02127337974 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7e7ca0ba1753f9088a9b2afb3351a02127337974/urllib.py
def open(self, fullurl, data=None): fullurl = unwrap(fullurl) if self.tempcache and self.tempcache.has_key(fullurl): filename, headers = self.tempcache[fullurl] fp = open(filename, 'rb') return addinfourl(fp, headers, fullurl) type, url = splittype(fullurl) if not type: type = 'file' if self.proxies.has_key(type): proxy = self.proxies[type] type, proxy = splittype(proxy) host, selector = splithost(proxy) url = (host, fullurl) # Signal special case to open_*() name = 'open_' + type if '-' in name: # replace - with _ name = string.join(string.split(name, '-'), '_') if not hasattr(self, name): if data is None: return self.open_unknown(fullurl) else: return self.open_unknown(fullurl, data) try: if data is None: return getattr(self, name)(url) else: return getattr(self, name)(url, data) except socket.error, msg: raise IOError, ('socket error', msg), sys.exc_info()[2]
7e7ca0ba1753f9088a9b2afb3351a02127337974 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7e7ca0ba1753f9088a9b2afb3351a02127337974/urllib.py
import tempfile filename = tempfile.mktemp() self.__tempfiles.append(filename)
import tempfile filename = tempfile.mktemp() self.__tempfiles.append(filename)
def retrieve(self, url, filename=None): url = unwrap(url) if self.tempcache and self.tempcache.has_key(url): return self.tempcache[url] type, url1 = splittype(url) if not filename and (not type or type == 'file'): try: fp = self.open_local_file(url1) del fp return url2pathname(splithost(url1)[1]), None except IOError, msg: pass fp = self.open(url) headers = fp.info() if not filename: import tempfile filename = tempfile.mktemp() self.__tempfiles.append(filename) result = filename, headers if self.tempcache is not None: self.tempcache[url] = result tfp = open(filename, 'wb') bs = 1024*8 block = fp.read(bs) while block: tfp.write(block) block = fp.read(bs) fp.close() tfp.close() del fp del tfp return result
7e7ca0ba1753f9088a9b2afb3351a02127337974 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7e7ca0ba1753f9088a9b2afb3351a02127337974/urllib.py
realhost = None
realhost = None
def open_http(self, url, data=None): import httplib if type(url) is type(""): host, selector = splithost(url) user_passwd, host = splituser(host) realhost = host else: host, selector = url urltype, rest = splittype(selector) user_passwd = None if string.lower(urltype) != 'http': realhost = None else: realhost, rest = splithost(rest) user_passwd, realhost = splituser(realhost) if user_passwd: selector = "%s://%s%s" % (urltype, realhost, rest) #print "proxy via http:", host, selector if not host: raise IOError, ('http error', 'no host given') if user_passwd: import base64 auth = string.strip(base64.encodestring(user_passwd)) else: auth = None h = httplib.HTTP(host) if data is not None: h.putrequest('POST', selector) h.putheader('Content-type', 'application/x-www-form-urlencoded') h.putheader('Content-length', '%d' % len(data)) else: h.putrequest('GET', selector) if auth: h.putheader('Authorization', 'Basic %s' % auth) if realhost: h.putheader('Host', realhost) for args in self.addheaders: apply(h.putheader, args) h.endheaders() if data is not None: h.send(data + '\r\n') errcode, errmsg, headers = h.getreply() fp = h.getfile() if errcode == 200: return addinfourl(fp, headers, "http:" + url) else: return self.http_error(url, fp, errcode, errmsg, headers)
7e7ca0ba1753f9088a9b2afb3351a02127337974 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7e7ca0ba1753f9088a9b2afb3351a02127337974/urllib.py
realhost, rest = splithost(rest) user_passwd, realhost = splituser(realhost) if user_passwd: selector = "%s://%s%s" % (urltype, realhost, rest)
realhost, rest = splithost(rest) user_passwd, realhost = splituser(realhost) if user_passwd: selector = "%s://%s%s" % (urltype, realhost, rest)
def open_http(self, url, data=None): import httplib if type(url) is type(""): host, selector = splithost(url) user_passwd, host = splituser(host) realhost = host else: host, selector = url urltype, rest = splittype(selector) user_passwd = None if string.lower(urltype) != 'http': realhost = None else: realhost, rest = splithost(rest) user_passwd, realhost = splituser(realhost) if user_passwd: selector = "%s://%s%s" % (urltype, realhost, rest) #print "proxy via http:", host, selector if not host: raise IOError, ('http error', 'no host given') if user_passwd: import base64 auth = string.strip(base64.encodestring(user_passwd)) else: auth = None h = httplib.HTTP(host) if data is not None: h.putrequest('POST', selector) h.putheader('Content-type', 'application/x-www-form-urlencoded') h.putheader('Content-length', '%d' % len(data)) else: h.putrequest('GET', selector) if auth: h.putheader('Authorization', 'Basic %s' % auth) if realhost: h.putheader('Host', realhost) for args in self.addheaders: apply(h.putheader, args) h.endheaders() if data is not None: h.send(data + '\r\n') errcode, errmsg, headers = h.getreply() fp = h.getfile() if errcode == 200: return addinfourl(fp, headers, "http:" + url) else: return self.http_error(url, fp, errcode, errmsg, headers)
7e7ca0ba1753f9088a9b2afb3351a02127337974 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7e7ca0ba1753f9088a9b2afb3351a02127337974/urllib.py
if url[:2] == '//' and url[2:3] != '/': return self.open_ftp(url) else: return self.open_local_file(url)
if url[:2] == '//' and url[2:3] != '/': return self.open_ftp(url) else: return self.open_local_file(url)
def open_file(self, url): if url[:2] == '//' and url[2:3] != '/': return self.open_ftp(url) else: return self.open_local_file(url)
7e7ca0ba1753f9088a9b2afb3351a02127337974 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7e7ca0ba1753f9088a9b2afb3351a02127337974/urllib.py
return addinfourl(fp, headers, "http:" + url)
return addinfourl(fp, headers, "http:" + url)
def http_error_default(self, url, fp, errcode, errmsg, headers): return addinfourl(fp, headers, "http:" + url)
7e7ca0ba1753f9088a9b2afb3351a02127337974 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7e7ca0ba1753f9088a9b2afb3351a02127337974/urllib.py
scheme, realm = match.groups()
scheme, realm = match.groups()
def http_error_401(self, url, fp, errcode, errmsg, headers): if headers.has_key('www-authenticate'): stuff = headers['www-authenticate'] import re match = re.match( '[ \t]*([^ \t]+)[ \t]+realm="([^"]*)"', stuff) if match: scheme, realm = match.groups() if string.lower(scheme) == 'basic': return self.retry_http_basic_auth( url, realm)
7e7ca0ba1753f9088a9b2afb3351a02127337974 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7e7ca0ba1753f9088a9b2afb3351a02127337974/urllib.py
import re _typeprog = re.compile('^([^/:]+):') match = _typeprog.match(url)
import re _typeprog = re.compile('^([^/:]+):') match = _typeprog.match(url)
def splittype(url): global _typeprog if _typeprog is None: import re _typeprog = re.compile('^([^/:]+):') match = _typeprog.match(url) if match: scheme = match.group(1) return scheme, url[len(scheme) + 1:] return None, url
7e7ca0ba1753f9088a9b2afb3351a02127337974 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7e7ca0ba1753f9088a9b2afb3351a02127337974/urllib.py
import re _hostprog = re.compile('^//([^/]+)(.*)$')
import re _hostprog = re.compile('^//([^/]+)(.*)$')
def splithost(url): global _hostprog if _hostprog is None: import re _hostprog = re.compile('^//([^/]+)(.*)$') match = _hostprog.match(url) if match: return match.group(1, 2) return None, url
7e7ca0ba1753f9088a9b2afb3351a02127337974 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7e7ca0ba1753f9088a9b2afb3351a02127337974/urllib.py
import re _userprog = re.compile('^([^@]*)@(.*)$')
import re _userprog = re.compile('^([^@]*)@(.*)$')
def splituser(host): global _userprog if _userprog is None: import re _userprog = re.compile('^([^@]*)@(.*)$') match = _userprog.match(host) if match: return match.group(1, 2) return None, host
7e7ca0ba1753f9088a9b2afb3351a02127337974 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7e7ca0ba1753f9088a9b2afb3351a02127337974/urllib.py
import re _passwdprog = re.compile('^([^:]*):(.*)$')
import re _passwdprog = re.compile('^([^:]*):(.*)$')
def splitpasswd(user): global _passwdprog if _passwdprog is None: import re _passwdprog = re.compile('^([^:]*):(.*)$') match = _passwdprog.match(user) if match: return match.group(1, 2) return user, None
7e7ca0ba1753f9088a9b2afb3351a02127337974 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7e7ca0ba1753f9088a9b2afb3351a02127337974/urllib.py
import re _portprog = re.compile('^(.*):([0-9]+)$')
import re _portprog = re.compile('^(.*):([0-9]+)$')
def splitport(host): global _portprog if _portprog is None: import re _portprog = re.compile('^(.*):([0-9]+)$') match = _portprog.match(host) if match: return match.group(1, 2) return host, None
7e7ca0ba1753f9088a9b2afb3351a02127337974 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7e7ca0ba1753f9088a9b2afb3351a02127337974/urllib.py
import re _nportprog = re.compile('^(.*):(.*)$')
import re _nportprog = re.compile('^(.*):(.*)$')
def splitnport(host, defport=-1): global _nportprog if _nportprog is None: import re _nportprog = re.compile('^(.*):(.*)$') match = _nportprog.match(host) if match: host, port = match.group(1, 2) try: if not port: raise string.atoi_error, "no digits" nport = string.atoi(port) except string.atoi_error: nport = None return host, nport return host, defport
7e7ca0ba1753f9088a9b2afb3351a02127337974 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7e7ca0ba1753f9088a9b2afb3351a02127337974/urllib.py
host, port = match.group(1, 2) try: if not port: raise string.atoi_error, "no digits" nport = string.atoi(port) except string.atoi_error: nport = None return host, nport
host, port = match.group(1, 2) try: if not port: raise string.atoi_error, "no digits" nport = string.atoi(port) except string.atoi_error: nport = None return host, nport
def splitnport(host, defport=-1): global _nportprog if _nportprog is None: import re _nportprog = re.compile('^(.*):(.*)$') match = _nportprog.match(host) if match: host, port = match.group(1, 2) try: if not port: raise string.atoi_error, "no digits" nport = string.atoi(port) except string.atoi_error: nport = None return host, nport return host, defport
7e7ca0ba1753f9088a9b2afb3351a02127337974 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7e7ca0ba1753f9088a9b2afb3351a02127337974/urllib.py
import re _queryprog = re.compile('^(.*)\?([^?]*)$')
import re _queryprog = re.compile('^(.*)\?([^?]*)$')
def splitquery(url): global _queryprog if _queryprog is None: import re _queryprog = re.compile('^(.*)\?([^?]*)$') match = _queryprog.match(url) if match: return match.group(1, 2) return url, None
7e7ca0ba1753f9088a9b2afb3351a02127337974 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7e7ca0ba1753f9088a9b2afb3351a02127337974/urllib.py
import re _tagprog = re.compile('^(.*)
import re _tagprog = re.compile('^(.*)
def splittag(url): global _tagprog if _tagprog is None: import re _tagprog = re.compile('^(.*)#([^#]*)$') match = _tagprog.match(url) if match: return match.group(1, 2) return url, None
7e7ca0ba1753f9088a9b2afb3351a02127337974 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7e7ca0ba1753f9088a9b2afb3351a02127337974/urllib.py
import re _valueprog = re.compile('^([^=]*)=(.*)$') match = _valueprog.match(attr)
import re _valueprog = re.compile('^([^=]*)=(.*)$') match = _valueprog.match(attr)
def splitvalue(attr): global _valueprog if _valueprog is None: import re _valueprog = re.compile('^([^=]*)=(.*)$') match = _valueprog.match(attr) if match: return match.group(1, 2) return attr, None
7e7ca0ba1753f9088a9b2afb3351a02127337974 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7e7ca0ba1753f9088a9b2afb3351a02127337974/urllib.py
import re _quoteprog = re.compile('%[0-9a-fA-F][0-9a-fA-F]')
import re _quoteprog = re.compile('%[0-9a-fA-F][0-9a-fA-F]')
def unquote(s): global _quoteprog if _quoteprog is None: import re _quoteprog = re.compile('%[0-9a-fA-F][0-9a-fA-F]') i = 0 n = len(s) res = [] while 0 <= i < n: match = _quoteprog.search(s, i) if not match: res.append(s[i:]) break j = match.start(0) res.append(s[i:j] + chr(string.atoi(s[j+1:j+3], 16))) i = j+3 return string.joinfields(res, '')
7e7ca0ba1753f9088a9b2afb3351a02127337974 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7e7ca0ba1753f9088a9b2afb3351a02127337974/urllib.py
if '+' in s: s = string.join(string.split(s, '+'), ' ') return unquote(s)
if '+' in s: s = string.join(string.split(s, '+'), ' ') return unquote(s)
def unquote_plus(s): if '+' in s: # replace '+' with ' ' s = string.join(string.split(s, '+'), ' ') return unquote(s)
7e7ca0ba1753f9088a9b2afb3351a02127337974 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7e7ca0ba1753f9088a9b2afb3351a02127337974/urllib.py
if ' ' in s: s = string.join(string.split(s, ' '), '+') return quote(s, safe + '+') else: return quote(s, safe)
if ' ' in s: s = string.join(string.split(s, ' '), '+') return quote(s, safe + '+') else: return quote(s, safe)
def quote_plus(s, safe = '/'): if ' ' in s: # replace ' ' with '+' s = string.join(string.split(s, ' '), '+') return quote(s, safe + '+') else: return quote(s, safe)
7e7ca0ba1753f9088a9b2afb3351a02127337974 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7e7ca0ba1753f9088a9b2afb3351a02127337974/urllib.py
table = string.maketrans("", "") data = string.translate(data, table, "\r")
table = string.maketrans("", "") data = string.translate(data, table, "\r")
def test(): import sys args = sys.argv[1:] if not args: args = [ '/etc/passwd', 'file:/etc/passwd', 'file://localhost/etc/passwd', 'ftp://ftp.python.org/etc/passwd', 'gopher://gopher.micro.umn.edu/1/', 'http://www.python.org/index.html', ] try: for url in args: print '-'*10, url, '-'*10 fn, h = urlretrieve(url) print fn, h if h: print '======' for k in h.keys(): print k + ':', h[k] print '======' fp = open(fn, 'rb') data = fp.read() del fp if '\r' in data: table = string.maketrans("", "") data = string.translate(data, table, "\r") print data fn, h = None, None print '-'*40 finally: urlcleanup()
7e7ca0ba1753f9088a9b2afb3351a02127337974 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7e7ca0ba1753f9088a9b2afb3351a02127337974/urllib.py
- reuse_address
- allow_reuse_address
def handle_error(self, request, client_address): """Handle an error gracefully. May be overridden.
3aaad5079b6df05a34df64a26ca9e840f8685af1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3aaad5079b6df05a34df64a26ca9e840f8685af1/SocketServer.py
with private names and those defined in other modules. + C.__doc__ for all classes C in M.__dict__.values(), except those with private names and those defined in other modules.
defined in other modules. + C.__doc__ for all classes C in M.__dict__.values(), except those defined in other modules.
def _test(): import doctest, M # replace M with your module's name return doctest.testmod(M) # ditto
71adf7e9d8fb2aca563eeca806ea127409c82bb6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/71adf7e9d8fb2aca563eeca806ea127409c82bb6/doctest.py
their contained methods and nested classes. Private names reached from M's globals are skipped, but all names reached from M.__test__ are searched. By default, a name is considered to be private if it begins with an underscore (like "_my_func") but doesn't both begin and end with (at least) two underscores (like "__init__"). You can change the default by passing your own "isprivate" function to testmod.
their contained methods and nested classes. All names reached from M.__test__ are searched. Optionally, functions with private names can be skipped (unless listed in M.__test__) by supplying a function to the "isprivate" argument that will identify private functions. For convenience, one such function is supplied. docttest.is_private considers a name to be private if it begins with an underscore (like "_my_func") but doesn't both begin and end with (at least) two underscores (like "__init__"). By supplying this function or your own "isprivate" function to testmod, the behavior can be customized.
def _test(): import doctest, M # replace M with your module's name return doctest.testmod(M) # ditto
71adf7e9d8fb2aca563eeca806ea127409c82bb6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/71adf7e9d8fb2aca563eeca806ea127409c82bb6/doctest.py
whether a name is private. The default function is doctest.is_private; see its docs for details.
whether a name is private. The default function is to assume that no functions are private. The "isprivate" arg may be set to doctest.is_private in order to skip over functions marked as private using an underscore naming convention; see its docs for details.
def __init__(self, mod=None, globs=None, verbose=None, isprivate=None, optionflags=0): """mod=None, globs=None, verbose=None, isprivate=None,
71adf7e9d8fb2aca563eeca806ea127409c82bb6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/71adf7e9d8fb2aca563eeca806ea127409c82bb6/doctest.py
isprivate = is_private
isprivate = lambda prefix, base: 0
def __init__(self, mod=None, globs=None, verbose=None, isprivate=None, optionflags=0): """mod=None, globs=None, verbose=None, isprivate=None,
71adf7e9d8fb2aca563eeca806ea127409c82bb6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/71adf7e9d8fb2aca563eeca806ea127409c82bb6/doctest.py
>>> t = Tester(globs={}, verbose=0)
>>> t = Tester(globs={}, verbose=0, isprivate=is_private)
... def bar(self):
71adf7e9d8fb2aca563eeca806ea127409c82bb6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/71adf7e9d8fb2aca563eeca806ea127409c82bb6/doctest.py
Again, but with a custom isprivate function allowing _f: >>> t = Tester(globs={}, verbose=0, isprivate=lambda x,y: 0)
Again, but with the default isprivate function allowing _f: >>> t = Tester(globs={}, verbose=0)
... def bar(self):
71adf7e9d8fb2aca563eeca806ea127409c82bb6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/71adf7e9d8fb2aca563eeca806ea127409c82bb6/doctest.py
>>> t = Tester(globs={}, verbose=0, isprivate=lambda x,y: 0)
>>> t = Tester(globs={}, verbose=0)
... def bar(self):
71adf7e9d8fb2aca563eeca806ea127409c82bb6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/71adf7e9d8fb2aca563eeca806ea127409c82bb6/doctest.py
>>> testmod(m1)
>>> testmod(m1, isprivate=is_private)
... def bar(self):
71adf7e9d8fb2aca563eeca806ea127409c82bb6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/71adf7e9d8fb2aca563eeca806ea127409c82bb6/doctest.py
with m.__doc__. Private names are skipped.
with m.__doc__. Unless isprivate is specified, private names are not skipped.
def testmod(m=None, name=None, globs=None, verbose=None, isprivate=None, report=True, optionflags=0): """m=None, name=None, globs=None, verbose=None, isprivate=None, report=True, optionflags=0 Test examples in docstrings in functions and classes reachable from module m (or the current module if m is not supplied), starting with m.__doc__. Private names are skipped. Also test examples reachable from dict m.__test__ if it exists and is not None. m.__dict__ maps names to functions, classes and strings; function and class docstrings are tested even if the name is private; strings are tested directly, as if they were docstrings. Return (#failures, #tests). See doctest.__doc__ for an overview. Optional keyword arg "name" gives the name of the module; by default use m.__name__. Optional keyword arg "globs" gives a dict to be used as the globals when executing examples; by default, use m.__dict__. A copy of this dict is actually used for each docstring, so that each docstring's examples start with a clean slate. Optional keyword arg "verbose" prints lots of stuff if true, prints only failures if false; by default, it's true iff "-v" is in sys.argv. Optional keyword arg "isprivate" specifies a function used to determine whether a name is private. The default function is doctest.is_private; see its docs for details. Optional keyword arg "report" prints a summary at the end when true, else prints nothing at the end. In verbose mode, the summary is detailed, else very brief (in fact, empty if all tests passed). Optional keyword arg "optionflags" or's together module constants, and defaults to 0. This is new in 2.3. Possible values: DONT_ACCEPT_TRUE_FOR_1 By default, if an expected output block contains just "1", an actual output block containing just "True" is considered to be a match, and similarly for "0" versus "False". When DONT_ACCEPT_TRUE_FOR_1 is specified, neither substitution is allowed. Advanced tomfoolery: testmod runs methods of a local instance of class doctest.Tester, then merges the results into (or creates) global Tester instance doctest.master. Methods of doctest.master can be called directly too, if you want to do something unusual. Passing report=0 to testmod is especially useful then, to delay displaying a summary. Invoke doctest.master.summarize(verbose) when you're done fiddling. """ global master if m is None: import sys # DWA - m will still be None if this wasn't invoked from the command # line, in which case the following TypeError is about as good an error # as we should expect m = sys.modules.get('__main__') if not _ismodule(m): raise TypeError("testmod: module required; " + `m`) if name is None: name = m.__name__ tester = Tester(m, globs=globs, verbose=verbose, isprivate=isprivate, optionflags=optionflags) failures, tries = tester.rundoc(m, name) f, t = tester.rundict(m.__dict__, name, m) failures += f tries += t if hasattr(m, "__test__"): testdict = m.__test__ if testdict: if not hasattr(testdict, "items"): raise TypeError("testmod: module.__test__ must support " ".items(); " + `testdict`) f, t = tester.run__test__(testdict, name + ".__test__") failures += f tries += t if report: tester.summarize() if master is None: master = tester else: master.merge(tester) return failures, tries
71adf7e9d8fb2aca563eeca806ea127409c82bb6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/71adf7e9d8fb2aca563eeca806ea127409c82bb6/doctest.py
doctest.is_private; see its docs for details.
treat all functions as public. Optionally, "isprivate" can be set to doctest.is_private to skip over functions marked as private using the underscore naming convention; see its docs for details.
def testmod(m=None, name=None, globs=None, verbose=None, isprivate=None, report=True, optionflags=0): """m=None, name=None, globs=None, verbose=None, isprivate=None, report=True, optionflags=0 Test examples in docstrings in functions and classes reachable from module m (or the current module if m is not supplied), starting with m.__doc__. Private names are skipped. Also test examples reachable from dict m.__test__ if it exists and is not None. m.__dict__ maps names to functions, classes and strings; function and class docstrings are tested even if the name is private; strings are tested directly, as if they were docstrings. Return (#failures, #tests). See doctest.__doc__ for an overview. Optional keyword arg "name" gives the name of the module; by default use m.__name__. Optional keyword arg "globs" gives a dict to be used as the globals when executing examples; by default, use m.__dict__. A copy of this dict is actually used for each docstring, so that each docstring's examples start with a clean slate. Optional keyword arg "verbose" prints lots of stuff if true, prints only failures if false; by default, it's true iff "-v" is in sys.argv. Optional keyword arg "isprivate" specifies a function used to determine whether a name is private. The default function is doctest.is_private; see its docs for details. Optional keyword arg "report" prints a summary at the end when true, else prints nothing at the end. In verbose mode, the summary is detailed, else very brief (in fact, empty if all tests passed). Optional keyword arg "optionflags" or's together module constants, and defaults to 0. This is new in 2.3. Possible values: DONT_ACCEPT_TRUE_FOR_1 By default, if an expected output block contains just "1", an actual output block containing just "True" is considered to be a match, and similarly for "0" versus "False". When DONT_ACCEPT_TRUE_FOR_1 is specified, neither substitution is allowed. Advanced tomfoolery: testmod runs methods of a local instance of class doctest.Tester, then merges the results into (or creates) global Tester instance doctest.master. Methods of doctest.master can be called directly too, if you want to do something unusual. Passing report=0 to testmod is especially useful then, to delay displaying a summary. Invoke doctest.master.summarize(verbose) when you're done fiddling. """ global master if m is None: import sys # DWA - m will still be None if this wasn't invoked from the command # line, in which case the following TypeError is about as good an error # as we should expect m = sys.modules.get('__main__') if not _ismodule(m): raise TypeError("testmod: module required; " + `m`) if name is None: name = m.__name__ tester = Tester(m, globs=globs, verbose=verbose, isprivate=isprivate, optionflags=optionflags) failures, tries = tester.rundoc(m, name) f, t = tester.rundict(m.__dict__, name, m) failures += f tries += t if hasattr(m, "__test__"): testdict = m.__test__ if testdict: if not hasattr(testdict, "items"): raise TypeError("testmod: module.__test__ must support " ".items(); " + `testdict`) f, t = tester.run__test__(testdict, name + ".__test__") failures += f tries += t if report: tester.summarize() if master is None: master = tester else: master.merge(tester) return failures, tries
71adf7e9d8fb2aca563eeca806ea127409c82bb6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/71adf7e9d8fb2aca563eeca806ea127409c82bb6/doctest.py
if not _type_to_name_map:
if _type_to_name_map=={}:
def type_to_name(gtype): global _type_to_name_map if not _type_to_name_map: for name in _names: if name[:2] == 'A_': _type_to_name_map[eval(name)] = name[2:] if _type_to_name_map.has_key(gtype): return _type_to_name_map[gtype] return 'TYPE=' + `gtype`
d2dd9a8b7f3446b904600ec5de6945a2d9f5598c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d2dd9a8b7f3446b904600ec5de6945a2d9f5598c/gopherlib.py
return self.getdelimited('[', ']\r', 0)
return '[%s]' % self.getdelimited('[', ']\r', 0)
def getdomainliteral(self): """Parse an RFC-822 domain-literal.""" return self.getdelimited('[', ']\r', 0)
2ea2b1133eb9676454bc680450bf121e1493f7a4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2ea2b1133eb9676454bc680450bf121e1493f7a4/rfc822.py
self.wfile = StringIO.StringIO(self.packet)
self.wfile = StringIO.StringIO()
def setup(self): import StringIO self.packet, self.socket = self.request self.rfile = StringIO.StringIO(self.packet) self.wfile = StringIO.StringIO(self.packet)
beae4777673fa2a749d326b4860c6a2b0b1ffa12 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/beae4777673fa2a749d326b4860c6a2b0b1ffa12/SocketServer.py
SetDialogItemText(text_h, "Progress...")
SetDialogItemText(text_h, label)
def __init__(self, label="Working...", maxval=100): self.label = label self.maxval = maxval self.curval = -1 self.d = GetNewDialog(259, -1) tp, text_h, rect = self.d.GetDialogItem(2) SetDialogItemText(text_h, "Progress...") self._update(0)
3a4b3b0132a553444b29bbb9a04b28af71852660 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3a4b3b0132a553444b29bbb9a04b28af71852660/EasyDialogs.py
Qd.PaintRect(inner_rect) l, t, r, b = inner_rect r = int(l + (r-l)*value/self.maxval) inner_rect = l, t, r, b Qd.ForeColor(QuickDraw.blackColor) Qd.BackColor(QuickDraw.blackColor) Qd.PaintRect(inner_rect)
Qd.PaintRect((int(l + (r-l)*value/self.maxval), t, r, b))
def _update(self, value): tp, h, bar_rect = self.d.GetDialogItem(3) Qd.SetPort(self.d) Qd.FrameRect(bar_rect) # Draw outline inner_rect = Qd.InsetRect(bar_rect, 1, 1) Qd.ForeColor(QuickDraw.whiteColor) Qd.BackColor(QuickDraw.whiteColor) Qd.PaintRect(inner_rect) # Clear internal l, t, r, b = inner_rect r = int(l + (r-l)*value/self.maxval) inner_rect = l, t, r, b Qd.ForeColor(QuickDraw.blackColor) Qd.BackColor(QuickDraw.blackColor) Qd.PaintRect(inner_rect) # Draw bar # Restore settings Qd.ForeColor(QuickDraw.blackColor) Qd.BackColor(QuickDraw.whiteColor) # Test for cancel button if ModalDialog(_ProgressBar_filterfunc) == 1: raise KeyboardInterrupt
3a4b3b0132a553444b29bbb9a04b28af71852660 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3a4b3b0132a553444b29bbb9a04b28af71852660/EasyDialogs.py
level = 0 if "absolute_import" in self.futures else -1
level = 0 if self.graph.checkFlag(CO_FUTURE_ABSIMPORT) else -1
def visitImport(self, node): self.set_lineno(node) level = 0 if "absolute_import" in self.futures else -1 for name, alias in node.names: if VERSION > 1: self.emit('LOAD_CONST', level) self.emit('LOAD_CONST', None) self.emit('IMPORT_NAME', name) mod = name.split(".")[0] if alias: self._resolveDots(name) self.storeName(alias) else: self.storeName(mod)
d4e30357016f0b2e2a5093d810b7edea33501cd3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d4e30357016f0b2e2a5093d810b7edea33501cd3/pycodegen.py
if level == 0 and "absolute_import" not in self.futures:
if level == 0 and not self.graph.checkFlag(CO_FUTURE_ABSIMPORT):
def visitFrom(self, node): self.set_lineno(node) level = node.level if level == 0 and "absolute_import" not in self.futures: level = -1 fromlist = map(lambda (name, alias): name, node.names) if VERSION > 1: self.emit('LOAD_CONST', level) self.emit('LOAD_CONST', tuple(fromlist)) self.emit('IMPORT_NAME', node.modname) for name, alias in node.names: if VERSION > 1: if name == '*': self.namespace = 0 self.emit('IMPORT_STAR') # There can only be one name w/ from ... import * assert len(node.names) == 1 return else: self.emit('IMPORT_FROM', name) self._resolveDots(name) self.storeName(alias or name) else: self.emit('IMPORT_FROM', name) self.emit('POP_TOP')
d4e30357016f0b2e2a5093d810b7edea33501cd3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d4e30357016f0b2e2a5093d810b7edea33501cd3/pycodegen.py
if self.debuglevel > 0: print 'connect:', (host, port)
if self.debuglevel > 0: print>>stderr, 'connect:', (host, port)
def connect(self, host='localhost', port = 0): """Connect to a host on a given port.
e6f8a89d1a7f530d68a69b9867535d4fd7707846 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e6f8a89d1a7f530d68a69b9867535d4fd7707846/smtplib.py
if self.debuglevel > 0: print 'connect:', (host, port)
if self.debuglevel > 0: print>>stderr, 'connect:', (host, port)
def connect(self, host='localhost', port = 0): """Connect to a host on a given port.
e6f8a89d1a7f530d68a69b9867535d4fd7707846 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e6f8a89d1a7f530d68a69b9867535d4fd7707846/smtplib.py
if self.debuglevel > 0: print 'connect fail:', (host, port)
if self.debuglevel > 0: print>>stderr, 'connect fail:', (host, port)
def connect(self, host='localhost', port = 0): """Connect to a host on a given port.
e6f8a89d1a7f530d68a69b9867535d4fd7707846 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e6f8a89d1a7f530d68a69b9867535d4fd7707846/smtplib.py
if self.debuglevel > 0: print "connect:", msg
if self.debuglevel > 0: print>>stderr, "connect:", msg
def connect(self, host='localhost', port = 0): """Connect to a host on a given port.
e6f8a89d1a7f530d68a69b9867535d4fd7707846 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e6f8a89d1a7f530d68a69b9867535d4fd7707846/smtplib.py
if self.debuglevel > 0: print 'send:', repr(str)
if self.debuglevel > 0: print>>stderr, 'send:', repr(str)
def send(self, str): """Send `str' to the server.""" if self.debuglevel > 0: print 'send:', repr(str) if self.sock: try: self.sock.sendall(str) except socket.error: self.close() raise SMTPServerDisconnected('Server not connected') else: raise SMTPServerDisconnected('please run connect() first')
e6f8a89d1a7f530d68a69b9867535d4fd7707846 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e6f8a89d1a7f530d68a69b9867535d4fd7707846/smtplib.py
if self.debuglevel > 0: print 'reply:', repr(line)
if self.debuglevel > 0: print>>stderr, 'reply:', repr(line)
def getreply(self): """Get a reply from the server.
e6f8a89d1a7f530d68a69b9867535d4fd7707846 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e6f8a89d1a7f530d68a69b9867535d4fd7707846/smtplib.py
print 'reply: retcode (%s); Msg: %s' % (errcode,errmsg)
print>>stderr, 'reply: retcode (%s); Msg: %s' % (errcode,errmsg)
def getreply(self): """Get a reply from the server.
e6f8a89d1a7f530d68a69b9867535d4fd7707846 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e6f8a89d1a7f530d68a69b9867535d4fd7707846/smtplib.py
if self.debuglevel >0 : print "data:", (code,repl)
if self.debuglevel >0 : print>>stderr, "data:", (code,repl)
def data(self,msg): """SMTP 'DATA' command -- sends message data to server.
e6f8a89d1a7f530d68a69b9867535d4fd7707846 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e6f8a89d1a7f530d68a69b9867535d4fd7707846/smtplib.py
if self.debuglevel >0 : print "data:", (code,msg)
if self.debuglevel >0 : print>>stderr, "data:", (code,msg)
def data(self,msg): """SMTP 'DATA' command -- sends message data to server.
e6f8a89d1a7f530d68a69b9867535d4fd7707846 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e6f8a89d1a7f530d68a69b9867535d4fd7707846/smtplib.py
des = "_%s__%s" % (klass.__name__, name)
des = "1"
def adaptgetter(name, klass, getter): kind, des = getter if kind == 1: # AV happens when stepping from this line to next if des == "": des = "_%s__%s" % (klass.__name__, name) return lambda obj: getattr(obj, des)
ccae8377a329fe60193a605697b5ffefb4734960 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ccae8377a329fe60193a605697b5ffefb4734960/test_scope.py
print "20. eval with free variables"
print "20. eval and exec with free variables"
def adaptgetter(name, klass, getter): kind, des = getter if kind == 1: # AV happens when stepping from this line to next if des == "": des = "_%s__%s" % (klass.__name__, name) return lambda obj: getattr(obj, des)
ccae8377a329fe60193a605697b5ffefb4734960 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ccae8377a329fe60193a605697b5ffefb4734960/test_scope.py
self._color = color
self._set_color(color)
def color(self, *args): if not args: raise Error, "no color arguments" if len(args) == 1: color = args[0] if type(color) == type(""): # Test the color first try: id = self._canvas.create_line(0, 0, 0, 0, fill=color) except Tkinter.TclError: raise Error, "bad color string: %s" % `color` self._color = color return try: r, g, b = color except: raise Error, "bad color sequence: %s" % `color` else: try: r, g, b = args except: raise Error, "bad color arguments: %s" % `args` assert 0 <= r <= 1 assert 0 <= g <= 1 assert 0 <= b <= 1 x = 255.0 y = 0.5 self._color = "#%02x%02x%02x" % (int(r*x+y), int(g*x+y), int(b*x+y))
3c7a25a4d9ea07f2aa8e4b70fecd84e33de82c2e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3c7a25a4d9ea07f2aa8e4b70fecd84e33de82c2e/turtle.py
self._color = "
self._set_color(" def _set_color(self,color): self._color = color self._draw_turtle()
def color(self, *args): if not args: raise Error, "no color arguments" if len(args) == 1: color = args[0] if type(color) == type(""): # Test the color first try: id = self._canvas.create_line(0, 0, 0, 0, fill=color) except Tkinter.TclError: raise Error, "bad color string: %s" % `color` self._color = color return try: r, g, b = color except: raise Error, "bad color sequence: %s" % `color` else: try: r, g, b = args except: raise Error, "bad color arguments: %s" % `args` assert 0 <= r <= 1 assert 0 <= g <= 1 assert 0 <= b <= 1 x = 255.0 y = 0.5 self._color = "#%02x%02x%02x" % (int(r*x+y), int(g*x+y), int(b*x+y))
3c7a25a4d9ea07f2aa8e4b70fecd84e33de82c2e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3c7a25a4d9ea07f2aa8e4b70fecd84e33de82c2e/turtle.py
if self._tracing:
if self._tracing:
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, arrow="last", 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._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)
3c7a25a4d9ea07f2aa8e4b70fecd84e33de82c2e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3c7a25a4d9ea07f2aa8e4b70fecd84e33de82c2e/turtle.py
arrow="last",
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, arrow="last", 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._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)
3c7a25a4d9ea07f2aa8e4b70fecd84e33de82c2e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3c7a25a4d9ea07f2aa8e4b70fecd84e33de82c2e/turtle.py
effective = (effective / tabwidth + 1) * tabwidth
effective = (int(effective / tabwidth) + 1) * tabwidth
def classifyws(s, tabwidth): raw = effective = 0 for ch in s: if ch == ' ': raw = raw + 1 effective = effective + 1 elif ch == '\t': raw = raw + 1 effective = (effective / tabwidth + 1) * tabwidth else: break return raw, effective
4509168dbf56a3b400db6cddfe12796aaa00e36b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4509168dbf56a3b400db6cddfe12796aaa00e36b/AutoIndent.py
try: unicode(u'decoding unicode is not supported', 'utf-8', 'strict') except TypeError: pass else: raise TestFailed, "decoding unicode should NOT be supported"
if not sys.platform.startswith('java'): try: unicode(u'decoding unicode is not supported', 'utf-8', 'strict') except TypeError: pass else: raise TestFailed, "decoding unicode should NOT be supported"
def __str__(self): return self.x
2b29cb2593c2ca96eb4a0b32b1a6167ce5f18b7c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2b29cb2593c2ca96eb4a0b32b1a6167ce5f18b7c/test_unicode.py
verify(unicode(buffer('character buffers are decoded to unicode'), 'utf-8', 'strict') == u'character buffers are decoded to unicode')
if not sys.platform.startswith('java'): verify(unicode(buffer('character buffers are decoded to unicode'), 'utf-8', 'strict') == u'character buffers are decoded to unicode')
def __str__(self): return self.x
2b29cb2593c2ca96eb4a0b32b1a6167ce5f18b7c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2b29cb2593c2ca96eb4a0b32b1a6167ce5f18b7c/test_unicode.py
return data[:-3] + '\n'
return data.replace('\r\r\n', '\n')
def normalize_output(data): # Some operating systems do conversions on newline. We could possibly # fix that by doing the appropriate termios.tcsetattr()s. I couldn't # figure out the right combo on Tru64 and I don't have an IRIX box. # So just normalize the output and doc the problem O/Ses by allowing # certain combinations for some platforms, but avoid allowing other # differences (like extra whitespace, trailing garbage, etc.) # This is about the best we can do without getting some feedback # from someone more knowledgable. # OSF/1 (Tru64) apparently turns \n into \r\r\n. if data.endswith('\r\r\n'): return data[:-3] + '\n' # IRIX apparently turns \n into \r\n. if data.endswith('\r\n'): return data[:-2] + '\n' return data
9cc3b1ccef8f348ebfc36a13ec54e78423e9b4ff /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9cc3b1ccef8f348ebfc36a13ec54e78423e9b4ff/test_pty.py
return data[:-2] + '\n'
return data.replace('\r\n', '\n')
def normalize_output(data): # Some operating systems do conversions on newline. We could possibly # fix that by doing the appropriate termios.tcsetattr()s. I couldn't # figure out the right combo on Tru64 and I don't have an IRIX box. # So just normalize the output and doc the problem O/Ses by allowing # certain combinations for some platforms, but avoid allowing other # differences (like extra whitespace, trailing garbage, etc.) # This is about the best we can do without getting some feedback # from someone more knowledgable. # OSF/1 (Tru64) apparently turns \n into \r\r\n. if data.endswith('\r\r\n'): return data[:-3] + '\n' # IRIX apparently turns \n into \r\n. if data.endswith('\r\n'): return data[:-2] + '\n' return data
9cc3b1ccef8f348ebfc36a13ec54e78423e9b4ff /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9cc3b1ccef8f348ebfc36a13ec54e78423e9b4ff/test_pty.py
self.read_multi()
self.read_multi(environ, keep_blank_values, strict_parsing)
def __init__(self, fp=None, headers=None, outerboundary="", environ=os.environ, keep_blank_values=0, strict_parsing=0): """Constructor. Read multipart/* until last part.
f5745008d2c78d3830e62cbd4e8f223fe69977c5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f5745008d2c78d3830e62cbd4e8f223fe69977c5/cgi.py
def read_multi(self):
def read_multi(self, environ, keep_blank_values, strict_parsing):
def read_multi(self): """Internal: read a part that is itself multipart.""" self.list = [] part = self.__class__(self.fp, {}, self.innerboundary) # Throw first part away while not part.done: headers = rfc822.Message(self.fp) part = self.__class__(self.fp, headers, self.innerboundary) self.list.append(part) self.skip_lines()
f5745008d2c78d3830e62cbd4e8f223fe69977c5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f5745008d2c78d3830e62cbd4e8f223fe69977c5/cgi.py
part = self.__class__(self.fp, {}, self.innerboundary)
part = self.__class__(self.fp, {}, self.innerboundary, environ, keep_blank_values, strict_parsing)
def read_multi(self): """Internal: read a part that is itself multipart.""" self.list = [] part = self.__class__(self.fp, {}, self.innerboundary) # Throw first part away while not part.done: headers = rfc822.Message(self.fp) part = self.__class__(self.fp, headers, self.innerboundary) self.list.append(part) self.skip_lines()
f5745008d2c78d3830e62cbd4e8f223fe69977c5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f5745008d2c78d3830e62cbd4e8f223fe69977c5/cgi.py
part = self.__class__(self.fp, headers, self.innerboundary)
part = self.__class__(self.fp, headers, self.innerboundary, environ, keep_blank_values, strict_parsing)
def read_multi(self): """Internal: read a part that is itself multipart.""" self.list = [] part = self.__class__(self.fp, {}, self.innerboundary) # Throw first part away while not part.done: headers = rfc822.Message(self.fp) part = self.__class__(self.fp, headers, self.innerboundary) self.list.append(part) self.skip_lines()
f5745008d2c78d3830e62cbd4e8f223fe69977c5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f5745008d2c78d3830e62cbd4e8f223fe69977c5/cgi.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 ()
1ae32466792dde8eab7cafc933f1dbb5984847f6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1ae32466792dde8eab7cafc933f1dbb5984847f6/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."""
1ae32466792dde8eab7cafc933f1dbb5984847f6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1ae32466792dde8eab7cafc933f1dbb5984847f6/core.py
filter = callable
filter = template
def _subn(pattern, template, string, count=0): # internal: pattern.subn implementation hook if callable(template): filter = callable else: # FIXME: prepare template def filter(match, template=template): return _expand(match, template) n = i = 0 s = [] append = s.append c = pattern.cursor(string) while not count or n < count: m = c.search() if not m: break j = m.start() if j > i: append(string[i:j]) append(filter(m)) i = m.end() n = n + 1 if i < len(string): append(string[i:]) return string[:0].join(s), n
e8d52af54bb90459d941ecdd683bc8416bc47b48 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e8d52af54bb90459d941ecdd683bc8416bc47b48/sre.py
def test_original_excepthook(self): savestderr = sys.stderr err = cStringIO.StringIO() sys.stderr = err
e7028ac56cb34b6ec4757308afdd588611a82db6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e7028ac56cb34b6ec4757308afdd588611a82db6/test_sys.py
print exc_type_name + ':', repr.repr(exc_value)
print exc_type_name + ':', _saferepr(exc_value)
def user_exception(self, frame, (exc_type, exc_value, exc_traceback)): """This function is called if an exception occurs, but only if we are to stop at or just below this level.""" frame.f_locals['__exception__'] = exc_type, exc_value if type(exc_type) == type(''): exc_type_name = exc_type else: exc_type_name = exc_type.__name__ print exc_type_name + ':', repr.repr(exc_value) self.interaction(frame, exc_traceback)
6f8ee59653261731d73f0e16bd3f667db57133bd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6f8ee59653261731d73f0e16bd3f667db57133bd/pdb.py
for attr in dir(self.metadata): meth_name = "get_" + attr setattr(self, meth_name, getattr(self.metadata, meth_name))
method_basenames = dir(self.metadata) + \ ['fullname', 'contact', 'contact_email'] for basename in method_basenames: method_name = "get_" + basename setattr(self, method_name, getattr(self.metadata, method_name))
def __init__ (self, attrs=None): """Construct a new Distribution instance: initialize all the attributes of a Distribution, and then uses 'attrs' (a dictionary mapping attribute names to values) to assign some of those attributes their "real" values. (Any attributes not mentioned in 'attrs' will be assigned to some null value: 0, None, an empty list or dictionary, etc.) Most importantly, initialize the 'command_obj' attribute to the empty dictionary; this will be filled in with real command objects by 'parse_command_line()'."""
4982f98bc919d2a6377e3e0e82c186bc5b1d70ff /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4982f98bc919d2a6377e3e0e82c186bc5b1d70ff/dist.py
if hasattr(os, 'chmod'):
if hasattr(os, 'chmod') and sys.platform[:6] != 'cygwin':
def test_rmtree_errors(self): # filename is guaranteed not to exist filename = tempfile.mktemp() self.assertRaises(OSError, shutil.rmtree, filename)
8e6f2ded301055b3e8b61018175cd758ec4ad150 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8e6f2ded301055b3e8b61018175cd758ec4ad150/test_shutil.py
def dump(*stuff): sys.__stdout__.write(string.join(map(str, stuff), " ") + "\n")
9428fa607b6edc7c5ef46814cd869291a8b4619e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9428fa607b6edc7c5ef46814cd869291a8b4619e/PyParse.py
(?: \s+ | ( [^\s[\](){} )+
[^[\](){}
def dump(*stuff): sys.__stdout__.write(string.join(map(str, stuff), " ") + "\n")
9428fa607b6edc7c5ef46814cd869291a8b4619e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9428fa607b6edc7c5ef46814cd869291a8b4619e/PyParse.py
i = m.end(1) - 1
p = m.end() i = p-1 while i >= 0 and str[i] in " \t\n": i = i-1
def _study2(self, _rfind=string.rfind, _find=string.find, _ws=string.whitespace): if self.study_level >= 2: return self._study1() self.study_level = 2
9428fa607b6edc7c5ef46814cd869291a8b4619e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9428fa607b6edc7c5ef46814cd869291a8b4619e/PyParse.py
p = m.end()
def _study2(self, _rfind=string.rfind, _find=string.find, _ws=string.whitespace): if self.study_level >= 2: return self._study1() self.study_level = 2
9428fa607b6edc7c5ef46814cd869291a8b4619e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9428fa607b6edc7c5ef46814cd869291a8b4619e/PyParse.py
else: raise ValueError, "zero step for randrange()"
else: raise ValueError, "zero step for randrange()"
def randrange(self, start, stop=None, step=1, # Do not supply the following arguments int=int, default=None): # This code is a bit messy to make it fast for the # common case while still doing adequate error checking istart = int(start) if istart != start: raise ValueError, "non-integer arg 1 for randrange()" if stop is default: if istart > 0: return int(self.random() * istart) raise ValueError, "empty range for randrange()" istop = int(stop) if istop != stop: raise ValueError, "non-integer stop for randrange()" if step == 1: if istart < istop: return istart + int(self.random() * (istop - istart)) raise ValueError, "empty range for randrange()" istep = int(step) if istep != step: raise ValueError, "non-integer step for randrange()" if istep > 0: n = (istop - istart + istep - 1) / istep elif istep < 0: n = (istop - istart + istep + 1) / istep else: raise ValueError, "zero step for randrange()"
cc221c470fc51ab318ed3976119ab51c12a1d01c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/cc221c470fc51ab318ed3976119ab51c12a1d01c/whrandom.py
if n <= 0: raise ValueError, "empty range for randrange()" return istart + istep*int(self.random() * n)
if n <= 0: raise ValueError, "empty range for randrange()" return istart + istep*int(self.random() * n)
def randrange(self, start, stop=None, step=1, # Do not supply the following arguments int=int, default=None): # This code is a bit messy to make it fast for the # common case while still doing adequate error checking istart = int(start) if istart != start: raise ValueError, "non-integer arg 1 for randrange()" if stop is default: if istart > 0: return int(self.random() * istart) raise ValueError, "empty range for randrange()" istop = int(stop) if istop != stop: raise ValueError, "non-integer stop for randrange()" if step == 1: if istart < istop: return istart + int(self.random() * (istop - istart)) raise ValueError, "empty range for randrange()" istep = int(step) if istep != step: raise ValueError, "non-integer step for randrange()" if istep > 0: n = (istop - istart + istep - 1) / istep elif istep < 0: n = (istop - istart + istep + 1) / istep else: raise ValueError, "zero step for randrange()"
cc221c470fc51ab318ed3976119ab51c12a1d01c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/cc221c470fc51ab318ed3976119ab51c12a1d01c/whrandom.py
other = HMAC("")
other = HMAC(_secret_backdoor_key)
def copy(self): """Return a separate copy of this hashing object.
934d31b1d340f1d309d6ec6a861fa94077033b0f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/934d31b1d340f1d309d6ec6a861fa94077033b0f/hmac.py
exclude=0, single=0, randomize=0, leakdebug=0,
exclude=0, single=0, randomize=0, findleaks=0,
def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, leakdebug=0, use_large_resources=0): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdir -- the directory in which to look for tests (optional) Users other than the Python test suite will certainly want to specify testdir; if it's omitted, the directory containing the Python test suite is searched for. If the tests argument is omitted, the tests listed on the command-line will be used. If that's empty, too, then all *.py files beginning with test_ will be used. The other seven default arguments (verbose, quiet, generate, exclude, single, randomize, and leakdebug) allow programmers calling main() directly to set the values that would normally be set by flags on the command line. """ try: opts, args = getopt.getopt(sys.argv[1:], 'vgqxsrl', ['have-resources']) except getopt.error, msg: print msg print __doc__ return 2 for o, a in opts: if o == '-v': verbose = verbose+1 if o == '-q': quiet = 1; verbose = 0 if o == '-g': generate = 1 if o == '-x': exclude = 1 if o == '-s': single = 1 if o == '-r': randomize = 1 if o == '-l': leakdebug = 1 if o == '--have-resources': use_large_resources = 1 if generate and verbose: print "-g and -v don't go together!" return 2 good = [] bad = [] skipped = [] if leakdebug: try: import gc except ImportError: print 'cycle garbage collection not available' else: gc.set_debug(gc.DEBUG_LEAK) if single: from tempfile import gettempdir filename = os.path.join(gettempdir(), 'pynexttest') try: fp = open(filename, 'r') next = string.strip(fp.read()) tests = [next] fp.close() except IOError: pass for i in range(len(args)): # Strip trailing ".py" from arguments if args[i][-3:] == '.py': args[i] = args[i][:-3] stdtests = STDTESTS[:] nottests = NOTTESTS[:] if exclude: for arg in args: if arg in stdtests: stdtests.remove(arg) nottests[:0] = args args = [] tests = tests or args or findtests(testdir, stdtests, nottests) if single: tests = tests[:1] if randomize: random.shuffle(tests) test_support.verbose = verbose # Tell tests to be moderately quiet test_support.use_large_resources = use_large_resources save_modules = sys.modules.keys() for test in tests: if not quiet: print test ok = runtest(test, generate, verbose, quiet, testdir) if ok > 0: good.append(test) elif ok == 0: bad.append(test) else: skipped.append(test) # Unload the newly imported modules (best effort finalization) for module in sys.modules.keys(): if module not in save_modules and module.startswith("test."): test_support.unload(module) if good and not quiet: if not bad and not skipped and len(good) > 1: print "All", print count(len(good), "test"), "OK." if bad: print count(len(bad), "test"), "failed:", print string.join(bad) if skipped and not quiet: print count(len(skipped), "test"), "skipped:", print string.join(skipped) if single: alltests = findtests(testdir, stdtests, nottests) for i in range(len(alltests)): if tests[0] == alltests[i]: if i == len(alltests) - 1: os.unlink(filename) else: fp = open(filename, 'w') fp.write(alltests[i+1] + '\n') fp.close() break else: os.unlink(filename) return len(bad) > 0
d569f23da94babd616751cd46eea38963e4edfa1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d569f23da94babd616751cd46eea38963e4edfa1/regrtest.py
single, randomize, and leakdebug) allow programmers calling main()
single, randomize, and findleaks) allow programmers calling main()
def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, leakdebug=0, use_large_resources=0): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdir -- the directory in which to look for tests (optional) Users other than the Python test suite will certainly want to specify testdir; if it's omitted, the directory containing the Python test suite is searched for. If the tests argument is omitted, the tests listed on the command-line will be used. If that's empty, too, then all *.py files beginning with test_ will be used. The other seven default arguments (verbose, quiet, generate, exclude, single, randomize, and leakdebug) allow programmers calling main() directly to set the values that would normally be set by flags on the command line. """ try: opts, args = getopt.getopt(sys.argv[1:], 'vgqxsrl', ['have-resources']) except getopt.error, msg: print msg print __doc__ return 2 for o, a in opts: if o == '-v': verbose = verbose+1 if o == '-q': quiet = 1; verbose = 0 if o == '-g': generate = 1 if o == '-x': exclude = 1 if o == '-s': single = 1 if o == '-r': randomize = 1 if o == '-l': leakdebug = 1 if o == '--have-resources': use_large_resources = 1 if generate and verbose: print "-g and -v don't go together!" return 2 good = [] bad = [] skipped = [] if leakdebug: try: import gc except ImportError: print 'cycle garbage collection not available' else: gc.set_debug(gc.DEBUG_LEAK) if single: from tempfile import gettempdir filename = os.path.join(gettempdir(), 'pynexttest') try: fp = open(filename, 'r') next = string.strip(fp.read()) tests = [next] fp.close() except IOError: pass for i in range(len(args)): # Strip trailing ".py" from arguments if args[i][-3:] == '.py': args[i] = args[i][:-3] stdtests = STDTESTS[:] nottests = NOTTESTS[:] if exclude: for arg in args: if arg in stdtests: stdtests.remove(arg) nottests[:0] = args args = [] tests = tests or args or findtests(testdir, stdtests, nottests) if single: tests = tests[:1] if randomize: random.shuffle(tests) test_support.verbose = verbose # Tell tests to be moderately quiet test_support.use_large_resources = use_large_resources save_modules = sys.modules.keys() for test in tests: if not quiet: print test ok = runtest(test, generate, verbose, quiet, testdir) if ok > 0: good.append(test) elif ok == 0: bad.append(test) else: skipped.append(test) # Unload the newly imported modules (best effort finalization) for module in sys.modules.keys(): if module not in save_modules and module.startswith("test."): test_support.unload(module) if good and not quiet: if not bad and not skipped and len(good) > 1: print "All", print count(len(good), "test"), "OK." if bad: print count(len(bad), "test"), "failed:", print string.join(bad) if skipped and not quiet: print count(len(skipped), "test"), "skipped:", print string.join(skipped) if single: alltests = findtests(testdir, stdtests, nottests) for i in range(len(alltests)): if tests[0] == alltests[i]: if i == len(alltests) - 1: os.unlink(filename) else: fp = open(filename, 'w') fp.write(alltests[i+1] + '\n') fp.close() break else: os.unlink(filename) return len(bad) > 0
d569f23da94babd616751cd46eea38963e4edfa1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d569f23da94babd616751cd46eea38963e4edfa1/regrtest.py
if o == '-l': leakdebug = 1
if o == '-l': findleaks = 1
def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, leakdebug=0, use_large_resources=0): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdir -- the directory in which to look for tests (optional) Users other than the Python test suite will certainly want to specify testdir; if it's omitted, the directory containing the Python test suite is searched for. If the tests argument is omitted, the tests listed on the command-line will be used. If that's empty, too, then all *.py files beginning with test_ will be used. The other seven default arguments (verbose, quiet, generate, exclude, single, randomize, and leakdebug) allow programmers calling main() directly to set the values that would normally be set by flags on the command line. """ try: opts, args = getopt.getopt(sys.argv[1:], 'vgqxsrl', ['have-resources']) except getopt.error, msg: print msg print __doc__ return 2 for o, a in opts: if o == '-v': verbose = verbose+1 if o == '-q': quiet = 1; verbose = 0 if o == '-g': generate = 1 if o == '-x': exclude = 1 if o == '-s': single = 1 if o == '-r': randomize = 1 if o == '-l': leakdebug = 1 if o == '--have-resources': use_large_resources = 1 if generate and verbose: print "-g and -v don't go together!" return 2 good = [] bad = [] skipped = [] if leakdebug: try: import gc except ImportError: print 'cycle garbage collection not available' else: gc.set_debug(gc.DEBUG_LEAK) if single: from tempfile import gettempdir filename = os.path.join(gettempdir(), 'pynexttest') try: fp = open(filename, 'r') next = string.strip(fp.read()) tests = [next] fp.close() except IOError: pass for i in range(len(args)): # Strip trailing ".py" from arguments if args[i][-3:] == '.py': args[i] = args[i][:-3] stdtests = STDTESTS[:] nottests = NOTTESTS[:] if exclude: for arg in args: if arg in stdtests: stdtests.remove(arg) nottests[:0] = args args = [] tests = tests or args or findtests(testdir, stdtests, nottests) if single: tests = tests[:1] if randomize: random.shuffle(tests) test_support.verbose = verbose # Tell tests to be moderately quiet test_support.use_large_resources = use_large_resources save_modules = sys.modules.keys() for test in tests: if not quiet: print test ok = runtest(test, generate, verbose, quiet, testdir) if ok > 0: good.append(test) elif ok == 0: bad.append(test) else: skipped.append(test) # Unload the newly imported modules (best effort finalization) for module in sys.modules.keys(): if module not in save_modules and module.startswith("test."): test_support.unload(module) if good and not quiet: if not bad and not skipped and len(good) > 1: print "All", print count(len(good), "test"), "OK." if bad: print count(len(bad), "test"), "failed:", print string.join(bad) if skipped and not quiet: print count(len(skipped), "test"), "skipped:", print string.join(skipped) if single: alltests = findtests(testdir, stdtests, nottests) for i in range(len(alltests)): if tests[0] == alltests[i]: if i == len(alltests) - 1: os.unlink(filename) else: fp = open(filename, 'w') fp.write(alltests[i+1] + '\n') fp.close() break else: os.unlink(filename) return len(bad) > 0
d569f23da94babd616751cd46eea38963e4edfa1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d569f23da94babd616751cd46eea38963e4edfa1/regrtest.py
if leakdebug:
if findleaks:
def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, leakdebug=0, use_large_resources=0): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdir -- the directory in which to look for tests (optional) Users other than the Python test suite will certainly want to specify testdir; if it's omitted, the directory containing the Python test suite is searched for. If the tests argument is omitted, the tests listed on the command-line will be used. If that's empty, too, then all *.py files beginning with test_ will be used. The other seven default arguments (verbose, quiet, generate, exclude, single, randomize, and leakdebug) allow programmers calling main() directly to set the values that would normally be set by flags on the command line. """ try: opts, args = getopt.getopt(sys.argv[1:], 'vgqxsrl', ['have-resources']) except getopt.error, msg: print msg print __doc__ return 2 for o, a in opts: if o == '-v': verbose = verbose+1 if o == '-q': quiet = 1; verbose = 0 if o == '-g': generate = 1 if o == '-x': exclude = 1 if o == '-s': single = 1 if o == '-r': randomize = 1 if o == '-l': leakdebug = 1 if o == '--have-resources': use_large_resources = 1 if generate and verbose: print "-g and -v don't go together!" return 2 good = [] bad = [] skipped = [] if leakdebug: try: import gc except ImportError: print 'cycle garbage collection not available' else: gc.set_debug(gc.DEBUG_LEAK) if single: from tempfile import gettempdir filename = os.path.join(gettempdir(), 'pynexttest') try: fp = open(filename, 'r') next = string.strip(fp.read()) tests = [next] fp.close() except IOError: pass for i in range(len(args)): # Strip trailing ".py" from arguments if args[i][-3:] == '.py': args[i] = args[i][:-3] stdtests = STDTESTS[:] nottests = NOTTESTS[:] if exclude: for arg in args: if arg in stdtests: stdtests.remove(arg) nottests[:0] = args args = [] tests = tests or args or findtests(testdir, stdtests, nottests) if single: tests = tests[:1] if randomize: random.shuffle(tests) test_support.verbose = verbose # Tell tests to be moderately quiet test_support.use_large_resources = use_large_resources save_modules = sys.modules.keys() for test in tests: if not quiet: print test ok = runtest(test, generate, verbose, quiet, testdir) if ok > 0: good.append(test) elif ok == 0: bad.append(test) else: skipped.append(test) # Unload the newly imported modules (best effort finalization) for module in sys.modules.keys(): if module not in save_modules and module.startswith("test."): test_support.unload(module) if good and not quiet: if not bad and not skipped and len(good) > 1: print "All", print count(len(good), "test"), "OK." if bad: print count(len(bad), "test"), "failed:", print string.join(bad) if skipped and not quiet: print count(len(skipped), "test"), "skipped:", print string.join(skipped) if single: alltests = findtests(testdir, stdtests, nottests) for i in range(len(alltests)): if tests[0] == alltests[i]: if i == len(alltests) - 1: os.unlink(filename) else: fp = open(filename, 'w') fp.write(alltests[i+1] + '\n') fp.close() break else: os.unlink(filename) return len(bad) > 0
d569f23da94babd616751cd46eea38963e4edfa1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d569f23da94babd616751cd46eea38963e4edfa1/regrtest.py
gc.set_debug(gc.DEBUG_LEAK)
gc.set_debug(gc.DEBUG_SAVEALL) found_garbage = []
def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, leakdebug=0, use_large_resources=0): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdir -- the directory in which to look for tests (optional) Users other than the Python test suite will certainly want to specify testdir; if it's omitted, the directory containing the Python test suite is searched for. If the tests argument is omitted, the tests listed on the command-line will be used. If that's empty, too, then all *.py files beginning with test_ will be used. The other seven default arguments (verbose, quiet, generate, exclude, single, randomize, and leakdebug) allow programmers calling main() directly to set the values that would normally be set by flags on the command line. """ try: opts, args = getopt.getopt(sys.argv[1:], 'vgqxsrl', ['have-resources']) except getopt.error, msg: print msg print __doc__ return 2 for o, a in opts: if o == '-v': verbose = verbose+1 if o == '-q': quiet = 1; verbose = 0 if o == '-g': generate = 1 if o == '-x': exclude = 1 if o == '-s': single = 1 if o == '-r': randomize = 1 if o == '-l': leakdebug = 1 if o == '--have-resources': use_large_resources = 1 if generate and verbose: print "-g and -v don't go together!" return 2 good = [] bad = [] skipped = [] if leakdebug: try: import gc except ImportError: print 'cycle garbage collection not available' else: gc.set_debug(gc.DEBUG_LEAK) if single: from tempfile import gettempdir filename = os.path.join(gettempdir(), 'pynexttest') try: fp = open(filename, 'r') next = string.strip(fp.read()) tests = [next] fp.close() except IOError: pass for i in range(len(args)): # Strip trailing ".py" from arguments if args[i][-3:] == '.py': args[i] = args[i][:-3] stdtests = STDTESTS[:] nottests = NOTTESTS[:] if exclude: for arg in args: if arg in stdtests: stdtests.remove(arg) nottests[:0] = args args = [] tests = tests or args or findtests(testdir, stdtests, nottests) if single: tests = tests[:1] if randomize: random.shuffle(tests) test_support.verbose = verbose # Tell tests to be moderately quiet test_support.use_large_resources = use_large_resources save_modules = sys.modules.keys() for test in tests: if not quiet: print test ok = runtest(test, generate, verbose, quiet, testdir) if ok > 0: good.append(test) elif ok == 0: bad.append(test) else: skipped.append(test) # Unload the newly imported modules (best effort finalization) for module in sys.modules.keys(): if module not in save_modules and module.startswith("test."): test_support.unload(module) if good and not quiet: if not bad and not skipped and len(good) > 1: print "All", print count(len(good), "test"), "OK." if bad: print count(len(bad), "test"), "failed:", print string.join(bad) if skipped and not quiet: print count(len(skipped), "test"), "skipped:", print string.join(skipped) if single: alltests = findtests(testdir, stdtests, nottests) for i in range(len(alltests)): if tests[0] == alltests[i]: if i == len(alltests) - 1: os.unlink(filename) else: fp = open(filename, 'w') fp.write(alltests[i+1] + '\n') fp.close() break else: os.unlink(filename) return len(bad) > 0
d569f23da94babd616751cd46eea38963e4edfa1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d569f23da94babd616751cd46eea38963e4edfa1/regrtest.py
if self.distribution.has_ext_modules():
if not self.skip_build and self.distribution.has_ext_modules():
def finalize_options (self): if self.bdist_dir is None: bdist_base = self.get_finalized_command('bdist').bdist_base self.bdist_dir = os.path.join(bdist_base, 'wininst') if not self.target_version: self.target_version = "" if self.distribution.has_ext_modules(): short_version = get_python_version() if self.target_version and self.target_version != short_version: raise DistutilsOptionError, \ "target version can only be" + short_version self.target_version = short_version
a19cdad6dc2815f6044c56601e8dd81d9c219631 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a19cdad6dc2815f6044c56601e8dd81d9c219631/bdist_wininst.py