rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
__main__.__dict__.keys()]:
self.namespace.keys()]:
def global_matches(self, text): """Compute matches when text is a simple name.
dbab3e3178d8819a839ad08571f995376edcba00 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/dbab3e3178d8819a839ad08571f995376edcba00/rlcompleter.py
evaluatable in the globals of __main__, it will be evaluated and its attributes (as revealed by dir()) are used as possible completions. (For class instances, class members are are also considered.)
evaluatable in self.namespace, it will be evaluated and its attributes (as revealed by dir()) are used as possible completions. (For class instances, class members are are also considered.)
def attr_matches(self, text): """Compute matches when text contains a dot.
dbab3e3178d8819a839ad08571f995376edcba00 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/dbab3e3178d8819a839ad08571f995376edcba00/rlcompleter.py
object = eval(expr, __main__.__dict__)
object = eval(expr, self.namespace)
def attr_matches(self, text): """Compute matches when text contains a dot.
dbab3e3178d8819a839ad08571f995376edcba00 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/dbab3e3178d8819a839ad08571f995376edcba00/rlcompleter.py
'Down Arrow': 'Down', 'Tab':'tab'}
'Down Arrow': 'Down', 'Tab':'Tab'}
def TranslateKey(self, key, modifiers): "Translate from keycap symbol to the Tkinter keysym" translateDict = {'Space':'space', '~':'asciitilde','!':'exclam','@':'at','#':'numbersign', '%':'percent','^':'asciicircum','&':'ampersand','*':'asterisk', '(':'parenleft',')':'parenright','_':'underscore','-':'minus', '+':'plus','=':'equal','{':'braceleft','}':'braceright', '[':'bracketleft',']':'bracketright','|':'bar',';':'semicolon', ':':'colon',',':'comma','.':'period','<':'less','>':'greater', '/':'slash','?':'question','Page Up':'Prior','Page Down':'Next', 'Left Arrow':'Left','Right Arrow':'Right','Up Arrow':'Up', 'Down Arrow': 'Down', 'Tab':'tab'} if key in translateDict.keys(): key = translateDict[key] if 'Shift' in modifiers and key in string.ascii_lowercase: key = key.upper() key = 'Key-' + key return key
4b7e35b530d06780ff905df2669ebdf892d6f75f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4b7e35b530d06780ff905df2669ebdf892d6f75f/keybindingDialog.py
if sys.byteorder == 'little': fmt = ossaudiodev.AFMT_S16_LE else: fmt = ossaudiodev.AFMT_S16_BE
def play_sound_file(data, rate, ssize, nchannels): try: dsp = ossaudiodev.open('w') except IOError, msg: if msg[0] in (errno.EACCES, errno.ENODEV, errno.EBUSY): raise TestSkipped, msg raise TestFailed, msg # set the data format if sys.byteorder == 'little': fmt = ossaudiodev.AFMT_S16_LE else: fmt = ossaudiodev.AFMT_S16_BE # at least check that these methods can be invoked dsp.bufsize() dsp.obufcount() dsp.obuffree() dsp.getptr() dsp.fileno() # set parameters based on .au file headers dsp.setparameters(fmt, nchannels, rate) t1 = time.time() print "playing test sound file..." dsp.write(data) dsp.close() t2 = time.time() print "elapsed time: %.1f sec" % (t2-t1)
8a709b30493e7ca36e203d213d19f6fde8740470 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8a709b30493e7ca36e203d213d19f6fde8740470/test_ossaudiodev.py
dsp.setparameters(fmt, nchannels, rate)
dsp.setparameters(AFMT_S16_NE, nchannels, rate)
def play_sound_file(data, rate, ssize, nchannels): try: dsp = ossaudiodev.open('w') except IOError, msg: if msg[0] in (errno.EACCES, errno.ENODEV, errno.EBUSY): raise TestSkipped, msg raise TestFailed, msg # set the data format if sys.byteorder == 'little': fmt = ossaudiodev.AFMT_S16_LE else: fmt = ossaudiodev.AFMT_S16_BE # at least check that these methods can be invoked dsp.bufsize() dsp.obufcount() dsp.obuffree() dsp.getptr() dsp.fileno() # set parameters based on .au file headers dsp.setparameters(fmt, nchannels, rate) t1 = time.time() print "playing test sound file..." dsp.write(data) dsp.close() t2 = time.time() print "elapsed time: %.1f sec" % (t2-t1)
8a709b30493e7ca36e203d213d19f6fde8740470 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8a709b30493e7ca36e203d213d19f6fde8740470/test_ossaudiodev.py
os.fsync(f.fileno())
if hasattr(os, 'fsync'): os.fsync(f.fileno())
def _sync_flush(f): """Ensure changes to file f are physically on disk.""" f.flush() os.fsync(f.fileno())
1646568b5ed4a3d11e1bf938048b01d7ae3dd0f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1646568b5ed4a3d11e1bf938048b01d7ae3dd0f7/mailbox.py
import MacOS
def __init__(self, timer=None): self.timings = {} self.cur = None self.cmd = ""
e4deb959cce4b35c17a48c7a7ec3cfb7bf860edf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e4deb959cce4b35c17a48c7a7ec3cfb7bf860edf/profile.py
import sys, traceback
import traceback
def _run_exitfuncs(): """run any registered exit functions _exithandlers is traversed in reverse order so functions are executed last in, first out. """ exc_info = None while _exithandlers: func, targs, kargs = _exithandlers.pop() try: func(*targs, **kargs) except SystemExit: exc_info = sys.exc_info() except: import sys, traceback print >> sys.stderr, "Error in atexit._run_exitfuncs:" traceback.print_exc() exc_info = sys.exc_info() if exc_info is not None: raise exc_info[0], exc_info[1], exc_info[2]
a9ef5e565d3e33e3a6f410d9c610ffe5bdc6c474 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a9ef5e565d3e33e3a6f410d9c610ffe5bdc6c474/atexit.py
import sys
def register(func, *targs, **kargs): """register a function to be executed upon normal program termination func - function to be called at exit targs - optional arguments to pass to func kargs - optional keyword arguments to pass to func """ _exithandlers.append((func, targs, kargs))
a9ef5e565d3e33e3a6f410d9c610ffe5bdc6c474 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a9ef5e565d3e33e3a6f410d9c610ffe5bdc6c474/atexit.py
del sys
def register(func, *targs, **kargs): """register a function to be executed upon normal program termination func - function to be called at exit targs - optional arguments to pass to func kargs - optional keyword arguments to pass to func """ _exithandlers.append((func, targs, kargs))
a9ef5e565d3e33e3a6f410d9c610ffe5bdc6c474 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a9ef5e565d3e33e3a6f410d9c610ffe5bdc6c474/atexit.py
size = stats[stat.ST_SIZE] modified = rfc822.formatdate(stats[stat.ST_MTIME])
size = stats.st_size modified = rfc822.formatdate(stats.st_mtime)
def open_local_file(self, req): host = req.get_host() file = req.get_selector() localfile = url2pathname(file) stats = os.stat(localfile) size = stats[stat.ST_SIZE] modified = rfc822.formatdate(stats[stat.ST_MTIME]) mtype = mimetypes.guess_type(file)[0] stats = os.stat(localfile) headers = mimetools.Message(StringIO( 'Content-Type: %s\nContent-Length: %d\nLast-modified: %s\n' % (mtype or 'text/plain', size, modified))) if host: host, port = splitport(host) if not host or \ (not port and socket.gethostbyname(host) in self.get_names()): return addinfourl(open(localfile, 'rb'), headers, 'file:'+file) raise URLError('file not on local host')
9d3eba87d697231dde1672bdd30d5f59890700b4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9d3eba87d697231dde1672bdd30d5f59890700b4/urllib2.py
stats = os.stat(localfile)
def open_local_file(self, req): host = req.get_host() file = req.get_selector() localfile = url2pathname(file) stats = os.stat(localfile) size = stats[stat.ST_SIZE] modified = rfc822.formatdate(stats[stat.ST_MTIME]) mtype = mimetypes.guess_type(file)[0] stats = os.stat(localfile) headers = mimetools.Message(StringIO( 'Content-Type: %s\nContent-Length: %d\nLast-modified: %s\n' % (mtype or 'text/plain', size, modified))) if host: host, port = splitport(host) if not host or \ (not port and socket.gethostbyname(host) in self.get_names()): return addinfourl(open(localfile, 'rb'), headers, 'file:'+file) raise URLError('file not on local host')
9d3eba87d697231dde1672bdd30d5f59890700b4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9d3eba87d697231dde1672bdd30d5f59890700b4/urllib2.py
def check(a, b): if a != b: print '*** check failed: %s != %s' % (repr(a), repr(b)) else: print '%s == %s: OK' % (a, b)
import test.test_support, unittest
def check(a, b): if a != b: print '*** check failed: %s != %s' % (repr(a), repr(b)) else: print '%s == %s: OK' % (a, b)
bb2734ab65970eba1d361932f12843799496d1ea /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/bb2734ab65970eba1d361932f12843799496d1ea/test_charmapcodec.py
check(unicode('abc', codecname), u'abc') check(unicode('xdef', codecname), u'abcdef') check(unicode('defx', codecname), u'defabc') check(unicode('dxf', codecname), u'dabcf') check(unicode('dxfx', codecname), u'dabcfabc')
class CharmapCodecTest(unittest.TestCase): def test_constructorx(self): self.assertEquals(unicode('abc', codecname), u'abc') self.assertEquals(unicode('xdef', codecname), u'abcdef') self.assertEquals(unicode('defx', codecname), u'defabc') self.assertEquals(unicode('dxf', codecname), u'dabcf') self.assertEquals(unicode('dxfx', codecname), u'dabcfabc')
def check(a, b): if a != b: print '*** check failed: %s != %s' % (repr(a), repr(b)) else: print '%s == %s: OK' % (a, b)
bb2734ab65970eba1d361932f12843799496d1ea /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/bb2734ab65970eba1d361932f12843799496d1ea/test_charmapcodec.py
check(u'abc'.encode(codecname), 'abc') check(u'xdef'.encode(codecname), 'abcdef') check(u'defx'.encode(codecname), 'defabc') check(u'dxf'.encode(codecname), 'dabcf') check(u'dxfx'.encode(codecname), 'dabcfabc')
def test_encodex(self): self.assertEquals(u'abc'.encode(codecname), 'abc') self.assertEquals(u'xdef'.encode(codecname), 'abcdef') self.assertEquals(u'defx'.encode(codecname), 'defabc') self.assertEquals(u'dxf'.encode(codecname), 'dabcf') self.assertEquals(u'dxfx'.encode(codecname), 'dabcfabc')
def check(a, b): if a != b: print '*** check failed: %s != %s' % (repr(a), repr(b)) else: print '%s == %s: OK' % (a, b)
bb2734ab65970eba1d361932f12843799496d1ea /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/bb2734ab65970eba1d361932f12843799496d1ea/test_charmapcodec.py
check(unicode('ydef', codecname), u'def') check(unicode('defy', codecname), u'def') check(unicode('dyf', codecname), u'df') check(unicode('dyfy', codecname), u'df')
def test_constructory(self): self.assertEquals(unicode('ydef', codecname), u'def') self.assertEquals(unicode('defy', codecname), u'def') self.assertEquals(unicode('dyf', codecname), u'df') self.assertEquals(unicode('dyfy', codecname), u'df')
def check(a, b): if a != b: print '*** check failed: %s != %s' % (repr(a), repr(b)) else: print '%s == %s: OK' % (a, b)
bb2734ab65970eba1d361932f12843799496d1ea /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/bb2734ab65970eba1d361932f12843799496d1ea/test_charmapcodec.py
try: unicode('abc\001', codecname) except UnicodeError: print '\\001 maps to undefined: OK' else: print '*** check failed: \\001 does not map to undefined'
def test_maptoundefined(self): self.assertRaises(UnicodeError, unicode, 'abc\001', codecname) def test_main(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(CharmapCodecTest)) test.test_support.run_suite(suite) if __name__ == "__main__": test_main()
def check(a, b): if a != b: print '*** check failed: %s != %s' % (repr(a), repr(b)) else: print '%s == %s: OK' % (a, b)
bb2734ab65970eba1d361932f12843799496d1ea /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/bb2734ab65970eba1d361932f12843799496d1ea/test_charmapcodec.py
return Message(**options).show()
res = Message(**options).show() if isinstance(res, bool): if res: return YES return NO return res
def _show(title=None, message=None, icon=None, type=None, **options): if icon: options["icon"] = icon if type: options["type"] = type if title: options["title"] = title if message: options["message"] = message return Message(**options).show()
b0c670ce398e7f8953b9a13ae0e40de6ef70d05f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b0c670ce398e7f8953b9a13ae0e40de6ef70d05f/tkMessageBox.py
except string.atoi_error: pass
except string.atoi_error: raise socket.error, "nonnumeric port"
def connect(self, host, port = 0): if not port: i = string.find(host, ':') if i >= 0: host, port = host[:i], host[i+1:] try: port = string.atoi(port) except string.atoi_error: pass if not port: port = HTTP_PORT self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) if self.debuglevel > 0: print 'connect:', (host, port) self.sock.connect(host, port)
928fcede658e8ae533677095e7055b58a64e7dc4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/928fcede658e8ae533677095e7055b58a64e7dc4/httplib.py
self._addkey(key, (pos, siz))
def __setitem__(self, key, val): if not type(key) == type('') == type(val): raise TypeError, "keys and values must be strings" if not self._index.has_key(key): (pos, siz) = self._addval(val) self._addkey(key, (pos, siz)) else: pos, siz = self._index[key] oldblocks = (siz + _BLOCKSIZE - 1) / _BLOCKSIZE newblocks = (len(val) + _BLOCKSIZE - 1) / _BLOCKSIZE if newblocks <= oldblocks: pos, siz = self._setval(pos, val) self._index[key] = pos, siz else: pos, siz = self._addval(val) self._index[key] = pos, siz self._addkey(key, (pos, siz))
a48dbde93b661372bb82e088672854c258dc6609 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a48dbde93b661372bb82e088672854c258dc6609/dumbdbm.py
nodes = []
nodesl = []
def expr_stmt(self, nodelist): # augassign testlist | testlist ('=' testlist)* en = nodelist[-1] exprNode = self.lookup_node(en)(en[1:]) if len(nodelist) == 1: n = Discard(exprNode) n.lineno = exprNode.lineno return n if nodelist[1][0] == token.EQUAL: nodes = [] for i in range(0, len(nodelist) - 2, 2): nodes.append(self.com_assign(nodelist[i], OP_ASSIGN)) n = Assign(nodes, exprNode) n.lineno = nodelist[1][2] else: lval = self.com_augassign(nodelist[0]) op = self.com_augassign_op(nodelist[1]) n = AugAssign(lval, op[1], exprNode) n.lineno = op[2] return n
51e234aa68697decbd360240bc68fb439f522951 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/51e234aa68697decbd360240bc68fb439f522951/transformer.py
nodes.append(self.com_assign(nodelist[i], OP_ASSIGN)) n = Assign(nodes, exprNode)
nodesl.append(self.com_assign(nodelist[i], OP_ASSIGN)) n = Assign(nodesl, exprNode)
def expr_stmt(self, nodelist): # augassign testlist | testlist ('=' testlist)* en = nodelist[-1] exprNode = self.lookup_node(en)(en[1:]) if len(nodelist) == 1: n = Discard(exprNode) n.lineno = exprNode.lineno return n if nodelist[1][0] == token.EQUAL: nodes = [] for i in range(0, len(nodelist) - 2, 2): nodes.append(self.com_assign(nodelist[i], OP_ASSIGN)) n = Assign(nodes, exprNode) n.lineno = nodelist[1][2] else: lval = self.com_augassign(nodelist[0]) op = self.com_augassign_op(nodelist[1]) n = AugAssign(lval, op[1], exprNode) n.lineno = op[2] return n
51e234aa68697decbd360240bc68fb439f522951 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/51e234aa68697decbd360240bc68fb439f522951/transformer.py
print 'd=', d
def message(str = "Hello, world!", id = MESSAGE_ID): """Show a simple alert with a text message""" d = GetNewDialog(id, -1) d.SetDialogDefaultItem(1) print 'd=', d tp, h, rect = d.GetDialogItem(2) SetDialogItemText(h, str) while 1: n = ModalDialog(None) if n == 1: break
10496eb5719d2f33ae92396431e0da0a6806d68d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/10496eb5719d2f33ae92396431e0da0a6806d68d/EditPythonPrefs.py
return [0]*7, None return map(lambda x: ord(x), opr.data), opr
return [0]*9, None options = map(lambda x: ord(x), opr.data) while len(options) < 9: options = options + [0] return options, opr
def getoptions(id): try: opr = GetResource('Popt', id) except (MacOS.Error, Res.Error): return [0]*7, None return map(lambda x: ord(x), opr.data), opr
10496eb5719d2f33ae92396431e0da0a6806d68d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/10496eb5719d2f33ae92396431e0da0a6806d68d/EditPythonPrefs.py
print 'Created new GUSI option' ngusi_opr = Resource(gusi_opr.data)
ngusi_opr = Resource(newdata)
def edit_preferences(): preff_handle = openpreffile(WRITE) l, sr = getprefpath(PATH_STRINGS_ID) if l == None: message('Cannot find any sys.path resource! (Old python?)') sys.exit(0) fss, dr, fss_changed = getprefdir(DIRECTORY_ID) if fss == None: fss = macfs.FSSpec(os.getcwd()) fss_changed = 1 options, opr = getoptions(OPTIONS_ID) saved_options = options[:] creator, type, delaycons, gusi_opr = getgusioptions(GUSI_ID) saved_gusi_options = creator, type, delaycons # Let the user play away result = interact(l, fss, (options, creator, type, delaycons), 'System-wide preferences') # See what we have to update, and how if result == None: sys.exit(0) pathlist, nfss, (options, creator, type, delaycons) = result if nfss != fss: fss_changed = 1 if fss_changed: alias = nfss.NewAlias() if dr: dr.data = alias.data dr.ChangedResource() else: dr = Resource(alias.data) dr.AddResource('alis', DIRECTORY_ID, '') if pathlist != l: if pathlist == []: if sr.HomeResFile() == preff_handle: sr.RemoveResource() elif sr.HomeResFile() == preff_handle: sr.data = listtores(pathlist) sr.ChangedResource() else: sr = Resource(listtores(pathlist)) sr.AddResource('STR#', PATH_STRINGS_ID, '') if options != saved_options: newdata = reduce(lambda x, y: x+chr(y), options, '') if opr and opr.HomeResFile() == preff_handle: opr.data = newdata opr.ChangedResource() else: opr = Resource(newdata) opr.AddResource('Popt', OPTIONS_ID, '') if (creator, type, delaycons) != saved_gusi_options: newdata = setgusioptions(gusi_opr, creator, type, delaycons) if gusi_opr.HomeResFile() == preff_handle: gusi_opr.data = newdata gusi_opr.ChangedResource() else: print 'Created new GUSI option' ngusi_opr = Resource(gusi_opr.data) ngusi_opr.AddResource('GU\267I', GUSI_ID, '') CloseResFile(preff_handle)
10496eb5719d2f33ae92396431e0da0a6806d68d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/10496eb5719d2f33ae92396431e0da0a6806d68d/EditPythonPrefs.py
if not opr:
if not gusi_opr:
def edit_applet(name): pref_handle = openpreffile(READ) app_handle = openapplet(name) notfound = '' l, sr = getprefpath(OVERRIDE_PATH_STRINGS_ID) if l == None: notfound = 'path' l, dummy = getprefpath(PATH_STRINGS_ID) if l == None: message('Cannot find any sys.path resource! (Old python?)') sys.exit(0) fss, dr, fss_changed = getprefdir(OVERRIDE_DIRECTORY_ID) if fss == None: if notfound: notfound = notfound + ', directory' else: notfound = 'directory' fss, dummy, dummy2 = getprefdir(DIRECTORY_ID) if fss == None: fss = macfs.FSSpec(os.getcwd()) fss_changed = 1 options, opr = getoptions(OVERRIDE_OPTIONS_ID) if not opr: if notfound: notfound = notfound + ', options' else: notfound = 'options' options, dummy = getoptions(OPTIONS_ID) saved_options = options[:] creator, type, delaycons, gusi_opr = getgusioptions(OVERRIDE_GUSI_ID) if not opr: if notfound: notfound = notfound + ', GUSI options' else: notfound = 'GUSI options' creator, type, delaycons, dummy = getgusioptions(GUSI_ID) saved_gusi_options = creator, type, delaycons dummy = dummy2 = None # Discard them. if notfound: message('Warning: initial %s taken from system-wide defaults'%notfound) # Let the user play away result = interact(l, fss, (options, creator, type, delaycons), name) # See what we have to update, and how if result == None: sys.exit(0) pathlist, nfss, options = result if nfss != fss: fss_changed = 1 if fss_changed: alias = nfss.NewAlias() if dr: dr.data = alias.data dr.ChangedResource() else: dr = Resource(alias.data) dr.AddResource('alis', OVERRIDE_DIRECTORY_ID, '') if pathlist != l: if pathlist == []: if sr.HomeResFile() == app_handle: sr.RemoveResource() elif sr and sr.HomeResFile() == app_handle: sr.data = listtores(pathlist) sr.ChangedResource() else: sr = Resource(listtores(pathlist)) sr.AddResource('STR#', OVERRIDE_PATH_STRINGS_ID, '') if options != saved_options: newdata = reduce(lambda x, y: x+chr(y), options, '') if opr and opr.HomeResFile() == app_handle: opr.data = newdata opr.ChangedResource() else: opr = Resource(newdata) opr.AddResource('Popt', OVERRIDE_OPTIONS_ID, '') if (creator, type, delaycons) != saved_gusi_options: newdata = setgusioptions(gusi_opr, creator, type, delaycons) if gusi_opr.HomeResFile == app_handle: gusi_opr.data = newdata gusi_opr.ChangedResource() else: gusi_opr = Resource(gusi_opr.data) gusi_opr.AddResource('GU\267I', OVERRIDE_GUSI_ID, '') CloseResFile(app_handle)
10496eb5719d2f33ae92396431e0da0a6806d68d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/10496eb5719d2f33ae92396431e0da0a6806d68d/EditPythonPrefs.py
creator, type, delaycons, dummy = getgusioptions(GUSI_ID)
creator, type, delaycons, gusi_opr = getgusioptions(GUSI_ID)
def edit_applet(name): pref_handle = openpreffile(READ) app_handle = openapplet(name) notfound = '' l, sr = getprefpath(OVERRIDE_PATH_STRINGS_ID) if l == None: notfound = 'path' l, dummy = getprefpath(PATH_STRINGS_ID) if l == None: message('Cannot find any sys.path resource! (Old python?)') sys.exit(0) fss, dr, fss_changed = getprefdir(OVERRIDE_DIRECTORY_ID) if fss == None: if notfound: notfound = notfound + ', directory' else: notfound = 'directory' fss, dummy, dummy2 = getprefdir(DIRECTORY_ID) if fss == None: fss = macfs.FSSpec(os.getcwd()) fss_changed = 1 options, opr = getoptions(OVERRIDE_OPTIONS_ID) if not opr: if notfound: notfound = notfound + ', options' else: notfound = 'options' options, dummy = getoptions(OPTIONS_ID) saved_options = options[:] creator, type, delaycons, gusi_opr = getgusioptions(OVERRIDE_GUSI_ID) if not opr: if notfound: notfound = notfound + ', GUSI options' else: notfound = 'GUSI options' creator, type, delaycons, dummy = getgusioptions(GUSI_ID) saved_gusi_options = creator, type, delaycons dummy = dummy2 = None # Discard them. if notfound: message('Warning: initial %s taken from system-wide defaults'%notfound) # Let the user play away result = interact(l, fss, (options, creator, type, delaycons), name) # See what we have to update, and how if result == None: sys.exit(0) pathlist, nfss, options = result if nfss != fss: fss_changed = 1 if fss_changed: alias = nfss.NewAlias() if dr: dr.data = alias.data dr.ChangedResource() else: dr = Resource(alias.data) dr.AddResource('alis', OVERRIDE_DIRECTORY_ID, '') if pathlist != l: if pathlist == []: if sr.HomeResFile() == app_handle: sr.RemoveResource() elif sr and sr.HomeResFile() == app_handle: sr.data = listtores(pathlist) sr.ChangedResource() else: sr = Resource(listtores(pathlist)) sr.AddResource('STR#', OVERRIDE_PATH_STRINGS_ID, '') if options != saved_options: newdata = reduce(lambda x, y: x+chr(y), options, '') if opr and opr.HomeResFile() == app_handle: opr.data = newdata opr.ChangedResource() else: opr = Resource(newdata) opr.AddResource('Popt', OVERRIDE_OPTIONS_ID, '') if (creator, type, delaycons) != saved_gusi_options: newdata = setgusioptions(gusi_opr, creator, type, delaycons) if gusi_opr.HomeResFile == app_handle: gusi_opr.data = newdata gusi_opr.ChangedResource() else: gusi_opr = Resource(gusi_opr.data) gusi_opr.AddResource('GU\267I', OVERRIDE_GUSI_ID, '') CloseResFile(app_handle)
10496eb5719d2f33ae92396431e0da0a6806d68d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/10496eb5719d2f33ae92396431e0da0a6806d68d/EditPythonPrefs.py
pathlist, nfss, options = result
pathlist, nfss, (options, creator, type, delaycons) = result
def edit_applet(name): pref_handle = openpreffile(READ) app_handle = openapplet(name) notfound = '' l, sr = getprefpath(OVERRIDE_PATH_STRINGS_ID) if l == None: notfound = 'path' l, dummy = getprefpath(PATH_STRINGS_ID) if l == None: message('Cannot find any sys.path resource! (Old python?)') sys.exit(0) fss, dr, fss_changed = getprefdir(OVERRIDE_DIRECTORY_ID) if fss == None: if notfound: notfound = notfound + ', directory' else: notfound = 'directory' fss, dummy, dummy2 = getprefdir(DIRECTORY_ID) if fss == None: fss = macfs.FSSpec(os.getcwd()) fss_changed = 1 options, opr = getoptions(OVERRIDE_OPTIONS_ID) if not opr: if notfound: notfound = notfound + ', options' else: notfound = 'options' options, dummy = getoptions(OPTIONS_ID) saved_options = options[:] creator, type, delaycons, gusi_opr = getgusioptions(OVERRIDE_GUSI_ID) if not opr: if notfound: notfound = notfound + ', GUSI options' else: notfound = 'GUSI options' creator, type, delaycons, dummy = getgusioptions(GUSI_ID) saved_gusi_options = creator, type, delaycons dummy = dummy2 = None # Discard them. if notfound: message('Warning: initial %s taken from system-wide defaults'%notfound) # Let the user play away result = interact(l, fss, (options, creator, type, delaycons), name) # See what we have to update, and how if result == None: sys.exit(0) pathlist, nfss, options = result if nfss != fss: fss_changed = 1 if fss_changed: alias = nfss.NewAlias() if dr: dr.data = alias.data dr.ChangedResource() else: dr = Resource(alias.data) dr.AddResource('alis', OVERRIDE_DIRECTORY_ID, '') if pathlist != l: if pathlist == []: if sr.HomeResFile() == app_handle: sr.RemoveResource() elif sr and sr.HomeResFile() == app_handle: sr.data = listtores(pathlist) sr.ChangedResource() else: sr = Resource(listtores(pathlist)) sr.AddResource('STR#', OVERRIDE_PATH_STRINGS_ID, '') if options != saved_options: newdata = reduce(lambda x, y: x+chr(y), options, '') if opr and opr.HomeResFile() == app_handle: opr.data = newdata opr.ChangedResource() else: opr = Resource(newdata) opr.AddResource('Popt', OVERRIDE_OPTIONS_ID, '') if (creator, type, delaycons) != saved_gusi_options: newdata = setgusioptions(gusi_opr, creator, type, delaycons) if gusi_opr.HomeResFile == app_handle: gusi_opr.data = newdata gusi_opr.ChangedResource() else: gusi_opr = Resource(gusi_opr.data) gusi_opr.AddResource('GU\267I', OVERRIDE_GUSI_ID, '') CloseResFile(app_handle)
10496eb5719d2f33ae92396431e0da0a6806d68d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/10496eb5719d2f33ae92396431e0da0a6806d68d/EditPythonPrefs.py
if gusi_opr.HomeResFile == app_handle:
id, type, name = gusi_opr.GetResInfo() if gusi_opr.HomeResFile() == app_handle and id == OVERRIDE_GUSI_ID:
def edit_applet(name): pref_handle = openpreffile(READ) app_handle = openapplet(name) notfound = '' l, sr = getprefpath(OVERRIDE_PATH_STRINGS_ID) if l == None: notfound = 'path' l, dummy = getprefpath(PATH_STRINGS_ID) if l == None: message('Cannot find any sys.path resource! (Old python?)') sys.exit(0) fss, dr, fss_changed = getprefdir(OVERRIDE_DIRECTORY_ID) if fss == None: if notfound: notfound = notfound + ', directory' else: notfound = 'directory' fss, dummy, dummy2 = getprefdir(DIRECTORY_ID) if fss == None: fss = macfs.FSSpec(os.getcwd()) fss_changed = 1 options, opr = getoptions(OVERRIDE_OPTIONS_ID) if not opr: if notfound: notfound = notfound + ', options' else: notfound = 'options' options, dummy = getoptions(OPTIONS_ID) saved_options = options[:] creator, type, delaycons, gusi_opr = getgusioptions(OVERRIDE_GUSI_ID) if not opr: if notfound: notfound = notfound + ', GUSI options' else: notfound = 'GUSI options' creator, type, delaycons, dummy = getgusioptions(GUSI_ID) saved_gusi_options = creator, type, delaycons dummy = dummy2 = None # Discard them. if notfound: message('Warning: initial %s taken from system-wide defaults'%notfound) # Let the user play away result = interact(l, fss, (options, creator, type, delaycons), name) # See what we have to update, and how if result == None: sys.exit(0) pathlist, nfss, options = result if nfss != fss: fss_changed = 1 if fss_changed: alias = nfss.NewAlias() if dr: dr.data = alias.data dr.ChangedResource() else: dr = Resource(alias.data) dr.AddResource('alis', OVERRIDE_DIRECTORY_ID, '') if pathlist != l: if pathlist == []: if sr.HomeResFile() == app_handle: sr.RemoveResource() elif sr and sr.HomeResFile() == app_handle: sr.data = listtores(pathlist) sr.ChangedResource() else: sr = Resource(listtores(pathlist)) sr.AddResource('STR#', OVERRIDE_PATH_STRINGS_ID, '') if options != saved_options: newdata = reduce(lambda x, y: x+chr(y), options, '') if opr and opr.HomeResFile() == app_handle: opr.data = newdata opr.ChangedResource() else: opr = Resource(newdata) opr.AddResource('Popt', OVERRIDE_OPTIONS_ID, '') if (creator, type, delaycons) != saved_gusi_options: newdata = setgusioptions(gusi_opr, creator, type, delaycons) if gusi_opr.HomeResFile == app_handle: gusi_opr.data = newdata gusi_opr.ChangedResource() else: gusi_opr = Resource(gusi_opr.data) gusi_opr.AddResource('GU\267I', OVERRIDE_GUSI_ID, '') CloseResFile(app_handle)
10496eb5719d2f33ae92396431e0da0a6806d68d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/10496eb5719d2f33ae92396431e0da0a6806d68d/EditPythonPrefs.py
gusi_opr = Resource(gusi_opr.data) gusi_opr.AddResource('GU\267I', OVERRIDE_GUSI_ID, '')
ngusi_opr = Resource(newdata) ngusi_opr.AddResource('GU\267I', OVERRIDE_GUSI_ID, '')
def edit_applet(name): pref_handle = openpreffile(READ) app_handle = openapplet(name) notfound = '' l, sr = getprefpath(OVERRIDE_PATH_STRINGS_ID) if l == None: notfound = 'path' l, dummy = getprefpath(PATH_STRINGS_ID) if l == None: message('Cannot find any sys.path resource! (Old python?)') sys.exit(0) fss, dr, fss_changed = getprefdir(OVERRIDE_DIRECTORY_ID) if fss == None: if notfound: notfound = notfound + ', directory' else: notfound = 'directory' fss, dummy, dummy2 = getprefdir(DIRECTORY_ID) if fss == None: fss = macfs.FSSpec(os.getcwd()) fss_changed = 1 options, opr = getoptions(OVERRIDE_OPTIONS_ID) if not opr: if notfound: notfound = notfound + ', options' else: notfound = 'options' options, dummy = getoptions(OPTIONS_ID) saved_options = options[:] creator, type, delaycons, gusi_opr = getgusioptions(OVERRIDE_GUSI_ID) if not opr: if notfound: notfound = notfound + ', GUSI options' else: notfound = 'GUSI options' creator, type, delaycons, dummy = getgusioptions(GUSI_ID) saved_gusi_options = creator, type, delaycons dummy = dummy2 = None # Discard them. if notfound: message('Warning: initial %s taken from system-wide defaults'%notfound) # Let the user play away result = interact(l, fss, (options, creator, type, delaycons), name) # See what we have to update, and how if result == None: sys.exit(0) pathlist, nfss, options = result if nfss != fss: fss_changed = 1 if fss_changed: alias = nfss.NewAlias() if dr: dr.data = alias.data dr.ChangedResource() else: dr = Resource(alias.data) dr.AddResource('alis', OVERRIDE_DIRECTORY_ID, '') if pathlist != l: if pathlist == []: if sr.HomeResFile() == app_handle: sr.RemoveResource() elif sr and sr.HomeResFile() == app_handle: sr.data = listtores(pathlist) sr.ChangedResource() else: sr = Resource(listtores(pathlist)) sr.AddResource('STR#', OVERRIDE_PATH_STRINGS_ID, '') if options != saved_options: newdata = reduce(lambda x, y: x+chr(y), options, '') if opr and opr.HomeResFile() == app_handle: opr.data = newdata opr.ChangedResource() else: opr = Resource(newdata) opr.AddResource('Popt', OVERRIDE_OPTIONS_ID, '') if (creator, type, delaycons) != saved_gusi_options: newdata = setgusioptions(gusi_opr, creator, type, delaycons) if gusi_opr.HomeResFile == app_handle: gusi_opr.data = newdata gusi_opr.ChangedResource() else: gusi_opr = Resource(gusi_opr.data) gusi_opr.AddResource('GU\267I', OVERRIDE_GUSI_ID, '') CloseResFile(app_handle)
10496eb5719d2f33ae92396431e0da0a6806d68d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/10496eb5719d2f33ae92396431e0da0a6806d68d/EditPythonPrefs.py
except IOError:
except IOError, reason:
def main(self):
f6fc4540841438757eaf6488fa3ca300f5e1361f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f6fc4540841438757eaf6488fa3ca300f5e1361f/pybench.py
except IOError:
except IOError, reason:
def main(self):
f6fc4540841438757eaf6488fa3ca300f5e1361f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f6fc4540841438757eaf6488fa3ca300f5e1361f/pybench.py
import os,sys
import os,sys,copy
# dlltool --dllname python15.dll --def python15.def \
b1dceae3df683a4ca673e45f25581048f31095c8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b1dceae3df683a4ca673e45f25581048f31095c8/cygwinccompiler.py
gcc_version = None dllwrap_version = None ld_version = None
obj_extension = ".o" static_lib_extension = ".a" shared_lib_extension = ".dll" static_lib_format = "lib%s%s" shared_lib_format = "%s%s" exe_extension = ".exe"
# dlltool --dllname python15.dll --def python15.def \
b1dceae3df683a4ca673e45f25581048f31095c8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b1dceae3df683a4ca673e45f25581048f31095c8/cygwinccompiler.py
if check_config_h()<=0:
check_result = check_config_h() self.debug_print("Python's GCC status: %s" % check_result) if check_result[:2] <> "OK":
def __init__ (self, verbose=0, dry_run=0, force=0):
b1dceae3df683a4ca673e45f25581048f31095c8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b1dceae3df683a4ca673e45f25581048f31095c8/cygwinccompiler.py
sys.stderr.write(self.compiler_type + ": gcc %s, ld %s, dllwrap %s\n" %
self.debug_print(self.compiler_type + ": gcc %s, ld %s, dllwrap %s\n" %
def __init__ (self, verbose=0, dry_run=0, force=0):
b1dceae3df683a4ca673e45f25581048f31095c8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b1dceae3df683a4ca673e45f25581048f31095c8/cygwinccompiler.py
extra_preargs = list(extra_preargs or []) libraries = list(libraries or [])
extra_preargs = copy.copy(extra_preargs or []) libraries = copy.copy(libraries or [])
def link_shared_object (self, objects, output_filename, output_dir=None, libraries=None, library_dirs=None, runtime_library_dirs=None, export_symbols=None, debug=0, extra_preargs=None, extra_postargs=None, build_temp=None): # use separate copies, so can modify the lists extra_preargs = list(extra_preargs or []) libraries = list(libraries or []) # Additional libraries libraries.extend(self.dll_libraries) # we want to put some files in the same directory as the # object files are, build_temp doesn't help much
b1dceae3df683a4ca673e45f25581048f31095c8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b1dceae3df683a4ca673e45f25581048f31095c8/cygwinccompiler.py
def check_config_h(): """Checks if the GCC compiler is mentioned in config.h. If it is not, compiling probably doesn't work. """ # return values # 2: OK, python was compiled with GCC # 1: OK, python's config.h mentions __GCC__ # 0: uncertain, because we couldn't check it # -1: probably not OK, because we didn't found it in config.h # You could check check_config_h()>0 => OK from distutils import sysconfig import string,sys # if sys.version contains GCC then python was compiled with # GCC, and the config.h file should be OK if -1 == string.find(sys.version,"GCC"): pass # go to the next test else: return 2 try: # It would probably better to read single lines to search. # But we do this only once, and it is fast enough f=open(sysconfig.get_config_h_filename()) s=f.read() f.close() # is somewhere a #ifdef __GNUC__ or something similar if -1 == string.find(s,"__GNUC__"): return -1 else: return 1 except IOError: # if we can't read this file, we cannot say it is wrong # the compiler will complain later about this file as missing pass return 0
b1dceae3df683a4ca673e45f25581048f31095c8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b1dceae3df683a4ca673e45f25581048f31095c8/cygwinccompiler.py
return 2
return "OK, python was compiled with GCC"
def check_config_h(): """Checks if the GCC compiler is mentioned in config.h. If it is not, compiling probably doesn't work. """ # return values # 2: OK, python was compiled with GCC # 1: OK, python's config.h mentions __GCC__ # 0: uncertain, because we couldn't check it # -1: probably not OK, because we didn't found it in config.h # You could check check_config_h()>0 => OK from distutils import sysconfig import string,sys # if sys.version contains GCC then python was compiled with # GCC, and the config.h file should be OK if -1 == string.find(sys.version,"GCC"): pass # go to the next test else: return 2 try: # It would probably better to read single lines to search. # But we do this only once, and it is fast enough f=open(sysconfig.get_config_h_filename()) s=f.read() f.close() # is somewhere a #ifdef __GNUC__ or something similar if -1 == string.find(s,"__GNUC__"): return -1 else: return 1 except IOError: # if we can't read this file, we cannot say it is wrong # the compiler will complain later about this file as missing pass return 0
b1dceae3df683a4ca673e45f25581048f31095c8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b1dceae3df683a4ca673e45f25581048f31095c8/cygwinccompiler.py
return -1 else: return 1
return "not OK, because we didn't found __GCC__ in config.h" else: return "OK, python's config.h mentions __GCC__"
# is somewhere a #ifdef __GNUC__ or something similar
b1dceae3df683a4ca673e45f25581048f31095c8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b1dceae3df683a4ca673e45f25581048f31095c8/cygwinccompiler.py
return 0
return "uncertain, because we couldn't check it"
# is somewhere a #ifdef __GNUC__ or something similar
b1dceae3df683a4ca673e45f25581048f31095c8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b1dceae3df683a4ca673e45f25581048f31095c8/cygwinccompiler.py
(fd, filename) = tempfile.mkstemp() file = os.fdopen(fd, 'w')
filename = tempfile.mktemp() file = open(filename, 'w')
def tempfilepager(text, cmd): """Page through text by invoking a program on a temporary file.""" import tempfile (fd, filename) = tempfile.mkstemp() file = os.fdopen(fd, 'w') file.write(text) file.close() try: os.system(cmd + ' ' + filename) finally: os.unlink(filename)
550e4e558367e0460a89fc4d253e491661a35b78 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/550e4e558367e0460a89fc4d253e491661a35b78/pydoc.py
r'(?P<header>[-\w_.*,(){} ]+)'
r'(?P<header>[^]]+)'
def remove_section(self, section): """Remove a file section.""" if self.__sections.has_key(section): del self.__sections[section] return 1 else: return 0
d4df94b56d762c8d68e186c256a6d4b741044046 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d4df94b56d762c8d68e186c256a6d4b741044046/ConfigParser.py
self.socket = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM) 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)
self._connect_unixsocket(address)
def __init__(self, address=('localhost', SYSLOG_UDP_PORT), facility=LOG_USER): """ Initialize a handler.
a1974c1459a424fdc9d8bbce55500f6006d0297d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a1974c1459a424fdc9d8bbce55500f6006d0297d/handlers.py
self.socket.send(msg)
try: self.socket.send(msg) except socket.error: self._connect_unixsocket(self.address) self.socket.send(msg)
def emit(self, record): """ Emit a record.
a1974c1459a424fdc9d8bbce55500f6006d0297d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a1974c1459a424fdc9d8bbce55500f6006d0297d/handlers.py
if cl.super:
if hasattr(cl, "super") and cl.super:
def listclasses(self): dir, file = os.path.split(self.file) name, ext = os.path.splitext(file) if os.path.normcase(ext) != ".py": return [] try: dict = pyclbr.readmodule_ex(name, [dir] + sys.path) except ImportError, msg: return [] items = [] self.classes = {} for key, cl in dict.items(): if cl.module == name: s = key if cl.super: supers = [] for sup in cl.super: if type(sup) is type(''): sname = sup else: sname = sup.name if sup.module != cl.module: sname = "%s.%s" % (sup.module, sname) supers.append(sname) s = s + "(%s)" % ", ".join(supers) items.append((cl.lineno, s)) self.classes[s] = cl items.sort() list = [] for item, s in items: list.append(s) return list
18acea7c8ea44fe1e655d64fe4f04fc9710f9ea7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/18acea7c8ea44fe1e655d64fe4f04fc9710f9ea7/ClassBrowser.py
all = self.db.guess_all_extensions('text/plain', strict=True) all.sort() eq(all, ['.bat', '.c', '.h', '.ksh', '.pl', '.txt'])
unless = self.failUnless all = Set(self.db.guess_all_extensions('text/plain', strict=True)) unless(all >= Set(['.bat', '.c', '.h', '.ksh', '.pl', '.txt']))
def test_guess_all_types(self): eq = self.assertEqual # First try strict all = self.db.guess_all_extensions('text/plain', strict=True) all.sort() eq(all, ['.bat', '.c', '.h', '.ksh', '.pl', '.txt']) # And now non-strict all = self.db.guess_all_extensions('image/jpg', strict=False) all.sort() eq(all, ['.jpg']) # And now for no hits all = self.db.guess_all_extensions('image/jpg', strict=True) eq(all, [])
ceca5d29243cae41f5304fa16bf54b7258f6ad42 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ceca5d29243cae41f5304fa16bf54b7258f6ad42/test_mimetypes.py
self.transient(parent)
if parent.winfo_viewable(): self.transient(parent)
def __init__(self, parent, title = None):
c73a4a4f5170c6f9631d8f07979af8a953507933 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c73a4a4f5170c6f9631d8f07979af8a953507933/tkSimpleDialog.py
self._do('tag_lower', belowThis)
self._do('lower', belowThis)
def lower(self, belowThis=None): self._do('tag_lower', belowThis)
40f3c7fdf0e16dab993315d8531d9b0078aac796 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/40f3c7fdf0e16dab993315d8531d9b0078aac796/Canvas.py
self._do('tag_raise', aboveThis)
self._do('raise', aboveThis)
def tkraise(self, aboveThis=None): self._do('tag_raise', aboveThis)
40f3c7fdf0e16dab993315d8531d9b0078aac796 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/40f3c7fdf0e16dab993315d8531d9b0078aac796/Canvas.py
elif type(in_file) == type(''):
elif isinstance(in_file, StringType):
def encode(in_file, out_file, name=None, mode=None): """Uuencode file""" # # If in_file is a pathname open it and change defaults # if in_file == '-': in_file = sys.stdin elif type(in_file) == type(''): if name is None: name = os.path.basename(in_file) if mode is None: try: mode = os.stat(in_file)[0] except AttributeError: pass in_file = open(in_file, 'rb') # # Open out_file if it is a pathname # if out_file == '-': out_file = sys.stdout elif type(out_file) == type(''): out_file = open(out_file, 'w') # # Set defaults for name and mode # if name is None: name = '-' if mode is None: mode = 0666 # # Write the data # out_file.write('begin %o %s\n' % ((mode&0777),name)) str = in_file.read(45) while len(str) > 0: out_file.write(binascii.b2a_uu(str)) str = in_file.read(45) out_file.write(' \nend\n')
59dae8ad360d2a13e1e7615c04c29863f7de562b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/59dae8ad360d2a13e1e7615c04c29863f7de562b/uu.py
elif type(out_file) == type(''):
elif isinstance(out_file, StringType):
def encode(in_file, out_file, name=None, mode=None): """Uuencode file""" # # If in_file is a pathname open it and change defaults # if in_file == '-': in_file = sys.stdin elif type(in_file) == type(''): if name is None: name = os.path.basename(in_file) if mode is None: try: mode = os.stat(in_file)[0] except AttributeError: pass in_file = open(in_file, 'rb') # # Open out_file if it is a pathname # if out_file == '-': out_file = sys.stdout elif type(out_file) == type(''): out_file = open(out_file, 'w') # # Set defaults for name and mode # if name is None: name = '-' if mode is None: mode = 0666 # # Write the data # out_file.write('begin %o %s\n' % ((mode&0777),name)) str = in_file.read(45) while len(str) > 0: out_file.write(binascii.b2a_uu(str)) str = in_file.read(45) out_file.write(' \nend\n')
59dae8ad360d2a13e1e7615c04c29863f7de562b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/59dae8ad360d2a13e1e7615c04c29863f7de562b/uu.py
def decode(in_file, out_file=None, mode=None):
def decode(in_file, out_file=None, mode=None, quiet=0):
def decode(in_file, out_file=None, mode=None): """Decode uuencoded file""" # # Open the input file, if needed. # if in_file == '-': in_file = sys.stdin elif type(in_file) == type(''): in_file = open(in_file) # # Read until a begin is encountered or we've exhausted the file # while 1: hdr = in_file.readline() if not hdr: raise Error, 'No valid begin line found in input file' if hdr[:5] != 'begin': continue hdrfields = hdr.split(" ", 2) if len(hdrfields) == 3 and hdrfields[0] == 'begin': try: int(hdrfields[1], 8) break except ValueError: pass if out_file is None: out_file = hdrfields[2].rstrip() if mode is None: mode = int(hdrfields[1], 8) # # Open the output file # if out_file == '-': out_file = sys.stdout elif type(out_file) == type(''): fp = open(out_file, 'wb') try: os.path.chmod(out_file, mode) except AttributeError: pass out_file = fp # # Main decoding loop # s = in_file.readline() while s and s != 'end\n': try: data = binascii.a2b_uu(s) except binascii.Error, v: # Workaround for broken uuencoders by /Fredrik Lundh nbytes = (((ord(s[0])-32) & 63) * 4 + 5) / 3 data = binascii.a2b_uu(s[:nbytes]) sys.stderr.write("Warning: %s\n" % str(v)) out_file.write(data) s = in_file.readline() if not s: raise Error, 'Truncated input file'
59dae8ad360d2a13e1e7615c04c29863f7de562b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/59dae8ad360d2a13e1e7615c04c29863f7de562b/uu.py
elif type(in_file) == type(''):
elif isinstance(in_file, StringType):
def decode(in_file, out_file=None, mode=None): """Decode uuencoded file""" # # Open the input file, if needed. # if in_file == '-': in_file = sys.stdin elif type(in_file) == type(''): in_file = open(in_file) # # Read until a begin is encountered or we've exhausted the file # while 1: hdr = in_file.readline() if not hdr: raise Error, 'No valid begin line found in input file' if hdr[:5] != 'begin': continue hdrfields = hdr.split(" ", 2) if len(hdrfields) == 3 and hdrfields[0] == 'begin': try: int(hdrfields[1], 8) break except ValueError: pass if out_file is None: out_file = hdrfields[2].rstrip() if mode is None: mode = int(hdrfields[1], 8) # # Open the output file # if out_file == '-': out_file = sys.stdout elif type(out_file) == type(''): fp = open(out_file, 'wb') try: os.path.chmod(out_file, mode) except AttributeError: pass out_file = fp # # Main decoding loop # s = in_file.readline() while s and s != 'end\n': try: data = binascii.a2b_uu(s) except binascii.Error, v: # Workaround for broken uuencoders by /Fredrik Lundh nbytes = (((ord(s[0])-32) & 63) * 4 + 5) / 3 data = binascii.a2b_uu(s[:nbytes]) sys.stderr.write("Warning: %s\n" % str(v)) out_file.write(data) s = in_file.readline() if not s: raise Error, 'Truncated input file'
59dae8ad360d2a13e1e7615c04c29863f7de562b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/59dae8ad360d2a13e1e7615c04c29863f7de562b/uu.py
elif type(out_file) == type(''):
elif isinstance(out_file, StringType):
def decode(in_file, out_file=None, mode=None): """Decode uuencoded file""" # # Open the input file, if needed. # if in_file == '-': in_file = sys.stdin elif type(in_file) == type(''): in_file = open(in_file) # # Read until a begin is encountered or we've exhausted the file # while 1: hdr = in_file.readline() if not hdr: raise Error, 'No valid begin line found in input file' if hdr[:5] != 'begin': continue hdrfields = hdr.split(" ", 2) if len(hdrfields) == 3 and hdrfields[0] == 'begin': try: int(hdrfields[1], 8) break except ValueError: pass if out_file is None: out_file = hdrfields[2].rstrip() if mode is None: mode = int(hdrfields[1], 8) # # Open the output file # if out_file == '-': out_file = sys.stdout elif type(out_file) == type(''): fp = open(out_file, 'wb') try: os.path.chmod(out_file, mode) except AttributeError: pass out_file = fp # # Main decoding loop # s = in_file.readline() while s and s != 'end\n': try: data = binascii.a2b_uu(s) except binascii.Error, v: # Workaround for broken uuencoders by /Fredrik Lundh nbytes = (((ord(s[0])-32) & 63) * 4 + 5) / 3 data = binascii.a2b_uu(s[:nbytes]) sys.stderr.write("Warning: %s\n" % str(v)) out_file.write(data) s = in_file.readline() if not s: raise Error, 'Truncated input file'
59dae8ad360d2a13e1e7615c04c29863f7de562b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/59dae8ad360d2a13e1e7615c04c29863f7de562b/uu.py
while s and s != 'end\n':
while s and s.strip() != 'end':
def decode(in_file, out_file=None, mode=None): """Decode uuencoded file""" # # Open the input file, if needed. # if in_file == '-': in_file = sys.stdin elif type(in_file) == type(''): in_file = open(in_file) # # Read until a begin is encountered or we've exhausted the file # while 1: hdr = in_file.readline() if not hdr: raise Error, 'No valid begin line found in input file' if hdr[:5] != 'begin': continue hdrfields = hdr.split(" ", 2) if len(hdrfields) == 3 and hdrfields[0] == 'begin': try: int(hdrfields[1], 8) break except ValueError: pass if out_file is None: out_file = hdrfields[2].rstrip() if mode is None: mode = int(hdrfields[1], 8) # # Open the output file # if out_file == '-': out_file = sys.stdout elif type(out_file) == type(''): fp = open(out_file, 'wb') try: os.path.chmod(out_file, mode) except AttributeError: pass out_file = fp # # Main decoding loop # s = in_file.readline() while s and s != 'end\n': try: data = binascii.a2b_uu(s) except binascii.Error, v: # Workaround for broken uuencoders by /Fredrik Lundh nbytes = (((ord(s[0])-32) & 63) * 4 + 5) / 3 data = binascii.a2b_uu(s[:nbytes]) sys.stderr.write("Warning: %s\n" % str(v)) out_file.write(data) s = in_file.readline() if not s: raise Error, 'Truncated input file'
59dae8ad360d2a13e1e7615c04c29863f7de562b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/59dae8ad360d2a13e1e7615c04c29863f7de562b/uu.py
sys.stderr.write("Warning: %s\n" % str(v))
if not quiet: sys.stderr.write("Warning: %s\n" % str(v))
def decode(in_file, out_file=None, mode=None): """Decode uuencoded file""" # # Open the input file, if needed. # if in_file == '-': in_file = sys.stdin elif type(in_file) == type(''): in_file = open(in_file) # # Read until a begin is encountered or we've exhausted the file # while 1: hdr = in_file.readline() if not hdr: raise Error, 'No valid begin line found in input file' if hdr[:5] != 'begin': continue hdrfields = hdr.split(" ", 2) if len(hdrfields) == 3 and hdrfields[0] == 'begin': try: int(hdrfields[1], 8) break except ValueError: pass if out_file is None: out_file = hdrfields[2].rstrip() if mode is None: mode = int(hdrfields[1], 8) # # Open the output file # if out_file == '-': out_file = sys.stdout elif type(out_file) == type(''): fp = open(out_file, 'wb') try: os.path.chmod(out_file, mode) except AttributeError: pass out_file = fp # # Main decoding loop # s = in_file.readline() while s and s != 'end\n': try: data = binascii.a2b_uu(s) except binascii.Error, v: # Workaround for broken uuencoders by /Fredrik Lundh nbytes = (((ord(s[0])-32) & 63) * 4 + 5) / 3 data = binascii.a2b_uu(s[:nbytes]) sys.stderr.write("Warning: %s\n" % str(v)) out_file.write(data) s = in_file.readline() if not s: raise Error, 'Truncated input file'
59dae8ad360d2a13e1e7615c04c29863f7de562b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/59dae8ad360d2a13e1e7615c04c29863f7de562b/uu.py
if type(output) == type(''):
if isinstance(output, StringType):
def test(): """uuencode/uudecode main program""" import getopt dopt = 0 topt = 0 input = sys.stdin output = sys.stdout ok = 1 try: optlist, args = getopt.getopt(sys.argv[1:], 'dt') except getopt.error: ok = 0 if not ok or len(args) > 2: print 'Usage:', sys.argv[0], '[-d] [-t] [input [output]]' print ' -d: Decode (in stead of encode)' print ' -t: data is text, encoded format unix-compatible text' sys.exit(1) for o, a in optlist: if o == '-d': dopt = 1 if o == '-t': topt = 1 if len(args) > 0: input = args[0] if len(args) > 1: output = args[1] if dopt: if topt: if type(output) == type(''): output = open(output, 'w') else: print sys.argv[0], ': cannot do -t to stdout' sys.exit(1) decode(input, output) else: if topt: if type(input) == type(''): input = open(input, 'r') else: print sys.argv[0], ': cannot do -t from stdin' sys.exit(1) encode(input, output)
59dae8ad360d2a13e1e7615c04c29863f7de562b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/59dae8ad360d2a13e1e7615c04c29863f7de562b/uu.py
if type(input) == type(''):
if isinstance(input, StringType):
def test(): """uuencode/uudecode main program""" import getopt dopt = 0 topt = 0 input = sys.stdin output = sys.stdout ok = 1 try: optlist, args = getopt.getopt(sys.argv[1:], 'dt') except getopt.error: ok = 0 if not ok or len(args) > 2: print 'Usage:', sys.argv[0], '[-d] [-t] [input [output]]' print ' -d: Decode (in stead of encode)' print ' -t: data is text, encoded format unix-compatible text' sys.exit(1) for o, a in optlist: if o == '-d': dopt = 1 if o == '-t': topt = 1 if len(args) > 0: input = args[0] if len(args) > 1: output = args[1] if dopt: if topt: if type(output) == type(''): output = open(output, 'w') else: print sys.argv[0], ': cannot do -t to stdout' sys.exit(1) decode(input, output) else: if topt: if type(input) == type(''): input = open(input, 'r') else: print sys.argv[0], ': cannot do -t from stdin' sys.exit(1) encode(input, output)
59dae8ad360d2a13e1e7615c04c29863f7de562b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/59dae8ad360d2a13e1e7615c04c29863f7de562b/uu.py
if not string.find(value, "%("):
if string.find(value, "%(") >= 0:
def get(self, section, option, raw=0, vars=None): """Get an option value for a given section.
a5a24b76f494c2e5a83c08061a471963e3e297a9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a5a24b76f494c2e5a83c08061a471963e3e297a9/ConfigParser.py
self.checkequal(('http://www.python.org', '', ''), S, 'rpartition', '?')
self.checkequal(('', '', 'http://www.python.org'), S, 'rpartition', '?')
def test_rpartition(self):
a0c95fa4d8f6cdc500e29a390bc7357a74b69572 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a0c95fa4d8f6cdc500e29a390bc7357a74b69572/string_tests.py
if type(url) == Types.StringType:
if type(url) == types.StringType:
def checkonly(package, url, version, verbose=0): if verbose >= VERBOSE_EACHFILE: print '%s:'%package if type(url) == Types.StringType: ok, newversion, fp = _check1version(package, url, version, verbose) else: for u in url: ok, newversion, fp = _check1version(package, u, version, verbose) if ok >= 0 and verbose < VERBOSE_CHECKALL: break return ok, newversion, fp
982209dc6920726236ec60f1fbc2e7143db0034f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/982209dc6920726236ec60f1fbc2e7143db0034f/pyversioncheck.py
or code in (302, 303) and m == "POST"):
or code in (301, 302, 303) and m == "POST"):
def redirect_request(self, req, fp, code, msg, headers, newurl): """Return a Request or None in response to a redirect.
162f081fb3c3e68e08e477a87311121fd5b72b18 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/162f081fb3c3e68e08e477a87311121fd5b72b18/urllib2.py
inf_msg = "The HTTP server returned a redirect error that would" \
inf_msg = "The HTTP server returned a redirect error that would " \
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)
162f081fb3c3e68e08e477a87311121fd5b72b18 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/162f081fb3c3e68e08e477a87311121fd5b72b18/urllib2.py
"The last 302 error message was:\n"
"The last 30x error message was:\n"
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)
162f081fb3c3e68e08e477a87311121fd5b72b18 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/162f081fb3c3e68e08e477a87311121fd5b72b18/urllib2.py
self.assertEqual(pwd.getpwuid(e.pw_uid), e)
entriesbyuid.setdefault(e.pw_uid, []).append(e) for e in entries: self.assert_(pwd.getpwuid(e.pw_uid) in entriesbyuid[e.pw_uid])
def test_values(self): entries = pwd.getpwall()
66e1e508b98f5538066a3e4196b83eb5b6904269 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/66e1e508b98f5538066a3e4196b83eb5b6904269/test_pwd.py
while 1:
while True:
def _do_cmp(f1, f2): bufsize = BUFSIZE fp1 = open(f1, 'rb') fp2 = open(f2, 'rb') while 1: b1 = fp1.read(bufsize) b2 = fp2.read(bufsize) if b1 != b2: return 0 if not b1: return 1
05595e9d73b2c05fcd9492cf8f5d126282b82053 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/05595e9d73b2c05fcd9492cf8f5d126282b82053/filecmp.py
return 0
return False
def _do_cmp(f1, f2): bufsize = BUFSIZE fp1 = open(f1, 'rb') fp2 = open(f2, 'rb') while 1: b1 = fp1.read(bufsize) b2 = fp2.read(bufsize) if b1 != b2: return 0 if not b1: return 1
05595e9d73b2c05fcd9492cf8f5d126282b82053 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/05595e9d73b2c05fcd9492cf8f5d126282b82053/filecmp.py
return 1
return True
def _do_cmp(f1, f2): bufsize = BUFSIZE fp1 = open(f1, 'rb') fp2 = open(f2, 'rb') while 1: b1 = fp1.read(bufsize) b2 = fp2.read(bufsize) if b1 != b2: return 0 if not b1: return 1
05595e9d73b2c05fcd9492cf8f5d126282b82053 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/05595e9d73b2c05fcd9492cf8f5d126282b82053/filecmp.py
__p4_attrs = ('subdirs',) __p3_attrs = ('same_files', 'diff_files', 'funny_files') __p2_attrs = ('common_dirs', 'common_files', 'common_funny') __p1_attrs = ('common', 'left_only', 'right_only') __p0_attrs = ('left_list', 'right_list') def __getattr__(self, attr): if attr in self.__p4_attrs: self.phase4() elif attr in self.__p3_attrs: self.phase3() elif attr in self.__p2_attrs: self.phase2() elif attr in self.__p1_attrs: self.phase1() elif attr in self.__p0_attrs: self.phase0() else: raise AttributeError, attr return getattr(self, attr)
def phase0(self): # Compare everything except common subdirectories self.left_list = _filter(os.listdir(self.left), self.hide+self.ignore) self.right_list = _filter(os.listdir(self.right), self.hide+self.ignore) self.left_list.sort() self.right_list.sort()
05595e9d73b2c05fcd9492cf8f5d126282b82053 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/05595e9d73b2c05fcd9492cf8f5d126282b82053/filecmp.py
a_only, b_only = [], [] common = {} b = {} for fnm in self.right_list: b[fnm] = 1 for x in self.left_list: if b.get(x, 0): common[x] = 1 else: a_only.append(x) for x in self.right_list: if common.get(x, 0): pass else: b_only.append(x)
b = dict.fromkeys(self.right_list) common = dict.fromkeys(ifilter(b.has_key, self.left_list)) self.left_only = list(ifilterfalse(common.has_key, self.left_list)) self.right_only = list(ifilterfalse(common.has_key, self.right_list))
def phase1(self): # Compute common names a_only, b_only = [], [] common = {} b = {} for fnm in self.right_list: b[fnm] = 1 for x in self.left_list: if b.get(x, 0): common[x] = 1 else: a_only.append(x) for x in self.right_list: if common.get(x, 0): pass else: b_only.append(x) self.common = common.keys() self.left_only = a_only self.right_only = b_only
05595e9d73b2c05fcd9492cf8f5d126282b82053 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/05595e9d73b2c05fcd9492cf8f5d126282b82053/filecmp.py
self.left_only = a_only self.right_only = b_only
def phase1(self): # Compute common names a_only, b_only = [], [] common = {} b = {} for fnm in self.right_list: b[fnm] = 1 for x in self.left_list: if b.get(x, 0): common[x] = 1 else: a_only.append(x) for x in self.right_list: if common.get(x, 0): pass else: b_only.append(x) self.common = common.keys() self.left_only = a_only self.right_only = b_only
05595e9d73b2c05fcd9492cf8f5d126282b82053 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/05595e9d73b2c05fcd9492cf8f5d126282b82053/filecmp.py
def _cmp(a, b, sh):
def _cmp(a, b, sh, abs=abs, cmp=cmp):
def _cmp(a, b, sh): try: return not abs(cmp(a, b, sh)) except os.error: return 2
05595e9d73b2c05fcd9492cf8f5d126282b82053 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/05595e9d73b2c05fcd9492cf8f5d126282b82053/filecmp.py
def _filter(list, skip): result = [] for item in list: if item not in skip: result.append(item) return result
def _filter(flist, skip): return list(ifilterfalse(skip.__contains__, flist))
def _filter(list, skip): result = [] for item in list: if item not in skip: result.append(item) return result
05595e9d73b2c05fcd9492cf8f5d126282b82053 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/05595e9d73b2c05fcd9492cf8f5d126282b82053/filecmp.py
byte_increments = [ord(c) for c in co.co_lnotab[0::2]] line_increments = [ord(c) for c in co.co_lnotab[1::2]] table_length = len(byte_increments) lineno = co.co_firstlineno table_index = 0 while (table_index < table_length and byte_increments[table_index] == 0): lineno += line_increments[table_index] table_index += 1 addr = 0 line_incr = 0
def disassemble(co, lasti=-1): """Disassemble a code object.""" code = co.co_code byte_increments = [ord(c) for c in co.co_lnotab[0::2]] line_increments = [ord(c) for c in co.co_lnotab[1::2]] table_length = len(byte_increments) # == len(line_increments) lineno = co.co_firstlineno table_index = 0 while (table_index < table_length and byte_increments[table_index] == 0): lineno += line_increments[table_index] table_index += 1 addr = 0 line_incr = 0 labels = findlabels(code) n = len(code) i = 0 extended_arg = 0 free = None while i < n: c = code[i] op = ord(c) if i >= addr: lineno += line_incr while table_index < table_length: addr += byte_increments[table_index] line_incr = line_increments[table_index] table_index += 1 if line_incr: break else: addr = sys.maxint if i > 0: print print "%3d"%lineno, else: print ' ', if i == lasti: print '-->', else: print ' ', if i in labels: print '>>', else: print ' ', print `i`.rjust(4), print opname[op].ljust(20), i = i+1 if op >= HAVE_ARGUMENT: oparg = ord(code[i]) + ord(code[i+1])*256 + extended_arg extended_arg = 0 i = i+2 if op == EXTENDED_ARG: extended_arg = oparg*65536L print `oparg`.rjust(5), if op in hasconst: print '(' + `co.co_consts[oparg]` + ')', elif op in hasname: print '(' + co.co_names[oparg] + ')', elif op in hasjrel: print '(to ' + `i + oparg` + ')', elif op in haslocal: print '(' + co.co_varnames[oparg] + ')', elif op in hascompare: print '(' + cmp_op[oparg] + ')', elif op in hasfree: if free is None: free = co.co_cellvars + co.co_freevars print '(' + free[oparg] + ')', print
9c8f7eafcad308792478c2636dff8fe9110e0d77 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9c8f7eafcad308792478c2636dff8fe9110e0d77/dis.py
if i >= addr: lineno += line_incr while table_index < table_length: addr += byte_increments[table_index] line_incr = line_increments[table_index] table_index += 1 if line_incr: break else: addr = sys.maxint
if i in linestarts:
def disassemble(co, lasti=-1): """Disassemble a code object.""" code = co.co_code byte_increments = [ord(c) for c in co.co_lnotab[0::2]] line_increments = [ord(c) for c in co.co_lnotab[1::2]] table_length = len(byte_increments) # == len(line_increments) lineno = co.co_firstlineno table_index = 0 while (table_index < table_length and byte_increments[table_index] == 0): lineno += line_increments[table_index] table_index += 1 addr = 0 line_incr = 0 labels = findlabels(code) n = len(code) i = 0 extended_arg = 0 free = None while i < n: c = code[i] op = ord(c) if i >= addr: lineno += line_incr while table_index < table_length: addr += byte_increments[table_index] line_incr = line_increments[table_index] table_index += 1 if line_incr: break else: addr = sys.maxint if i > 0: print print "%3d"%lineno, else: print ' ', if i == lasti: print '-->', else: print ' ', if i in labels: print '>>', else: print ' ', print `i`.rjust(4), print opname[op].ljust(20), i = i+1 if op >= HAVE_ARGUMENT: oparg = ord(code[i]) + ord(code[i+1])*256 + extended_arg extended_arg = 0 i = i+2 if op == EXTENDED_ARG: extended_arg = oparg*65536L print `oparg`.rjust(5), if op in hasconst: print '(' + `co.co_consts[oparg]` + ')', elif op in hasname: print '(' + co.co_names[oparg] + ')', elif op in hasjrel: print '(to ' + `i + oparg` + ')', elif op in haslocal: print '(' + co.co_varnames[oparg] + ')', elif op in hascompare: print '(' + cmp_op[oparg] + ')', elif op in hasfree: if free is None: free = co.co_cellvars + co.co_freevars print '(' + free[oparg] + ')', print
9c8f7eafcad308792478c2636dff8fe9110e0d77 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9c8f7eafcad308792478c2636dff8fe9110e0d77/dis.py
print "%3d"%lineno,
print "%3d" % linestarts[i],
def disassemble(co, lasti=-1): """Disassemble a code object.""" code = co.co_code byte_increments = [ord(c) for c in co.co_lnotab[0::2]] line_increments = [ord(c) for c in co.co_lnotab[1::2]] table_length = len(byte_increments) # == len(line_increments) lineno = co.co_firstlineno table_index = 0 while (table_index < table_length and byte_increments[table_index] == 0): lineno += line_increments[table_index] table_index += 1 addr = 0 line_incr = 0 labels = findlabels(code) n = len(code) i = 0 extended_arg = 0 free = None while i < n: c = code[i] op = ord(c) if i >= addr: lineno += line_incr while table_index < table_length: addr += byte_increments[table_index] line_incr = line_increments[table_index] table_index += 1 if line_incr: break else: addr = sys.maxint if i > 0: print print "%3d"%lineno, else: print ' ', if i == lasti: print '-->', else: print ' ', if i in labels: print '>>', else: print ' ', print `i`.rjust(4), print opname[op].ljust(20), i = i+1 if op >= HAVE_ARGUMENT: oparg = ord(code[i]) + ord(code[i+1])*256 + extended_arg extended_arg = 0 i = i+2 if op == EXTENDED_ARG: extended_arg = oparg*65536L print `oparg`.rjust(5), if op in hasconst: print '(' + `co.co_consts[oparg]` + ')', elif op in hasname: print '(' + co.co_names[oparg] + ')', elif op in hasjrel: print '(to ' + `i + oparg` + ')', elif op in haslocal: print '(' + co.co_varnames[oparg] + ')', elif op in hascompare: print '(' + cmp_op[oparg] + ')', elif op in hasfree: if free is None: free = co.co_cellvars + co.co_freevars print '(' + free[oparg] + ')', print
9c8f7eafcad308792478c2636dff8fe9110e0d77 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9c8f7eafcad308792478c2636dff8fe9110e0d77/dis.py
if op == opmap['SET_LINENO'] and i > 0: print
def disassemble_string(code, lasti=-1, varnames=None, names=None, constants=None): labels = findlabels(code) n = len(code) i = 0 while i < n: c = code[i] op = ord(c) if op == opmap['SET_LINENO'] and i > 0: print # Extra blank line if i == lasti: print '-->', else: print ' ', if i in labels: print '>>', else: print ' ', print `i`.rjust(4), print opname[op].ljust(15), i = i+1 if op >= HAVE_ARGUMENT: oparg = ord(code[i]) + ord(code[i+1])*256 i = i+2 print `oparg`.rjust(5), if op in hasconst: if constants: print '(' + `constants[oparg]` + ')', else: print '(%d)'%oparg, elif op in hasname: if names is not None: print '(' + names[oparg] + ')', else: print '(%d)'%oparg, elif op in hasjrel: print '(to ' + `i + oparg` + ')', elif op in haslocal: if varnames: print '(' + varnames[oparg] + ')', else: print '(%d)' % oparg, elif op in hascompare: print '(' + cmp_op[oparg] + ')', print
9c8f7eafcad308792478c2636dff8fe9110e0d77 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9c8f7eafcad308792478c2636dff8fe9110e0d77/dis.py
self._file_.close()
if hasattr(self, "_file_"): self._file_.close()
def __del__(self): self._file_.close()
16c4aa441bba65ac0e4386e4b04d25119e8fc609 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/16c4aa441bba65ac0e4386e4b04d25119e8fc609/posixfile.py
str = self.__rmjunk.sub('', str)
for pattern, replacement in REPLACEMENTS: str = pattern.sub(replacement, str)
def __init__(self, link, str, seqno): self.links = [link] self.seqno = seqno # remove <#\d+#> left in by moving the data out of LaTeX2HTML str = self.__rmjunk.sub('', str) # build up the text self.text = split_entry_text(str) self.key = split_entry_key(str)
63a0191c8af880be4bc45ec4147de74b74df10cc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/63a0191c8af880be4bc45ec4147de74b74df10cc/buildindex.py
def _msgobj(self, filename):
def _msgobj(self, filename, strict=False):
def _msgobj(self, filename): fp = openfile(findfile(filename)) try: msg = email.message_from_file(fp) finally: fp.close() return msg
a0a00761a500478223f0e076983fddcdfb4ac587 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a0a00761a500478223f0e076983fddcdfb4ac587/test_email.py
msg = email.message_from_file(fp)
msg = email.message_from_file(fp, strict=strict)
def _msgobj(self, filename): fp = openfile(findfile(filename)) try: msg = email.message_from_file(fp) finally: fp.close() return msg
a0a00761a500478223f0e076983fddcdfb4ac587 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a0a00761a500478223f0e076983fddcdfb4ac587/test_email.py
eq(msg.get_payload(decode=1), None)
eq(msg.get_payload(decode=True), None)
def test_get_decoded_payload(self): eq = self.assertEqual msg = self._msgobj('msg_10.txt') # The outer message is a multipart eq(msg.get_payload(decode=1), None) # Subpart 1 is 7bit encoded eq(msg.get_payload(0).get_payload(decode=1), 'This is a 7bit encoded message.\n') # Subpart 2 is quopri eq(msg.get_payload(1).get_payload(decode=1), '\xa1This is a Quoted Printable encoded message!\n') # Subpart 3 is base64 eq(msg.get_payload(2).get_payload(decode=1), 'This is a Base64 encoded message.') # Subpart 4 has no Content-Transfer-Encoding: header. eq(msg.get_payload(3).get_payload(decode=1), 'This has no Content-Transfer-Encoding: header.\n')
a0a00761a500478223f0e076983fddcdfb4ac587 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a0a00761a500478223f0e076983fddcdfb4ac587/test_email.py
eq(msg.get_payload(0).get_payload(decode=1),
eq(msg.get_payload(0).get_payload(decode=True),
def test_get_decoded_payload(self): eq = self.assertEqual msg = self._msgobj('msg_10.txt') # The outer message is a multipart eq(msg.get_payload(decode=1), None) # Subpart 1 is 7bit encoded eq(msg.get_payload(0).get_payload(decode=1), 'This is a 7bit encoded message.\n') # Subpart 2 is quopri eq(msg.get_payload(1).get_payload(decode=1), '\xa1This is a Quoted Printable encoded message!\n') # Subpart 3 is base64 eq(msg.get_payload(2).get_payload(decode=1), 'This is a Base64 encoded message.') # Subpart 4 has no Content-Transfer-Encoding: header. eq(msg.get_payload(3).get_payload(decode=1), 'This has no Content-Transfer-Encoding: header.\n')
a0a00761a500478223f0e076983fddcdfb4ac587 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a0a00761a500478223f0e076983fddcdfb4ac587/test_email.py
eq(msg.get_payload(1).get_payload(decode=1),
eq(msg.get_payload(1).get_payload(decode=True),
def test_get_decoded_payload(self): eq = self.assertEqual msg = self._msgobj('msg_10.txt') # The outer message is a multipart eq(msg.get_payload(decode=1), None) # Subpart 1 is 7bit encoded eq(msg.get_payload(0).get_payload(decode=1), 'This is a 7bit encoded message.\n') # Subpart 2 is quopri eq(msg.get_payload(1).get_payload(decode=1), '\xa1This is a Quoted Printable encoded message!\n') # Subpart 3 is base64 eq(msg.get_payload(2).get_payload(decode=1), 'This is a Base64 encoded message.') # Subpart 4 has no Content-Transfer-Encoding: header. eq(msg.get_payload(3).get_payload(decode=1), 'This has no Content-Transfer-Encoding: header.\n')
a0a00761a500478223f0e076983fddcdfb4ac587 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a0a00761a500478223f0e076983fddcdfb4ac587/test_email.py
eq(msg.get_payload(2).get_payload(decode=1),
eq(msg.get_payload(2).get_payload(decode=True),
def test_get_decoded_payload(self): eq = self.assertEqual msg = self._msgobj('msg_10.txt') # The outer message is a multipart eq(msg.get_payload(decode=1), None) # Subpart 1 is 7bit encoded eq(msg.get_payload(0).get_payload(decode=1), 'This is a 7bit encoded message.\n') # Subpart 2 is quopri eq(msg.get_payload(1).get_payload(decode=1), '\xa1This is a Quoted Printable encoded message!\n') # Subpart 3 is base64 eq(msg.get_payload(2).get_payload(decode=1), 'This is a Base64 encoded message.') # Subpart 4 has no Content-Transfer-Encoding: header. eq(msg.get_payload(3).get_payload(decode=1), 'This has no Content-Transfer-Encoding: header.\n')
a0a00761a500478223f0e076983fddcdfb4ac587 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a0a00761a500478223f0e076983fddcdfb4ac587/test_email.py
eq(msg.get_payload(3).get_payload(decode=1),
eq(msg.get_payload(3).get_payload(decode=True),
def test_get_decoded_payload(self): eq = self.assertEqual msg = self._msgobj('msg_10.txt') # The outer message is a multipart eq(msg.get_payload(decode=1), None) # Subpart 1 is 7bit encoded eq(msg.get_payload(0).get_payload(decode=1), 'This is a 7bit encoded message.\n') # Subpart 2 is quopri eq(msg.get_payload(1).get_payload(decode=1), '\xa1This is a Quoted Printable encoded message!\n') # Subpart 3 is base64 eq(msg.get_payload(2).get_payload(decode=1), 'This is a Base64 encoded message.') # Subpart 4 has no Content-Transfer-Encoding: header. eq(msg.get_payload(3).get_payload(decode=1), 'This has no Content-Transfer-Encoding: header.\n')
a0a00761a500478223f0e076983fddcdfb4ac587 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a0a00761a500478223f0e076983fddcdfb4ac587/test_email.py
eq(msg.get_param('importance', unquote=0), '"high value"')
eq(msg.get_param('importance', unquote=False), '"high value"')
def test_set_param(self): eq = self.assertEqual msg = Message() msg.set_param('charset', 'iso-2022-jp') eq(msg.get_param('charset'), 'iso-2022-jp') msg.set_param('importance', 'high value') eq(msg.get_param('importance'), 'high value') eq(msg.get_param('importance', unquote=0), '"high value"') eq(msg.get_params(), [('text/plain', ''), ('charset', 'iso-2022-jp'), ('importance', 'high value')]) eq(msg.get_params(unquote=0), [('text/plain', ''), ('charset', '"iso-2022-jp"'), ('importance', '"high value"')]) msg.set_param('charset', 'iso-9999-xx', header='X-Jimmy') eq(msg.get_param('charset', header='X-Jimmy'), 'iso-9999-xx')
a0a00761a500478223f0e076983fddcdfb4ac587 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a0a00761a500478223f0e076983fddcdfb4ac587/test_email.py
eq(msg.get_params(unquote=0), [('text/plain', ''),
eq(msg.get_params(unquote=False), [('text/plain', ''),
def test_set_param(self): eq = self.assertEqual msg = Message() msg.set_param('charset', 'iso-2022-jp') eq(msg.get_param('charset'), 'iso-2022-jp') msg.set_param('importance', 'high value') eq(msg.get_param('importance'), 'high value') eq(msg.get_param('importance', unquote=0), '"high value"') eq(msg.get_params(), [('text/plain', ''), ('charset', 'iso-2022-jp'), ('importance', 'high value')]) eq(msg.get_params(unquote=0), [('text/plain', ''), ('charset', '"iso-2022-jp"'), ('importance', '"high value"')]) msg.set_param('charset', 'iso-9999-xx', header='X-Jimmy') eq(msg.get_param('charset', header='X-Jimmy'), 'iso-9999-xx')
a0a00761a500478223f0e076983fddcdfb4ac587 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a0a00761a500478223f0e076983fddcdfb4ac587/test_email.py
g = Generator(s, mangle_from_=1)
g = Generator(s, mangle_from_=True)
def test_mangled_from(self): s = StringIO() g = Generator(s, mangle_from_=1) g.flatten(self.msg) self.assertEqual(s.getvalue(), """\
a0a00761a500478223f0e076983fddcdfb4ac587 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a0a00761a500478223f0e076983fddcdfb4ac587/test_email.py
g = Generator(s, mangle_from_=0)
g = Generator(s, mangle_from_=False)
def test_dont_mangle_from(self): s = StringIO() g = Generator(s, mangle_from_=0) g.flatten(self.msg) self.assertEqual(s.getvalue(), """\
a0a00761a500478223f0e076983fddcdfb4ac587 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a0a00761a500478223f0e076983fddcdfb4ac587/test_email.py
p = Parser(strict=1)
p = Parser(strict=True)
def test_bogus_boundary(self): fp = openfile(findfile('msg_15.txt')) try: data = fp.read() finally: fp.close() p = Parser(strict=1) # Note, under a future non-strict parsing mode, this would parse the # message into the intended message tree. self.assertRaises(Errors.BoundaryError, p.parsestr, data)
a0a00761a500478223f0e076983fddcdfb4ac587 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a0a00761a500478223f0e076983fddcdfb4ac587/test_email.py
Utils.parsedate(Utils.formatdate(now, localtime=1))[:6],
Utils.parsedate(Utils.formatdate(now, localtime=True))[:6],
def test_formatdate_localtime(self): now = time.time() self.assertEqual( Utils.parsedate(Utils.formatdate(now, localtime=1))[:6], time.localtime(now)[:6])
a0a00761a500478223f0e076983fddcdfb4ac587 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a0a00761a500478223f0e076983fddcdfb4ac587/test_email.py
eq(he('hello\nworld', keep_eols=1),
eq(he('hello\nworld', keep_eols=True),
def test_header_encode(self): eq = self.assertEqual he = base64MIME.header_encode eq(he('hello'), '=?iso-8859-1?b?aGVsbG8=?=') eq(he('hello\nworld'), '=?iso-8859-1?b?aGVsbG8NCndvcmxk?=') # Test the charset option eq(he('hello', charset='iso-8859-2'), '=?iso-8859-2?b?aGVsbG8=?=') # Test the keep_eols flag eq(he('hello\nworld', keep_eols=1), '=?iso-8859-1?b?aGVsbG8Kd29ybGQ=?=') # Test the maxlinelen argument eq(he('xxxx ' * 20, maxlinelen=40), """\
a0a00761a500478223f0e076983fddcdfb4ac587 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a0a00761a500478223f0e076983fddcdfb4ac587/test_email.py
eq(he('hello\nworld', keep_eols=1), '=?iso-8859-1?q?hello=0Aworld?=')
eq(he('hello\nworld', keep_eols=True), '=?iso-8859-1?q?hello=0Aworld?=')
def test_header_encode(self): eq = self.assertEqual he = quopriMIME.header_encode eq(he('hello'), '=?iso-8859-1?q?hello?=') eq(he('hello\nworld'), '=?iso-8859-1?q?hello=0D=0Aworld?=') # Test the charset option eq(he('hello', charset='iso-8859-2'), '=?iso-8859-2?q?hello?=') # Test the keep_eols flag eq(he('hello\nworld', keep_eols=1), '=?iso-8859-1?q?hello=0Aworld?=') # Test a non-ASCII character eq(he('hello\xc7there'), '=?iso-8859-1?q?hello=C7there?=') # Test the maxlinelen argument eq(he('xxxx ' * 20, maxlinelen=40), """\
a0a00761a500478223f0e076983fddcdfb4ac587 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a0a00761a500478223f0e076983fddcdfb4ac587/test_email.py
eq(msg.get_param('title', unquote=0),
eq(msg.get_param('title', unquote=False),
def test_get_param(self): eq = self.assertEqual msg = self._msgobj('msg_29.txt') eq(msg.get_param('title'), ('us-ascii', 'en', 'This is even more ***fun*** isn\'t it!')) eq(msg.get_param('title', unquote=0), ('us-ascii', 'en', '"This is even more ***fun*** isn\'t it!"'))
a0a00761a500478223f0e076983fddcdfb4ac587 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a0a00761a500478223f0e076983fddcdfb4ac587/test_email.py
self.num_regs=len(regs)/2
self.num_regs=len(regs)
def match(self, string, pos=0):
af8d2bf4d8643f7da7389a475f364c21836e8afe /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/af8d2bf4d8643f7da7389a475f364c21836e8afe/re.py
def list(self, which=None):
def list(self, msg=None):
def list(self, which=None): """Request listing, return result. Result is in form ['response', ['mesg_num octets', ...]].
f6ae743cb53a2953c7fb063963ec48029206c8b0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f6ae743cb53a2953c7fb063963ec48029206c8b0/poplib.py
Result is in form ['response', ['mesg_num octets', ...]]. Unsure what the optional 'msg' arg does.
Result without a msg argument is in form ['response', ['mesg_num octets', ...]]. Result when a msg argument is given is a single response: the "scan listing" for that message.
def list(self, which=None): """Request listing, return result. Result is in form ['response', ['mesg_num octets', ...]].
f6ae743cb53a2953c7fb063963ec48029206c8b0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f6ae743cb53a2953c7fb063963ec48029206c8b0/poplib.py