rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
def handle_charref(self, name): try: n = int(name) except ValueError: self.unknown_charref(name) return if not 0 <= n <= 255: self.unknown_charref(name) return self.handle_data(chr(n))
08f8dd6d0caead7891d1a70f956409a88d0ed5a6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/08f8dd6d0caead7891d1a70f956409a88d0ed5a6/sgmllib.py
if dir[-1] == '\n': dir = dir[:-1]
dir = dir.rstrip()
def addpackage(sitedir, name): global _dirs_in_sys_path if _dirs_in_sys_path is None: _init_pathinfo() reset = 1 else: reset = 0 fullname = os.path.join(sitedir, name) try: f = open(fullname) except IOError: return while 1: dir = f.readline() if not dir: break if dir[0] == '#': continue if dir.startswith("import"): exec dir continue if dir[-1] == '\n': dir = dir[:-1] dir, dircase = makepath(sitedir, dir) if not dircase in _dirs_in_sys_path and os.path.exists(dir): sys.path.append(dir) _dirs_in_sys_path[dircase] = 1 if reset: _dirs_in_sys_path = None
497331fa2ba93ee290144046754c59b3025b5eb1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/497331fa2ba93ee290144046754c59b3025b5eb1/site.py
return st[stat.ST_MTIME]
return st[stat.ST_ATIME]
def getatime(filename): """Return the last access time of a file, reported by os.stat()""" st = os.stat(filename) return st[stat.ST_MTIME]
162bd855a631ed66f83ff3ed76ae1533de033298 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/162bd855a631ed66f83ff3ed76ae1533de033298/ntpath.py
import imp
def load_dynamic(self, name, filename, file): if name not in self.ok_dynamic_modules: raise ImportError, "untrusted dynamic module: %s" % name if sys.modules.has_key(name): src = sys.modules[name] else: import imp src = imp.load_dynamic(name, filename, file) dst = self.copy_except(src, []) return dst
59b2a74c752578cb67b02b6966f283fd049f646a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/59b2a74c752578cb67b02b6966f283fd049f646a/rexec.py
print '%s.%s%s =? %s... ' % (repr(input), method, args, output),
print '%s.%s%s =? %s... ' % (repr(input), method, args, repr(output)),
def test(method, input, output, *args): if verbose: print '%s.%s%s =? %s... ' % (repr(input), method, args, output), try: f = getattr(input, method) value = apply(f, args) except: value = sys.exc_type exc = sys.exc_info()[:2] else: exc = None if value != output: if verbose: print 'no' print '*',f, `input`, `output`, `value` if exc: print ' value == %s: %s' % (exc) else: if verbose: print 'yes'
15ffc71c0f811d4c3053efb0480d70502ec35c99 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/15ffc71c0f811d4c3053efb0480d70502ec35c99/test_unicode.py
if value != output:
if value != output or type(value) is not type(output):
def test(method, input, output, *args): if verbose: print '%s.%s%s =? %s... ' % (repr(input), method, args, output), try: f = getattr(input, method) value = apply(f, args) except: value = sys.exc_type exc = sys.exc_info()[:2] else: exc = None if value != output: if verbose: print 'no' print '*',f, `input`, `output`, `value` if exc: print ' value == %s: %s' % (exc) else: if verbose: print 'yes'
15ffc71c0f811d4c3053efb0480d70502ec35c99 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/15ffc71c0f811d4c3053efb0480d70502ec35c99/test_unicode.py
def __init__(self): self.seq = 'wxyz'
def __init__(self, seq): self.seq = seq
def __init__(self): self.seq = 'wxyz'
15ffc71c0f811d4c3053efb0480d70502ec35c99 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/15ffc71c0f811d4c3053efb0480d70502ec35c99/test_unicode.py
test('join', u' ', u'w x y z', Sequence())
test('join', u' ', u'w x y z', Sequence('wxyz'))
def __getitem__(self, i): return self.seq[i]
15ffc71c0f811d4c3053efb0480d70502ec35c99 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/15ffc71c0f811d4c3053efb0480d70502ec35c99/test_unicode.py
class BadSeq(Sequence): def __init__(self): self.seq = [7, u'hello', 123L] test('join', u' ', TypeError, BadSeq())
test('join', u' ', TypeError, Sequence([7, u'hello', 123L])) test('join', ' ', u'a b c d', [u'a', u'b', u'c', u'd']) test('join', ' ', u'a b c d', ['a', 'b', u'c', u'd']) test('join', '', u'abcd', (u'a', u'b', u'c', u'd')) test('join', ' ', u'w x y z', Sequence(u'wxyz')) test('join', ' ', TypeError, 7)
def __getitem__(self, i): return self.seq[i]
15ffc71c0f811d4c3053efb0480d70502ec35c99 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/15ffc71c0f811d4c3053efb0480d70502ec35c99/test_unicode.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') )
090e636add33907d196b9899eb0f019654a055e8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/090e636add33907d196b9899eb0f019654a055e8/EditorWindow.py
os.rename(tmp_file.name, dest)
try: if hasattr(os, 'link'): os.link(tmp_file.name, dest) os.remove(tmp_file.name) else: os.rename(tmp_file.name, dest) except OSError, e: os.remove(tmp_file.name) if e.errno == errno.EEXIST: raise ExternalClashError('Name clash with existing message: %s' % dest) else: raise
def add(self, message): """Add message and return assigned key.""" tmp_file = self._create_tmp() try: self._dump_message(message, tmp_file) finally: _sync_close(tmp_file) if isinstance(message, MaildirMessage): subdir = message.get_subdir() suffix = self.colon + message.get_info() if suffix == self.colon: suffix = '' else: subdir = 'new' suffix = '' uniq = os.path.basename(tmp_file.name).split(self.colon)[0] dest = os.path.join(self._path, subdir, uniq + suffix) os.rename(tmp_file.name, dest) if isinstance(message, MaildirMessage): os.utime(dest, (os.path.getatime(dest), message.get_date())) return uniq
7ea928c452e2baaa929e5a078d796ece3720e765 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7ea928c452e2baaa929e5a078d796ece3720e765/mailbox.py
return open(path, 'wb+')
try: return _create_carefully(path) except OSError, e: if e.errno != errno.EEXIST: raise
def _create_tmp(self): """Create a file in the tmp subdirectory and open and return it.""" now = time.time() hostname = socket.gethostname() if '/' in hostname: hostname = hostname.replace('/', r'\057') if ':' in hostname: hostname = hostname.replace(':', r'\072') uniq = "%s.M%sP%sQ%s.%s" % (int(now), int(now % 1 * 1e6), os.getpid(), Maildir._count, hostname) path = os.path.join(self._path, 'tmp', uniq) try: os.stat(path) except OSError, e: if e.errno == errno.ENOENT: Maildir._count += 1 return open(path, 'wb+') else: raise else: raise ExternalClashError('Name clash prevented file creation: %s' % path)
7ea928c452e2baaa929e5a078d796ece3720e765 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7ea928c452e2baaa929e5a078d796ece3720e765/mailbox.py
else: raise ExternalClashError('Name clash prevented file creation: %s' % path)
raise ExternalClashError('Name clash prevented file creation: %s' % path)
def _create_tmp(self): """Create a file in the tmp subdirectory and open and return it.""" now = time.time() hostname = socket.gethostname() if '/' in hostname: hostname = hostname.replace('/', r'\057') if ':' in hostname: hostname = hostname.replace(':', r'\072') uniq = "%s.M%sP%sQ%s.%s" % (int(now), int(now % 1 * 1e6), os.getpid(), Maildir._count, hostname) path = os.path.join(self._path, 'tmp', uniq) try: os.stat(path) except OSError, e: if e.errno == errno.ENOENT: Maildir._count += 1 return open(path, 'wb+') else: raise else: raise ExternalClashError('Name clash prevented file creation: %s' % path)
7ea928c452e2baaa929e5a078d796ece3720e765 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7ea928c452e2baaa929e5a078d796ece3720e765/mailbox.py
parts = ctype.split('/') if len(parts) > 0: return ctype.split('/')[0] return failobj
if ctype.count('/') <> 1: return failobj return ctype.split('/')[0]
def get_main_type(self, failobj=None): """Return the message's main content type if present.""" missing = [] ctype = self.get_type(missing) if ctype is missing: return failobj parts = ctype.split('/') if len(parts) > 0: return ctype.split('/')[0] return failobj
c10686426edd6883b88950a754335b678750bf67 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c10686426edd6883b88950a754335b678750bf67/Message.py
parts = ctype.split('/') if len(parts) > 1: return ctype.split('/')[1] return failobj
if ctype.count('/') <> 1: return failobj return ctype.split('/')[1] def get_content_type(self): """Returns the message's content type. The returned string is coerced to lowercase and returned as a ingle string of the form `maintype/subtype'. If there was no Content-Type: header in the message, the default type as give by get_default_type() will be returned. Since messages always have a default type this will always return a value. The current state of RFC standards define a message's default type to be text/plain unless it appears inside a multipart/digest container, in which case it would be message/rfc822. """ missing = [] value = self.get('content-type', missing) if value is missing: return self.get_default_type() return paramre.split(value)[0].lower().strip() def get_content_maintype(self): """Returns the message's main content type. This is the `maintype' part of the string returned by get_content_type(). If no slash is found in the full content type, a ValueError is raised. """ ctype = self.get_content_type() if ctype.count('/') <> 1: raise ValueError, 'No maintype found in: %s' % ctype return ctype.split('/')[0] def get_content_subtype(self): """Returns the message's sub content type. This is the `subtype' part of the string returned by get_content_type(). If no slash is found in the full content type, a ValueError is raised. """ ctype = self.get_content_type() if ctype.count('/') <> 1: raise ValueError, 'No subtype found in: %s' % ctype return ctype.split('/')[1]
def get_subtype(self, failobj=None): """Return the message's content subtype if present.""" missing = [] ctype = self.get_type(missing) if ctype is missing: return failobj parts = ctype.split('/') if len(parts) > 1: return ctype.split('/')[1] return failobj
c10686426edd6883b88950a754335b678750bf67 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c10686426edd6883b88950a754335b678750bf67/Message.py
ctype must be either "text/plain" or "message/rfc822". The default content type is not stored in the Content-Type: header. """ if ctype not in ('text/plain', 'message/rfc822'): raise ValueError( 'first arg must be either "text/plain" or "message/rfc822"')
ctype should be either "text/plain" or "message/rfc822", although this is not enforced. The default content type is not stored in the Content-Type: header. """
def set_default_type(self, ctype): """Set the `default' content type.
c10686426edd6883b88950a754335b678750bf67 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c10686426edd6883b88950a754335b678750bf67/Message.py
def seek(self): raise IOError, 'Random access not allowed in gzip files' def tell(self): raise IOError, 'I won\'t tell() you for gzip files'
def flush(self): self.fileobj.flush()
44f5f8fb26185b211d50fd9501ba42446505a8d7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/44f5f8fb26185b211d50fd9501ba42446505a8d7/gzip.py
if len(error_302_dict)>10 or req.error_302_dict.has_key(newurl):
if len(req.error_302_dict)>10 or \ req.error_302_dict.has_key(newurl):
def http_error_302(self, req, fp, code, msg, headers): if headers.has_key('location'): newurl = headers['location'] elif headers.has_key('uri'): newurl = headers['uri'] else: return nil = fp.read() fp.close()
2d996c07049db6648ddf33aedff52e78908949c6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2d996c07049db6648ddf33aedff52e78908949c6/urllib2.py
srcfss = macfs.FSSpec(src) dstfss = macfs.FSSpec(dst)
def copy(src, dst, createpath=0, copydates=1, forcetype=None): """Copy a file, including finder info, resource fork, etc""" if createpath: mkdirs(os.path.split(dst)[0]) srcfss = macfs.FSSpec(src) dstfss = macfs.FSSpec(dst) ifp = open(srcfss.as_pathname(), 'rb') ofp = open(dstfss.as_pathname(), 'wb') d = ifp.read(BUFSIZ) while d: ofp.write(d) d = ifp.read(BUFSIZ) ifp.close() ofp.close() ifp = openrf(srcfss.as_pathname(), '*rb') ofp = openrf(dstfss.as_pathname(), '*wb') d = ifp.read(BUFSIZ) while d: ofp.write(d) d = ifp.read(BUFSIZ) ifp.close() ofp.close() sf = srcfss.GetFInfo() df = dstfss.GetFInfo() df.Creator, df.Type = sf.Creator, sf.Type if forcetype != None: df.Type = forcetype df.Flags = (sf.Flags & (kIsStationary|kNameLocked|kHasBundle|kIsInvisible|kIsAlias)) dstfss.SetFInfo(df) if copydates: crdate, mddate, bkdate = srcfss.GetDates() dstfss.SetDates(crdate, mddate, bkdate) touched(dstfss)
0a9d7559e8e07336860fb2aa901c1ba8b77b5921 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0a9d7559e8e07336860fb2aa901c1ba8b77b5921/macostools.py
ifp = open(srcfss.as_pathname(), 'rb') ofp = open(dstfss.as_pathname(), 'wb')
ifp = open(src, 'rb') ofp = open(dst, 'wb')
def copy(src, dst, createpath=0, copydates=1, forcetype=None): """Copy a file, including finder info, resource fork, etc""" if createpath: mkdirs(os.path.split(dst)[0]) srcfss = macfs.FSSpec(src) dstfss = macfs.FSSpec(dst) ifp = open(srcfss.as_pathname(), 'rb') ofp = open(dstfss.as_pathname(), 'wb') d = ifp.read(BUFSIZ) while d: ofp.write(d) d = ifp.read(BUFSIZ) ifp.close() ofp.close() ifp = openrf(srcfss.as_pathname(), '*rb') ofp = openrf(dstfss.as_pathname(), '*wb') d = ifp.read(BUFSIZ) while d: ofp.write(d) d = ifp.read(BUFSIZ) ifp.close() ofp.close() sf = srcfss.GetFInfo() df = dstfss.GetFInfo() df.Creator, df.Type = sf.Creator, sf.Type if forcetype != None: df.Type = forcetype df.Flags = (sf.Flags & (kIsStationary|kNameLocked|kHasBundle|kIsInvisible|kIsAlias)) dstfss.SetFInfo(df) if copydates: crdate, mddate, bkdate = srcfss.GetDates() dstfss.SetDates(crdate, mddate, bkdate) touched(dstfss)
0a9d7559e8e07336860fb2aa901c1ba8b77b5921 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0a9d7559e8e07336860fb2aa901c1ba8b77b5921/macostools.py
ifp = openrf(srcfss.as_pathname(), '*rb') ofp = openrf(dstfss.as_pathname(), '*wb')
ifp = openrf(src, '*rb') ofp = openrf(dst, '*wb')
def copy(src, dst, createpath=0, copydates=1, forcetype=None): """Copy a file, including finder info, resource fork, etc""" if createpath: mkdirs(os.path.split(dst)[0]) srcfss = macfs.FSSpec(src) dstfss = macfs.FSSpec(dst) ifp = open(srcfss.as_pathname(), 'rb') ofp = open(dstfss.as_pathname(), 'wb') d = ifp.read(BUFSIZ) while d: ofp.write(d) d = ifp.read(BUFSIZ) ifp.close() ofp.close() ifp = openrf(srcfss.as_pathname(), '*rb') ofp = openrf(dstfss.as_pathname(), '*wb') d = ifp.read(BUFSIZ) while d: ofp.write(d) d = ifp.read(BUFSIZ) ifp.close() ofp.close() sf = srcfss.GetFInfo() df = dstfss.GetFInfo() df.Creator, df.Type = sf.Creator, sf.Type if forcetype != None: df.Type = forcetype df.Flags = (sf.Flags & (kIsStationary|kNameLocked|kHasBundle|kIsInvisible|kIsAlias)) dstfss.SetFInfo(df) if copydates: crdate, mddate, bkdate = srcfss.GetDates() dstfss.SetDates(crdate, mddate, bkdate) touched(dstfss)
0a9d7559e8e07336860fb2aa901c1ba8b77b5921 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0a9d7559e8e07336860fb2aa901c1ba8b77b5921/macostools.py
verify(tuple(a).__class__ is tuple)
def rev(self): if self._rev is not None: return self._rev L = list(self) L.reverse() self._rev = self.__class__(L) return self._rev
4c3a0a35cd80a0abb9628dc8d4ade911fe2d5015 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4c3a0a35cd80a0abb9628dc8d4ade911fe2d5015/test_descr.py
for version in ['8.4', '84', '8.3', '83', '8.2',
for version in ['8.5', '85', '8.4', '84', '8.3', '83', '8.2',
def detect_tkinter(self, inc_dirs, lib_dirs): # The _tkinter module.
4c4a45de8f992bb0c5cf35910d34ed6c63fa9d14 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4c4a45de8f992bb0c5cf35910d34ed6c63fa9d14/setup.py
d[types.CodeType] = _deepcopy_atomic
try: d[types.CodeType] = _deepcopy_atomic except AttributeError: pass
def _deepcopy_atomic(x, memo): return x
88b666ca3f2e403d23c05a94fbc8038ad2c1fc4d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/88b666ca3f2e403d23c05a94fbc8038ad2c1fc4d/copy.py
the local hostname is found using gethostbyname().
the local hostname is found using socket.getfqdn().
def __init__(self, host = '', port = 0, local_hostname = None): """Initialize a new instance.
4b186aff486400c3a7412ee552587f5a30be2381 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4b186aff486400c3a7412ee552587f5a30be2381/smtplib.py
modname = modname + dirname + '.'
modname = dirname + '.' + modname
def getenvironment(self): if self.path: file = self.path dir = os.path.dirname(file) # check if we're part of a package modname = "" while os.path.exists(os.path.join(dir, "__init__.py")): dir, dirname = os.path.split(dir) modname = modname + dirname + '.' subname = _filename_as_modname(self.title) if modname: if subname == "__init__": modname = modname[:-1] # strip trailing period else: modname = modname + subname else: modname = subname if sys.modules.has_key(modname): globals = sys.modules[modname].__dict__ self.globals = {} else: globals = self.globals else: file = '<%s>' % self.title globals = self.globals modname = file return globals, file, modname
2aaeb52665fb297b3d65006b8b22eee290f17e7f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2aaeb52665fb297b3d65006b8b22eee290f17e7f/PyEdit.py
modname = modname[:-1]
modname = modname[:-1]
def getenvironment(self): if self.path: file = self.path dir = os.path.dirname(file) # check if we're part of a package modname = "" while os.path.exists(os.path.join(dir, "__init__.py")): dir, dirname = os.path.split(dir) modname = modname + dirname + '.' subname = _filename_as_modname(self.title) if modname: if subname == "__init__": modname = modname[:-1] # strip trailing period else: modname = modname + subname else: modname = subname if sys.modules.has_key(modname): globals = sys.modules[modname].__dict__ self.globals = {} else: globals = self.globals else: file = '<%s>' % self.title globals = self.globals modname = file return globals, file, modname
2aaeb52665fb297b3d65006b8b22eee290f17e7f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2aaeb52665fb297b3d65006b8b22eee290f17e7f/PyEdit.py
modname = modname + subname
modname = modname + subname
def getenvironment(self): if self.path: file = self.path dir = os.path.dirname(file) # check if we're part of a package modname = "" while os.path.exists(os.path.join(dir, "__init__.py")): dir, dirname = os.path.split(dir) modname = modname + dirname + '.' subname = _filename_as_modname(self.title) if modname: if subname == "__init__": modname = modname[:-1] # strip trailing period else: modname = modname + subname else: modname = subname if sys.modules.has_key(modname): globals = sys.modules[modname].__dict__ self.globals = {} else: globals = self.globals else: file = '<%s>' % self.title globals = self.globals modname = file return globals, file, modname
2aaeb52665fb297b3d65006b8b22eee290f17e7f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2aaeb52665fb297b3d65006b8b22eee290f17e7f/PyEdit.py
def __init__(self, text):
def __init__(self, text, fileclass=StringIO.StringIO):
def __init__(self, text): self.text = text
121d34af198b2d051eec158fd1be7aa19a224c28 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/121d34af198b2d051eec158fd1be7aa19a224c28/test_httplib.py
return StringIO.StringIO(self.text)
return self.fileclass(self.text) class NoEOFStringIO(StringIO.StringIO): """Like StringIO, but raises AssertionError on EOF. This is used below to test that httplib doesn't try to read more from the underlying file than it should. """ def read(self, n=-1): data = StringIO.StringIO.read(self, n) if data == '': raise AssertionError('caller tried to read past EOF') return data def readline(self, length=None): data = StringIO.StringIO.readline(self, length) if data == '': raise AssertionError('caller tried to read past EOF') return data
def makefile(self, mode, bufsize=None): if mode != 'r' and mode != 'rb': raise httplib.UnimplementedFileMode() return StringIO.StringIO(self.text)
121d34af198b2d051eec158fd1be7aa19a224c28 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/121d34af198b2d051eec158fd1be7aa19a224c28/test_httplib.py
import sys
def makefile(self, mode, bufsize=None): if mode != 'r' and mode != 'rb': raise httplib.UnimplementedFileMode() return StringIO.StringIO(self.text)
121d34af198b2d051eec158fd1be7aa19a224c28 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/121d34af198b2d051eec158fd1be7aa19a224c28/test_httplib.py
def redirect_request(self, req, fp, code, msg, headers):
def redirect_request(self, req, fp, code, msg, headers, newurl):
def redirect_request(self, req, fp, code, msg, headers): """Return a Request or None in response to a redirect.
0389295dcdc72df81a037d2712afea600aad9445 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0389295dcdc72df81a037d2712afea600aad9445/urllib2.py
if "location" in headers: newurl = headers["location"] elif "uri" in headers: newurl = headers["uri"] else: return newurl = urlparse.urljoin(req.get_full_url(), newurl)
def redirect_request(self, req, fp, code, msg, headers): """Return a Request or None in response to a redirect.
0389295dcdc72df81a037d2712afea600aad9445 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0389295dcdc72df81a037d2712afea600aad9445/urllib2.py
new = self.redirect_request(req, fp, code, msg, headers)
new = self.redirect_request(req, fp, code, msg, headers, newurl)
def http_error_302(self, req, fp, code, msg, headers): if 'location' in headers: newurl = headers['location'] elif 'uri' in headers: newurl = headers['uri'] else: return newurl = urlparse.urljoin(req.get_full_url(), newurl)
0389295dcdc72df81a037d2712afea600aad9445 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0389295dcdc72df81a037d2712afea600aad9445/urllib2.py
host = 'www.cwi.nl:80' selector = '/index.html'
host = 'www.python.org' selector = '/'
def test(): import sys import getopt opts, args = getopt.getopt(sys.argv[1:], 'd') dl = 0 for o, a in opts: if o == '-d': dl = dl + 1 host = 'www.cwi.nl:80' selector = '/index.html' if args[0:]: host = args[0] if args[1:]: selector = args[1] h = HTTP() h.set_debuglevel(dl) h.connect(host) h.putrequest('GET', selector) errcode, errmsg, headers = h.getreply() print 'errcode =', errcode print 'headers =', headers print 'errmsg =', errmsg if headers: for header in headers.headers: print string.strip(header) print h.getfile().read()
a0dfc7ad65429e026e28d175626c32bd9fa1d078 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a0dfc7ad65429e026e28d175626c32bd9fa1d078/httplib.py
print 'headers =', headers
def test(): import sys import getopt opts, args = getopt.getopt(sys.argv[1:], 'd') dl = 0 for o, a in opts: if o == '-d': dl = dl + 1 host = 'www.cwi.nl:80' selector = '/index.html' if args[0:]: host = args[0] if args[1:]: selector = args[1] h = HTTP() h.set_debuglevel(dl) h.connect(host) h.putrequest('GET', selector) errcode, errmsg, headers = h.getreply() print 'errcode =', errcode print 'headers =', headers print 'errmsg =', errmsg if headers: for header in headers.headers: print string.strip(header) print h.getfile().read()
a0dfc7ad65429e026e28d175626c32bd9fa1d078 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a0dfc7ad65429e026e28d175626c32bd9fa1d078/httplib.py
def sample(self, population, k, int=int):
def sample(self, population, k):
def sample(self, population, k, int=int): """Chooses k unique random elements from a population sequence.
fdbe5223b7402ee34c4f0c06caa6faabd9e73e35 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fdbe5223b7402ee34c4f0c06caa6faabd9e73e35/random.py
j = int(random() * (n-i))
j = _int(random() * (n-i))
def sample(self, population, k, int=int): """Chooses k unique random elements from a population sequence.
fdbe5223b7402ee34c4f0c06caa6faabd9e73e35 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fdbe5223b7402ee34c4f0c06caa6faabd9e73e35/random.py
j = int(random() * n)
j = _int(random() * n)
def sample(self, population, k, int=int): """Chooses k unique random elements from a population sequence.
fdbe5223b7402ee34c4f0c06caa6faabd9e73e35 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fdbe5223b7402ee34c4f0c06caa6faabd9e73e35/random.py
j = int(random() * n)
j = _int(random() * n)
def sample(self, population, k, int=int): """Chooses k unique random elements from a population sequence.
fdbe5223b7402ee34c4f0c06caa6faabd9e73e35 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fdbe5223b7402ee34c4f0c06caa6faabd9e73e35/random.py
if ((template_exists and (template_newer or setup_newer)) or self.force_manifest or self.manifest_only):
if manifest_outofdate or neither_exists or force_regen:
def get_file_list (self): """Figure out the list of files to include in the source distribution, and put it in 'self.filelist'. This might involve reading the manifest template (and writing the manifest), or just reading the manifest, or just using the default file set -- it all depends on the user's options and the state of the filesystem. """
d3b76a8fbfc2af2d01ce48c323c9f76c0947af49 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d3b76a8fbfc2af2d01ce48c323c9f76c0947af49/sdist.py
standards = [('README', 'README.txt'), 'setup.py']
standards = [('README', 'README.txt'), self.distribution.script_name]
def add_defaults (self): """Add all the default files to self.filelist: - README or README.txt - setup.py - test/test*.py - all pure Python modules mentioned in setup script - all C sources listed as part of extensions or C libraries in the setup script (doesn't catch C headers!) Warns if (README or README.txt) or setup.py are missing; everything else is optional. """
d3b76a8fbfc2af2d01ce48c323c9f76c0947af49 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d3b76a8fbfc2af2d01ce48c323c9f76c0947af49/sdist.py
import saxutils
from . import saxutils
def parse(self, source): import saxutils source = saxutils.prepare_input_source(source)
7ec155f5be6cdcbf55a607c2846cbd4ea80c3681 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7ec155f5be6cdcbf55a607c2846cbd4ea80c3681/xmlreader.py
socket = _socketobject
socket = SocketType = _socketobject
_s = ("def %s(self, *args): return self._sock.%s(*args)\n\n" "%s.__doc__ = _realsocket.%s.__doc__\n")
dbfb12148d59933273d9bf68cb0cbe5486b1ca61 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/dbfb12148d59933273d9bf68cb0cbe5486b1ca61/socket.py
def gen_id(self, dir, file):
def gen_id(self, file):
def gen_id(self, dir, file): logical = _logical = make_id(file) pos = 1 while logical in self.filenames: logical = "%s.%d" % (_logical, pos) pos += 1 self.filenames.add(logical) return logical
388a8c26fae0c9fdce06fcf69223b7b43cb25acf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/388a8c26fae0c9fdce06fcf69223b7b43cb25acf/__init__.py
def append(self, full, logical):
def append(self, full, file, logical):
def append(self, full, logical): if os.path.isdir(full): return self.index += 1 self.files.append((full, logical)) return self.index, logical
388a8c26fae0c9fdce06fcf69223b7b43cb25acf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/388a8c26fae0c9fdce06fcf69223b7b43cb25acf/__init__.py
sequence, logical = self.cab.append(absolute, logical)
sequence, logical = self.cab.append(absolute, file, logical)
def add_file(self, file, src=None, version=None, language=None): """Add a file to the current component of the directory, starting a new one one if there is no current component. By default, the file name in the source and the file table will be identical. If the src file is specified, it is interpreted relative to the current directory. Optionally, a version and a language can be specified for the entry in the File table.""" if not self.component: self.start_component(self.logical, current_feature, 0) if not src: # Allow relative paths for file if src is not specified src = file file = os.path.basename(file) absolute = os.path.join(self.absolute, src) assert not re.search(r'[\?|><:/*]"', file) # restrictions on long names if self.keyfiles.has_key(file): logical = self.keyfiles[file] else: logical = None sequence, logical = self.cab.append(absolute, logical) assert logical not in self.ids self.ids.add(logical) short = self.make_short(file) full = "%s|%s" % (short, file) filesize = os.stat(absolute).st_size # constants.msidbFileAttributesVital # Compressed omitted, since it is the database default # could add r/o, system, hidden attributes = 512 add_data(self.db, "File", [(logical, self.component, full, filesize, version, language, attributes, sequence)]) #if not version: # # Add hash if the file is not versioned # filehash = FileHash(absolute, 0) # add_data(self.db, "MsiFileHash", # [(logical, 0, filehash.IntegerData(1), # filehash.IntegerData(2), filehash.IntegerData(3), # filehash.IntegerData(4))]) # Automatically remove .pyc/.pyo files on uninstall (2) # XXX: adding so many RemoveFile entries makes installer unbelievably # slow. So instead, we have to use wildcard remove entries if file.endswith(".py"): add_data(self.db, "RemoveFile", [(logical+"c", self.component, "%sC|%sc" % (short, file), self.logical, 2), (logical+"o", self.component, "%sO|%so" % (short, file), self.logical, 2)]) return logical
388a8c26fae0c9fdce06fcf69223b7b43cb25acf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/388a8c26fae0c9fdce06fcf69223b7b43cb25acf/__init__.py
def mapping(self, mapping, attribute):
def mapping(self, event, attribute):
def mapping(self, mapping, attribute): add_data(self.dlg.db, "EventMapping", [(self.dlg.name, self.name, event, attribute)])
388a8c26fae0c9fdce06fcf69223b7b43cb25acf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/388a8c26fae0c9fdce06fcf69223b7b43cb25acf/__init__.py
mo = AbstractBasicAuthHandler.rx.match(authreq)
mo = AbstractBasicAuthHandler.rx.search(authreq)
def http_error_auth_reqed(self, authreq, host, req, headers): # XXX could be multiple headers authreq = headers.get(authreq, None) if authreq: mo = AbstractBasicAuthHandler.rx.match(authreq) if mo: scheme, realm = mo.groups() if scheme.lower() == 'basic': return self.retry_http_basic_auth(host, req, realm)
65a7975f16f92f0e715a16b807f732c0d7a34bf0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/65a7975f16f92f0e715a16b807f732c0d7a34bf0/urllib2.py
doc = getattr(ob, "__doc__", "")
doc = getattr(ob, "__doc__", "").lstrip()
def get_arg_text(ob): "Get a string describing the arguments for the given object" argText = "" if ob is not None: argOffset = 0 if type(ob)==types.ClassType: # Look for the highest __init__ in the class chain. fob = _find_constructor(ob) if fob is None: fob = lambda: None else: argOffset = 1 elif type(ob)==types.MethodType: # bit of a hack for methods - turn it into a function # but we drop the "self" param. fob = ob.im_func argOffset = 1 else: fob = ob # Try and build one for Python defined functions if type(fob) in [types.FunctionType, types.LambdaType]: try: realArgs = fob.func_code.co_varnames[argOffset:fob.func_code.co_argcount] defaults = fob.func_defaults or [] defaults = list(map(lambda name: "=%s" % name, defaults)) defaults = [""] * (len(realArgs)-len(defaults)) + defaults items = map(lambda arg, dflt: arg+dflt, realArgs, defaults) if fob.func_code.co_flags & 0x4: items.append("...") if fob.func_code.co_flags & 0x8: items.append("***") argText = ", ".join(items) argText = "(%s)" % argText except: pass # See if we can use the docstring doc = getattr(ob, "__doc__", "") if doc: while doc[:1] in " \t\n": doc = doc[1:] pos = doc.find("\n") if pos < 0 or pos > 70: pos = 70 if argText: argText += "\n" argText += doc[:pos] return argText
61bfb736b4989b7eb639c63ef0589c8e398bfc5a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/61bfb736b4989b7eb639c63ef0589c8e398bfc5a/CallTips.py
while doc[:1] in " \t\n": doc = doc[1:]
def get_arg_text(ob): "Get a string describing the arguments for the given object" argText = "" if ob is not None: argOffset = 0 if type(ob)==types.ClassType: # Look for the highest __init__ in the class chain. fob = _find_constructor(ob) if fob is None: fob = lambda: None else: argOffset = 1 elif type(ob)==types.MethodType: # bit of a hack for methods - turn it into a function # but we drop the "self" param. fob = ob.im_func argOffset = 1 else: fob = ob # Try and build one for Python defined functions if type(fob) in [types.FunctionType, types.LambdaType]: try: realArgs = fob.func_code.co_varnames[argOffset:fob.func_code.co_argcount] defaults = fob.func_defaults or [] defaults = list(map(lambda name: "=%s" % name, defaults)) defaults = [""] * (len(realArgs)-len(defaults)) + defaults items = map(lambda arg, dflt: arg+dflt, realArgs, defaults) if fob.func_code.co_flags & 0x4: items.append("...") if fob.func_code.co_flags & 0x8: items.append("***") argText = ", ".join(items) argText = "(%s)" % argText except: pass # See if we can use the docstring doc = getattr(ob, "__doc__", "") if doc: while doc[:1] in " \t\n": doc = doc[1:] pos = doc.find("\n") if pos < 0 or pos > 70: pos = 70 if argText: argText += "\n" argText += doc[:pos] return argText
61bfb736b4989b7eb639c63ef0589c8e398bfc5a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/61bfb736b4989b7eb639c63ef0589c8e398bfc5a/CallTips.py
tarinfo = self.tarfile.next() if not tarinfo: self.tarfile._loaded = True raise StopIteration
if not self.tarfile._loaded: tarinfo = self.tarfile.next() if not tarinfo: self.tarfile._loaded = True raise StopIteration else: try: tarinfo = self.tarfile.members[self.index] except IndexError: raise StopIteration self.index += 1
def next(self): """Return the next item using TarFile's next() method. When all members have been read, set TarFile as _loaded. """ tarinfo = self.tarfile.next() if not tarinfo: self.tarfile._loaded = True raise StopIteration return tarinfo
637431bf145a4e35458219c18db843a054e0adf3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/637431bf145a4e35458219c18db843a054e0adf3/tarfile.py
pointer = -1
if self.cyclic: pointer = -1 else: self.text.bell() return
def history_do(self, reverse): nhist = len(self.history) pointer = self.history_pointer prefix = self.history_prefix if pointer is not None and prefix is not None: if self.text.compare("insert", "!=", "end-1c") or \ self._get_source("iomark", "end-1c") != self.history[pointer]: pointer = prefix = None if pointer is None or prefix is None: prefix = self._get_source("iomark", "end-1c") if reverse: pointer = nhist else: pointer = -1 nprefix = len(prefix) while 1: if reverse: pointer = pointer - 1 else: pointer = pointer + 1 if pointer < 0 or pointer >= nhist: self.text.bell() if self._get_source("iomark", "end-1c") != prefix: self.text.delete("iomark", "end-1c") self._put_source("iomark", prefix) pointer = prefix = None break item = self.history[pointer] if item[:nprefix] == prefix and len(item) > nprefix: self.text.delete("iomark", "end-1c") self._put_source("iomark", item) break self.text.mark_set("insert", "end-1c") self.text.see("insert") self.text.tag_remove("sel", "1.0", "end") self.history_pointer = pointer self.history_prefix = prefix
0676dfdce06f6b01f35d76a4fb77c77c03468366 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0676dfdce06f6b01f35d76a4fb77c77c03468366/IdleHistory.py
if self._get_source("iomark", "end-1c") != prefix: self.text.delete("iomark", "end-1c") self._put_source("iomark", prefix) pointer = prefix = None
if not self.cyclic and pointer < 0: return else: if self._get_source("iomark", "end-1c") != prefix: self.text.delete("iomark", "end-1c") self._put_source("iomark", prefix) pointer = prefix = None
def history_do(self, reverse): nhist = len(self.history) pointer = self.history_pointer prefix = self.history_prefix if pointer is not None and prefix is not None: if self.text.compare("insert", "!=", "end-1c") or \ self._get_source("iomark", "end-1c") != self.history[pointer]: pointer = prefix = None if pointer is None or prefix is None: prefix = self._get_source("iomark", "end-1c") if reverse: pointer = nhist else: pointer = -1 nprefix = len(prefix) while 1: if reverse: pointer = pointer - 1 else: pointer = pointer + 1 if pointer < 0 or pointer >= nhist: self.text.bell() if self._get_source("iomark", "end-1c") != prefix: self.text.delete("iomark", "end-1c") self._put_source("iomark", prefix) pointer = prefix = None break item = self.history[pointer] if item[:nprefix] == prefix and len(item) > nprefix: self.text.delete("iomark", "end-1c") self._put_source("iomark", item) break self.text.mark_set("insert", "end-1c") self.text.see("insert") self.text.tag_remove("sel", "1.0", "end") self.history_pointer = pointer self.history_prefix = prefix
0676dfdce06f6b01f35d76a4fb77c77c03468366 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0676dfdce06f6b01f35d76a4fb77c77c03468366/IdleHistory.py
val = int(value) self.write("<value><int>%s</int></value>\n" % val)
if value > MAXINT or value < MININT: raise OverflowError, "long int exceeds XML-RPC limits" self.write("<value><int>%s</int></value>\n" % int(value))
def dump_long(self, value): val = int(value) self.write("<value><int>%s</int></value>\n" % val)
5449e08412a5abd83c21d59764ef6240c58872b0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5449e08412a5abd83c21d59764ef6240c58872b0/xmlrpclib.py
self.send_error(403, "CGI script is not a plain file (%r)" %
self.send_error(403, "CGI script is not a plain file (%r)" %
def run_cgi(self): """Execute a CGI script.""" dir, rest = self.cgi_info i = rest.rfind('?') if i >= 0: rest, query = rest[:i], rest[i+1:] else: query = '' i = rest.find('/') if i >= 0: script, rest = rest[:i], rest[i:] else: script, rest = rest, '' scriptname = dir + '/' + script scriptfile = self.translate_path(scriptname) if not os.path.exists(scriptfile): self.send_error(404, "No such CGI script (%r)" % scriptname) return if not os.path.isfile(scriptfile): self.send_error(403, "CGI script is not a plain file (%r)" % scriptname) return ispy = self.is_python(scriptname) if not ispy: if not (self.have_fork or self.have_popen2 or self.have_popen3): self.send_error(403, "CGI script is not a Python script (%r)" % scriptname) return if not self.is_executable(scriptfile): self.send_error(403, "CGI script is not executable (%r)" % scriptname) return
27f49610afe5ca8fdce780490ec22def39bbbe3c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/27f49610afe5ca8fdce780490ec22def39bbbe3c/CGIHTTPServer.py
chunk.skip()
if formlength > 0: chunk.skip()
def initfp(self, file): self._file = file self._version = 0 self._decomp = None self._markers = [] self._soundpos = 0 form = self._file.read(4) if form != 'FORM': raise Error, 'file does not start with FORM id' formlength = _read_long(self._file) if formlength <= 0: raise Error, 'invalid FORM chunk data size' formdata = self._file.read(4) formlength = formlength - 4 if formdata == 'AIFF': self._aifc = 0 elif formdata == 'AIFC': self._aifc = 1 else: raise Error, 'not an AIFF or AIFF-C file' self._comm_chunk_read = 0 while formlength > 0: self._ssnd_seek_needed = 1 chunk = Chunk().init(self._file) formlength = formlength - 8 - chunk.chunksize if chunk.chunksize & 1: formlength = formlength - 1 if chunk.chunkname == 'COMM': self._read_comm_chunk(chunk) self._comm_chunk_read = 1 elif chunk.chunkname == 'SSND': self._ssnd_chunk = chunk dummy = chunk.read(8) self._ssnd_seek_needed = 0 elif chunk.chunkname == 'FVER': self._version = _read_long(chunk) elif chunk.chunkname == 'MARK': self._readmark(chunk) elif chunk.chunkname in _skiplist: pass else: raise Error, 'unrecognized chunk type '+chunk.chunkname chunk.skip() if not self._comm_chunk_read or not self._ssnd_chunk: raise Error, 'COMM chunk and/or SSND chunk missing' if self._aifc and self._decomp: params = [CL.ORIGINAL_FORMAT, 0, \ CL.BITS_PER_COMPONENT, 0, \ CL.FRAME_RATE, self._framerate] if self._nchannels == AL.MONO: params[1] = CL.MONO else: params[1] = CL.STEREO_INTERLEAVED if self._sampwidth == AL.SAMPLE_8: params[3] = 8 elif self._sampwidth == AL.SAMPLE_16: params[3] = 16 else: params[3] = 24 self._decomp.SetParams(params) return self
93f07400737a430ce642b4e7f6c9bd3e4460229c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/93f07400737a430ce642b4e7f6c9bd3e4460229c/aifc.py
params = [CL.FRAME_BUFFER_SIZE, len(data) * 2]
params = [CL.FRAME_BUFFER_SIZE, len(data) * 2, \ CL.COMPRESSED_BUFFER_SIZE, len(data)]
def readframes(self, nframes): if self._ssnd_seek_needed: self._ssnd_chunk.rewind() dummy = self._ssnd_chunk.read(8) pos = self._soundpos * self._nchannels * self._sampwidth if self._decomp: if self._comptype in ('ULAW', 'ALAW'): pos = pos / 2 if pos: self._ssnd_chunk.setpos(pos + 8) self._ssnd_seek_needed = 0 size = nframes * self._nchannels * self._sampwidth if self._decomp: if self._comptype in ('ULAW', 'ALAW'): size = size / 2 data = self._ssnd_chunk.read(size) if self._decomp and data: params = [CL.FRAME_BUFFER_SIZE, len(data) * 2] self._decomp.SetParams(params) data = self._decomp.Decompress(len(data) / self._nchannels, data) self._soundpos = self._soundpos + len(data) / (self._nchannels * self._sampwidth) return data
93f07400737a430ce642b4e7f6c9bd3e4460229c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/93f07400737a430ce642b4e7f6c9bd3e4460229c/aifc.py
has_cte = is_qp = 0
has_cte = is_qp = is_base64 = 0
def mimify_part(ifile, ofile, is_mime): '''Convert an 8bit part of a MIME mail message to quoted-printable.''' has_cte = is_qp = 0 multipart = None must_quote_body = must_quote_header = has_iso_chars = 0 header = [] header_end = '' message = [] message_end = '' # read header hfile = HeaderFile(ifile) while 1: line = hfile.readline() if not line: break if not must_quote_header and iso_char.search(line) >= 0: must_quote_header = 1 if mv.match(line) >= 0: is_mime = 1 if cte.match(line) >= 0: has_cte = 1 if qp.match(line) >= 0: is_qp = 1 if mp.match(line) >= 0: multipart = '--' + mp.group(1) if he.match(line) >= 0: header_end = line break header.append(line) # read body while 1: line = ifile.readline() if not line: break if multipart: if line == multipart + '--\n': message_end = line break if line == multipart + '\n': message_end = line break if is_qp: while line[-2:] == '=\n': line = line[:-2] newline = ifile.readline() if newline[:len(QUOTE)] == QUOTE: newline = newline[len(QUOTE):] line = line + newline line = mime_decode(line) message.append(line) if not has_iso_chars: if iso_char.search(line) >= 0: has_iso_chars = must_quote_body = 1 if not must_quote_body: if len(line) > MAXLEN: must_quote_body = 1 # convert and output header and body for line in header: if must_quote_header: line = mime_encode_header(line) if chrset.match(line) >= 0: if has_iso_chars: # change us-ascii into iso-8859-1 if string.lower(chrset.group(2)) == 'us-ascii': line = chrset.group(1) + \ CHARSET + chrset.group(3) else: # change iso-8859-* into us-ascii line = chrset.group(1) + 'us-ascii' + chrset.group(3) if has_cte and cte.match(line) >= 0: line = 'Content-Transfer-Encoding: ' if must_quote_body: line = line + 'quoted-printable\n' else: line = line + '7bit\n' ofile.write(line) if (must_quote_header or must_quote_body) and not is_mime: ofile.write('Mime-Version: 1.0\n') ofile.write('Content-Type: text/plain; ') if has_iso_chars: ofile.write('charset="%s"\n' % CHARSET) else: ofile.write('charset="us-ascii"\n') if must_quote_body and not has_cte: ofile.write('Content-Transfer-Encoding: quoted-printable\n') ofile.write(header_end) for line in message: if must_quote_body: line = mime_encode(line, 0) ofile.write(line) ofile.write(message_end) line = message_end while multipart: if line == multipart + '--\n': return if line == multipart + '\n': nifile = File(ifile, multipart) mimify_part(nifile, ofile, 1) line = nifile.peek ofile.write(line) continue
69155682e614bba1ad5978f605263f04f37b2ced /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/69155682e614bba1ad5978f605263f04f37b2ced/mimify.py
if must_quote_body:
if is_base64: line = line + 'base64\n' elif must_quote_body:
def mimify_part(ifile, ofile, is_mime): '''Convert an 8bit part of a MIME mail message to quoted-printable.''' has_cte = is_qp = 0 multipart = None must_quote_body = must_quote_header = has_iso_chars = 0 header = [] header_end = '' message = [] message_end = '' # read header hfile = HeaderFile(ifile) while 1: line = hfile.readline() if not line: break if not must_quote_header and iso_char.search(line) >= 0: must_quote_header = 1 if mv.match(line) >= 0: is_mime = 1 if cte.match(line) >= 0: has_cte = 1 if qp.match(line) >= 0: is_qp = 1 if mp.match(line) >= 0: multipart = '--' + mp.group(1) if he.match(line) >= 0: header_end = line break header.append(line) # read body while 1: line = ifile.readline() if not line: break if multipart: if line == multipart + '--\n': message_end = line break if line == multipart + '\n': message_end = line break if is_qp: while line[-2:] == '=\n': line = line[:-2] newline = ifile.readline() if newline[:len(QUOTE)] == QUOTE: newline = newline[len(QUOTE):] line = line + newline line = mime_decode(line) message.append(line) if not has_iso_chars: if iso_char.search(line) >= 0: has_iso_chars = must_quote_body = 1 if not must_quote_body: if len(line) > MAXLEN: must_quote_body = 1 # convert and output header and body for line in header: if must_quote_header: line = mime_encode_header(line) if chrset.match(line) >= 0: if has_iso_chars: # change us-ascii into iso-8859-1 if string.lower(chrset.group(2)) == 'us-ascii': line = chrset.group(1) + \ CHARSET + chrset.group(3) else: # change iso-8859-* into us-ascii line = chrset.group(1) + 'us-ascii' + chrset.group(3) if has_cte and cte.match(line) >= 0: line = 'Content-Transfer-Encoding: ' if must_quote_body: line = line + 'quoted-printable\n' else: line = line + '7bit\n' ofile.write(line) if (must_quote_header or must_quote_body) and not is_mime: ofile.write('Mime-Version: 1.0\n') ofile.write('Content-Type: text/plain; ') if has_iso_chars: ofile.write('charset="%s"\n' % CHARSET) else: ofile.write('charset="us-ascii"\n') if must_quote_body and not has_cte: ofile.write('Content-Transfer-Encoding: quoted-printable\n') ofile.write(header_end) for line in message: if must_quote_body: line = mime_encode(line, 0) ofile.write(line) ofile.write(message_end) line = message_end while multipart: if line == multipart + '--\n': return if line == multipart + '\n': nifile = File(ifile, multipart) mimify_part(nifile, ofile, 1) line = nifile.peek ofile.write(line) continue
69155682e614bba1ad5978f605263f04f37b2ced /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/69155682e614bba1ad5978f605263f04f37b2ced/mimify.py
verify(f4.func_code.co_varnames == ('two', '.2', 'compound', 'argument', 'list')) verify(f5.func_code.co_varnames == ('.0', 'two', 'compound', 'first'))
if sys.platform.startswith('java'): verify(f4.func_code.co_varnames == ('two', '(compound, (argument, list))',)) verify(f5.func_code.co_varnames == ('(compound, first)', 'two', 'compound', 'first')) else: verify(f4.func_code.co_varnames == ('two', '.2', 'compound', 'argument', 'list')) verify(f5.func_code.co_varnames == ('.0', 'two', 'compound', 'first'))
def f5((compound, first), two): pass
7d3dff2b390272dec07ca687f53ad34bd00df39b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7d3dff2b390272dec07ca687f53ad34bd00df39b/test_grammar.py
verify(v3.func_code.co_varnames == ('a', '.2', 'rest', 'b', 'c'))
if sys.platform.startswith('java'): verify(v3.func_code.co_varnames == ('a', '(b, c)', 'rest', 'b', 'c')) else: verify(v3.func_code.co_varnames == ('a', '.2', 'rest', 'b', 'c'))
def v3(a, (b, c), *rest): return a, b, c, rest
7d3dff2b390272dec07ca687f53ad34bd00df39b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7d3dff2b390272dec07ca687f53ad34bd00df39b/test_grammar.py
u = u''.join(map(unichr, xrange(1024))) for encoding in ('utf-7', 'utf-8', 'utf-16', 'utf-16-le', 'utf-16-be', 'raw_unicode_escape', 'unicode_escape', 'unicode_internal'): self.assertEqual(unicode(u.encode(encoding),encoding), u)
for c in xrange(1024): u = unichr(c) for encoding in ('utf-7', 'utf-8', 'utf-16', 'utf-16-le', 'utf-16-be', 'raw_unicode_escape', 'unicode_escape', 'unicode_internal'): self.assertEqual(unicode(u.encode(encoding),encoding), u)
def test_codecs(self): # Encoding self.assertEqual(u'hello'.encode('ascii'), 'hello') self.assertEqual(u'hello'.encode('utf-7'), 'hello') self.assertEqual(u'hello'.encode('utf-8'), 'hello') self.assertEqual(u'hello'.encode('utf8'), 'hello') self.assertEqual(u'hello'.encode('utf-16-le'), 'h\000e\000l\000l\000o\000') self.assertEqual(u'hello'.encode('utf-16-be'), '\000h\000e\000l\000l\000o') self.assertEqual(u'hello'.encode('latin-1'), 'hello')
835b243c71f5529da95aca5ca78fb9939278cffe /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/835b243c71f5529da95aca5ca78fb9939278cffe/test_unicode.py
u = u''.join(map(unichr, xrange(256))) for encoding in ('latin-1',): self.assertEqual(unicode(u.encode(encoding),encoding), u)
for c in xrange(256): u = unichr(c) for encoding in ('latin-1',): self.assertEqual(unicode(u.encode(encoding),encoding), u)
def test_codecs(self): # Encoding self.assertEqual(u'hello'.encode('ascii'), 'hello') self.assertEqual(u'hello'.encode('utf-7'), 'hello') self.assertEqual(u'hello'.encode('utf-8'), 'hello') self.assertEqual(u'hello'.encode('utf8'), 'hello') self.assertEqual(u'hello'.encode('utf-16-le'), 'h\000e\000l\000l\000o\000') self.assertEqual(u'hello'.encode('utf-16-be'), '\000h\000e\000l\000l\000o') self.assertEqual(u'hello'.encode('latin-1'), 'hello')
835b243c71f5529da95aca5ca78fb9939278cffe /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/835b243c71f5529da95aca5ca78fb9939278cffe/test_unicode.py
u = u''.join(map(unichr, xrange(128))) for encoding in ('ascii',): self.assertEqual(unicode(u.encode(encoding),encoding), u)
for c in xrange(128): u = unichr(c) for encoding in ('ascii',): self.assertEqual(unicode(u.encode(encoding),encoding), u)
def test_codecs(self): # Encoding self.assertEqual(u'hello'.encode('ascii'), 'hello') self.assertEqual(u'hello'.encode('utf-7'), 'hello') self.assertEqual(u'hello'.encode('utf-8'), 'hello') self.assertEqual(u'hello'.encode('utf8'), 'hello') self.assertEqual(u'hello'.encode('utf-16-le'), 'h\000e\000l\000l\000o\000') self.assertEqual(u'hello'.encode('utf-16-be'), '\000h\000e\000l\000l\000o') self.assertEqual(u'hello'.encode('latin-1'), 'hello')
835b243c71f5529da95aca5ca78fb9939278cffe /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/835b243c71f5529da95aca5ca78fb9939278cffe/test_unicode.py
s = "Module(%r" % % (self.__name__,)
s = "Module(%r" % (self.__name__,)
def __repr__(self): s = "Module(%r" % % (self.__name__,) if self.__file__ is not None: s = s + ", %r" % (self.__file__,) if self.__path__ is not None: s = s + ", %r" % (self.__path__,) s = s + ")" return s
32d23c9264a44316b028f712bdc516fbddb0a752 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/32d23c9264a44316b028f712bdc516fbddb0a752/modulefinder.py
self.socket.close()
def process_request(self, request, client_address): """Fork a new subprocess to process the request.""" self.collect_children() pid = os.fork() if pid: # Parent process if self.active_children is None: self.active_children = [] self.active_children.append(pid) return else: # Child process. # This must never return, hence os._exit()! try: self.finish_request(request, client_address) os._exit(0) except: try: self.socket.close() self.handle_error(request, client_address) finally: os._exit(1)
198e7cac5a3267ffa7243514ac085410f2638c69 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/198e7cac5a3267ffa7243514ac085410f2638c69/SocketServer.py
testboth("% testboth("% testboth("% testboth("%
testboth("% testboth("% testboth("% testboth("%
def testboth(formatstr, *args): testformat(formatstr, *args) testformat(unicode(formatstr), *args)
fff53250789c3879e5f63d4dde80d17e0b9c4dbb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fff53250789c3879e5f63d4dde80d17e0b9c4dbb/test_format.py
def set_link_objects (self, objects): """Set the list of object files (or analogues) to be included in every link to 'objects'. This does not affect any standard object files that the linker may include by default (such as system libraries). """ self.objects = copy (objects)
e65008038eccdcef396b0b2c09c8b4d72cf9b915 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e65008038eccdcef396b0b2c09c8b4d72cf9b915/ccompiler.py
n = int(s.rstrip(NUL) or "0", 8)
n = int(s.rstrip(NUL + " ") or "0", 8)
def nti(s): """Convert a number field to a python number. """ # There are two possible encodings for a number field, see # itn() below. if s[0] != chr(0200): n = int(s.rstrip(NUL) or "0", 8) else: n = 0L for i in xrange(len(s) - 1): n <<= 8 n += ord(s[i + 1]) return n
58bf57fa040741496cd4c53c85e3269a3e11af1b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/58bf57fa040741496cd4c53c85e3269a3e11af1b/tarfile.py
if re.match(e[1], result): continue
if re.match(escapestr(e[1], ampm), result): continue
def strftest(now): if verbose: print "strftime test for", time.ctime(now) nowsecs = str(long(now))[:-1] gmt = time.gmtime(now) now = time.localtime(now) if now[3] < 12: ampm='(AM|am)' else: ampm='(PM|pm)' jan1 = time.localtime(time.mktime((now[0], 1, 1, 0, 0, 0, 0, 1, 0))) try: if now[8]: tz = time.tzname[1] else: tz = time.tzname[0] except AttributeError: tz = '' if now[3] > 12: clock12 = now[3] - 12 elif now[3] > 0: clock12 = now[3] else: clock12 = 12 expectations = ( ('%a', calendar.day_abbr[now[6]], 'abbreviated weekday name'), ('%A', calendar.day_name[now[6]], 'full weekday name'), ('%b', calendar.month_abbr[now[1]], 'abbreviated month name'), ('%B', calendar.month_name[now[1]], 'full month name'), # %c see below ('%d', '%02d' % now[2], 'day of month as number (00-31)'), ('%H', '%02d' % now[3], 'hour (00-23)'), ('%I', '%02d' % clock12, 'hour (01-12)'), ('%j', '%03d' % now[7], 'julian day (001-366)'), ('%m', '%02d' % now[1], 'month as number (01-12)'), ('%M', '%02d' % now[4], 'minute, (00-59)'), ('%p', ampm, 'AM or PM as appropriate'), ('%S', '%02d' % now[5], 'seconds of current time (00-60)'), ('%U', '%02d' % ((now[7] + jan1[6])//7), 'week number of the year (Sun 1st)'), ('%w', '0?%d' % ((1+now[6]) % 7), 'weekday as a number (Sun 1st)'), ('%W', '%02d' % ((now[7] + (jan1[6] - 1)%7)//7), 'week number of the year (Mon 1st)'), # %x see below ('%X', '%02d:%02d:%02d' % (now[3], now[4], now[5]), '%H:%M:%S'), ('%y', '%02d' % (now[0]%100), 'year without century'), ('%Y', '%d' % now[0], 'year with century'), # %Z see below ('%%', '%', 'single percent sign'), ) nonstandard_expectations = ( # These are standard but don't have predictable output ('%c', fixasctime(time.asctime(now)), 'near-asctime() format'), ('%x', '%02d/%02d/%02d' % (now[1], now[2], (now[0]%100)), '%m/%d/%y %H:%M:%S'), ('%Z', '%s' % tz, 'time zone name'), # These are some platform specific extensions ('%D', '%02d/%02d/%02d' % (now[1], now[2], (now[0]%100)), 'mm/dd/yy'), ('%e', '%2d' % now[2], 'day of month as number, blank padded ( 0-31)'), ('%h', calendar.month_abbr[now[1]], 'abbreviated month name'), ('%k', '%2d' % now[3], 'hour, blank padded ( 0-23)'), ('%n', '\n', 'newline character'), ('%r', '%02d:%02d:%02d %s' % (clock12, now[4], now[5], ampm), '%I:%M:%S %p'), ('%R', '%02d:%02d' % (now[3], now[4]), '%H:%M'), ('%s', nowsecs, 'seconds since the Epoch in UCT'), ('%t', '\t', 'tab character'), ('%T', '%02d:%02d:%02d' % (now[3], now[4], now[5]), '%H:%M:%S'), ('%3y', '%03d' % (now[0]%100), 'year without century rendered using fieldwidth'), ) if verbose: print "Strftime test, platform: %s, Python version: %s" % \ (sys.platform, sys.version.split()[0]) for e in expectations: try: result = time.strftime(e[0], now) except ValueError, error: print "Standard '%s' format gave error:" % e[0], error continue if re.match(e[1], result): continue if not result or result[0] == '%': print "Does not support standard '%s' format (%s)" % (e[0], e[2]) else: print "Conflict for %s (%s):" % (e[0], e[2]) print " Expected %s, but got %s" % (e[1], result) for e in nonstandard_expectations: try: result = time.strftime(e[0], now) except ValueError, result: if verbose: print "Error for nonstandard '%s' format (%s): %s" % \ (e[0], e[2], str(result)) continue if re.match(e[1], result): if verbose: print "Supports nonstandard '%s' format (%s)" % (e[0], e[2]) elif not result or result[0] == '%': if verbose: print "Does not appear to support '%s' format (%s)" % (e[0], e[2]) else: if verbose: print "Conflict for nonstandard '%s' format (%s):" % (e[0], e[2]) print " Expected %s, but got %s" % (e[1], result)
c82208eecbe97e1535be4b1c8c12a68d54d29bd5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c82208eecbe97e1535be4b1c8c12a68d54d29bd5/test_strftime.py
if re.match(e[1], result):
if re.match(escapestr(e[1], ampm), result):
def strftest(now): if verbose: print "strftime test for", time.ctime(now) nowsecs = str(long(now))[:-1] gmt = time.gmtime(now) now = time.localtime(now) if now[3] < 12: ampm='(AM|am)' else: ampm='(PM|pm)' jan1 = time.localtime(time.mktime((now[0], 1, 1, 0, 0, 0, 0, 1, 0))) try: if now[8]: tz = time.tzname[1] else: tz = time.tzname[0] except AttributeError: tz = '' if now[3] > 12: clock12 = now[3] - 12 elif now[3] > 0: clock12 = now[3] else: clock12 = 12 expectations = ( ('%a', calendar.day_abbr[now[6]], 'abbreviated weekday name'), ('%A', calendar.day_name[now[6]], 'full weekday name'), ('%b', calendar.month_abbr[now[1]], 'abbreviated month name'), ('%B', calendar.month_name[now[1]], 'full month name'), # %c see below ('%d', '%02d' % now[2], 'day of month as number (00-31)'), ('%H', '%02d' % now[3], 'hour (00-23)'), ('%I', '%02d' % clock12, 'hour (01-12)'), ('%j', '%03d' % now[7], 'julian day (001-366)'), ('%m', '%02d' % now[1], 'month as number (01-12)'), ('%M', '%02d' % now[4], 'minute, (00-59)'), ('%p', ampm, 'AM or PM as appropriate'), ('%S', '%02d' % now[5], 'seconds of current time (00-60)'), ('%U', '%02d' % ((now[7] + jan1[6])//7), 'week number of the year (Sun 1st)'), ('%w', '0?%d' % ((1+now[6]) % 7), 'weekday as a number (Sun 1st)'), ('%W', '%02d' % ((now[7] + (jan1[6] - 1)%7)//7), 'week number of the year (Mon 1st)'), # %x see below ('%X', '%02d:%02d:%02d' % (now[3], now[4], now[5]), '%H:%M:%S'), ('%y', '%02d' % (now[0]%100), 'year without century'), ('%Y', '%d' % now[0], 'year with century'), # %Z see below ('%%', '%', 'single percent sign'), ) nonstandard_expectations = ( # These are standard but don't have predictable output ('%c', fixasctime(time.asctime(now)), 'near-asctime() format'), ('%x', '%02d/%02d/%02d' % (now[1], now[2], (now[0]%100)), '%m/%d/%y %H:%M:%S'), ('%Z', '%s' % tz, 'time zone name'), # These are some platform specific extensions ('%D', '%02d/%02d/%02d' % (now[1], now[2], (now[0]%100)), 'mm/dd/yy'), ('%e', '%2d' % now[2], 'day of month as number, blank padded ( 0-31)'), ('%h', calendar.month_abbr[now[1]], 'abbreviated month name'), ('%k', '%2d' % now[3], 'hour, blank padded ( 0-23)'), ('%n', '\n', 'newline character'), ('%r', '%02d:%02d:%02d %s' % (clock12, now[4], now[5], ampm), '%I:%M:%S %p'), ('%R', '%02d:%02d' % (now[3], now[4]), '%H:%M'), ('%s', nowsecs, 'seconds since the Epoch in UCT'), ('%t', '\t', 'tab character'), ('%T', '%02d:%02d:%02d' % (now[3], now[4], now[5]), '%H:%M:%S'), ('%3y', '%03d' % (now[0]%100), 'year without century rendered using fieldwidth'), ) if verbose: print "Strftime test, platform: %s, Python version: %s" % \ (sys.platform, sys.version.split()[0]) for e in expectations: try: result = time.strftime(e[0], now) except ValueError, error: print "Standard '%s' format gave error:" % e[0], error continue if re.match(e[1], result): continue if not result or result[0] == '%': print "Does not support standard '%s' format (%s)" % (e[0], e[2]) else: print "Conflict for %s (%s):" % (e[0], e[2]) print " Expected %s, but got %s" % (e[1], result) for e in nonstandard_expectations: try: result = time.strftime(e[0], now) except ValueError, result: if verbose: print "Error for nonstandard '%s' format (%s): %s" % \ (e[0], e[2], str(result)) continue if re.match(e[1], result): if verbose: print "Supports nonstandard '%s' format (%s)" % (e[0], e[2]) elif not result or result[0] == '%': if verbose: print "Does not appear to support '%s' format (%s)" % (e[0], e[2]) else: if verbose: print "Conflict for nonstandard '%s' format (%s):" % (e[0], e[2]) print " Expected %s, but got %s" % (e[1], result)
c82208eecbe97e1535be4b1c8c12a68d54d29bd5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c82208eecbe97e1535be4b1c8c12a68d54d29bd5/test_strftime.py
self.socket.connect(address)
self.socket.connect(address)
def _connect_unixsocket(self, address): self.socket = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM) # syslog may require either DGRAM or STREAM sockets try: self.socket.connect(address) except socket.error: self.socket.close() self.socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) self.socket.connect(address)
8b6b53f8ac132603e040145b5bbfd27a18015888 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8b6b53f8ac132603e040145b5bbfd27a18015888/handlers.py
s = pickle.dumps(d) e = pickle.loads(s) self.assertNotEqual(id(d), id(e)) self.assertEqual(list(d), list(e))
for i in (0, 1, 2): s = pickle.dumps(d, i) e = pickle.loads(s) self.assertNotEqual(id(d), id(e)) self.assertEqual(list(d), list(e)) def test_pickle_recursive(self): d = deque('abc') d.append(d) for i in (0, 1, 2): e = pickle.loads(pickle.dumps(d, i)) self.assertNotEqual(id(d), id(e)) self.assertEqual(id(e), id(e[-1]))
def test_pickle(self): d = deque(xrange(200)) s = pickle.dumps(d) e = pickle.loads(s) self.assertNotEqual(id(d), id(e)) self.assertEqual(list(d), list(e))
952f8808b264f82b6dbf8e613307769050eba611 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/952f8808b264f82b6dbf8e613307769050eba611/test_deque.py
def test(openmethod, what):
def test(openmethod, what, ondisk=1):
def test(openmethod, what): if verbose: print '\nTesting: ', what fname = tempfile.mktemp() f = openmethod(fname, 'c') verify(f.keys() == []) if verbose: print 'creation...' f['0'] = '' f['a'] = 'Guido' f['b'] = 'van' f['c'] = 'Rossum' f['d'] = 'invented' f['f'] = 'Python' if verbose: print '%s %s %s' % (f['a'], f['b'], f['c']) if what == 'BTree' : if verbose: print 'key ordering...' f.set_location(f.first()[0]) while 1: try: rec = f.next() except KeyError: if rec != f.last(): print 'Error, last != last!' f.previous() break if verbose: print rec if not f.has_key('a'): print 'Error, missing key!' f.sync() f.close() if verbose: print 'modification...' f = openmethod(fname, 'w') f['d'] = 'discovered' if verbose: print 'access...' for key in f.keys(): word = f[key] if verbose: print word f.close() try: os.remove(fname) except os.error: pass
8388895fe43da057006e50cae5d1b6e2a12083e0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8388895fe43da057006e50cae5d1b6e2a12083e0/test_bsddb.py
print '\nTesting: ', what
print '\nTesting: ', what, (ondisk and "on disk" or "in memory")
def test(openmethod, what): if verbose: print '\nTesting: ', what fname = tempfile.mktemp() f = openmethod(fname, 'c') verify(f.keys() == []) if verbose: print 'creation...' f['0'] = '' f['a'] = 'Guido' f['b'] = 'van' f['c'] = 'Rossum' f['d'] = 'invented' f['f'] = 'Python' if verbose: print '%s %s %s' % (f['a'], f['b'], f['c']) if what == 'BTree' : if verbose: print 'key ordering...' f.set_location(f.first()[0]) while 1: try: rec = f.next() except KeyError: if rec != f.last(): print 'Error, last != last!' f.previous() break if verbose: print rec if not f.has_key('a'): print 'Error, missing key!' f.sync() f.close() if verbose: print 'modification...' f = openmethod(fname, 'w') f['d'] = 'discovered' if verbose: print 'access...' for key in f.keys(): word = f[key] if verbose: print word f.close() try: os.remove(fname) except os.error: pass
8388895fe43da057006e50cae5d1b6e2a12083e0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8388895fe43da057006e50cae5d1b6e2a12083e0/test_bsddb.py
fname = tempfile.mktemp()
if ondisk: fname = tempfile.mktemp() else: fname = None
def test(openmethod, what): if verbose: print '\nTesting: ', what fname = tempfile.mktemp() f = openmethod(fname, 'c') verify(f.keys() == []) if verbose: print 'creation...' f['0'] = '' f['a'] = 'Guido' f['b'] = 'van' f['c'] = 'Rossum' f['d'] = 'invented' f['f'] = 'Python' if verbose: print '%s %s %s' % (f['a'], f['b'], f['c']) if what == 'BTree' : if verbose: print 'key ordering...' f.set_location(f.first()[0]) while 1: try: rec = f.next() except KeyError: if rec != f.last(): print 'Error, last != last!' f.previous() break if verbose: print rec if not f.has_key('a'): print 'Error, missing key!' f.sync() f.close() if verbose: print 'modification...' f = openmethod(fname, 'w') f['d'] = 'discovered' if verbose: print 'access...' for key in f.keys(): word = f[key] if verbose: print word f.close() try: os.remove(fname) except os.error: pass
8388895fe43da057006e50cae5d1b6e2a12083e0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8388895fe43da057006e50cae5d1b6e2a12083e0/test_bsddb.py
if verbose: print 'modification...' f = openmethod(fname, 'w') f['d'] = 'discovered'
if ondisk: if verbose: print 'modification...' f = openmethod(fname, 'w') f['d'] = 'discovered'
def test(openmethod, what): if verbose: print '\nTesting: ', what fname = tempfile.mktemp() f = openmethod(fname, 'c') verify(f.keys() == []) if verbose: print 'creation...' f['0'] = '' f['a'] = 'Guido' f['b'] = 'van' f['c'] = 'Rossum' f['d'] = 'invented' f['f'] = 'Python' if verbose: print '%s %s %s' % (f['a'], f['b'], f['c']) if what == 'BTree' : if verbose: print 'key ordering...' f.set_location(f.first()[0]) while 1: try: rec = f.next() except KeyError: if rec != f.last(): print 'Error, last != last!' f.previous() break if verbose: print rec if not f.has_key('a'): print 'Error, missing key!' f.sync() f.close() if verbose: print 'modification...' f = openmethod(fname, 'w') f['d'] = 'discovered' if verbose: print 'access...' for key in f.keys(): word = f[key] if verbose: print word f.close() try: os.remove(fname) except os.error: pass
8388895fe43da057006e50cae5d1b6e2a12083e0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8388895fe43da057006e50cae5d1b6e2a12083e0/test_bsddb.py
if verbose: print 'access...' for key in f.keys(): word = f[key]
def test(openmethod, what): if verbose: print '\nTesting: ', what fname = tempfile.mktemp() f = openmethod(fname, 'c') verify(f.keys() == []) if verbose: print 'creation...' f['0'] = '' f['a'] = 'Guido' f['b'] = 'van' f['c'] = 'Rossum' f['d'] = 'invented' f['f'] = 'Python' if verbose: print '%s %s %s' % (f['a'], f['b'], f['c']) if what == 'BTree' : if verbose: print 'key ordering...' f.set_location(f.first()[0]) while 1: try: rec = f.next() except KeyError: if rec != f.last(): print 'Error, last != last!' f.previous() break if verbose: print rec if not f.has_key('a'): print 'Error, missing key!' f.sync() f.close() if verbose: print 'modification...' f = openmethod(fname, 'w') f['d'] = 'discovered' if verbose: print 'access...' for key in f.keys(): word = f[key] if verbose: print word f.close() try: os.remove(fname) except os.error: pass
8388895fe43da057006e50cae5d1b6e2a12083e0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8388895fe43da057006e50cae5d1b6e2a12083e0/test_bsddb.py
print word
print 'access...' for key in f.keys(): word = f[key] if verbose: print word
def test(openmethod, what): if verbose: print '\nTesting: ', what fname = tempfile.mktemp() f = openmethod(fname, 'c') verify(f.keys() == []) if verbose: print 'creation...' f['0'] = '' f['a'] = 'Guido' f['b'] = 'van' f['c'] = 'Rossum' f['d'] = 'invented' f['f'] = 'Python' if verbose: print '%s %s %s' % (f['a'], f['b'], f['c']) if what == 'BTree' : if verbose: print 'key ordering...' f.set_location(f.first()[0]) while 1: try: rec = f.next() except KeyError: if rec != f.last(): print 'Error, last != last!' f.previous() break if verbose: print rec if not f.has_key('a'): print 'Error, missing key!' f.sync() f.close() if verbose: print 'modification...' f = openmethod(fname, 'w') f['d'] = 'discovered' if verbose: print 'access...' for key in f.keys(): word = f[key] if verbose: print word f.close() try: os.remove(fname) except os.error: pass
8388895fe43da057006e50cae5d1b6e2a12083e0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8388895fe43da057006e50cae5d1b6e2a12083e0/test_bsddb.py
f.close() try: os.remove(fname) except os.error: pass
f.close() try: os.remove(fname) except os.error: pass
def test(openmethod, what): if verbose: print '\nTesting: ', what fname = tempfile.mktemp() f = openmethod(fname, 'c') verify(f.keys() == []) if verbose: print 'creation...' f['0'] = '' f['a'] = 'Guido' f['b'] = 'van' f['c'] = 'Rossum' f['d'] = 'invented' f['f'] = 'Python' if verbose: print '%s %s %s' % (f['a'], f['b'], f['c']) if what == 'BTree' : if verbose: print 'key ordering...' f.set_location(f.first()[0]) while 1: try: rec = f.next() except KeyError: if rec != f.last(): print 'Error, last != last!' f.previous() break if verbose: print rec if not f.has_key('a'): print 'Error, missing key!' f.sync() f.close() if verbose: print 'modification...' f = openmethod(fname, 'w') f['d'] = 'discovered' if verbose: print 'access...' for key in f.keys(): word = f[key] if verbose: print word f.close() try: os.remove(fname) except os.error: pass
8388895fe43da057006e50cae5d1b6e2a12083e0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8388895fe43da057006e50cae5d1b6e2a12083e0/test_bsddb.py
test(type[0], type[1])
test(*type)
def test(openmethod, what): if verbose: print '\nTesting: ', what fname = tempfile.mktemp() f = openmethod(fname, 'c') verify(f.keys() == []) if verbose: print 'creation...' f['0'] = '' f['a'] = 'Guido' f['b'] = 'van' f['c'] = 'Rossum' f['d'] = 'invented' f['f'] = 'Python' if verbose: print '%s %s %s' % (f['a'], f['b'], f['c']) if what == 'BTree' : if verbose: print 'key ordering...' f.set_location(f.first()[0]) while 1: try: rec = f.next() except KeyError: if rec != f.last(): print 'Error, last != last!' f.previous() break if verbose: print rec if not f.has_key('a'): print 'Error, missing key!' f.sync() f.close() if verbose: print 'modification...' f = openmethod(fname, 'w') f['d'] = 'discovered' if verbose: print 'access...' for key in f.keys(): word = f[key] if verbose: print word f.close() try: os.remove(fname) except os.error: pass
8388895fe43da057006e50cae5d1b6e2a12083e0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8388895fe43da057006e50cae5d1b6e2a12083e0/test_bsddb.py
sys.stdout = sys.__stdout__
sys.stdout = saved_stdout
def assertValid(self, str, symbol='single'): '''succeed iff str is a valid piece of code''' if is_jython: code = compile_command(str, "<input>", symbol) self.assert_(code) if symbol == "single": d,r = {},{} sys.stdout = cStringIO.StringIO() try: exec code in d exec compile(str,"<input>","single") in r finally: sys.stdout = sys.__stdout__ elif symbol == 'eval': ctx = {'a': 2} d = { 'value': eval(code,ctx) } r = { 'value': eval(str,ctx) } self.assertEquals(unify_callables(r),unify_callables(d)) else: expected = compile(str, "<input>", symbol, PyCF_DONT_IMPLY_DEDENT) self.assertEquals( compile_command(str, "<input>", symbol), expected)
72c5c77ce17b5b1dbe23a10bc801d1169cf94d92 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/72c5c77ce17b5b1dbe23a10bc801d1169cf94d92/test_codeop.py
dbfile = s.optiondb()['DBFILE']
dbfile = s.optiondb().get('DBFILE')
def build(master=None, initialcolor=None, initfile=None, ignore=None, dbfile=None): # create all output widgets s = Switchboard(not ignore and initfile) # defer to the command line chosen color database, falling back to the one # in the .pynche file. if dbfile is None: dbfile = s.optiondb()['DBFILE'] # find a parseable color database colordb = None files = RGB_TXT[:] while colordb is None: try: colordb = ColorDB.get_colordb(dbfile) except (KeyError, IOError): pass if colordb is None: if not files: break dbfile = files.pop(0) if not colordb: usage(1, 'No color database file found, see the -d option.') s.set_colordb(colordb) # create the application window decorations app = PyncheWidget(__version__, s, master=master) w = app.window() # these built-in viewers live inside the main Pynche window s.add_view(StripViewer(s, w)) s.add_view(ChipViewer(s, w)) s.add_view(TypeinViewer(s, w)) # get the initial color as components and set the color on all views. if # there was no initial color given on the command line, use the one that's # stored in the option database if initialcolor is None: optiondb = s.optiondb() red = optiondb.get('RED') green = optiondb.get('GREEN') blue = optiondb.get('BLUE') # but if there wasn't any stored in the database, use grey50 if red is None or blue is None or green is None: red, green, blue = initial_color('grey50', colordb) else: red, green, blue = initial_color(initialcolor, colordb) s.update_views(red, green, blue) return app, s
eb296d967b4e1ff2e87d652cf1d80f6adedb1228 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/eb296d967b4e1ff2e87d652cf1d80f6adedb1228/Main.py
rounding = context.rounding
def __pow__(self, n, modulo = None, context=None): """Return self ** n (mod modulo)
76e60d687dde9d987f39e16f8fe7814daf1f1e26 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/76e60d687dde9d987f39e16f8fe7814daf1f1e26/decimal.py
shouldround = context._rounding_decision == ALWAYS_ROUND
def __pow__(self, n, modulo = None, context=None): """Return self ** n (mod modulo)
76e60d687dde9d987f39e16f8fe7814daf1f1e26 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/76e60d687dde9d987f39e16f8fe7814daf1f1e26/decimal.py
if shouldround:
if context._rounding_decision == ALWAYS_ROUND:
def __pow__(self, n, modulo = None, context=None): """Return self ** n (mod modulo)
76e60d687dde9d987f39e16f8fe7814daf1f1e26 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/76e60d687dde9d987f39e16f8fe7814daf1f1e26/decimal.py
out = 0
def _rescale(self, exp, rounding=None, context=None, watchexp=1): """Rescales so that the exponent is exp.
76e60d687dde9d987f39e16f8fe7814daf1f1e26 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/76e60d687dde9d987f39e16f8fe7814daf1f1e26/decimal.py
prevexact = context.flags[Inexact]
def _rescale(self, exp, rounding=None, context=None, watchexp=1): """Rescales so that the exponent is exp.
76e60d687dde9d987f39e16f8fe7814daf1f1e26 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/76e60d687dde9d987f39e16f8fe7814daf1f1e26/decimal.py
count = 1
def sqrt(self, context=None): """Return the square root of self.
76e60d687dde9d987f39e16f8fe7814daf1f1e26 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/76e60d687dde9d987f39e16f8fe7814daf1f1e26/decimal.py
context._rounding_decision == ALWAYS_ROUND return ans._fix(context)
if context._rounding_decision == ALWAYS_ROUND: return ans._fix(context) return ans
def max(self, other, context=None): """Returns the larger value.
76e60d687dde9d987f39e16f8fe7814daf1f1e26 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/76e60d687dde9d987f39e16f8fe7814daf1f1e26/decimal.py
context._rounding_decision == ALWAYS_ROUND return ans._fix(context)
if context._rounding_decision == ALWAYS_ROUND: return ans._fix(context) return ans
def min(self, other, context=None): """Returns the smaller value.
76e60d687dde9d987f39e16f8fe7814daf1f1e26 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/76e60d687dde9d987f39e16f8fe7814daf1f1e26/decimal.py
verify(log == [('getattr', '__init__'), ('getattr', '__setattr__'),
verify(log == [('getattr', '__setattr__'),
def __delattr__(self, name): log.append(("delattr", name)) MT.__delattr__(self, name)
a5be8eda37e864ed3c169b8e2c660d3c65eaec38 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a5be8eda37e864ed3c169b8e2c660d3c65eaec38/test_descr.py
cur = (32767 * viewoffset) / (destheight - viewheight)
cur = (32767L * viewoffset) / (destheight - viewheight)
def vscroll(self, value): lineheight = self.ted.WEGetHeight(0, 1) dr = self.ted.WEGetDestRect() vr = self.ted.WEGetViewRect() destheight = dr[3] - dr[1] viewheight = vr[3] - vr[1] viewoffset = maxdelta = vr[1] - dr[1] mindelta = vr[3] - dr[3] if value == "+": delta = lineheight elif value == "-": delta = - lineheight elif value == "++": delta = viewheight - lineheight elif value == "--": delta = lineheight - viewheight else: # in thumb cur = (32767 * viewoffset) / (destheight - viewheight) delta = (cur-value)*(destheight - viewheight)/32767 if abs(delta - viewoffset) <=2: # compensate for irritating rounding error delta = viewoffset delta = min(maxdelta, delta) delta = max(mindelta, delta) self.ted.WEScroll(0, delta) self.updatescrollbars()
6c487c4d34a0dc80b2ed942acb487d32f8938798 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6c487c4d34a0dc80b2ed942acb487d32f8938798/Wtext.py
tcl_version = self.tk.getvar('tcl_version')
tcl_version = str(self.tk.getvar('tcl_version'))
def __init__(self, screenName=None, baseName=None, className='Tk'): """Return a new Toplevel widget on screen SCREENNAME. A new Tcl interpreter will be created. BASENAME will be used for the identification of the profile file (see readprofile). It is constructed from sys.argv[0] without extensions if None is given. CLASSNAME is the name of the widget class.""" global _default_root self.master = None self.children = {} if baseName is None: import sys, os baseName = os.path.basename(sys.argv[0]) baseName, ext = os.path.splitext(baseName) if ext not in ('.py', '.pyc', '.pyo'): baseName = baseName + ext self.tk = _tkinter.create(screenName, baseName, className) self.tk.wantobjects(wantobjects) if _MacOS and hasattr(_MacOS, 'SchedParams'): # Disable event scanning except for Command-Period _MacOS.SchedParams(1, 0) # Work around nasty MacTk bug # XXX Is this one still needed? self.update() # Version sanity checks tk_version = self.tk.getvar('tk_version') if tk_version != _tkinter.TK_VERSION: raise RuntimeError, \ "tk.h version (%s) doesn't match libtk.a version (%s)" \ % (_tkinter.TK_VERSION, tk_version) tcl_version = self.tk.getvar('tcl_version') if tcl_version != _tkinter.TCL_VERSION: raise RuntimeError, \ "tcl.h version (%s) doesn't match libtcl.a version (%s)" \ % (_tkinter.TCL_VERSION, tcl_version) if TkVersion < 4.0: raise RuntimeError, \ "Tk 4.0 or higher is required; found Tk %s" \ % str(TkVersion) self.tk.createcommand('tkerror', _tkerror) self.tk.createcommand('exit', _exit) self.readprofile(baseName, className) if _support_default_root and not _default_root: _default_root = self self.protocol("WM_DELETE_WINDOW", self.destroy)
5489597f56e82f9b8d2b519651f80241f4ea4326 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5489597f56e82f9b8d2b519651f80241f4ea4326/Tkinter.py
base = base.replace("/", ".")
base = base.replace(os.sep, ".") if os.altsep: base = base.replace(os.altsep, ".")
def fullmodname(path): """Return a plausible module name for the path.""" # If the file 'path' is part of a package, then the filename isn't # enough to uniquely identify it. Try to do the right thing by # looking in sys.path for the longest matching prefix. We'll # assume that the rest is the package name. longest = "" for dir in sys.path: if path.startswith(dir) and path[len(dir)] == os.path.sep: if len(dir) > len(longest): longest = dir if longest: base = path[len(longest) + 1:] else: base = path base = base.replace("/", ".") filename, ext = os.path.splitext(base) return filename
bbca8da3ca5191d68c4cd8777b8ba8632c0cff44 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/bbca8da3ca5191d68c4cd8777b8ba8632c0cff44/trace.py
return
return 0, 0
def write_results_file(self, path, lines, lnotab, lines_hit): """Return a coverage results file in path."""
bbca8da3ca5191d68c4cd8777b8ba8632c0cff44 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/bbca8da3ca5191d68c4cd8777b8ba8632c0cff44/trace.py
raise RuntimeError, "UserList.__cmp__() is obsolete"
return cmp(self.data, self.__cast(other))
def __cmp__(self, other): raise RuntimeError, "UserList.__cmp__() is obsolete"
0163d6d6ef85dd0cd0ea4ea6dce4b867e39cd6b9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0163d6d6ef85dd0cd0ea4ea6dce4b867e39cd6b9/UserList.py
if brightness <= 0.5:
if brightness <= 128:
def __trackarrow(self, chip, rgbtuple): # invert the last chip if self.__lastchip is not None: color = self.__canvas.itemcget(self.__lastchip, 'fill') self.__canvas.itemconfigure(self.__lastchip, outline=color) self.__lastchip = chip
26f4b5dfe4f357d662a015f0c89a925fb0fe3465 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/26f4b5dfe4f357d662a015f0c89a925fb0fe3465/StripViewer.py
ioloop(s, otheraddr) except KeyboardInterrupt: log('client got intr') except error: log('client got error')
try: ioloop(s, otheraddr) except KeyboardInterrupt: log('client got intr') except error: log('client got error')
def client(hostname): print 'client starting' cmd = 'rsh ' + hostname + ' "cd ' + AUDIODIR cmd = cmd + '; DISPLAY=:0; export DISPLAY' cmd = cmd + '; ' + PYTHON + ' intercom.py -r ' for flag in debug: cmd = cmd + flag + ' ' cmd = cmd + gethostname() cmd = cmd + '"' if debug: print cmd pipe = posix.popen(cmd, 'r') ack = 0 nak = 0 while 1: line = pipe.readline() if not line: break sys.stdout.write('remote: ' + line) if line == 'NAK\n': nak = 1 break elif line == 'ACK\n': ack = 1 break if nak: print 'Remote user doesn\'t want to talk to you.' return if not ack: print 'No acknowledgement (remote side crashed?).' return # print 'Ready...' # s = socket(AF_INET, SOCK_DGRAM) s.bind('', PORT2) # otheraddr = gethostbyname(hostname), PORT1 try: ioloop(s, otheraddr) except KeyboardInterrupt: log('client got intr') except error: log('client got error') finally: s.sendto('', otheraddr) log('client finished sending empty packet to server') # log('client exit') print 'Done.'
6f1f39188c54b89bac8b0e3b91529ad733929bc4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6f1f39188c54b89bac8b0e3b91529ad733929bc4/intercom.py