rem
stringlengths 1
322k
| add
stringlengths 0
2.05M
| context
stringlengths 4
228k
| meta
stringlengths 156
215
|
---|---|---|---|
>>> class Seq: ... def __getitem__(self, i): ... if i >= 0 and i < 3: return i ... raise IndexError ... >>> a, b, c = Seq() >>> a == 0 and b == 1 and c == 2 True | def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError | 3981511070311e958bd2cd48b1ab16b24f8b350e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3981511070311e958bd2cd48b1ab16b24f8b350e/test_unpack.py |
|
if verbose: print 'unpack non-sequence' try: a, b, c = 7 raise TestFailed except TypeError: pass | Single element unpacking, with extra syntax | def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError | 3981511070311e958bd2cd48b1ab16b24f8b350e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3981511070311e958bd2cd48b1ab16b24f8b350e/test_unpack.py |
if verbose: print 'unpack tuple wrong size' try: a, b = t raise TestFailed except ValueError: pass | Now for some failures | def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError | 3981511070311e958bd2cd48b1ab16b24f8b350e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3981511070311e958bd2cd48b1ab16b24f8b350e/test_unpack.py |
if verbose: print 'unpack list wrong size' try: a, b = l raise TestFailed except ValueError: pass | Unpacking non-sequence | def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError | 3981511070311e958bd2cd48b1ab16b24f8b350e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3981511070311e958bd2cd48b1ab16b24f8b350e/test_unpack.py |
if verbose: print 'unpack sequence too short' try: a, b, c, d = Seq() raise TestFailed except ValueError: pass | Unpacking tuple of wrong size | def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError | 3981511070311e958bd2cd48b1ab16b24f8b350e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3981511070311e958bd2cd48b1ab16b24f8b350e/test_unpack.py |
if verbose: print 'unpack sequence too long' try: a, b = Seq() raise TestFailed except ValueError: pass | Unpacking tuple of wrong size | def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError | 3981511070311e958bd2cd48b1ab16b24f8b350e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3981511070311e958bd2cd48b1ab16b24f8b350e/test_unpack.py |
class BozoError(Exception): pass | Unpacking sequence too short | def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError | 3981511070311e958bd2cd48b1ab16b24f8b350e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3981511070311e958bd2cd48b1ab16b24f8b350e/test_unpack.py |
class BadSeq: def __getitem__(self, i): if i >= 0 and i < 3: return i elif i == 3: raise BozoError else: raise IndexError | >>> a, b, c, d = Seq() Traceback (most recent call last): ... ValueError: need more than 3 values to unpack | def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError | 3981511070311e958bd2cd48b1ab16b24f8b350e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3981511070311e958bd2cd48b1ab16b24f8b350e/test_unpack.py |
if verbose: print 'unpack sequence too long, wrong error' try: a, b, c, d, e = BadSeq() raise TestFailed except BozoError: pass | >>> a, b = Seq() Traceback (most recent call last): ... ValueError: too many values to unpack | def __getitem__(self, i): if i >= 0 and i < 3: return i elif i == 3: raise BozoError else: raise IndexError | 3981511070311e958bd2cd48b1ab16b24f8b350e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3981511070311e958bd2cd48b1ab16b24f8b350e/test_unpack.py |
if verbose: print 'unpack sequence too short, wrong error' try: a, b, c = BadSeq() raise TestFailed except BozoError: pass | Unpacking a sequence where the test for too long raises a different kind of error >>> class BozoError(Exception): ... pass ... >>> class BadSeq: ... def __getitem__(self, i): ... if i >= 0 and i < 3: ... return i ... elif i == 3: ... raise BozoError ... else: ... raise IndexError ... Trigger code while not expecting an IndexError (unpack sequence too long, wrong error) >>> a, b, c, d, e = BadSeq() Traceback (most recent call last): ... BozoError Trigger code while expecting an IndexError (unpack sequence too short, wrong error) >>> a, b, c = BadSeq() Traceback (most recent call last): ... BozoError """ __test__ = {'doctests' : doctests} def test_main(verbose=False): import sys from test import test_support from test import test_unpack test_support.run_doctest(test_unpack, verbose) if __name__ == "__main__": test_main(verbose=True) | def __getitem__(self, i): if i >= 0 and i < 3: return i elif i == 3: raise BozoError else: raise IndexError | 3981511070311e958bd2cd48b1ab16b24f8b350e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3981511070311e958bd2cd48b1ab16b24f8b350e/test_unpack.py |
self.d.GetDialogWindow().ShowWindow() | self.w.ShowWindow() | def __init__(self, title="Working...", maxval=100, label="", id=263): self.maxval = maxval self.curval = -1 self.d = GetNewDialog(id, -1) self.label(label) self._update(0) self.d.AutoSizeDialog() self.title(title) self.d.GetDialogWindow().ShowWindow() self.d.DrawDialog() | 784c61105343c2d4180128c382b65f48028dd8a3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/784c61105343c2d4180128c382b65f48028dd8a3/EasyDialogs.py |
self.d.BringToFront() self.d.HideWindow() | self.w.BringToFront() self.w.HideWindow() del self.w | def __del__( self ): self.d.BringToFront() self.d.HideWindow() del self.d | 784c61105343c2d4180128c382b65f48028dd8a3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/784c61105343c2d4180128c382b65f48028dd8a3/EasyDialogs.py |
w = self.d.GetDialogWindow() w.BringToFront() w.SetWTitle(newstr) | self.w.BringToFront() self.w.SetWTitle(newstr) | def title(self, newstr=""): """title(text) - Set title of progress window""" w = self.d.GetDialogWindow() w.BringToFront() w.SetWTitle(newstr) | 784c61105343c2d4180128c382b65f48028dd8a3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/784c61105343c2d4180128c382b65f48028dd8a3/EasyDialogs.py |
self.d.GetDialogWindow().BringToFront() | self.w.BringToFront() | def label( self, *newstr ): """label(text) - Set text in progress box""" self.d.GetDialogWindow().BringToFront() if newstr: self._label = lf2cr(newstr[0]) text_h = self.d.GetDialogItemAsControl(2) SetDialogItemText(text_h, self._label) | 784c61105343c2d4180128c382b65f48028dd8a3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/784c61105343c2d4180128c382b65f48028dd8a3/EasyDialogs.py |
raise TestFailed, "NotImplemented should have caused TypeErrpr" | raise TestFailed, "NotImplemented should have caused TypeError" | def __add__(self, other): return NotImplemented | 1af5e35a98008e5eb6406dc4f4ff831eee23a0e5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1af5e35a98008e5eb6406dc4f4ff831eee23a0e5/test_descr.py |
import os, fcntl | import os try: import fcntl except ImportError: fcntl = None | def export_add(self, x, y): return x + y | e29002ccb009966bc23d632f534d62bad56d0fd3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e29002ccb009966bc23d632f534d62bad56d0fd3/SimpleXMLRPCServer.py |
if hasattr(fcntl, 'FD_CLOEXEC'): | if fcntl is not None and hasattr(fcntl, 'FD_CLOEXEC'): | def __init__(self, addr, requestHandler=SimpleXMLRPCRequestHandler, logRequests=True, allow_none=False, encoding=None): self.logRequests = logRequests | e29002ccb009966bc23d632f534d62bad56d0fd3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e29002ccb009966bc23d632f534d62bad56d0fd3/SimpleXMLRPCServer.py |
if status != 100: | if status != CONTINUE: | def begin(self): if self.msg is not None: # we've already started reading the response return | 39a317890fa7651e8f124c1a566af5f7a72da792 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/39a317890fa7651e8f124c1a566af5f7a72da792/httplib.py |
if (status == 204 or status == 304 or | if (status == NO_CONTENT or status == NOT_MODIFIED or | def begin(self): if self.msg is not None: # we've already started reading the response return | 39a317890fa7651e8f124c1a566af5f7a72da792 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/39a317890fa7651e8f124c1a566af5f7a72da792/httplib.py |
try: str(u'Hello \u00E1') except Exception, e: sampleUnicodeEncodeError = e try: unicode('\xff') except Exception, e: sampleUnicodeDecodeError = e | try: str(u'Hello \u00E1') except Exception, e: sampleUnicodeEncodeError = e try: unicode('\xff') except Exception, e: sampleUnicodeDecodeError = e | def testAttributes(self): # test that exception attributes are happy try: str(u'Hello \u00E1') except Exception, e: sampleUnicodeEncodeError = e | 80dc76e9072c4adaedf5c52032699b859c82eca2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/80dc76e9072c4adaedf5c52032699b859c82eca2/test_exceptions.py |
except NameError: pass import pickle, random | except NameError: pass | def testAttributes(self): # test that exception attributes are happy try: str(u'Hello \u00E1') except Exception, e: sampleUnicodeEncodeError = e | 80dc76e9072c4adaedf5c52032699b859c82eca2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/80dc76e9072c4adaedf5c52032699b859c82eca2/test_exceptions.py |
if len(args) == 2: raise exc else: raise exc(*args[1]) | if len(args) == 2: raise exc else: raise exc(*args[1]) | def testAttributes(self): # test that exception attributes are happy try: str(u'Hello \u00E1') except Exception, e: sampleUnicodeEncodeError = e | 80dc76e9072c4adaedf5c52032699b859c82eca2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/80dc76e9072c4adaedf5c52032699b859c82eca2/test_exceptions.py |
type(e) is not exc): | type(e) is not exc): | def testAttributes(self): # test that exception attributes are happy try: str(u'Hello \u00E1') except Exception, e: sampleUnicodeEncodeError = e | 80dc76e9072c4adaedf5c52032699b859c82eca2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/80dc76e9072c4adaedf5c52032699b859c82eca2/test_exceptions.py |
new = pickle.loads(pickle.dumps(e, random.randint(0, 2))) for checkArgName in expected: self.assertEquals(repr(getattr(e, checkArgName)), repr(expected[checkArgName]), 'pickled exception "%s", attribute "%s' % (repr(e), checkArgName)) | for p in pickle, cPickle: for protocol in range(p.HIGHEST_PROTOCOL + 1): new = p.loads(p.dumps(e, protocol)) for checkArgName in expected: got = repr(getattr(new, checkArgName)) want = repr(expected[checkArgName]) self.assertEquals(got, want, 'pickled "%r", attribute "%s' % (e, checkArgName)) | def testAttributes(self): # test that exception attributes are happy try: str(u'Hello \u00E1') except Exception, e: sampleUnicodeEncodeError = e | 80dc76e9072c4adaedf5c52032699b859c82eca2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/80dc76e9072c4adaedf5c52032699b859c82eca2/test_exceptions.py |
if not included: self._version = dict.get('Version', '0.1') if self._version != PIMP_VERSION: sys.stderr.write("Warning: database version %s does not match %s\n" | if included: version = dict.get('Version') if version and version > self._version: sys.stderr.write("Warning: included database %s is for pimp version %s\n" % (url, version)) else: self._version = dict.get('Version') if not self._version: sys.stderr.write("Warning: database has no Version information\n") elif self._version > PIMP_VERSION: sys.stderr.write("Warning: database version %s newer than pimp version %s\n" | def appendURL(self, url, included=0): """Append packages from the database with the given URL. Only the first database should specify included=0, so the global information (maintainer, description) get stored.""" if url in self._urllist: return self._urllist.append(url) fp = urllib2.urlopen(url).fp dict = plistlib.Plist.fromFile(fp) # Test here for Pimp version, etc if not included: self._version = dict.get('Version', '0.1') if self._version != PIMP_VERSION: sys.stderr.write("Warning: database version %s does not match %s\n" % (self._version, PIMP_VERSION)) self._maintainer = dict.get('Maintainer', '') self._description = dict.get('Description', '') self._appendPackages(dict['Packages']) others = dict.get('Include', []) for url in others: self.appendURL(url, included=1) | b789a060ee0ac49785ce6718f0da5abf19a1629a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b789a060ee0ac49785ce6718f0da5abf19a1629a/pimp.py |
print " -D dir Set destination directory (default: site-packages)" | print " -D dir Set destination directory" print " (default: %s)" % DEFAULT_INSTALLDIR print " -u url URL for database" print " (default: %s)" % DEFAULT_PIMPDATABASE | def _help(): print "Usage: pimp [options] -s [package ...] List installed status" print " pimp [options] -l [package ...] Show package information" print " pimp [options] -i package ... Install packages" print " pimp -d Dump database to stdout" print "Options:" print " -v Verbose" print " -f Force installation" print " -D dir Set destination directory (default: site-packages)" sys.exit(1) | b789a060ee0ac49785ce6718f0da5abf19a1629a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b789a060ee0ac49785ce6718f0da5abf19a1629a/pimp.py |
opts, args = getopt.getopt(sys.argv[1:], "slifvdD:") except getopt.Error: | opts, args = getopt.getopt(sys.argv[1:], "slifvdD:Vu:") except getopt.GetoptError: | def _help(): print "Usage: pimp [options] -s [package ...] List installed status" print " pimp [options] -l [package ...] Show package information" print " pimp [options] -i package ... Install packages" print " pimp -d Dump database to stdout" print "Options:" print " -v Verbose" print " -f Force installation" print " -D dir Set destination directory (default: site-packages)" sys.exit(1) | b789a060ee0ac49785ce6718f0da5abf19a1629a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b789a060ee0ac49785ce6718f0da5abf19a1629a/pimp.py |
_run(mode, verbose, force, args, prefargs) | if mode == 'version': print 'Pimp version %s; module name is %s' % (PIMP_VERSION, __name__) else: _run(mode, verbose, force, args, prefargs) if __name__ != 'pimp_update': try: import pimp_update except ImportError: pass else: if pimp_update.PIMP_VERSION <= PIMP_VERSION: import warnings warnings.warn("pimp_update is version %s, not newer than pimp version %s" % (pimp_update.PIMP_VERSION, PIMP_VERSION)) else: from pimp_update import * | def _help(): print "Usage: pimp [options] -s [package ...] List installed status" print " pimp [options] -l [package ...] Show package information" print " pimp [options] -i package ... Install packages" print " pimp -d Dump database to stdout" print "Options:" print " -v Verbose" print " -f Force installation" print " -D dir Set destination directory (default: site-packages)" sys.exit(1) | b789a060ee0ac49785ce6718f0da5abf19a1629a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b789a060ee0ac49785ce6718f0da5abf19a1629a/pimp.py |
n = 100 | n = 200 | def test_tee(self): n = 100 def irange(n): for i in xrange(n): yield i | ad983e79d6f215235d205245c2599620e33cf719 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ad983e79d6f215235d205245c2599620e33cf719/test_itertools.py |
self.assertEqual(a.next(), 0) self.assertEqual(a.next(), 1) | for i in xrange(100): self.assertEqual(a.next(), i) | def irange(n): for i in xrange(n): yield i | ad983e79d6f215235d205245c2599620e33cf719 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ad983e79d6f215235d205245c2599620e33cf719/test_itertools.py |
self.assertEqual(a.next(), 0) self.assertEqual(a.next(), 1) | for i in xrange(100): self.assertEqual(a.next(), i) | def irange(n): for i in xrange(n): yield i | ad983e79d6f215235d205245c2599620e33cf719 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ad983e79d6f215235d205245c2599620e33cf719/test_itertools.py |
self.assertEqual(list(a), range(2, n)) | self.assertEqual(list(a), range(100, n)) | def irange(n): for i in xrange(n): yield i | ad983e79d6f215235d205245c2599620e33cf719 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ad983e79d6f215235d205245c2599620e33cf719/test_itertools.py |
try: class A(tee): pass except TypeError: pass else: self.fail("tee constructor should not be subclassable") a, b = tee(xrange(10)) self.assertRaises(TypeError, type(a)) self.assert_(a is iter(a)) | self.assertRaises(TypeError, tee, [1,2], 3, 'x') a, b = tee('abc') c = type(a)('def') self.assertEqual(list(c), list('def')) a, b, c = tee(xrange(2000), 3) for i in xrange(100): self.assertEqual(a.next(), i) self.assertEqual(list(b), range(2000)) self.assertEqual([c.next(), c.next()], range(2)) self.assertEqual(list(a), range(100,2000)) self.assertEqual(list(c), range(2,2000)) a, b = tee('abc') c, d = tee(a) self.assert_(a is c) | def irange(n): for i in xrange(n): yield i | ad983e79d6f215235d205245c2599620e33cf719 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ad983e79d6f215235d205245c2599620e33cf719/test_itertools.py |
def test_tee(self): a = [] p, q = t = tee([a]*2) a += [a, p, q, t] p.next() del a, p, q, t | def test_starmap(self): a = [] self.makecycle(starmap(lambda *t: t, [(a,a)]*2), a) | ad983e79d6f215235d205245c2599620e33cf719 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ad983e79d6f215235d205245c2599620e33cf719/test_itertools.py |
|
... return izip(a, islice(b, 1, None)) | ... try: ... b.next() ... except StopIteration: ... pass ... return izip(a, b) | >>> def pairwise(iterable): | ad983e79d6f215235d205245c2599620e33cf719 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ad983e79d6f215235d205245c2599620e33cf719/test_itertools.py |
print>>sys.__stderr__, "Idle accepted connection from ", address | def accept(self): working_sock, address = self.listening_sock.accept() if address[0] == '127.0.0.1': print>>sys.__stderr__, "Idle accepted connection from ", address SocketIO.__init__(self, working_sock) else: print>>sys.__stderr__, "Invalid host: ", address raise socket.error | 74d93c81c190f9dfd7302e17536a49b8dd4f7da6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/74d93c81c190f9dfd7302e17536a49b8dd4f7da6/rpc.py |
|
print>>sys.__stderr__, "Invalid host: ", address | print>>sys.__stderr__, "** Invalid host: ", address | def accept(self): working_sock, address = self.listening_sock.accept() if address[0] == '127.0.0.1': print>>sys.__stderr__, "Idle accepted connection from ", address SocketIO.__init__(self, working_sock) else: print>>sys.__stderr__, "Invalid host: ", address raise socket.error | 74d93c81c190f9dfd7302e17536a49b8dd4f7da6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/74d93c81c190f9dfd7302e17536a49b8dd4f7da6/rpc.py |
def __init__(self, completekey='tab'): | def __init__(self, completekey='tab', stdin=None, stdout=None): | def __init__(self, completekey='tab'): """Instantiate a line-oriented interpreter framework. | 983b00882400986b292837a25ef866fc897d603b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/983b00882400986b292837a25ef866fc897d603b/cmd.py |
The optional argument is the readline name of a completion key; it defaults to the Tab key. If completekey is not None and the readline module is available, command completion is done automatically. """ | The optional argument 'completekey' is the readline name of a completion key; it defaults to the Tab key. If completekey is not None and the readline module is available, command completion is done automatically. The optional arguments stdin and stdout specify alternate input and output file objects; if not specified, sys.stdin and sys.stdout are used. """ import sys if stdin is not None: self.stdin = stdin else: self.stdin = sys.stdin if stdout is not None: self.stdout = stdout else: self.stdout = sys.stdout | def __init__(self, completekey='tab'): """Instantiate a line-oriented interpreter framework. | 983b00882400986b292837a25ef866fc897d603b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/983b00882400986b292837a25ef866fc897d603b/cmd.py |
print self.intro | self.stdout.write(str(self.intro)+"\n") | def cmdloop(self, intro=None): """Repeatedly issue a prompt, accept input, parse an initial prefix off the received input, and dispatch to action methods, passing them the remainder of the line as argument. | 983b00882400986b292837a25ef866fc897d603b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/983b00882400986b292837a25ef866fc897d603b/cmd.py |
sys.stdout.write(self.prompt) sys.stdout.flush() line = sys.stdin.readline() | self.stdout.write(self.prompt) self.stdout.flush() line = self.stdin.readline() | def cmdloop(self, intro=None): """Repeatedly issue a prompt, accept input, parse an initial prefix off the received input, and dispatch to action methods, passing them the remainder of the line as argument. | 983b00882400986b292837a25ef866fc897d603b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/983b00882400986b292837a25ef866fc897d603b/cmd.py |
print '*** Unknown syntax:', line | self.stdout.write('*** Unknown syntax: %s\n'%line) | def default(self, line): """Called on an input line when the command prefix is not recognized. | 983b00882400986b292837a25ef866fc897d603b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/983b00882400986b292837a25ef866fc897d603b/cmd.py |
print doc | self.stdout.write("%s\n"%str(doc)) | def do_help(self, arg): if arg: # XXX check arg syntax try: func = getattr(self, 'help_' + arg) except AttributeError: try: doc=getattr(self, 'do_' + arg).__doc__ if doc: print doc return except AttributeError: pass print self.nohelp % (arg,) return func() else: names = self.get_names() cmds_doc = [] cmds_undoc = [] help = {} for name in names: if name[:5] == 'help_': help[name[5:]]=1 names.sort() # There can be duplicates if routines overridden prevname = '' for name in names: if name[:3] == 'do_': if name == prevname: continue prevname = name cmd=name[3:] if cmd in help: cmds_doc.append(cmd) del help[cmd] elif getattr(self, name).__doc__: cmds_doc.append(cmd) else: cmds_undoc.append(cmd) print self.doc_leader self.print_topics(self.doc_header, cmds_doc, 15,80) self.print_topics(self.misc_header, help.keys(),15,80) self.print_topics(self.undoc_header, cmds_undoc, 15,80) | 983b00882400986b292837a25ef866fc897d603b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/983b00882400986b292837a25ef866fc897d603b/cmd.py |
print self.nohelp % (arg,) | self.stdout.write("%s\n"%str(self.nohelp % (arg,))) | def do_help(self, arg): if arg: # XXX check arg syntax try: func = getattr(self, 'help_' + arg) except AttributeError: try: doc=getattr(self, 'do_' + arg).__doc__ if doc: print doc return except AttributeError: pass print self.nohelp % (arg,) return func() else: names = self.get_names() cmds_doc = [] cmds_undoc = [] help = {} for name in names: if name[:5] == 'help_': help[name[5:]]=1 names.sort() # There can be duplicates if routines overridden prevname = '' for name in names: if name[:3] == 'do_': if name == prevname: continue prevname = name cmd=name[3:] if cmd in help: cmds_doc.append(cmd) del help[cmd] elif getattr(self, name).__doc__: cmds_doc.append(cmd) else: cmds_undoc.append(cmd) print self.doc_leader self.print_topics(self.doc_header, cmds_doc, 15,80) self.print_topics(self.misc_header, help.keys(),15,80) self.print_topics(self.undoc_header, cmds_undoc, 15,80) | 983b00882400986b292837a25ef866fc897d603b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/983b00882400986b292837a25ef866fc897d603b/cmd.py |
print self.doc_leader | self.stdout.write("%s\n"%str(self.doc_leader)) | def do_help(self, arg): if arg: # XXX check arg syntax try: func = getattr(self, 'help_' + arg) except AttributeError: try: doc=getattr(self, 'do_' + arg).__doc__ if doc: print doc return except AttributeError: pass print self.nohelp % (arg,) return func() else: names = self.get_names() cmds_doc = [] cmds_undoc = [] help = {} for name in names: if name[:5] == 'help_': help[name[5:]]=1 names.sort() # There can be duplicates if routines overridden prevname = '' for name in names: if name[:3] == 'do_': if name == prevname: continue prevname = name cmd=name[3:] if cmd in help: cmds_doc.append(cmd) del help[cmd] elif getattr(self, name).__doc__: cmds_doc.append(cmd) else: cmds_undoc.append(cmd) print self.doc_leader self.print_topics(self.doc_header, cmds_doc, 15,80) self.print_topics(self.misc_header, help.keys(),15,80) self.print_topics(self.undoc_header, cmds_undoc, 15,80) | 983b00882400986b292837a25ef866fc897d603b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/983b00882400986b292837a25ef866fc897d603b/cmd.py |
print header | self.stdout.write("%s\n"%str(header)) | def print_topics(self, header, cmds, cmdlen, maxcol): if cmds: print header if self.ruler: print self.ruler * len(header) self.columnize(cmds, maxcol-1) print | 983b00882400986b292837a25ef866fc897d603b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/983b00882400986b292837a25ef866fc897d603b/cmd.py |
print self.ruler * len(header) | self.stdout.write("%s\n"%str(self.ruler * len(header))) | def print_topics(self, header, cmds, cmdlen, maxcol): if cmds: print header if self.ruler: print self.ruler * len(header) self.columnize(cmds, maxcol-1) print | 983b00882400986b292837a25ef866fc897d603b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/983b00882400986b292837a25ef866fc897d603b/cmd.py |
print | self.stdout.write("\n") | def print_topics(self, header, cmds, cmdlen, maxcol): if cmds: print header if self.ruler: print self.ruler * len(header) self.columnize(cmds, maxcol-1) print | 983b00882400986b292837a25ef866fc897d603b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/983b00882400986b292837a25ef866fc897d603b/cmd.py |
print "<empty>" | self.stdout.write("<empty>\n") | def columnize(self, list, displaywidth=80): """Display a list of strings as a compact set of columns. | 983b00882400986b292837a25ef866fc897d603b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/983b00882400986b292837a25ef866fc897d603b/cmd.py |
print list[0] | self.stdout.write('%s\n'%str(list[0])) | def columnize(self, list, displaywidth=80): """Display a list of strings as a compact set of columns. | 983b00882400986b292837a25ef866fc897d603b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/983b00882400986b292837a25ef866fc897d603b/cmd.py |
print " ".join(texts) | self.stdout.write("%s\n"%str(" ".join(texts))) | def columnize(self, list, displaywidth=80): """Display a list of strings as a compact set of columns. | 983b00882400986b292837a25ef866fc897d603b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/983b00882400986b292837a25ef866fc897d603b/cmd.py |
self.__messages.setdefault(msg, []).append(entry) | self.__messages.setdefault(msg, {})[entry] = 1 | def __addentry(self, msg, lineno=None): if lineno is None: lineno = self.__lineno if not msg in self.__options.toexclude: entry = (self.__curfile, lineno) self.__messages.setdefault(msg, []).append(entry) | 6e972414bec063ce953df9dea5a13239ac7e5604 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6e972414bec063ce953df9dea5a13239ac7e5604/pygettext.py |
sys.stderr.write(_("Can't read --exclude-file: %s") % options.excludefilename) | print >> sys.stderr, _( "Can't read --exclude-file: %s") % options.excludefilename | def main(): global default_keywords try: opts, args = getopt.getopt( sys.argv[1:], 'ad:DEhk:Kno:p:S:Vvw:x:', ['extract-all', 'default-domain', 'escape', 'help', 'keyword=', 'no-default-keywords', 'add-location', 'no-location', 'output=', 'output-dir=', 'style=', 'verbose', 'version', 'width=', 'exclude-file=', 'docstrings', ]) except getopt.error, msg: usage(1, msg) # for holding option values class Options: # constants GNU = 1 SOLARIS = 2 # defaults extractall = 0 # FIXME: currently this option has no effect at all. escape = 0 keywords = [] outpath = '' outfile = 'messages.pot' writelocations = 1 locationstyle = GNU verbose = 0 width = 78 excludefilename = '' docstrings = 0 options = Options() locations = {'gnu' : options.GNU, 'solaris' : options.SOLARIS, } # parse options for opt, arg in opts: if opt in ('-h', '--help'): usage(0) elif opt in ('-a', '--extract-all'): options.extractall = 1 elif opt in ('-d', '--default-domain'): options.outfile = arg + '.pot' elif opt in ('-E', '--escape'): options.escape = 1 elif opt in ('-D', '--docstrings'): options.docstrings = 1 elif opt in ('-k', '--keyword'): options.keywords.append(arg) elif opt in ('-K', '--no-default-keywords'): default_keywords = [] elif opt in ('-n', '--add-location'): options.writelocations = 1 elif opt in ('--no-location',): options.writelocations = 0 elif opt in ('-S', '--style'): options.locationstyle = locations.get(arg.lower()) if options.locationstyle is None: usage(1, _('Invalid value for --style: %s') % arg) elif opt in ('-o', '--output'): options.outfile = arg elif opt in ('-p', '--output-dir'): options.outpath = arg elif opt in ('-v', '--verbose'): options.verbose = 1 elif opt in ('-V', '--version'): print _('pygettext.py (xgettext for Python) %s') % __version__ sys.exit(0) elif opt in ('-w', '--width'): try: options.width = int(arg) except ValueError: usage(1, _('--width argument must be an integer: %s') % arg) elif opt in ('-x', '--exclude-file'): options.excludefilename = arg # calculate escapes make_escapes(options.escape) # calculate all keywords options.keywords.extend(default_keywords) # initialize list of strings to exclude if options.excludefilename: try: fp = open(options.excludefilename) options.toexclude = fp.readlines() fp.close() except IOError: sys.stderr.write(_("Can't read --exclude-file: %s") % options.excludefilename) sys.exit(1) else: options.toexclude = [] # slurp through all the files eater = TokenEater(options) for filename in args: if filename == '-': if options.verbose: print _('Reading standard input') fp = sys.stdin closep = 0 else: if options.verbose: print _('Working on %s') % filename fp = open(filename) closep = 1 try: eater.set_filename(filename) try: tokenize.tokenize(fp.readline, eater) except tokenize.TokenError, e: sys.stderr.write('%s: %s, line %d, column %d\n' % (e[0], filename, e[1][0], e[1][1])) finally: if closep: fp.close() # write the output if options.outfile == '-': fp = sys.stdout closep = 0 else: if options.outpath: options.outfile = os.path.join(options.outpath, options.outfile) fp = open(options.outfile, 'w') closep = 1 try: eater.write(fp) finally: if closep: fp.close() | 6e972414bec063ce953df9dea5a13239ac7e5604 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6e972414bec063ce953df9dea5a13239ac7e5604/pygettext.py |
sys.stderr.write('%s: %s, line %d, column %d\n' % (e[0], filename, e[1][0], e[1][1])) | print >> sys.stderr, '%s: %s, line %d, column %d' % ( e[0], filename, e[1][0], e[1][1]) | def main(): global default_keywords try: opts, args = getopt.getopt( sys.argv[1:], 'ad:DEhk:Kno:p:S:Vvw:x:', ['extract-all', 'default-domain', 'escape', 'help', 'keyword=', 'no-default-keywords', 'add-location', 'no-location', 'output=', 'output-dir=', 'style=', 'verbose', 'version', 'width=', 'exclude-file=', 'docstrings', ]) except getopt.error, msg: usage(1, msg) # for holding option values class Options: # constants GNU = 1 SOLARIS = 2 # defaults extractall = 0 # FIXME: currently this option has no effect at all. escape = 0 keywords = [] outpath = '' outfile = 'messages.pot' writelocations = 1 locationstyle = GNU verbose = 0 width = 78 excludefilename = '' docstrings = 0 options = Options() locations = {'gnu' : options.GNU, 'solaris' : options.SOLARIS, } # parse options for opt, arg in opts: if opt in ('-h', '--help'): usage(0) elif opt in ('-a', '--extract-all'): options.extractall = 1 elif opt in ('-d', '--default-domain'): options.outfile = arg + '.pot' elif opt in ('-E', '--escape'): options.escape = 1 elif opt in ('-D', '--docstrings'): options.docstrings = 1 elif opt in ('-k', '--keyword'): options.keywords.append(arg) elif opt in ('-K', '--no-default-keywords'): default_keywords = [] elif opt in ('-n', '--add-location'): options.writelocations = 1 elif opt in ('--no-location',): options.writelocations = 0 elif opt in ('-S', '--style'): options.locationstyle = locations.get(arg.lower()) if options.locationstyle is None: usage(1, _('Invalid value for --style: %s') % arg) elif opt in ('-o', '--output'): options.outfile = arg elif opt in ('-p', '--output-dir'): options.outpath = arg elif opt in ('-v', '--verbose'): options.verbose = 1 elif opt in ('-V', '--version'): print _('pygettext.py (xgettext for Python) %s') % __version__ sys.exit(0) elif opt in ('-w', '--width'): try: options.width = int(arg) except ValueError: usage(1, _('--width argument must be an integer: %s') % arg) elif opt in ('-x', '--exclude-file'): options.excludefilename = arg # calculate escapes make_escapes(options.escape) # calculate all keywords options.keywords.extend(default_keywords) # initialize list of strings to exclude if options.excludefilename: try: fp = open(options.excludefilename) options.toexclude = fp.readlines() fp.close() except IOError: sys.stderr.write(_("Can't read --exclude-file: %s") % options.excludefilename) sys.exit(1) else: options.toexclude = [] # slurp through all the files eater = TokenEater(options) for filename in args: if filename == '-': if options.verbose: print _('Reading standard input') fp = sys.stdin closep = 0 else: if options.verbose: print _('Working on %s') % filename fp = open(filename) closep = 1 try: eater.set_filename(filename) try: tokenize.tokenize(fp.readline, eater) except tokenize.TokenError, e: sys.stderr.write('%s: %s, line %d, column %d\n' % (e[0], filename, e[1][0], e[1][1])) finally: if closep: fp.close() # write the output if options.outfile == '-': fp = sys.stdout closep = 0 else: if options.outpath: options.outfile = os.path.join(options.outpath, options.outfile) fp = open(options.outfile, 'w') closep = 1 try: eater.write(fp) finally: if closep: fp.close() | 6e972414bec063ce953df9dea5a13239ac7e5604 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6e972414bec063ce953df9dea5a13239ac7e5604/pygettext.py |
for name in ('lib', 'purelib', 'platlib', | for name in ('libbase', 'lib', 'purelib', 'platlib', | def finalize_options (self): | 1b024d37a7e56279db00c7d775397f19927736a9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1b024d37a7e56279db00c7d775397f19927736a9/install.py |
st = os.lstat(name) | try: st = os.lstat(name) except os.error: continue | def walk(top, func, arg): """walk(top,func,arg) calls func(arg, d, files) for each directory "d" in the tree rooted at "top" (including "top" itself). "files" is a list of all the files and subdirs in directory "d". """ try: names = os.listdir(top) except os.error: return func(arg, top, names) for name in names: name = join(top, name) st = os.lstat(name) if stat.S_ISDIR(st[stat.ST_MODE]): walk(name, func, arg) | a490d5856dc0bcfbb286feb76dbc5e7a4edddef8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a490d5856dc0bcfbb286feb76dbc5e7a4edddef8/posixpath.py |
instance.menuRecentFiles.delete(1,END) | menu = instance.menuRecentFiles menu.delete(1,END) i = 0 ; ul = 0; ullen = len(ullist) | def UpdateRecentFilesList(self,newFile=None): "Load or update the recent files list, and menu if required" rfList=[] if os.path.exists(self.recentFilesPath): RFfile=open(self.recentFilesPath,'r') try: rfList=RFfile.readlines() finally: RFfile.close() if newFile: newFile=os.path.abspath(newFile)+'\n' if newFile in rfList: rfList.remove(newFile) rfList.insert(0,newFile) rfList=self.__CleanRecentFiles(rfList) #print self.flist.inversedict #print self.top.instanceDict #print self if rfList: for instance in self.top.instanceDict.keys(): instance.menuRecentFiles.delete(1,END) for file in rfList: fileName=file[0:-1] instance.menuRecentFiles.add_command(label=fileName, command=instance.__RecentFileCallback(fileName)) | c9a5b5c72e6017c154b26d2796141091e7614d44 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c9a5b5c72e6017c154b26d2796141091e7614d44/EditorWindow.py |
instance.menuRecentFiles.add_command(label=fileName, command=instance.__RecentFileCallback(fileName)) | callback = instance.__RecentFileCallback(fileName) if i > ullen: ul=None menu.add_command(label=ullist[i] + " " + fileName, command=callback, underline=ul) i += 1 | def UpdateRecentFilesList(self,newFile=None): "Load or update the recent files list, and menu if required" rfList=[] if os.path.exists(self.recentFilesPath): RFfile=open(self.recentFilesPath,'r') try: rfList=RFfile.readlines() finally: RFfile.close() if newFile: newFile=os.path.abspath(newFile)+'\n' if newFile in rfList: rfList.remove(newFile) rfList.insert(0,newFile) rfList=self.__CleanRecentFiles(rfList) #print self.flist.inversedict #print self.top.instanceDict #print self if rfList: for instance in self.top.instanceDict.keys(): instance.menuRecentFiles.delete(1,END) for file in rfList: fileName=file[0:-1] instance.menuRecentFiles.add_command(label=fileName, command=instance.__RecentFileCallback(fileName)) | c9a5b5c72e6017c154b26d2796141091e7614d44 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c9a5b5c72e6017c154b26d2796141091e7614d44/EditorWindow.py |
def write(self, arg, move=0): x, y = start = self._position | def write(self, text, move=False): """ Write text at the current pen position. If move is true, the pen is moved to the bottom-right corner of the text. By default, move is False. Example: >>> turtle.write('The race is on!') >>> turtle.write('Home = (0, 0)', True) """ x, y = self._position | def write(self, arg, move=0): x, y = start = self._position x = x-1 # correction -- calibrated for Windows item = self._canvas.create_text(x, y, text=str(arg), anchor="sw", fill=self._color) self._items.append(item) if move: x0, y0, x1, y1 = self._canvas.bbox(item) self._goto(x1, y1) self._draw_turtle() | e3a25838db0ac392aa9e68379e167635f8e67a43 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e3a25838db0ac392aa9e68379e167635f8e67a43/turtle.py |
text=str(arg), anchor="sw", | text=str(text), anchor="sw", | def write(self, arg, move=0): x, y = start = self._position x = x-1 # correction -- calibrated for Windows item = self._canvas.create_text(x, y, text=str(arg), anchor="sw", fill=self._color) self._items.append(item) if move: x0, y0, x1, y1 = self._canvas.bbox(item) self._goto(x1, y1) self._draw_turtle() | e3a25838db0ac392aa9e68379e167635f8e67a43 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e3a25838db0ac392aa9e68379e167635f8e67a43/turtle.py |
self._canvas.lower(item) | def fill(self, flag): if self._filling: path = tuple(self._path) smooth = self._filling < 0 if len(path) > 2: item = self._canvas._create('polygon', path, {'fill': self._color, 'smooth': smooth}) self._items.append(item) self._canvas.lower(item) if self._tofill: for item in self._tofill: self._canvas.itemconfigure(item, fill=self._color) self._items.append(item) self._path = [] self._tofill = [] self._filling = flag if flag: self._path.append(self._position) self.forward(0) | e3a25838db0ac392aa9e68379e167635f8e67a43 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e3a25838db0ac392aa9e68379e167635f8e67a43/turtle.py |
|
start = self._angle - 90.0 | start = self._angle - (self._fullcircle / 4.0) | def circle(self, radius, extent=None): if extent is None: extent = self._fullcircle x0, y0 = self._position xc = x0 - radius * sin(self._angle * self._invradian) yc = y0 - radius * cos(self._angle * self._invradian) if radius >= 0.0: start = self._angle - 90.0 else: start = self._angle + 90.0 extent = -extent if self._filling: if abs(extent) >= self._fullcircle: item = self._canvas.create_oval(xc-radius, yc-radius, xc+radius, yc+radius, width=self._width, outline="") self._tofill.append(item) item = self._canvas.create_arc(xc-radius, yc-radius, xc+radius, yc+radius, style="chord", start=start, extent=extent, width=self._width, outline="") self._tofill.append(item) if self._drawing: if abs(extent) >= self._fullcircle: item = self._canvas.create_oval(xc-radius, yc-radius, xc+radius, yc+radius, width=self._width, outline=self._color) self._items.append(item) item = self._canvas.create_arc(xc-radius, yc-radius, xc+radius, yc+radius, style="arc", start=start, extent=extent, width=self._width, outline=self._color) self._items.append(item) angle = start + extent x1 = xc + abs(radius) * cos(angle * self._invradian) y1 = yc - abs(radius) * sin(angle * self._invradian) self._angle = (self._angle + extent) % self._fullcircle self._position = x1, y1 if self._filling: self._path.append(self._position) self._draw_turtle() | e3a25838db0ac392aa9e68379e167635f8e67a43 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e3a25838db0ac392aa9e68379e167635f8e67a43/turtle.py |
start = self._angle + 90.0 | start = self._angle + (self._fullcircle / 4.0) | def circle(self, radius, extent=None): if extent is None: extent = self._fullcircle x0, y0 = self._position xc = x0 - radius * sin(self._angle * self._invradian) yc = y0 - radius * cos(self._angle * self._invradian) if radius >= 0.0: start = self._angle - 90.0 else: start = self._angle + 90.0 extent = -extent if self._filling: if abs(extent) >= self._fullcircle: item = self._canvas.create_oval(xc-radius, yc-radius, xc+radius, yc+radius, width=self._width, outline="") self._tofill.append(item) item = self._canvas.create_arc(xc-radius, yc-radius, xc+radius, yc+radius, style="chord", start=start, extent=extent, width=self._width, outline="") self._tofill.append(item) if self._drawing: if abs(extent) >= self._fullcircle: item = self._canvas.create_oval(xc-radius, yc-radius, xc+radius, yc+radius, width=self._width, outline=self._color) self._items.append(item) item = self._canvas.create_arc(xc-radius, yc-radius, xc+radius, yc+radius, style="arc", start=start, extent=extent, width=self._width, outline=self._color) self._items.append(item) angle = start + extent x1 = xc + abs(radius) * cos(angle * self._invradian) y1 = yc - abs(radius) * sin(angle * self._invradian) self._angle = (self._angle + extent) % self._fullcircle self._position = x1, y1 if self._filling: self._path.append(self._position) self._draw_turtle() | e3a25838db0ac392aa9e68379e167635f8e67a43 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e3a25838db0ac392aa9e68379e167635f8e67a43/turtle.py |
x0, y0 = start = self._position | x0, y0 = self._position | def _goto(self, x1, y1): x0, y0 = start = self._position self._position = map(float, (x1, y1)) if self._filling: self._path.append(self._position) if self._drawing: if self._tracing: dx = float(x1 - x0) dy = float(y1 - y0) distance = hypot(dx, dy) nhops = int(distance) item = self._canvas.create_line(x0, y0, x0, y0, width=self._width, capstyle="round", fill=self._color) try: for i in range(1, 1+nhops): x, y = x0 + dx*i/nhops, y0 + dy*i/nhops self._canvas.coords(item, x0, y0, x, y) self._draw_turtle((x,y)) self._canvas.update() self._canvas.after(10) # in case nhops==0 self._canvas.coords(item, x0, y0, x1, y1) self._canvas.itemconfigure(item, arrow="none") except Tkinter.TclError: # Probably the window was closed! return else: item = self._canvas.create_line(x0, y0, x1, y1, width=self._width, capstyle="round", fill=self._color) self._items.append(item) self._draw_turtle() | e3a25838db0ac392aa9e68379e167635f8e67a43 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e3a25838db0ac392aa9e68379e167635f8e67a43/turtle.py |
self._canvas.after(10) | self._canvas.after(self._delay) | def _goto(self, x1, y1): x0, y0 = start = self._position self._position = map(float, (x1, y1)) if self._filling: self._path.append(self._position) if self._drawing: if self._tracing: dx = float(x1 - x0) dy = float(y1 - y0) distance = hypot(dx, dy) nhops = int(distance) item = self._canvas.create_line(x0, y0, x0, y0, width=self._width, capstyle="round", fill=self._color) try: for i in range(1, 1+nhops): x, y = x0 + dx*i/nhops, y0 + dy*i/nhops self._canvas.coords(item, x0, y0, x, y) self._draw_turtle((x,y)) self._canvas.update() self._canvas.after(10) # in case nhops==0 self._canvas.coords(item, x0, y0, x1, y1) self._canvas.itemconfigure(item, arrow="none") except Tkinter.TclError: # Probably the window was closed! return else: item = self._canvas.create_line(x0, y0, x1, y1, width=self._width, capstyle="round", fill=self._color) self._items.append(item) self._draw_turtle() | e3a25838db0ac392aa9e68379e167635f8e67a43 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e3a25838db0ac392aa9e68379e167635f8e67a43/turtle.py |
def _draw_turtle(self,position=[]): | def speed(self, speed): """ Set the turtle's speed. speed must one of these five strings: 'fastest' is a 0 ms delay 'fast' is a 5 ms delay 'normal' is a 10 ms delay 'slow' is a 15 ms delay 'slowest' is a 20 ms delay Example: >>> turtle.speed('slow') """ try: speed = speed.strip().lower() self._delay = speeds.index(speed) * 5 except: raise ValueError("%r is not a valid speed. speed must be " "one of %s" % (speed, speeds)) def delay(self, delay): """ Set the drawing delay in milliseconds. This is intended to allow finer control of the drawing speed than the speed() method Example: >>> turtle.delay(15) """ if int(delay) < 0: raise ValueError("delay must be greater than or equal to 0") self._delay = int(delay) def _draw_turtle(self, position=[]): | def _draw_turtle(self,position=[]): if not self._tracing: return if position == []: position = self._position x,y = position distance = 8 dx = distance * cos(self._angle*self._invradian) dy = distance * sin(self._angle*self._invradian) self._delete_turtle() self._arrow = self._canvas.create_line(x-dx,y+dy,x,y, width=self._width, arrow="last", capstyle="round", fill=self._color) self._canvas.update() | e3a25838db0ac392aa9e68379e167635f8e67a43 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e3a25838db0ac392aa9e68379e167635f8e67a43/turtle.py |
self._arrow = 0 | self._arrow = 0 | def _delete_turtle(self): if self._arrow != 0: self._canvas.delete(self._arrow) self._arrow = 0 | e3a25838db0ac392aa9e68379e167635f8e67a43 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e3a25838db0ac392aa9e68379e167635f8e67a43/turtle.py |
def _destroy(self): global _root, _canvas, _pen root = self._canvas._root() if root is _root: _pen = None _root = None _canvas = None root.destroy() | e3a25838db0ac392aa9e68379e167635f8e67a43 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e3a25838db0ac392aa9e68379e167635f8e67a43/turtle.py |
||
pen = _pen if not pen: _pen = pen = Pen() return pen | if not _pen: _pen = Pen() return _pen class Turtle(Pen): pass """For documentation of the following functions see the RawPen methods with the same names """ | def _getpen(): global _pen pen = _pen if not pen: _pen = pen = Pen() return pen | e3a25838db0ac392aa9e68379e167635f8e67a43 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e3a25838db0ac392aa9e68379e167635f8e67a43/turtle.py |
if __name__ == '__main__': _root.mainloop() | def demo2(): speed('fast') width(3) setheading(towards(0,0)) x,y = position() r = (x**2+y**2)**.5/2.0 right(90) pendown = True for i in range(18): if pendown: up() pendown = False else: down() pendown = True circle(r,10) sleep(2) reset() left(90) l = 10 color("green") width(3) left(180) sp = 5 for i in range(-2,16): if i > 0: color(1.0-0.05*i,0,0.05*i) fill(1) color("green") for j in range(3): forward(l) left(120) l += 10 left(15) if sp > 0: sp = sp-1 speed(speeds[sp]) color(0.25,0,0.75) fill(0) color("green") left(130) up() forward(90) color("red") speed('fastest') down(); turtle=Turtle() turtle.reset() turtle.left(90) turtle.speed('normal') turtle.up() turtle.goto(280,40) turtle.left(24) turtle.down() turtle.speed('fast') turtle.color("blue") turtle.width(2) speed('fastest') setheading(towards(turtle)) while ( abs(position()[0]-turtle.position()[0])>4 or abs(position()[1]-turtle.position()[1])>4): turtle.forward(3.5) turtle.left(0.6) setheading(towards(turtle)) forward(4) write("CAUGHT! ", move=True) | def demo(): reset() tracer(1) up() backward(100) down() # draw 3 squares; the last filled width(3) for i in range(3): if i == 2: fill(1) for j in range(4): forward(20) left(90) if i == 2: color("maroon") fill(0) up() forward(30) down() width(1) color("black") # move out of the way tracer(0) up() right(90) forward(100) right(90) forward(100) right(180) down() # some text write("startstart", 1) write("start", 1) color("red") # staircase for i in range(5): forward(20) left(90) forward(20) right(90) # filled staircase fill(1) for i in range(5): forward(20) left(90) forward(20) right(90) fill(0) # more text write("end") if __name__ == '__main__': _root.mainloop() | e3a25838db0ac392aa9e68379e167635f8e67a43 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e3a25838db0ac392aa9e68379e167635f8e67a43/turtle.py |
('file://nonsensename/etc/passwd', None, (OSError, socket.error)) | ('file://nonsensename/etc/passwd', None, (EnvironmentError, socket.error)) | def test_file(self): TESTFN = test_support.TESTFN f = open(TESTFN, 'w') try: f.write('hi there\n') f.close() urls = [ 'file:'+sanepathname2url(os.path.abspath(TESTFN)), | 896c1ea15e9ec67fd1b33998ba8daaf17528ba31 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/896c1ea15e9ec67fd1b33998ba8daaf17528ba31/test_urllib2net.py |
Optional keyword arg "name" gives the name of the file; by default use the file's name. | Optional keyword arg "name" gives the name of the test; by default use the file's basename. | def testfile(filename, module_relative=True, name=None, package=None, globs=None, verbose=None, report=True, optionflags=0, extraglobs=None, raise_on_error=False): """ Test examples in the given file. Return (#failures, #tests). Optional keyword arg "module_relative" specifies how filenames should be interpreted: - If "module_relative" is True (the default), then "filename" specifies a module-relative path. By default, this path is relative to the calling module's directory; but if the "package" argument is specified, then it is relative to that package. To ensure os-independence, "filename" should use "/" characters to separate path segments, and should not be an absolute path (i.e., it may not begin with "/"). - If "module_relative" is False, then "filename" specifies an os-specific path. The path may be absolute or relative (to the current working directory). Optional keyword arg "name" gives the name of the file; by default use the file's name. Optional keyword argument "package" is a Python package or the name of a Python package whose directory should be used as the base directory for a module relative filename. If no package is specified, then the calling module's directory is used as the base directory for module relative filenames. It is an error to specify "package" if "module_relative" is False. Optional keyword arg "globs" gives a dict to be used as the globals when executing examples; by default, use {}. A copy of this dict is actually used for each docstring, so that each docstring's examples start with a clean slate. Optional keyword arg "extraglobs" gives a dictionary that should be merged into the globals that are used to execute examples. By default, no extra globals are used. Optional keyword arg "verbose" prints lots of stuff if true, prints only failures if false; by default, it's true iff "-v" is in sys.argv. Optional keyword arg "report" prints a summary at the end when true, else prints nothing at the end. In verbose mode, the summary is detailed, else very brief (in fact, empty if all tests passed). Optional keyword arg "optionflags" or's together module constants, and defaults to 0. Possible values (see the docs for details): DONT_ACCEPT_TRUE_FOR_1 DONT_ACCEPT_BLANKLINE NORMALIZE_WHITESPACE ELLIPSIS IGNORE_EXCEPTION_DETAIL REPORT_UDIFF REPORT_CDIFF REPORT_NDIFF REPORT_ONLY_FIRST_FAILURE Optional keyword arg "raise_on_error" raises an exception on the first unexpected exception or failure. This allows failures to be post-mortem debugged. Advanced tomfoolery: testmod runs methods of a local instance of class doctest.Tester, then merges the results into (or creates) global Tester instance doctest.master. Methods of doctest.master can be called directly too, if you want to do something unusual. Passing report=0 to testmod is especially useful then, to delay displaying a summary. Invoke doctest.master.summarize(verbose) when you're done fiddling. """ global master if package and not module_relative: raise ValueError("Package may only be specified for module-" "relative paths.") # Relativize the path if module_relative: package = _normalize_module(package) filename = _module_relative_path(package, filename) # If no name was given, then use the file's name. if name is None: name = os.path.split(filename)[-1] # Assemble the globals. if globs is None: globs = {} else: globs = globs.copy() if extraglobs is not None: globs.update(extraglobs) if raise_on_error: runner = DebugRunner(verbose=verbose, optionflags=optionflags) else: runner = DocTestRunner(verbose=verbose, optionflags=optionflags) # Read the file, convert it to a test, and run it. s = open(filename).read() test = DocTestParser().get_doctest(s, globs, name, filename, 0) runner.run(test) if report: runner.summarize() if master is None: master = runner else: master.merge(runner) return runner.failures, runner.tries | a2fc7ec80aea43768c11c50922a665a08b3885c0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a2fc7ec80aea43768c11c50922a665a08b3885c0/doctest.py |
name = os.path.split(filename)[-1] | name = os.path.basename(filename) | def testfile(filename, module_relative=True, name=None, package=None, globs=None, verbose=None, report=True, optionflags=0, extraglobs=None, raise_on_error=False): """ Test examples in the given file. Return (#failures, #tests). Optional keyword arg "module_relative" specifies how filenames should be interpreted: - If "module_relative" is True (the default), then "filename" specifies a module-relative path. By default, this path is relative to the calling module's directory; but if the "package" argument is specified, then it is relative to that package. To ensure os-independence, "filename" should use "/" characters to separate path segments, and should not be an absolute path (i.e., it may not begin with "/"). - If "module_relative" is False, then "filename" specifies an os-specific path. The path may be absolute or relative (to the current working directory). Optional keyword arg "name" gives the name of the file; by default use the file's name. Optional keyword argument "package" is a Python package or the name of a Python package whose directory should be used as the base directory for a module relative filename. If no package is specified, then the calling module's directory is used as the base directory for module relative filenames. It is an error to specify "package" if "module_relative" is False. Optional keyword arg "globs" gives a dict to be used as the globals when executing examples; by default, use {}. A copy of this dict is actually used for each docstring, so that each docstring's examples start with a clean slate. Optional keyword arg "extraglobs" gives a dictionary that should be merged into the globals that are used to execute examples. By default, no extra globals are used. Optional keyword arg "verbose" prints lots of stuff if true, prints only failures if false; by default, it's true iff "-v" is in sys.argv. Optional keyword arg "report" prints a summary at the end when true, else prints nothing at the end. In verbose mode, the summary is detailed, else very brief (in fact, empty if all tests passed). Optional keyword arg "optionflags" or's together module constants, and defaults to 0. Possible values (see the docs for details): DONT_ACCEPT_TRUE_FOR_1 DONT_ACCEPT_BLANKLINE NORMALIZE_WHITESPACE ELLIPSIS IGNORE_EXCEPTION_DETAIL REPORT_UDIFF REPORT_CDIFF REPORT_NDIFF REPORT_ONLY_FIRST_FAILURE Optional keyword arg "raise_on_error" raises an exception on the first unexpected exception or failure. This allows failures to be post-mortem debugged. Advanced tomfoolery: testmod runs methods of a local instance of class doctest.Tester, then merges the results into (or creates) global Tester instance doctest.master. Methods of doctest.master can be called directly too, if you want to do something unusual. Passing report=0 to testmod is especially useful then, to delay displaying a summary. Invoke doctest.master.summarize(verbose) when you're done fiddling. """ global master if package and not module_relative: raise ValueError("Package may only be specified for module-" "relative paths.") # Relativize the path if module_relative: package = _normalize_module(package) filename = _module_relative_path(package, filename) # If no name was given, then use the file's name. if name is None: name = os.path.split(filename)[-1] # Assemble the globals. if globs is None: globs = {} else: globs = globs.copy() if extraglobs is not None: globs.update(extraglobs) if raise_on_error: runner = DebugRunner(verbose=verbose, optionflags=optionflags) else: runner = DocTestRunner(verbose=verbose, optionflags=optionflags) # Read the file, convert it to a test, and run it. s = open(filename).read() test = DocTestParser().get_doctest(s, globs, name, filename, 0) runner.run(test) if report: runner.summarize() if master is None: master = runner else: master.merge(runner) return runner.failures, runner.tries | a2fc7ec80aea43768c11c50922a665a08b3885c0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a2fc7ec80aea43768c11c50922a665a08b3885c0/doctest.py |
package The name of a Python package. Text-file paths will be interpreted relative to the directory containing this package. The package may be supplied as a package object or as a dotted package name. | def DocTestSuite(module=None, globs=None, extraglobs=None, test_finder=None, **options): """ Convert doctest tests for a module to a unittest test suite. This converts each documentation string in a module that contains doctest tests to a unittest test case. If any of the tests in a doc string fail, then the test case fails. An exception is raised showing the name of the file containing the test and a (sometimes approximate) line number. The `module` argument provides the module to be tested. The argument can be either a module or a module name. If no argument is given, the calling module is used. A number of options may be provided as keyword arguments: package The name of a Python package. Text-file paths will be interpreted relative to the directory containing this package. The package may be supplied as a package object or as a dotted package name. setUp The name of a set-up function. This is called before running the tests in each file. The setUp function will be passed a DocTest object. The setUp function can access the test globals as the globs attribute of the test passed. tearDown The name of a tear-down function. This is called after running the tests in each file. The tearDown function will be passed a DocTest object. The tearDown function can access the test globals as the globs attribute of the test passed. globs A dictionary containing initial global variables for the tests. optionflags A set of doctest option flags expressed as an integer. """ if test_finder is None: test_finder = DocTestFinder() module = _normalize_module(module) tests = test_finder.find(module, globs=globs, extraglobs=extraglobs) if globs is None: globs = module.__dict__ if not tests: # Why do we want to do this? Because it reveals a bug that might # otherwise be hidden. raise ValueError(module, "has no tests") tests.sort() suite = unittest.TestSuite() for test in tests: if len(test.examples) == 0: continue if not test.filename: filename = module.__file__ if filename[-4:] in (".pyc", ".pyo"): filename = filename[:-1] test.filename = filename suite.addTest(DocTestCase(test, **options)) return suite | a2fc7ec80aea43768c11c50922a665a08b3885c0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a2fc7ec80aea43768c11c50922a665a08b3885c0/doctest.py |
|
The name of a set-up function. This is called before running the | A set-up function. This is called before running the | def DocTestSuite(module=None, globs=None, extraglobs=None, test_finder=None, **options): """ Convert doctest tests for a module to a unittest test suite. This converts each documentation string in a module that contains doctest tests to a unittest test case. If any of the tests in a doc string fail, then the test case fails. An exception is raised showing the name of the file containing the test and a (sometimes approximate) line number. The `module` argument provides the module to be tested. The argument can be either a module or a module name. If no argument is given, the calling module is used. A number of options may be provided as keyword arguments: package The name of a Python package. Text-file paths will be interpreted relative to the directory containing this package. The package may be supplied as a package object or as a dotted package name. setUp The name of a set-up function. This is called before running the tests in each file. The setUp function will be passed a DocTest object. The setUp function can access the test globals as the globs attribute of the test passed. tearDown The name of a tear-down function. This is called after running the tests in each file. The tearDown function will be passed a DocTest object. The tearDown function can access the test globals as the globs attribute of the test passed. globs A dictionary containing initial global variables for the tests. optionflags A set of doctest option flags expressed as an integer. """ if test_finder is None: test_finder = DocTestFinder() module = _normalize_module(module) tests = test_finder.find(module, globs=globs, extraglobs=extraglobs) if globs is None: globs = module.__dict__ if not tests: # Why do we want to do this? Because it reveals a bug that might # otherwise be hidden. raise ValueError(module, "has no tests") tests.sort() suite = unittest.TestSuite() for test in tests: if len(test.examples) == 0: continue if not test.filename: filename = module.__file__ if filename[-4:] in (".pyc", ".pyo"): filename = filename[:-1] test.filename = filename suite.addTest(DocTestCase(test, **options)) return suite | a2fc7ec80aea43768c11c50922a665a08b3885c0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a2fc7ec80aea43768c11c50922a665a08b3885c0/doctest.py |
The name of a tear-down function. This is called after running the | A tear-down function. This is called after running the | def DocTestSuite(module=None, globs=None, extraglobs=None, test_finder=None, **options): """ Convert doctest tests for a module to a unittest test suite. This converts each documentation string in a module that contains doctest tests to a unittest test case. If any of the tests in a doc string fail, then the test case fails. An exception is raised showing the name of the file containing the test and a (sometimes approximate) line number. The `module` argument provides the module to be tested. The argument can be either a module or a module name. If no argument is given, the calling module is used. A number of options may be provided as keyword arguments: package The name of a Python package. Text-file paths will be interpreted relative to the directory containing this package. The package may be supplied as a package object or as a dotted package name. setUp The name of a set-up function. This is called before running the tests in each file. The setUp function will be passed a DocTest object. The setUp function can access the test globals as the globs attribute of the test passed. tearDown The name of a tear-down function. This is called after running the tests in each file. The tearDown function will be passed a DocTest object. The tearDown function can access the test globals as the globs attribute of the test passed. globs A dictionary containing initial global variables for the tests. optionflags A set of doctest option flags expressed as an integer. """ if test_finder is None: test_finder = DocTestFinder() module = _normalize_module(module) tests = test_finder.find(module, globs=globs, extraglobs=extraglobs) if globs is None: globs = module.__dict__ if not tests: # Why do we want to do this? Because it reveals a bug that might # otherwise be hidden. raise ValueError(module, "has no tests") tests.sort() suite = unittest.TestSuite() for test in tests: if len(test.examples) == 0: continue if not test.filename: filename = module.__file__ if filename[-4:] in (".pyc", ".pyo"): filename = filename[:-1] test.filename = filename suite.addTest(DocTestCase(test, **options)) return suite | a2fc7ec80aea43768c11c50922a665a08b3885c0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a2fc7ec80aea43768c11c50922a665a08b3885c0/doctest.py |
name = os.path.split(path)[-1] | name = os.path.basename(path) | def DocFileTest(path, module_relative=True, package=None, globs=None, **options): if globs is None: globs = {} if package and not module_relative: raise ValueError("Package may only be specified for module-" "relative paths.") # Relativize the path. if module_relative: package = _normalize_module(package) path = _module_relative_path(package, path) # Find the file and read it. name = os.path.split(path)[-1] doc = open(path).read() # Convert it to a test, and wrap it in a DocFileCase. test = DocTestParser().get_doctest(doc, globs, name, path, 0) return DocFileCase(test, **options) | a2fc7ec80aea43768c11c50922a665a08b3885c0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a2fc7ec80aea43768c11c50922a665a08b3885c0/doctest.py |
The name of a set-up function. This is called before running the | A set-up function. This is called before running the | def DocFileSuite(*paths, **kw): """A unittest suite for one or more doctest files. The path to each doctest file is given as a string; the interpretation of that string depends on the keyword argument "module_relative". A number of options may be provided as keyword arguments: module_relative If "module_relative" is True, then the given file paths are interpreted as os-independent module-relative paths. By default, these paths are relative to the calling module's directory; but if the "package" argument is specified, then they are relative to that package. To ensure os-independence, "filename" should use "/" characters to separate path segments, and may not be an absolute path (i.e., it may not begin with "/"). If "module_relative" is False, then the given file paths are interpreted as os-specific paths. These paths may be absolute or relative (to the current working directory). package A Python package or the name of a Python package whose directory should be used as the base directory for module relative paths. If "package" is not specified, then the calling module's directory is used as the base directory for module relative filenames. It is an error to specify "package" if "module_relative" is False. setUp The name of a set-up function. This is called before running the tests in each file. The setUp function will be passed a DocTest object. The setUp function can access the test globals as the globs attribute of the test passed. tearDown The name of a tear-down function. This is called after running the tests in each file. The tearDown function will be passed a DocTest object. The tearDown function can access the test globals as the globs attribute of the test passed. globs A dictionary containing initial global variables for the tests. optionflags A set of doctest option flags expressed as an integer. """ suite = unittest.TestSuite() # We do this here so that _normalize_module is called at the right # level. If it were called in DocFileTest, then this function # would be the caller and we might guess the package incorrectly. if kw.get('module_relative', True): kw['package'] = _normalize_module(kw.get('package')) for path in paths: suite.addTest(DocFileTest(path, **kw)) return suite | a2fc7ec80aea43768c11c50922a665a08b3885c0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a2fc7ec80aea43768c11c50922a665a08b3885c0/doctest.py |
The name of a tear-down function. This is called after running the | A tear-down function. This is called after running the | def DocFileSuite(*paths, **kw): """A unittest suite for one or more doctest files. The path to each doctest file is given as a string; the interpretation of that string depends on the keyword argument "module_relative". A number of options may be provided as keyword arguments: module_relative If "module_relative" is True, then the given file paths are interpreted as os-independent module-relative paths. By default, these paths are relative to the calling module's directory; but if the "package" argument is specified, then they are relative to that package. To ensure os-independence, "filename" should use "/" characters to separate path segments, and may not be an absolute path (i.e., it may not begin with "/"). If "module_relative" is False, then the given file paths are interpreted as os-specific paths. These paths may be absolute or relative (to the current working directory). package A Python package or the name of a Python package whose directory should be used as the base directory for module relative paths. If "package" is not specified, then the calling module's directory is used as the base directory for module relative filenames. It is an error to specify "package" if "module_relative" is False. setUp The name of a set-up function. This is called before running the tests in each file. The setUp function will be passed a DocTest object. The setUp function can access the test globals as the globs attribute of the test passed. tearDown The name of a tear-down function. This is called after running the tests in each file. The tearDown function will be passed a DocTest object. The tearDown function can access the test globals as the globs attribute of the test passed. globs A dictionary containing initial global variables for the tests. optionflags A set of doctest option flags expressed as an integer. """ suite = unittest.TestSuite() # We do this here so that _normalize_module is called at the right # level. If it were called in DocFileTest, then this function # would be the caller and we might guess the package incorrectly. if kw.get('module_relative', True): kw['package'] = _normalize_module(kw.get('package')) for path in paths: suite.addTest(DocFileTest(path, **kw)) return suite | a2fc7ec80aea43768c11c50922a665a08b3885c0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a2fc7ec80aea43768c11c50922a665a08b3885c0/doctest.py |
if ok: | if fss: | def interact(options, title): """Let the user interact with the dialog""" try: # Try to go to the "correct" dir for GetDirectory os.chdir(options['dir'].as_pathname()) except os.error: pass d = GetNewDialog(DIALOG_ID, -1) htext = d.GetDialogItemAsControl(TITLE_ITEM) SetDialogItemText(htext, title) path_ctl = d.GetDialogItemAsControl(TEXT_ITEM) data = string.joinfields(options['path'], '\r') path_ctl.SetControlData(Controls.kControlEditTextPart, Controls.kControlEditTextTextTag, data) d.SelectDialogItemText(TEXT_ITEM, 0, 32767) d.SelectDialogItemText(TEXT_ITEM, 0, 0) | 2373ff4e4ffbcd35112e13528b162ee80e4786cc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2373ff4e4ffbcd35112e13528b162ee80e4786cc/EditPythonPrefs.py |
modulesbyfile[getabsfile(module)] = module.__name__ | modulesbyfile[ os.path.realpath( getabsfile(module))] = module.__name__ | def getmodule(object): """Return the module an object was defined in, or None if not found.""" if ismodule(object): return object if isclass(object): return sys.modules.get(object.__module__) try: file = getabsfile(object) except TypeError: return None if file in modulesbyfile: return sys.modules.get(modulesbyfile[file]) for module in sys.modules.values(): if hasattr(module, '__file__'): modulesbyfile[getabsfile(module)] = module.__name__ if file in modulesbyfile: return sys.modules.get(modulesbyfile[file]) main = sys.modules['__main__'] if not hasattr(object, '__name__'): return None if hasattr(main, object.__name__): mainobject = getattr(main, object.__name__) if mainobject is object: return main builtin = sys.modules['__builtin__'] if hasattr(builtin, object.__name__): builtinobject = getattr(builtin, object.__name__) if builtinobject is object: return builtin | b3de2e13baaac7573720c62276984cba13c01c75 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b3de2e13baaac7573720c62276984cba13c01c75/inspect.py |
chunks.append(size) | chunks.append(data) | def read(self, size): """Read 'size' bytes from remote.""" # sslobj.read() sometimes returns < size bytes chunks = [] read = 0 while read < size: data = self.sslobj.read(size-read) read += len(data) chunks.append(size) | c1e32b651896e24877e0e601fd7eb6215dbb916d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c1e32b651896e24877e0e601fd7eb6215dbb916d/imaplib.py |
suffix_map = db.encodings_map | suffix_map = db.suffix_map | def init(files=None): global guess_extension, guess_type global suffix_map, types_map, encodings_map global inited inited = 1 db = MimeTypes() if files is None: files = knownfiles for file in files: if os.path.isfile(file): db.readfp(open(file)) encodings_map = db.encodings_map suffix_map = db.encodings_map types_map = db.types_map guess_extension = db.guess_extension guess_type = db.guess_type | c81a06998f1de7e5f97a7c9599310c34214cec8f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c81a06998f1de7e5f97a7c9599310c34214cec8f/mimetypes.py |
isbigendian = struct.pack('=i', 1)[0] == chr(0) | def any_err(func, *args): try: apply(func, args) except (struct.error, OverflowError, TypeError): pass else: raise TestFailed, "%s%s did not raise error" % ( func.__name__, args) | 17e17d440644f780e793466b47ca354459a8d68a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/17e17d440644f780e793466b47ca354459a8d68a/test_struct.py |
|
('='+fmt, isbigendian and big or lil)]: | ('='+fmt, ISBIGENDIAN and big or lil)]: | def any_err(func, *args): try: apply(func, args) except (struct.error, OverflowError, TypeError): pass else: raise TestFailed, "%s%s did not raise error" % ( func.__name__, args) | 17e17d440644f780e793466b47ca354459a8d68a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/17e17d440644f780e793466b47ca354459a8d68a/test_struct.py |
def any_err(func, *args): try: apply(func, args) except (struct.error, OverflowError, TypeError): pass else: raise TestFailed, "%s%s did not raise error" % ( func.__name__, args) | 17e17d440644f780e793466b47ca354459a8d68a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/17e17d440644f780e793466b47ca354459a8d68a/test_struct.py |
||
def string_reverse(s): chars = list(s) chars.reverse() return "".join(chars) def bigendian_to_native(value): if isbigendian: return value else: return string_reverse(value) | def any_err(func, *args): try: apply(func, args) except (struct.error, OverflowError, TypeError): pass else: raise TestFailed, "%s%s did not raise error" % ( func.__name__, args) | 17e17d440644f780e793466b47ca354459a8d68a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/17e17d440644f780e793466b47ca354459a8d68a/test_struct.py |
|
MIN_Q, MAX_Q = 0, 2L**64 - 1 MIN_q, MAX_q = -(2L**63), 2L**63 - 1 | def test_native_qQ(): bytes = struct.calcsize('q') # The expected values here are in big-endian format, primarily because # I'm on a little-endian machine and so this is the clearest way (for # me) to force the code to get exercised. for format, input, expected in ( ('q', -1, '\xff' * bytes), ('q', 0, '\x00' * bytes), ('Q', 0, '\x00' * bytes), ('q', 1L, '\x00' * (bytes-1) + '\x01'), ('Q', (1L << (8*bytes))-1, '\xff' * bytes), ('q', (1L << (8*bytes-1))-1, '\x7f' + '\xff' * (bytes - 1))): got = struct.pack(format, input) native_expected = bigendian_to_native(expected) verify(got == native_expected, "%r-pack of %r gave %r, not %r" % (format, input, got, native_expected)) retrieved = struct.unpack(format, got)[0] verify(retrieved == input, "%r-unpack of %r gave %r, not %r" % (format, got, retrieved, input)) | 17e17d440644f780e793466b47ca354459a8d68a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/17e17d440644f780e793466b47ca354459a8d68a/test_struct.py |
|
def test_one_qQ(x, pack=struct.pack, unpack=struct.unpack, unhexlify=binascii.unhexlify): if verbose: print "trying std q/Q on", x, "==", hex(x) if MIN_q <= x <= MAX_q: expected = long(x) if x < 0: expected += 1L << 64 assert expected > 0 expected = hex(expected)[2:-1] if len(expected) & 1: expected = "0" + expected expected = unhexlify(expected) expected = "\x00" * (8 - len(expected)) + expected got = pack(">q", x) verify(got == expected, "'>q'-pack of %r gave %r, not %r" % (x, got, expected)) retrieved = unpack(">q", got)[0] verify(x == retrieved, "'>q'-unpack of %r gave %r, not %r" % (got, retrieved, x)) any_err(unpack, ">q", '\x01' + got) expected = string_reverse(expected) got = pack("<q", x) verify(got == expected, "'<q'-pack of %r gave %r, not %r" % (x, got, expected)) retrieved = unpack("<q", got)[0] verify(x == retrieved, "'<q'-unpack of %r gave %r, not %r" % (got, retrieved, x)) any_err(unpack, "<q", '\x01' + got) else: any_err(pack, '>q', x) any_err(pack, '<q', x) if MIN_Q <= x <= MAX_Q: expected = long(x) expected = hex(expected)[2:-1] if len(expected) & 1: expected = "0" + expected expected = unhexlify(expected) expected = "\x00" * (8 - len(expected)) + expected got = pack(">Q", x) verify(got == expected, "'>Q'-pack of %r gave %r, not %r" % (x, got, expected)) retrieved = unpack(">Q", got)[0] verify(x == retrieved, "'>Q'-unpack of %r gave %r, not %r" % (got, retrieved, x)) any_err(unpack, ">Q", '\x01' + got) expected = string_reverse(expected) got = pack("<Q", x) verify(got == expected, "'<Q'-pack of %r gave %r, not %r" % (x, got, expected)) retrieved = unpack("<Q", got)[0] verify(x == retrieved, "'<Q'-unpack of %r gave %r, not %r" % (got, retrieved, x)) any_err(unpack, "<Q", '\x01' + got) else: any_err(pack, '>Q', x) any_err(pack, '<Q', x) def test_std_qQ(): from random import randrange values = [] for exp in range(70): values.append(1L << exp) for i in range(50): val = 0L for j in range(8): val = (val << 8) | randrange(256) values.append(val) for base in values: for val in -base, base: for incr in -1, 0, 1: x = val + incr try: x = int(x) except OverflowError: pass test_one_qQ(x) for direction in "<>": for letter in "qQ": for badobject in "a string", 3+42j, randrange: any_err(struct.pack, direction + letter, badobject) test_std_qQ() | class IntTester: BUGGY_RANGE_CHECK = "bBhHIL" def __init__(self, formatpair, bytesize): assert len(formatpair) == 2 self.formatpair = formatpair for direction in "<>!=": for code in formatpair: format = direction + code verify(struct.calcsize(format) == bytesize) self.bytesize = bytesize self.bitsize = bytesize * 8 self.signed_code, self.unsigned_code = formatpair self.unsigned_min = 0 self.unsigned_max = 2L**self.bitsize - 1 self.signed_min = -(2L**(self.bitsize-1)) self.signed_max = 2L**(self.bitsize-1) - 1 def test_one(self, x, pack=struct.pack, unpack=struct.unpack, unhexlify=binascii.unhexlify): if verbose: print "trying std", self.formatpair, "on", x, "==", hex(x) code = self.signed_code if self.signed_min <= x <= self.signed_max: expected = long(x) if x < 0: expected += 1L << self.bitsize assert expected > 0 expected = hex(expected)[2:-1] if len(expected) & 1: expected = "0" + expected expected = unhexlify(expected) expected = "\x00" * (self.bytesize - len(expected)) + expected format = ">" + code got = pack(format, x) verify(got == expected, "'%s'-pack of %r gave %r, not %r" % (format, x, got, expected)) retrieved = unpack(format, got)[0] verify(x == retrieved, "'%s'-unpack of %r gave %r, not %r" % (format, got, retrieved, x)) any_err(unpack, format, '\x01' + got) format = "<" + code expected = string_reverse(expected) got = pack(format, x) verify(got == expected, "'%s'-pack of %r gave %r, not %r" % (format, x, got, expected)) retrieved = unpack(format, got)[0] verify(x == retrieved, "'%s'-unpack of %r gave %r, not %r" % (format, got, retrieved, x)) any_err(unpack, format, '\x01' + got) else: if code in self.BUGGY_RANGE_CHECK: if verbose: print "Skipping buggy range check for code", code else: any_err(pack, ">" + code, x) any_err(pack, "<" + code, x) code = self.unsigned_code if self.unsigned_min <= x <= self.unsigned_max: format = ">" + code expected = long(x) expected = hex(expected)[2:-1] if len(expected) & 1: expected = "0" + expected expected = unhexlify(expected) expected = "\x00" * (self.bytesize - len(expected)) + expected got = pack(format, x) verify(got == expected, "'%s'-pack of %r gave %r, not %r" % (format, x, got, expected)) retrieved = unpack(format, got)[0] verify(x == retrieved, "'%s'-unpack of %r gave %r, not %r" % (format, got, retrieved, x)) any_err(unpack, format, '\x01' + got) format = "<" + code expected = string_reverse(expected) got = pack(format, x) verify(got == expected, "'%s'-pack of %r gave %r, not %r" % (format, x, got, expected)) retrieved = unpack(format, got)[0] verify(x == retrieved, "'%s'-unpack of %r gave %r, not %r" % (format, got, retrieved, x)) any_err(unpack, format, '\x01' + got) else: if code in self.BUGGY_RANGE_CHECK: if verbose: print "Skipping buggy range check for code", code else: any_err(pack, ">" + code, x) any_err(pack, "<" + code, x) def run(self): from random import randrange values = [] for exp in range(self.bitsize + 3): values.append(1L << exp) for i in range(self.bitsize): val = 0L for j in range(self.bytesize): val = (val << 8) | randrange(256) values.append(val) for base in values: for val in -base, base: for incr in -1, 0, 1: x = val + incr try: x = int(x) except OverflowError: pass self.test_one(x) for direction in "<>": for code in self.formatpair: for badobject in "a string", 3+42j, randrange: any_err(struct.pack, direction + code, badobject) for args in [("bB", 1), ("hH", 2), ("iI", 4), ("lL", 4), ("qQ", 8)]: t = IntTester(*args) t.run() | def test_one_qQ(x, pack=struct.pack, unpack=struct.unpack, unhexlify=binascii.unhexlify): if verbose: print "trying std q/Q on", x, "==", hex(x) # Try 'q'. if MIN_q <= x <= MAX_q: # Try '>q'. expected = long(x) if x < 0: expected += 1L << 64 assert expected > 0 expected = hex(expected)[2:-1] # chop "0x" and trailing 'L' if len(expected) & 1: expected = "0" + expected expected = unhexlify(expected) expected = "\x00" * (8 - len(expected)) + expected # >q pack work? got = pack(">q", x) verify(got == expected, "'>q'-pack of %r gave %r, not %r" % (x, got, expected)) # >q unpack work? retrieved = unpack(">q", got)[0] verify(x == retrieved, "'>q'-unpack of %r gave %r, not %r" % (got, retrieved, x)) # Adding any byte should cause a "too big" error. any_err(unpack, ">q", '\x01' + got) # Try '<q'. expected = string_reverse(expected) # <q pack work? got = pack("<q", x) verify(got == expected, "'<q'-pack of %r gave %r, not %r" % (x, got, expected)) # <q unpack work? retrieved = unpack("<q", got)[0] verify(x == retrieved, "'<q'-unpack of %r gave %r, not %r" % (got, retrieved, x)) # Adding any byte should cause a "too big" error. any_err(unpack, "<q", '\x01' + got) else: # x is out of q's range -- verify pack realizes that. any_err(pack, '>q', x) any_err(pack, '<q', x) # Much the same for 'Q'. if MIN_Q <= x <= MAX_Q: # Try '>Q'. expected = long(x) expected = hex(expected)[2:-1] # chop "0x" and trailing 'L' if len(expected) & 1: expected = "0" + expected expected = unhexlify(expected) expected = "\x00" * (8 - len(expected)) + expected # >Q pack work? got = pack(">Q", x) verify(got == expected, "'>Q'-pack of %r gave %r, not %r" % (x, got, expected)) # >Q unpack work? retrieved = unpack(">Q", got)[0] verify(x == retrieved, "'>Q'-unpack of %r gave %r, not %r" % (got, retrieved, x)) # Adding any byte should cause a "too big" error. any_err(unpack, ">Q", '\x01' + got) # Try '<Q'. expected = string_reverse(expected) # <Q pack work? got = pack("<Q", x) verify(got == expected, "'<Q'-pack of %r gave %r, not %r" % (x, got, expected)) # <Q unpack work? retrieved = unpack("<Q", got)[0] verify(x == retrieved, "'<Q'-unpack of %r gave %r, not %r" % (got, retrieved, x)) # Adding any byte should cause a "too big" error. any_err(unpack, "<Q", '\x01' + got) else: # x is out of Q's range -- verify pack realizes that. any_err(pack, '>Q', x) any_err(pack, '<Q', x) | 17e17d440644f780e793466b47ca354459a8d68a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/17e17d440644f780e793466b47ca354459a8d68a/test_struct.py |
self.__testMethodName = methodName | self._testMethodName = methodName | def __init__(self, methodName='runTest'): """Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name. """ try: self.__testMethodName = methodName testMethod = getattr(self, methodName) self.__testMethodDoc = testMethod.__doc__ except AttributeError: raise ValueError, "no such test method in %s: %s" % \ (self.__class__, methodName) | 81cdb4ebe1e8062168f44f12c80e0426344add31 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/81cdb4ebe1e8062168f44f12c80e0426344add31/unittest.py |
self.__testMethodDoc = testMethod.__doc__ | self._testMethodDoc = testMethod.__doc__ | def __init__(self, methodName='runTest'): """Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name. """ try: self.__testMethodName = methodName testMethod = getattr(self, methodName) self.__testMethodDoc = testMethod.__doc__ except AttributeError: raise ValueError, "no such test method in %s: %s" % \ (self.__class__, methodName) | 81cdb4ebe1e8062168f44f12c80e0426344add31 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/81cdb4ebe1e8062168f44f12c80e0426344add31/unittest.py |
doc = self.__testMethodDoc | doc = self._testMethodDoc | def shortDescription(self): """Returns a one-line description of the test, or None if no description has been provided. | 81cdb4ebe1e8062168f44f12c80e0426344add31 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/81cdb4ebe1e8062168f44f12c80e0426344add31/unittest.py |
return "%s.%s" % (_strclass(self.__class__), self.__testMethodName) | return "%s.%s" % (_strclass(self.__class__), self._testMethodName) | def id(self): return "%s.%s" % (_strclass(self.__class__), self.__testMethodName) | 81cdb4ebe1e8062168f44f12c80e0426344add31 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/81cdb4ebe1e8062168f44f12c80e0426344add31/unittest.py |
return "%s (%s)" % (self.__testMethodName, _strclass(self.__class__)) | return "%s (%s)" % (self._testMethodName, _strclass(self.__class__)) | def __str__(self): return "%s (%s)" % (self.__testMethodName, _strclass(self.__class__)) | 81cdb4ebe1e8062168f44f12c80e0426344add31 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/81cdb4ebe1e8062168f44f12c80e0426344add31/unittest.py |
(_strclass(self.__class__), self.__testMethodName) | (_strclass(self.__class__), self._testMethodName) | def __repr__(self): return "<%s testMethod=%s>" % \ (_strclass(self.__class__), self.__testMethodName) | 81cdb4ebe1e8062168f44f12c80e0426344add31 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/81cdb4ebe1e8062168f44f12c80e0426344add31/unittest.py |
testMethod = getattr(self, self.__testMethodName) | testMethod = getattr(self, self._testMethodName) | def run(self, result=None): if result is None: result = self.defaultTestResult() result.startTest(self) testMethod = getattr(self, self.__testMethodName) try: try: self.setUp() except KeyboardInterrupt: raise except: result.addError(self, self.__exc_info()) return | 81cdb4ebe1e8062168f44f12c80e0426344add31 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/81cdb4ebe1e8062168f44f12c80e0426344add31/unittest.py |
result.addError(self, self.__exc_info()) | result.addError(self, self._exc_info()) | def run(self, result=None): if result is None: result = self.defaultTestResult() result.startTest(self) testMethod = getattr(self, self.__testMethodName) try: try: self.setUp() except KeyboardInterrupt: raise except: result.addError(self, self.__exc_info()) return | 81cdb4ebe1e8062168f44f12c80e0426344add31 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/81cdb4ebe1e8062168f44f12c80e0426344add31/unittest.py |
result.addFailure(self, self.__exc_info()) | result.addFailure(self, self._exc_info()) | def run(self, result=None): if result is None: result = self.defaultTestResult() result.startTest(self) testMethod = getattr(self, self.__testMethodName) try: try: self.setUp() except KeyboardInterrupt: raise except: result.addError(self, self.__exc_info()) return | 81cdb4ebe1e8062168f44f12c80e0426344add31 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/81cdb4ebe1e8062168f44f12c80e0426344add31/unittest.py |
result.addError(self, self.__exc_info()) | result.addError(self, self._exc_info()) | def run(self, result=None): if result is None: result = self.defaultTestResult() result.startTest(self) testMethod = getattr(self, self.__testMethodName) try: try: self.setUp() except KeyboardInterrupt: raise except: result.addError(self, self.__exc_info()) return | 81cdb4ebe1e8062168f44f12c80e0426344add31 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/81cdb4ebe1e8062168f44f12c80e0426344add31/unittest.py |
result.addError(self, self.__exc_info()) | result.addError(self, self._exc_info()) | def run(self, result=None): if result is None: result = self.defaultTestResult() result.startTest(self) testMethod = getattr(self, self.__testMethodName) try: try: self.setUp() except KeyboardInterrupt: raise except: result.addError(self, self.__exc_info()) return | 81cdb4ebe1e8062168f44f12c80e0426344add31 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/81cdb4ebe1e8062168f44f12c80e0426344add31/unittest.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.