rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
self.name = fileobj.name
self.name = os.path.abspath(fileobj.name)
def __init__(self, name=None, mode="r", fileobj=None): """Open an (uncompressed) tar archive `name'. `mode' is either 'r' to read from an existing archive, 'a' to append data to an existing file or 'w' to create a new file overwriting an existing one. `mode' defaults to 'r'. If `fileobj' is given, it is used for reading or writing data. If it can be determined, `mode' is overridden by `fileobj's mode. `fileobj' is not closed, when TarFile is closed. """ self.name = name
70a24c339655d7f552a52c9eea55ff6f9c3fd5d5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/70a24c339655d7f552a52c9eea55ff6f9c3fd5d5/tarfile.py
pre = os.path.basename(pre)
def gzopen(cls, name, mode="r", fileobj=None, compresslevel=9): """Open gzip compressed tar archive name for reading or writing. Appending is not allowed. """ if len(mode) > 1 or mode not in "rw": raise ValueError, "mode must be 'r' or 'w'"
70a24c339655d7f552a52c9eea55ff6f9c3fd5d5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/70a24c339655d7f552a52c9eea55ff6f9c3fd5d5/tarfile.py
tarname = pre + ext
tarname = os.path.basename(pre + ext)
def gzopen(cls, name, mode="r", fileobj=None, compresslevel=9): """Open gzip compressed tar archive name for reading or writing. Appending is not allowed. """ if len(mode) > 1 or mode not in "rw": raise ValueError, "mode must be 'r' or 'w'"
70a24c339655d7f552a52c9eea55ff6f9c3fd5d5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/70a24c339655d7f552a52c9eea55ff6f9c3fd5d5/tarfile.py
if mode != "r": name = tarname
def gzopen(cls, name, mode="r", fileobj=None, compresslevel=9): """Open gzip compressed tar archive name for reading or writing. Appending is not allowed. """ if len(mode) > 1 or mode not in "rw": raise ValueError, "mode must be 'r' or 'w'"
70a24c339655d7f552a52c9eea55ff6f9c3fd5d5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/70a24c339655d7f552a52c9eea55ff6f9c3fd5d5/tarfile.py
t = cls.taropen(tarname, mode, gzip.GzipFile(name, mode, compresslevel, fileobj)
t = cls.taropen(name, mode, gzip.GzipFile(tarname, mode, compresslevel, fileobj)
def gzopen(cls, name, mode="r", fileobj=None, compresslevel=9): """Open gzip compressed tar archive name for reading or writing. Appending is not allowed. """ if len(mode) > 1 or mode not in "rw": raise ValueError, "mode must be 'r' or 'w'"
70a24c339655d7f552a52c9eea55ff6f9c3fd5d5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/70a24c339655d7f552a52c9eea55ff6f9c3fd5d5/tarfile.py
pre, ext = os.path.splitext(name) pre = os.path.basename(pre) if ext == ".tbz2": ext = ".tar" if ext == ".bz2": ext = "" tarname = pre + ext
def bz2open(cls, name, mode="r", fileobj=None, compresslevel=9): """Open bzip2 compressed tar archive name for reading or writing. Appending is not allowed. """ if len(mode) > 1 or mode not in "rw": raise ValueError, "mode must be 'r' or 'w'."
70a24c339655d7f552a52c9eea55ff6f9c3fd5d5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/70a24c339655d7f552a52c9eea55ff6f9c3fd5d5/tarfile.py
t = cls.taropen(tarname, mode, bz2.BZ2File(name, mode, compresslevel=compresslevel))
t = cls.taropen(name, mode, bz2.BZ2File(name, mode, compresslevel=compresslevel))
def bz2open(cls, name, mode="r", fileobj=None, compresslevel=9): """Open bzip2 compressed tar archive name for reading or writing. Appending is not allowed. """ if len(mode) > 1 or mode not in "rw": raise ValueError, "mode must be 'r' or 'w'."
70a24c339655d7f552a52c9eea55ff6f9c3fd5d5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/70a24c339655d7f552a52c9eea55ff6f9c3fd5d5/tarfile.py
if self.name is not None \ and os.path.abspath(name) == os.path.abspath(self.name):
if self.name is not None and os.path.samefile(name, self.name):
def add(self, name, arcname=None, recursive=True): """Add the file `name' to the archive. `name' may be any type of file (directory, fifo, symbolic link, etc.). If given, `arcname' specifies an alternative name for the file in the archive. Directories are added recursively by default. This can be avoided by setting `recursive' to False. """ self._check("aw")
70a24c339655d7f552a52c9eea55ff6f9c3fd5d5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/70a24c339655d7f552a52c9eea55ff6f9c3fd5d5/tarfile.py
def tag_add(self, tagName, index1, index2=None):
def tag_add(self, tagName, index1, *args):
def tag_add(self, tagName, index1, index2=None): self.tk.call( self._w, 'tag', 'add', tagName, index1, index2)
1810bb829dfc082fa30f0f92ef910bdd3b408991 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1810bb829dfc082fa30f0f92ef910bdd3b408991/Tkinter.py
self._w, 'tag', 'add', tagName, index1, index2)
(self._w, 'tag', 'add', tagName, index1) + args)
def tag_add(self, tagName, index1, index2=None): self.tk.call( self._w, 'tag', 'add', tagName, index1, index2)
1810bb829dfc082fa30f0f92ef910bdd3b408991 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1810bb829dfc082fa30f0f92ef910bdd3b408991/Tkinter.py
for key, value in headers.iteritems():
for key, value in headers.items():
def __init__(self, url, data=None, headers={}): # unwrap('<URL:type://host/path>') --> 'type://host/path' self.__original = unwrap(url) self.type = None # self.__r_type is what's left after doing the splittype self.host = None self.port = None self.data = data self.headers = {} for key, value in headers.iteritems(): self.add_header(key, value)
0f0208d6aed62f3d60dd59042c93399bfc35bef4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/0f0208d6aed62f3d60dd59042c93399bfc35bef4/urllib2.py
for k, v in self.timeout.iteritems():
for k, v in self.timeout.items():
def check_cache(self): # first check for old ones t = time.time() if self.soonest <= t: for k, v in self.timeout.iteritems(): if v < t: self.cache[k].close() del self.cache[k] del self.timeout[k] self.soonest = min(self.timeout.values())
0f0208d6aed62f3d60dd59042c93399bfc35bef4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/0f0208d6aed62f3d60dd59042c93399bfc35bef4/urllib2.py
return self.readlines().join('')
return ''.join(self.readlines())
def read(self): # Note: no size argument -- read until EOF only! return self.readlines().join('')
a38eafabffbaad508e52c7f1c54f56cd38f1ca11 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a38eafabffbaad508e52c7f1c54f56cd38f1ca11/multifile.py
if not host: return addinfourl(open(url2pathname(file), 'r'), noheaders(), self.openedurl)
if not host: return addinfourl(open(url2pathname(file), 'r'), noheaders(), 'file:'+file)
def open_local_file(self, url): host, file = splithost(url) if not host: return addinfourl(open(url2pathname(file), 'r'), noheaders(), self.openedurl) host, port = splitport(host) if not port and socket.gethostbyname(host) in ( localhost(), thishost()): file = unquote(file) return addinfourl(open(url2pathname(file), 'r'), noheaders(), self.openedurl) raise IOError, ('local file error', 'not on local host')
7aea28ed02973842d489cab396a09efafa685e72 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/7aea28ed02973842d489cab396a09efafa685e72/urllib.py
return addinfourl(open(url2pathname(file), 'r'), noheaders(), self.openedurl)
return addinfourl(open(url2pathname(file), 'r'), noheaders(), 'file:'+file)
def open_local_file(self, url): host, file = splithost(url) if not host: return addinfourl(open(url2pathname(file), 'r'), noheaders(), self.openedurl) host, port = splitport(host) if not port and socket.gethostbyname(host) in ( localhost(), thishost()): file = unquote(file) return addinfourl(open(url2pathname(file), 'r'), noheaders(), self.openedurl) raise IOError, ('local file error', 'not on local host')
7aea28ed02973842d489cab396a09efafa685e72 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/7aea28ed02973842d489cab396a09efafa685e72/urllib.py
buf = ''
buf = ['', '']
def process_rawq(self): """Transfer from raw queue to cooked queue.
cd979e03aeea5eecb269eb7280831377f678d04f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/cd979e03aeea5eecb269eb7280831377f678d04f/telnetlib.py
if c == theNULL: continue if c == "\021": continue if c != IAC: buf = buf + c continue c = self.rawq_getchar() if c == IAC: buf = buf + c elif c in (DO, DONT): opt = self.rawq_getchar() self.msg('IAC %s %d', c == DO and 'DO' or 'DONT', ord(opt)) if self.option_callback: self.option_callback(self.sock, c, opt)
if not self.iacseq: if c == theNULL: continue if c == "\021": continue if c != IAC: buf[self.sb] = buf[self.sb] + c continue
def process_rawq(self): """Transfer from raw queue to cooked queue.
cd979e03aeea5eecb269eb7280831377f678d04f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/cd979e03aeea5eecb269eb7280831377f678d04f/telnetlib.py
self.sock.sendall(IAC + WONT + opt) elif c in (WILL, WONT): opt = self.rawq_getchar() self.msg('IAC %s %d', c == WILL and 'WILL' or 'WONT', ord(opt)) if self.option_callback: self.option_callback(self.sock, c, opt)
self.iacseq += c elif len(self.iacseq) == 1: 'IAC: IAC CMD [OPTION only for WILL/WONT/DO/DONT]' if c in (DO, DONT, WILL, WONT): self.iacseq += c continue self.iacseq = '' if c == IAC: buf[self.sb] = buf[self.sb] + c
def process_rawq(self): """Transfer from raw queue to cooked queue.
cd979e03aeea5eecb269eb7280831377f678d04f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/cd979e03aeea5eecb269eb7280831377f678d04f/telnetlib.py
self.sock.sendall(IAC + DONT + opt) else: self.msg('IAC %d not recognized' % ord(c))
if c == SB: self.sb = 1 self.sbdataq = '' elif c == SE: self.sb = 0 self.sbdataq = self.sbdataq + buf[1] buf[1] = '' if self.option_callback: self.option_callback(self.sock, c, NOOPT) else: self.msg('IAC %d not recognized' % ord(c)) elif len(self.iacseq) == 2: cmd = self.iacseq[1] self.iacseq = '' opt = c if cmd in (DO, DONT): self.msg('IAC %s %d', cmd == DO and 'DO' or 'DONT', ord(opt)) if self.option_callback: self.option_callback(self.sock, cmd, opt) else: self.sock.sendall(IAC + WONT + opt) elif cmd in (WILL, WONT): self.msg('IAC %s %d', cmd == WILL and 'WILL' or 'WONT', ord(opt)) if self.option_callback: self.option_callback(self.sock, cmd, opt) else: self.sock.sendall(IAC + DONT + opt)
def process_rawq(self): """Transfer from raw queue to cooked queue.
cd979e03aeea5eecb269eb7280831377f678d04f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/cd979e03aeea5eecb269eb7280831377f678d04f/telnetlib.py
self.cookedq = self.cookedq + buf
self.cookedq = self.cookedq + buf[0] self.sbdataq = self.sbdataq + buf[1]
def process_rawq(self): """Transfer from raw queue to cooked queue.
cd979e03aeea5eecb269eb7280831377f678d04f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/cd979e03aeea5eecb269eb7280831377f678d04f/telnetlib.py
self.ted.WEInsert(stuff, None, None)
try: self.ted.WEInsert(stuff, None, None) finally: self._buf = ""
def flush(self): stuff = string.split(self._buf, '\n') stuff = string.join(stuff, '\r') self.setselection_at_end() self.ted.WEInsert(stuff, None, None) selstart, selend = self.getselection() self._inputstart = selstart self._buf = "" self.ted.WEClearUndo() self.updatescrollbars() if self._parentwindow.wid.GetWindowPort().QDIsPortBuffered(): self._parentwindow.wid.GetWindowPort().QDFlushPortBuffer(None)
7793039a001b444fbe4d27e25fae5e6f9fa8c10a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/7793039a001b444fbe4d27e25fae5e6f9fa8c10a/PyConsole.py
self._buf = ""
def flush(self): stuff = string.split(self._buf, '\n') stuff = string.join(stuff, '\r') self.setselection_at_end() self.ted.WEInsert(stuff, None, None) selstart, selend = self.getselection() self._inputstart = selstart self._buf = "" self.ted.WEClearUndo() self.updatescrollbars() if self._parentwindow.wid.GetWindowPort().QDIsPortBuffered(): self._parentwindow.wid.GetWindowPort().QDFlushPortBuffer(None)
7793039a001b444fbe4d27e25fae5e6f9fa8c10a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/7793039a001b444fbe4d27e25fae5e6f9fa8c10a/PyConsole.py
self.w.outputtext.ted.WEInsert(stuff, None, None) self._buf = ""
try: self.w.outputtext.ted.WEInsert(stuff, None, None) finally: self._buf = ""
def flush(self): self.show() stuff = string.split(self._buf, '\n') stuff = string.join(stuff, '\r') end = self.w.outputtext.ted.WEGetTextLength() self.w.outputtext.setselection(end, end) self.w.outputtext.ted.WEFeatureFlag(WASTEconst.weFReadOnly, 0) self.w.outputtext.ted.WEInsert(stuff, None, None) self._buf = "" self.w.outputtext.updatescrollbars() self.w.outputtext.ted.WEFeatureFlag(WASTEconst.weFReadOnly, 1) if self.w.wid.GetWindowPort().QDIsPortBuffered(): self.w.wid.GetWindowPort().QDFlushPortBuffer(None)
7793039a001b444fbe4d27e25fae5e6f9fa8c10a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/7793039a001b444fbe4d27e25fae5e6f9fa8c10a/PyConsole.py
class BadException:
class BadException(Exception):
def ckmsg(src, msg): try: compile(src, '<fragment>', 'exec') except SyntaxError, e: print e.msg if e.msg == msg: print "ok" else: print "expected:", msg else: print "failed to get expected SyntaxError"
79be9601db13a78d43b0b3b5f164913cce7dbcf7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/79be9601db13a78d43b0b3b5f164913cce7dbcf7/test_exceptions.py
if (self.compiler.find_library_file(lib_dirs, 'z')): exts.append( Extension('zlib', ['zlibmodule.c'], libraries = ['z']) )
zlib_inc = find_file('zlib.h', [], inc_dirs) if zlib_inc is not None: zlib_h = zlib_inc[0] + '/zlib.h' version = '"0.0.0"' version_req = '"1.1.3"' fp = open(zlib_h) while 1: line = fp.readline() if not line: break if line.find(' version = line.split()[2] break if version >= version_req: if (self.compiler.find_library_file(lib_dirs, 'z')): exts.append( Extension('zlib', ['zlibmodule.c'], libraries = ['z']) )
def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.insert(0, '/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.insert(0, '/usr/local/include' )
6bf3d1b2cd4d00f4cbda2cb2ddc8fc7b5abba7da /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/6bf3d1b2cd4d00f4cbda2cb2ddc8fc7b5abba7da/setup.py
command = interpolate(SH_LOCK, file=file) p = os.popen(command) output = p.read()
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 = string.join(string.split(self.ui.title)) # 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 # XXX Should lock here try: os.unlink(file) except os.error: pass try: f = open(file, 'w') except IOError, why: self.error(CANTWRITE, file=file, why=why) return date = time.ctime(now) emit(FILEHEADER, self.ui, os.environ, date=date, _file=f, _quote=0) f.write('\n') f.write(self.ui.body) f.write('\n') f.close()
9d921e828bd1eaadd55ad85fbbd82b2a8312865f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9d921e828bd1eaadd55ad85fbbd82b2a8312865f/faqwiz.py
command = interpolate( SH_LOCK + '\n' + SH_CHECKIN, file=file, tfn=tfn)
command = interpolate(SH_CHECKIN, file=file, tfn=tfn) log("\n\n" + command)
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 = string.join(string.split(self.ui.title)) # 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 # XXX Should lock here try: os.unlink(file) except os.error: pass try: f = open(file, 'w') except IOError, why: self.error(CANTWRITE, file=file, why=why) return date = time.ctime(now) emit(FILEHEADER, self.ui, os.environ, date=date, _file=f, _quote=0) f.write('\n') f.write(self.ui.body) f.write('\n') f.close()
9d921e828bd1eaadd55ad85fbbd82b2a8312865f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9d921e828bd1eaadd55ad85fbbd82b2a8312865f/faqwiz.py
log("output: " + output) log("done: " + str(sts)) log("TempFile:\n" + open(tfn).read() + "end")
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 = string.join(string.split(self.ui.title)) # 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 # XXX Should lock here try: os.unlink(file) except os.error: pass try: f = open(file, 'w') except IOError, why: self.error(CANTWRITE, file=file, why=why) return date = time.ctime(now) emit(FILEHEADER, self.ui, os.environ, date=date, _file=f, _quote=0) f.write('\n') f.write(self.ui.body) f.write('\n') f.close()
9d921e828bd1eaadd55ad85fbbd82b2a8312865f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9d921e828bd1eaadd55ad85fbbd82b2a8312865f/faqwiz.py
def test_strftime_bounds_checking(self): # Make sure that strftime() checks the bounds of the various parts #of the time tuple.
8543a308afe19921c1847cf310049ec751535704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8543a308afe19921c1847cf310049ec751535704/test_time.py
self.assertRaises(ValueError, time.strftime, '', (1900, 0, 1, 0, 0, 0, 0, 1, -1))
self.assertRaises(ValueError, time.strftime, '', (1900, -1, 1, 0, 0, 0, 0, 1, -1))
def test_strftime_bounds_checking(self): # Make sure that strftime() checks the bounds of the various parts #of the time tuple.
8543a308afe19921c1847cf310049ec751535704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8543a308afe19921c1847cf310049ec751535704/test_time.py
self.assertRaises(ValueError, time.strftime, '', (1900, 1, 0, 0, 0, 0, 0, 1, -1))
self.assertRaises(ValueError, time.strftime, '', (1900, 1, -1, 0, 0, 0, 0, 1, -1))
def test_strftime_bounds_checking(self): # Make sure that strftime() checks the bounds of the various parts #of the time tuple.
8543a308afe19921c1847cf310049ec751535704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8543a308afe19921c1847cf310049ec751535704/test_time.py
def test_strftime_bounds_checking(self): # Make sure that strftime() checks the bounds of the various parts #of the time tuple.
8543a308afe19921c1847cf310049ec751535704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8543a308afe19921c1847cf310049ec751535704/test_time.py
def test_strftime_bounds_checking(self): # Make sure that strftime() checks the bounds of the various parts #of the time tuple.
8543a308afe19921c1847cf310049ec751535704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8543a308afe19921c1847cf310049ec751535704/test_time.py
def test_strftime_bounds_checking(self): # Make sure that strftime() checks the bounds of the various parts #of the time tuple.
8543a308afe19921c1847cf310049ec751535704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8543a308afe19921c1847cf310049ec751535704/test_time.py
self.assertRaises(ValueError, time.strftime, '', (1900, 1, 1, 0, 0, 0, 0, 0, -1))
self.assertRaises(ValueError, time.strftime, '', (1900, 1, 1, 0, 0, 0, 0, -1, -1))
def test_strftime_bounds_checking(self): # Make sure that strftime() checks the bounds of the various parts #of the time tuple.
8543a308afe19921c1847cf310049ec751535704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8543a308afe19921c1847cf310049ec751535704/test_time.py
def test_strftime_bounds_checking(self): # Make sure that strftime() checks the bounds of the various parts #of the time tuple.
8543a308afe19921c1847cf310049ec751535704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8543a308afe19921c1847cf310049ec751535704/test_time.py
def run (self):
fee53bc8f1351bfd4fd61ee232169dccdca95730 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/fee53bc8f1351bfd4fd61ee232169dccdca95730/install_lib.py
out_fn = string.replace (f, '.py', '.pyc')
out_fn = f + (__debug__ and "c" or "o") compile_msg = "byte-compiling %s to %s" % \ (f, os.path.basename (out_fn)) skip_msg = "byte-compilation of %s skipped" % f
def run (self):
fee53bc8f1351bfd4fd61ee232169dccdca95730 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/fee53bc8f1351bfd4fd61ee232169dccdca95730/install_lib.py
"byte-compiling %s" % f, "byte-compilation of %s skipped" % f)
compile_msg, skip_msg)
def run (self):
fee53bc8f1351bfd4fd61ee232169dccdca95730 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/fee53bc8f1351bfd4fd61ee232169dccdca95730/install_lib.py
if len_nodelist != 2 and isinstance(result, GenExpr):
if len_nodelist != 2 and isinstance(result, GenExpr) \ and len(node) == 3 and node[2][0] == symbol.gen_for:
def com_call_function(self, primaryNode, nodelist): if nodelist[0] == token.RPAR: return CallFunc(primaryNode, [], lineno=extractLineNo(nodelist)) args = [] kw = 0 len_nodelist = len(nodelist) for i in range(1, len_nodelist, 2): node = nodelist[i] if node[0] == token.STAR or node[0] == token.DOUBLESTAR: break kw, result = self.com_argument(node, kw) if len_nodelist != 2 and isinstance(result, GenExpr): raise SyntaxError, 'generator expression needs parenthesis' args.append(result) else: # No broken by star arg, so skip the last one we processed. i = i + 1 if i < len_nodelist and nodelist[i][0] == token.COMMA: # need to accept an application that looks like "f(a, b,)" i = i + 1 star_node = dstar_node = None while i < len_nodelist: tok = nodelist[i] ch = nodelist[i+1] i = i + 3 if tok[0]==token.STAR: if star_node is not None: raise SyntaxError, 'already have the varargs indentifier' star_node = self.com_node(ch) elif tok[0]==token.DOUBLESTAR: if dstar_node is not None: raise SyntaxError, 'already have the kwargs indentifier' dstar_node = self.com_node(ch) else: raise SyntaxError, 'unknown node type: %s' % tok return CallFunc(primaryNode, args, star_node, dstar_node, lineno=extractLineNo(nodelist))
0abf9131f7a348ed815eb30cf4159185e1273f9c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/0abf9131f7a348ed815eb30cf4159185e1273f9c/transformer.py
if (isinstance (filename, str)): new_base = base.decode(TESTFN_ENCODING) file_list = [f.decode(TESTFN_ENCODING) for f in os.listdir(path)] else: new_base = base file_list = os.listdir(path)
if isinstance(base, str): base = base.decode(TESTFN_ENCODING) file_list = os.listdir(path) if file_list and isinstance(file_list[0], str): file_list = [f.decode(TESTFN_ENCODING) for f in file_list]
def _do_single(self, filename): self.failUnless(os.path.exists(filename)) self.failUnless(os.path.isfile(filename)) self.failUnless(os.path.exists(os.path.abspath(filename))) self.failUnless(os.path.isfile(os.path.abspath(filename))) os.chmod(filename, 0777) os.utime(filename, None) os.utime(filename, (time.time(), time.time())) # Copy/rename etc tests using the same filename self._do_copyish(filename, filename) # Filename should appear in glob output self.failUnless( os.path.abspath(filename)==os.path.abspath(glob.glob(filename)[0])) # basename should appear in listdir. path, base = os.path.split(os.path.abspath(filename)) if (isinstance (filename, str)): new_base = base.decode(TESTFN_ENCODING) file_list = [f.decode(TESTFN_ENCODING) for f in os.listdir(path)] else: new_base = base file_list = os.listdir(path)
5f3109e85605c9c0c9e857ab81d8c558055d606b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/5f3109e85605c9c0c9e857ab81d8c558055d606b/test_unicode_file.py
new_base = unicodedata.normalize("NFD", new_base)
base = unicodedata.normalize("NFD", base)
def _do_single(self, filename): self.failUnless(os.path.exists(filename)) self.failUnless(os.path.isfile(filename)) self.failUnless(os.path.exists(os.path.abspath(filename))) self.failUnless(os.path.isfile(os.path.abspath(filename))) os.chmod(filename, 0777) os.utime(filename, None) os.utime(filename, (time.time(), time.time())) # Copy/rename etc tests using the same filename self._do_copyish(filename, filename) # Filename should appear in glob output self.failUnless( os.path.abspath(filename)==os.path.abspath(glob.glob(filename)[0])) # basename should appear in listdir. path, base = os.path.split(os.path.abspath(filename)) if (isinstance (filename, str)): new_base = base.decode(TESTFN_ENCODING) file_list = [f.decode(TESTFN_ENCODING) for f in os.listdir(path)] else: new_base = base file_list = os.listdir(path)
5f3109e85605c9c0c9e857ab81d8c558055d606b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/5f3109e85605c9c0c9e857ab81d8c558055d606b/test_unicode_file.py
self.failUnless(new_base in file_list)
self.failUnless(base in file_list)
def _do_single(self, filename): self.failUnless(os.path.exists(filename)) self.failUnless(os.path.isfile(filename)) self.failUnless(os.path.exists(os.path.abspath(filename))) self.failUnless(os.path.isfile(os.path.abspath(filename))) os.chmod(filename, 0777) os.utime(filename, None) os.utime(filename, (time.time(), time.time())) # Copy/rename etc tests using the same filename self._do_copyish(filename, filename) # Filename should appear in glob output self.failUnless( os.path.abspath(filename)==os.path.abspath(glob.glob(filename)[0])) # basename should appear in listdir. path, base = os.path.split(os.path.abspath(filename)) if (isinstance (filename, str)): new_base = base.decode(TESTFN_ENCODING) file_list = [f.decode(TESTFN_ENCODING) for f in os.listdir(path)] else: new_base = base file_list = os.listdir(path)
5f3109e85605c9c0c9e857ab81d8c558055d606b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/5f3109e85605c9c0c9e857ab81d8c558055d606b/test_unicode_file.py
Instantiate with: IMAP4_SSL([, host[, port[, keyfile[, certfile]]]])
Instantiate with: IMAP4_SSL([host[, port[, keyfile[, certfile]]]])
def print_log(self): self._mesg('last %d IMAP4 interactions:' % len(self._cmd_log)) i, n = self._cmd_log_idx, self._cmd_log_len while n: try: apply(self._mesg, self._cmd_log[i]) except: pass i += 1 if i >= self._cmd_log_len: i = 0 n -= 1
513ff3549774a7695d1577edd8942a3550f301be /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/513ff3549774a7695d1577edd8942a3550f301be/imaplib.py
def upload_file(self, command, pyversion, filename): # Sign if requested if self.sign: spawn(("gpg", "--detach-sign", "-a", filename), dry_run=self.dry_run)
ec06ba90ca4dc1f91043ad227b64ffa930194a34 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ec06ba90ca4dc1f91043ad227b64ffa930194a34/upload.py
':action':'file_upload', 'protcol_version':'1', 'name':self.distribution.get_name(), 'version':self.distribution.get_version(), 'content':(os.path.basename(filename),content), 'filetype':command, 'pyversion':pyversion, 'md5_digest':md5(content).hexdigest(),
':action': 'file_upload', 'protcol_version': '1', 'name': meta.get_name(), 'version': meta.get_version(), 'content': (os.path.basename(filename),content), 'filetype': command, 'pyversion': pyversion, 'md5_digest': md5(content).hexdigest(), 'metadata_version' : '1.0', 'summary': meta.get_description(), 'home_page': meta.get_url(), 'author': meta.get_contact(), 'author_email': meta.get_contact_email(), 'license': meta.get_licence(), 'description': meta.get_long_description(), 'keywords': meta.get_keywords(), 'platform': meta.get_platforms(), 'classifiers': meta.get_classifiers(), 'download_url': meta.get_download_url(), 'provides': meta.get_provides(), 'requires': meta.get_requires(), 'obsoletes': meta.get_obsoletes(),
def upload_file(self, command, pyversion, filename): # Sign if requested if self.sign: spawn(("gpg", "--detach-sign", "-a", filename), dry_run=self.dry_run)
ec06ba90ca4dc1f91043ad227b64ffa930194a34 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ec06ba90ca4dc1f91043ad227b64ffa930194a34/upload.py
class PackBufferTestCase(unittest.TestCase): """ Test the packing methods that work on buffers. """ def test_unpack_from( self ): test_string = 'abcd01234' fmt = '4s' s = struct.Struct(fmt) for cls in (str, buffer): data = cls(test_string) self.assertEquals(s.unpack_from(data), ('abcd',)) self.assertEquals(s.unpack_from(data, 2), ('cd01',)) self.assertEquals(s.unpack_from(data, 4), ('0123',)) for i in xrange(6): self.assertEquals(s.unpack_from(data, i), (data[i:i+4],)) for i in xrange(6, len(test_string) + 1): simple_err(s.unpack_from, data, i) for cls in (str, buffer): data = cls(test_string) self.assertEquals(struct.unpack_from(fmt, data), ('abcd',)) self.assertEquals(struct.unpack_from(fmt, data, 2), ('cd01',)) self.assertEquals(struct.unpack_from(fmt, data, 4), ('0123',)) for i in xrange(6): self.assertEquals(struct.unpack_from(fmt, data, i), (data[i:i+4],)) for i in xrange(6, len(test_string) + 1): simple_err(struct.unpack_from, fmt, data, i) def test_pack_to( self ): test_string = 'Reykjavik rocks, eow!' writable_buf = array.array('c', ' '*100) fmt = '21s' s = struct.Struct(fmt) s.pack_to(writable_buf, 0, test_string) from_buf = writable_buf.tostring()[:len(test_string)] self.assertEquals(from_buf, test_string) s.pack_to(writable_buf, 10, test_string) from_buf = writable_buf.tostring()[:len(test_string)+10] self.assertEquals(from_buf, (test_string[:10] + test_string)) small_buf = array.array('c', ' '*10) self.assertRaises(struct.error, s.pack_to, small_buf, 0, test_string) self.assertRaises(struct.error, s.pack_to, small_buf, 2, test_string) def test_pack_to_fn( self ): test_string = 'Reykjavik rocks, eow!' writable_buf = array.array('c', ' '*100) fmt = '21s' pack_to = lambda *args: struct.pack_to(fmt, *args) pack_to(writable_buf, 0, test_string) from_buf = writable_buf.tostring()[:len(test_string)] self.assertEquals(from_buf, test_string) pack_to(writable_buf, 10, test_string) from_buf = writable_buf.tostring()[:len(test_string)+10] self.assertEquals(from_buf, (test_string[:10] + test_string)) small_buf = array.array('c', ' '*10) self.assertRaises(struct.error, pack_to, small_buf, 0, test_string) self.assertRaises(struct.error, pack_to, small_buf, 2, test_string) def test_main(): test.test_support.run_unittest(PackBufferTestCase) if __name__ == "__main__": test_main()
def assertRaises(excClass, callableObj, *args, **kwargs): try: callableObj(*args, **kwargs) except excClass: return else: raise RuntimeError("%s not raised." % excClass) def test_unpack_from(): test_string = 'abcd01234' fmt = '4s' s = struct.Struct(fmt) for cls in (str, buffer): data = cls(test_string) assert s.unpack_from(data) == ('abcd',) assert s.unpack_from(data, 2) == ('cd01',) assert s.unpack_from(data, 4) == ('0123',) for i in xrange(6): assert s.unpack_from(data, i) == (data[i:i+4],) for i in xrange(6, len(test_string) + 1): simple_err(s.unpack_from, data, i) for cls in (str, buffer): data = cls(test_string) assert struct.unpack_from(fmt, data) == ('abcd',) assert struct.unpack_from(fmt, data, 2) == ('cd01',) assert struct.unpack_from(fmt, data, 4) == ('0123',) for i in xrange(6): assert (struct.unpack_from(fmt, data, i) == (data[i:i+4],)) for i in xrange(6, len(test_string) + 1): simple_err(struct.unpack_from, fmt, data, i) def test_pack_to(): test_string = 'Reykjavik rocks, eow!' writable_buf = array.array('c', ' '*100) fmt = '21s' s = struct.Struct(fmt) s.pack_to(writable_buf, 0, test_string) from_buf = writable_buf.tostring()[:len(test_string)] assert from_buf == test_string s.pack_to(writable_buf, 10, test_string) from_buf = writable_buf.tostring()[:len(test_string)+10] assert from_buf == (test_string[:10] + test_string) small_buf = array.array('c', ' '*10) assertRaises(struct.error, s.pack_to, small_buf, 0, test_string) assertRaises(struct.error, s.pack_to, small_buf, 2, test_string) def test_pack_to_fn(): test_string = 'Reykjavik rocks, eow!' writable_buf = array.array('c', ' '*100) fmt = '21s' pack_to = lambda *args: struct.pack_to(fmt, *args) pack_to(writable_buf, 0, test_string) from_buf = writable_buf.tostring()[:len(test_string)] assert from_buf == test_string pack_to(writable_buf, 10, test_string) from_buf = writable_buf.tostring()[:len(test_string)+10] assert from_buf == (test_string[:10] + test_string) small_buf = array.array('c', ' '*10) assertRaises(struct.error, pack_to, small_buf, 0, test_string) assertRaises(struct.error, pack_to, small_buf, 2, test_string) test_unpack_from() test_pack_to() test_pack_to_fn()
def test_1229380(): import sys for endian in ('', '>', '<'): for cls in (int, long): for fmt in ('B', 'H', 'I', 'L'): deprecated_err(struct.pack, endian + fmt, cls(-1)) deprecated_err(struct.pack, endian + 'B', cls(300)) deprecated_err(struct.pack, endian + 'H', cls(70000)) deprecated_err(struct.pack, endian + 'I', sys.maxint * 4L) deprecated_err(struct.pack, endian + 'L', sys.maxint * 4L)
d418864eb31f0b7282379e9dab72d39a8d892c58 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d418864eb31f0b7282379e9dab72d39a8d892c58/test_struct.py
if __debug__: stderr = re.sub(r"\[\d+ refs\]\r?\n?$", "", stderr) return stderr
return re.sub(r"\[\d+ refs\]\r?\n?$", "", stderr)
def remove_stderr_debug_decorations(stderr): if __debug__: stderr = re.sub(r"\[\d+ refs\]\r?\n?$", "", stderr) return stderr
eafdcd9e81518f8dccc6b6e10c2b91168e7f69f2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/eafdcd9e81518f8dccc6b6e10c2b91168e7f69f2/test_subprocess.py
def setcontext(context, _local=local): """Set this thread's context to context.""" if context in (DefaultContext, BasicContext, ExtendedContext): context = context.copy() context.clear_flags() _local.__decimal_context__ = context
05069e441412309fa5da59f2e1f6132b4e2386f6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/05069e441412309fa5da59f2e1f6132b4e2386f6/decimal.py
return Decimal((sign, self._int, self._exp))._fix(context=context)
return Decimal((sign, self._int, self._exp))._fix(context)
def __neg__(self, context=None): """Returns a copy with the sign switched.
05069e441412309fa5da59f2e1f6132b4e2386f6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/05069e441412309fa5da59f2e1f6132b4e2386f6/decimal.py
ans = self._fix(context=context)
ans = self._fix(context)
def __pos__(self, context=None): """Returns a copy, unless it is a sNaN.
05069e441412309fa5da59f2e1f6132b4e2386f6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/05069e441412309fa5da59f2e1f6132b4e2386f6/decimal.py
ans = ans._fix(context=context)
ans = ans._fix(context)
def __add__(self, other, context=None): """Returns self + other.
05069e441412309fa5da59f2e1f6132b4e2386f6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/05069e441412309fa5da59f2e1f6132b4e2386f6/decimal.py
ans = ans._fix(context=context)
ans = ans._fix(context)
def __add__(self, other, context=None): """Returns self + other.
05069e441412309fa5da59f2e1f6132b4e2386f6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/05069e441412309fa5da59f2e1f6132b4e2386f6/decimal.py
ans = ans._fix(context=context)
ans = ans._fix(context)
def __add__(self, other, context=None): """Returns self + other.
05069e441412309fa5da59f2e1f6132b4e2386f6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/05069e441412309fa5da59f2e1f6132b4e2386f6/decimal.py
ans = ans._fix(context=context)
ans = ans._fix(context)
def _increment(self, round=1, context=None): """Special case of add, adding 1eExponent
05069e441412309fa5da59f2e1f6132b4e2386f6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/05069e441412309fa5da59f2e1f6132b4e2386f6/decimal.py
ans = ans._fix(context=context)
ans = ans._fix(context)
def __mul__(self, other, context=None): """Return self * other.
05069e441412309fa5da59f2e1f6132b4e2386f6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/05069e441412309fa5da59f2e1f6132b4e2386f6/decimal.py
ans = ans._fix(context=context)
ans = ans._fix(context)
def __mul__(self, other, context=None): """Return self * other.
05069e441412309fa5da59f2e1f6132b4e2386f6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/05069e441412309fa5da59f2e1f6132b4e2386f6/decimal.py
ans = ans._fix(context=context)
ans = ans._fix(context)
def __mul__(self, other, context=None): """Return self * other.
05069e441412309fa5da59f2e1f6132b4e2386f6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/05069e441412309fa5da59f2e1f6132b4e2386f6/decimal.py
ans = ans._fix(context=context)
ans = ans._fix(context)
def __mul__(self, other, context=None): """Return self * other.
05069e441412309fa5da59f2e1f6132b4e2386f6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/05069e441412309fa5da59f2e1f6132b4e2386f6/decimal.py
ans2 = ans2._fix(context=context)
ans2 = ans2._fix(context)
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision.
05069e441412309fa5da59f2e1f6132b4e2386f6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/05069e441412309fa5da59f2e1f6132b4e2386f6/decimal.py
otherside = otherside._fix(context=context)
otherside = otherside._fix(context)
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision.
05069e441412309fa5da59f2e1f6132b4e2386f6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/05069e441412309fa5da59f2e1f6132b4e2386f6/decimal.py
ans = ans._fix(context=context)
ans = ans._fix(context)
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision.
05069e441412309fa5da59f2e1f6132b4e2386f6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/05069e441412309fa5da59f2e1f6132b4e2386f6/decimal.py
return r._fix(context=context)
return r._fix(context)
def remainder_near(self, other, context=None): """ Remainder nearest to 0- abs(remainder-near) <= other/2 """ other = _convert_other(other)
05069e441412309fa5da59f2e1f6132b4e2386f6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/05069e441412309fa5da59f2e1f6132b4e2386f6/decimal.py
return r._fix(context=context)
return r._fix(context)
def remainder_near(self, other, context=None): """ Remainder nearest to 0- abs(remainder-near) <= other/2 """ other = _convert_other(other)
05069e441412309fa5da59f2e1f6132b4e2386f6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/05069e441412309fa5da59f2e1f6132b4e2386f6/decimal.py
def _fix(self, prec=None, rounding=None, folddown=None, context=None):
def _fix(self, context):
def _fix(self, prec=None, rounding=None, folddown=None, context=None): """Round if it is necessary to keep self within prec precision.
05069e441412309fa5da59f2e1f6132b4e2386f6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/05069e441412309fa5da59f2e1f6132b4e2386f6/decimal.py
prec - precision to which to round. By default, the context decides. rounding - Rounding method. By default, the context decides. folddown - Fold down high elements, by default context._clamp
def _fix(self, prec=None, rounding=None, folddown=None, context=None): """Round if it is necessary to keep self within prec precision.
05069e441412309fa5da59f2e1f6132b4e2386f6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/05069e441412309fa5da59f2e1f6132b4e2386f6/decimal.py
if prec is None: prec = context.prec ans = Decimal(self) ans = ans._fixexponents(prec, rounding, folddown=folddown, context=context)
prec = context.prec ans = self._fixexponents(prec, context)
def _fix(self, prec=None, rounding=None, folddown=None, context=None): """Round if it is necessary to keep self within prec precision.
05069e441412309fa5da59f2e1f6132b4e2386f6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/05069e441412309fa5da59f2e1f6132b4e2386f6/decimal.py
ans = ans._round(prec, rounding, context=context) ans = ans._fixexponents(prec, rounding, folddown=folddown, context=context)
ans = ans._round(prec, context=context) ans = ans._fixexponents(prec, context)
def _fix(self, prec=None, rounding=None, folddown=None, context=None): """Round if it is necessary to keep self within prec precision.
05069e441412309fa5da59f2e1f6132b4e2386f6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/05069e441412309fa5da59f2e1f6132b4e2386f6/decimal.py
def _fixexponents(self, prec=None, rounding=None, folddown=None, context=None): """Fix the exponents and return a copy with the exponent in bounds.""" if self._is_special: return self if context is None: context = getcontext() if prec is None: prec = context.prec if folddown is None: folddown = context._clamp
def _fixexponents(self, prec, context): """Fix the exponents and return a copy with the exponent in bounds. Only call if known to not be a special value. """ folddown = context._clamp
def _fixexponents(self, prec=None, rounding=None, folddown=None, context=None): """Fix the exponents and return a copy with the exponent in bounds.""" if self._is_special: return self if context is None: context = getcontext() if prec is None: prec = context.prec if folddown is None: folddown = context._clamp Emin = context.Emin ans = Decimal(self) ans_adjusted = ans.adjusted() if ans_adjusted < Emin: Etiny = context.Etiny() if ans._exp < Etiny: if not ans: ans._exp = Etiny context._raise_error(Clamped) return ans ans = ans._rescale(Etiny, context=context) #It isn't zero, and exp < Emin => subnormal context._raise_error(Subnormal) if context.flags[Inexact]: context._raise_error(Underflow) else: if ans: #Only raise subnormal if non-zero. context._raise_error(Subnormal) else: Etop = context.Etop() if folddown and ans._exp > Etop: context._raise_error(Clamped) ans = ans._rescale(Etop, context=context) else: Emax = context.Emax if ans_adjusted > Emax: if not ans: ans._exp = Emax context._raise_error(Clamped) return ans context._raise_error(Inexact) context._raise_error(Rounded) return context._raise_error(Overflow, 'above Emax', ans._sign) return ans
05069e441412309fa5da59f2e1f6132b4e2386f6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/05069e441412309fa5da59f2e1f6132b4e2386f6/decimal.py
return val._fix(context=context)
return val._fix(context)
def __pow__(self, n, modulo = None, context=None): """Return self ** n (mod modulo)
05069e441412309fa5da59f2e1f6132b4e2386f6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/05069e441412309fa5da59f2e1f6132b4e2386f6/decimal.py
dup = self._fix(context=context)
dup = self._fix(context)
def normalize(self, context=None): """Normalize- strip trailing 0s, change anything equal to 0 to 0e0"""
05069e441412309fa5da59f2e1f6132b4e2386f6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/05069e441412309fa5da59f2e1f6132b4e2386f6/decimal.py
def quantize(self, exp, rounding = None, context=None, watchexp = 1):
def quantize(self, exp, rounding=None, context=None, watchexp=1):
def quantize(self, exp, rounding = None, context=None, watchexp = 1): """Quantize self so its exponent is the same as that of exp.
05069e441412309fa5da59f2e1f6132b4e2386f6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/05069e441412309fa5da59f2e1f6132b4e2386f6/decimal.py
def _rescale(self, exp, rounding = None, context=None, watchexp = 1):
def _rescale(self, exp, rounding=None, context=None, watchexp=1):
def _rescale(self, exp, rounding = None, context=None, watchexp = 1): """Rescales so that the exponent is exp.
05069e441412309fa5da59f2e1f6132b4e2386f6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/05069e441412309fa5da59f2e1f6132b4e2386f6/decimal.py
digits = len(self._int)+diff
digits = len(self._int) + diff
def _rescale(self, exp, rounding = None, context=None, watchexp = 1): """Rescales so that the exponent is exp.
05069e441412309fa5da59f2e1f6132b4e2386f6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/05069e441412309fa5da59f2e1f6132b4e2386f6/decimal.py
tmp._int = (0,)+tmp._int
tmp._int = (0,) + tmp._int
def _rescale(self, exp, rounding = None, context=None, watchexp = 1): """Rescales so that the exponent is exp.
05069e441412309fa5da59f2e1f6132b4e2386f6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/05069e441412309fa5da59f2e1f6132b4e2386f6/decimal.py
def to_integral(self, rounding = None, context=None):
def to_integral(self, rounding=None, context=None):
def to_integral(self, rounding = None, context=None): """Rounds to the nearest integer, without raising inexact, rounded.""" if self._is_special: ans = self._check_nans(context=context) if ans: return ans if self._exp >= 0: return self if context is None: context = getcontext() flags = context._ignore_flags(Rounded, Inexact) ans = self._rescale(0, rounding, context=context) context._regard_flags(flags) return ans
05069e441412309fa5da59f2e1f6132b4e2386f6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/05069e441412309fa5da59f2e1f6132b4e2386f6/decimal.py
ans = ans._fix(context=context)
ans = ans._fix(context)
def sqrt(self, context=None): """Return the square root of self.
05069e441412309fa5da59f2e1f6132b4e2386f6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/05069e441412309fa5da59f2e1f6132b4e2386f6/decimal.py
return ans._fix(context=context)
return ans._fix(context)
def sqrt(self, context=None): """Return the square root of self.
05069e441412309fa5da59f2e1f6132b4e2386f6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/05069e441412309fa5da59f2e1f6132b4e2386f6/decimal.py
return ans._fix(context=context)
return ans._fix(context)
def max(self, other, context=None): """Returns the larger value.
05069e441412309fa5da59f2e1f6132b4e2386f6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/05069e441412309fa5da59f2e1f6132b4e2386f6/decimal.py
return ans._fix(context=context)
return ans._fix(context)
def min(self, other, context=None): """Returns the smaller value.
05069e441412309fa5da59f2e1f6132b4e2386f6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/05069e441412309fa5da59f2e1f6132b4e2386f6/decimal.py
return d._fix(context=self)
return d._fix(self)
def create_decimal(self, num='0'): """Creates a new Decimal instance but using self as context.""" d = Decimal(num, context=self) return d._fix(context=self)
05069e441412309fa5da59f2e1f6132b4e2386f6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/05069e441412309fa5da59f2e1f6132b4e2386f6/decimal.py
return str(a._fix(context=self))
return str(a._fix(self))
def _apply(self, a): return str(a._fix(context=self))
05069e441412309fa5da59f2e1f6132b4e2386f6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/05069e441412309fa5da59f2e1f6132b4e2386f6/decimal.py
self.__buf = ''
self.__buf = _StringIO()
def reset(self): self.__buf = ''
b621203e075014e295705a6868a6c9ce80446501 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b621203e075014e295705a6868a6c9ce80446501/xdrlib.py
return self.__buf
return self.__buf.getvalue()
def get_buffer(self): return self.__buf
b621203e075014e295705a6868a6c9ce80446501 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b621203e075014e295705a6868a6c9ce80446501/xdrlib.py
self.__buf = self.__buf + struct.pack('>L', x)
self.__buf.write(struct.pack('>L', x))
def pack_uint(self, x): self.__buf = self.__buf + struct.pack('>L', x)
b621203e075014e295705a6868a6c9ce80446501 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b621203e075014e295705a6868a6c9ce80446501/xdrlib.py
if x: self.__buf = self.__buf + '\0\0\0\1' else: self.__buf = self.__buf + '\0\0\0\0'
if x: self.__buf.write('\0\0\0\1') else: self.__buf.write('\0\0\0\0')
def pack_bool(self, x): if x: self.__buf = self.__buf + '\0\0\0\1' else: self.__buf = self.__buf + '\0\0\0\0'
b621203e075014e295705a6868a6c9ce80446501 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b621203e075014e295705a6868a6c9ce80446501/xdrlib.py
try: self.__buf = self.__buf + struct.pack('>f', x)
try: self.__buf.write(struct.pack('>f', x))
def pack_float(self, x): try: self.__buf = self.__buf + struct.pack('>f', x) except struct.error, msg: raise ConversionError, msg
b621203e075014e295705a6868a6c9ce80446501 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b621203e075014e295705a6868a6c9ce80446501/xdrlib.py
try: self.__buf = self.__buf + struct.pack('>d', x)
try: self.__buf.write(struct.pack('>d', x))
def pack_double(self, x): try: self.__buf = self.__buf + struct.pack('>d', x) except struct.error, msg: raise ConversionError, msg
b621203e075014e295705a6868a6c9ce80446501 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b621203e075014e295705a6868a6c9ce80446501/xdrlib.py
self.__buf = self.__buf + data
self.__buf.write(data)
def pack_fstring(self, n, s): if n < 0: raise ValueError, 'fstring size must be nonnegative' n = ((n+3)/4)*4 data = s[:n] data = data + (n - len(data)) * '\0' self.__buf = self.__buf + data
b621203e075014e295705a6868a6c9ce80446501 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b621203e075014e295705a6868a6c9ce80446501/xdrlib.py
verify(str(s).__class__ is str)
def rev(self): if self._rev is not None: return self._rev L = list(self) L.reverse() self._rev = self.__class__("".join(L)) return self._rev
078b1d946e2295e7f318a0b889f4fa4ff6f4399a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/078b1d946e2295e7f318a0b889f4fa4ff6f4399a/test_descr.py
chmfile = os.path.join(sys.prefix, "Python%d%d.chm" % sys.version_info[:2])
chmfile = os.path.join(sys.prefix, 'Doc', 'Python%d%d.chm' % sys.version_info[:2])
def __init__(self, flist=None, filename=None, key=None, root=None): if EditorWindow.help_url is None: dochome = os.path.join(sys.prefix, 'Doc', 'index.html') if sys.platform.count('linux'): # look for html docs in a couple of standard places pyver = 'python-docs-' + '%s.%s.%s' % sys.version_info[:3] if os.path.isdir('/var/www/html/python/'): # "python2" rpm dochome = '/var/www/html/python/index.html' else: basepath = '/usr/share/doc/' # standard location dochome = os.path.join(basepath, pyver, 'Doc', 'index.html') elif sys.platform[:3] == 'win': chmfile = os.path.join(sys.prefix, "Python%d%d.chm" % sys.version_info[:2]) if os.path.isfile(chmfile): dochome = chmfile dochome = os.path.normpath(dochome) if os.path.isfile(dochome): EditorWindow.help_url = dochome else: EditorWindow.help_url = "http://www.python.org/doc/current" currentTheme=idleConf.CurrentTheme() self.flist = flist root = root or flist.root self.root = root self.menubar = Menu(root) self.top = top = self.Toplevel(root, menu=self.menubar) if flist: self.tkinter_vars = flist.vars #self.top.instance_dict makes flist.inversedict avalable to #configDialog.py so it can access all EditorWindow instaces self.top.instance_dict=flist.inversedict else: self.tkinter_vars = {} # keys: Tkinter event names # values: Tkinter variable instances self.recent_files_path=os.path.join(idleConf.GetUserCfgDir(), 'recent-files.lst') self.vbar = vbar = Scrollbar(top, name='vbar') self.text_frame = text_frame = Frame(top) self.width = idleConf.GetOption('main','EditorWindow','width') self.text = text = Text(text_frame, name='text', padx=5, wrap='none', foreground=idleConf.GetHighlight(currentTheme, 'normal',fgBg='fg'), background=idleConf.GetHighlight(currentTheme, 'normal',fgBg='bg'), highlightcolor=idleConf.GetHighlight(currentTheme, 'hilite',fgBg='fg'), highlightbackground=idleConf.GetHighlight(currentTheme, 'hilite',fgBg='bg'), insertbackground=idleConf.GetHighlight(currentTheme, 'cursor',fgBg='fg'), width=self.width, height=idleConf.GetOption('main','EditorWindow','height') )
933ca3ca4dc4077dae48757ffa083696f4c951f6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/933ca3ca4dc4077dae48757ffa083696f4c951f6/EditorWindow.py
self.copy_file(name, outfile, preserve_mode = 0)
self.copy_file(os.path.join(package_dir, name), outfile, preserve_mode = 0)
def run(self): # Copies all .py files, then also copies the txt and gif files build_py.run(self) assert self.packages == [idlelib] for name in txt_files: outfile = self.get_plain_outfile(self.build_lib, [idlelib], name) dir = os.path.dirname(outfile) self.mkpath(dir) self.copy_file(name, outfile, preserve_mode = 0) for name in Icons: outfile = self.get_plain_outfile(self.build_lib, [idlelib,"Icons"], name) dir = os.path.dirname(outfile) self.mkpath(dir) self.copy_file(os.path.join("Icons",name), outfile, preserve_mode = 0)
d43b3cf0b6b2ffd610dbb1edf1cf27b1ff443b8f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d43b3cf0b6b2ffd610dbb1edf1cf27b1ff443b8f/setup.py
icons = [os.path.join("Icons",name) for name in Icons]
icons = [os.path.join(package_dir, "Icons",name) for name in Icons] txts = [os.path.join(package_dir, name) for name in txt_files]
def get_source_files(self): # returns the .py files, the .txt files, and the icons icons = [os.path.join("Icons",name) for name in Icons] return build_py.get_source_files(self)+txt_files+icons
d43b3cf0b6b2ffd610dbb1edf1cf27b1ff443b8f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d43b3cf0b6b2ffd610dbb1edf1cf27b1ff443b8f/setup.py
package_dir = {idlelib:'.'},
package_dir = {idlelib: package_dir},
def _bytecode_filenames(self, files): files = [n for n in files if n.endswith('.py')] return install_lib._bytecode_filenames(self,files)
d43b3cf0b6b2ffd610dbb1edf1cf27b1ff443b8f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d43b3cf0b6b2ffd610dbb1edf1cf27b1ff443b8f/setup.py
scripts = ['idle']
scripts = [os.path.join(package_dir, 'idle')]
def _bytecode_filenames(self, files): files = [n for n in files if n.endswith('.py')] return install_lib._bytecode_filenames(self,files)
d43b3cf0b6b2ffd610dbb1edf1cf27b1ff443b8f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d43b3cf0b6b2ffd610dbb1edf1cf27b1ff443b8f/setup.py
expectedchecksum = 'b45b79f3203ee1a896d9b5655484adaff5d4964b'
expectedchecksum = '4e389f97e9f88b8b7ab743121fd643089116f9f2'
def tearDown(self): del self.db
7a30686a1eb1b75cac9a6f84ffba3dbadc603637 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/7a30686a1eb1b75cac9a6f84ffba3dbadc603637/test_unicodedata.py
test('replace', 'one!two!three!', 'one@two@three@', '!', '@', 0)
test('replace', 'one!two!three!', 'one!two!three!', '!', '@', 0)
def __getitem__(self, i): return self.seq[i]
eb269ed7800404d64f20bc23b81fb19750d3db39 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/eb269ed7800404d64f20bc23b81fb19750d3db39/test_strop.py
if cfg_target != cur_target:
elif map(int, cfg_target.split('.')) > map(int, cur_target.split('.')):
def _init_posix(): """Initialize the module as appropriate for POSIX systems.""" g = {} # load the installed Makefile: try: filename = get_makefile_filename() parse_makefile(filename, g) except IOError, msg: my_msg = "invalid Python installation: unable to open %s" % filename if hasattr(msg, "strerror"): my_msg = my_msg + " (%s)" % msg.strerror raise DistutilsPlatformError(my_msg) # load the installed pyconfig.h: try: filename = get_config_h_filename() parse_config_h(file(filename), g) except IOError, msg: my_msg = "invalid Python installation: unable to open %s" % filename if hasattr(msg, "strerror"): my_msg = my_msg + " (%s)" % msg.strerror raise DistutilsPlatformError(my_msg) # On MacOSX we need to check the setting of the environment variable # MACOSX_DEPLOYMENT_TARGET: configure bases some choices on it so # it needs to be compatible. # If it isn't set we set it to the configure-time value if sys.platform == 'darwin' and g.has_key('CONFIGURE_MACOSX_DEPLOYMENT_TARGET'): cfg_target = g['CONFIGURE_MACOSX_DEPLOYMENT_TARGET'] cur_target = os.getenv('MACOSX_DEPLOYMENT_TARGET', '') if cur_target == '': cur_target = cfg_target os.putenv('MACOSX_DEPLOYMENT_TARGET', cfg_target) if cfg_target != cur_target: my_msg = ('$MACOSX_DEPLOYMENT_TARGET mismatch: now "%s" but "%s" during configure' % (cur_target, cfg_target)) raise DistutilsPlatformError(my_msg) # On AIX, there are wrong paths to the linker scripts in the Makefile # -- these paths are relative to the Python source, but when installed # the scripts are in another directory. if python_build: g['LDSHARED'] = g['BLDSHARED'] elif get_python_version() < '2.1': # The following two branches are for 1.5.2 compatibility. if sys.platform == 'aix4': # what about AIX 3.x ? # Linker script is in the config directory, not in Modules as the # Makefile says. python_lib = get_python_lib(standard_lib=1) ld_so_aix = os.path.join(python_lib, 'config', 'ld_so_aix') python_exp = os.path.join(python_lib, 'config', 'python.exp') g['LDSHARED'] = "%s %s -bI:%s" % (ld_so_aix, g['CC'], python_exp) elif sys.platform == 'beos': # Linker script is in the config directory. In the Makefile it is # relative to the srcdir, which after installation no longer makes # sense. python_lib = get_python_lib(standard_lib=1) linkerscript_path = string.split(g['LDSHARED'])[0] linkerscript_name = os.path.basename(linkerscript_path) linkerscript = os.path.join(python_lib, 'config', linkerscript_name) # XXX this isn't the right place to do this: adding the Python # library to the link, if needed, should be in the "build_ext" # command. (It's also needed for non-MS compilers on Windows, and # it's taken care of for them by the 'build_ext.get_libraries()' # method.) g['LDSHARED'] = ("%s -L%s/lib -lpython%s" % (linkerscript, PREFIX, get_python_version())) global _config_vars _config_vars = g
f872878b567c2f328e9fd7a5f0bf12dcdf1a7309 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/f872878b567c2f328e9fd7a5f0bf12dcdf1a7309/sysconfig.py
if os.name in ('nt', 'os2'):
if os.name in ('nt', 'os2') or sys.platform == 'cygwin':
def setUp(self): TestMailbox.setUp(self) if os.name in ('nt', 'os2'): self._box.colon = '!'
57a74869669ea0c208cdca91822f69fd88f94ab5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/57a74869669ea0c208cdca91822f69fd88f94ab5/test_mailbox.py
self.assertRaises(mailbox.ExternalClashError, self._box.lock) exited_pid, status = os.waitpid(pid, 0)
try: self.assertRaises(mailbox.ExternalClashError, self._box.lock) finally: exited_pid, status = os.waitpid(pid, 0)
def test_lock_conflict(self): # Fork off a subprocess that will lock the file for 2 seconds, # unlock it, and then exit. if not hasattr(os, 'fork'): return pid = os.fork() if pid == 0: # In the child, lock the mailbox. self._box.lock() time.sleep(2) self._box.unlock() os._exit(0)
57a74869669ea0c208cdca91822f69fd88f94ab5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/57a74869669ea0c208cdca91822f69fd88f94ab5/test_mailbox.py