rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
self.parent.focus_set()
if self.parent is not None: self.parent.focus_set()
def cancel(self, event=None):
6b04ffe9e59dc8df46f2d68646ed82cbbef0714c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6b04ffe9e59dc8df46f2d68646ed82cbbef0714c/tkSimpleDialog.py
if intro is not None: self.intro = intro if self.intro: self.stdout.write(str(self.intro)+"\n") stop = None while not stop: if self.cmdqueue: line = self.cmdqueue.pop(0) else: if self.use_rawinput: try: line = raw_input(self.prompt) except EOFError: line = 'EOF' else: self.stdout.write(self.prompt) self.stdout.flush() line = self.stdin.readline() if not len(line): line = 'EOF' else: line = line[:-1] line = self.precmd(line) stop = self.onecmd(line) stop = self.postcmd(stop, line) self.postloop() def precmd(self, line): """Hook method executed just before the command line is interpreted, but after the input prompt is generated and issued. """ return line def postcmd(self, stop, line): """Hook method executed just after a command dispatch is finished.""" return stop def preloop(self): """Hook method executed once when the cmdloop() method is called.""" if self.completekey:
if self.use_rawinput and self.completekey:
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.
d7cc1bd809522ff3d9ad13bb5a470a392e506941 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d7cc1bd809522ff3d9ad13bb5a470a392e506941/cmd.py
if self.completekey: try: import readline readline.set_completer(self.old_completer) except ImportError: pass
pass
def postloop(self): """Hook method executed once when the cmdloop() method is about to return.
d7cc1bd809522ff3d9ad13bb5a470a392e506941 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d7cc1bd809522ff3d9ad13bb5a470a392e506941/cmd.py
def urlencode(dict): """Encode a dictionary of form entries into a URL query string."""
def urlencode(dict,doseq=0): """Encode a dictionary of form entries into a URL query string. If any values in the dict are sequences and doseq is true, each sequence element is converted to a separate parameter. """
def urlencode(dict): """Encode a dictionary of form entries into a URL query string.""" l = [] for k, v in dict.items(): k = quote_plus(str(k)) v = quote_plus(str(v)) l.append(k + '=' + v) return '&'.join(l)
a5d23a19e6685f7c754e459d4442242bac8dc84d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a5d23a19e6685f7c754e459d4442242bac8dc84d/urllib.py
for k, v in dict.items(): k = quote_plus(str(k)) v = quote_plus(str(v)) l.append(k + '=' + v)
if not doseq: for k, v in dict.items(): k = quote_plus(str(k)) v = quote_plus(str(v)) l.append(k + '=' + v) else: for k, v in dict.items(): k = quote_plus(str(k)) if type(v) == types.StringType: v = quote_plus(v) l.append(k + '=' + v) elif type(v) == types.UnicodeType: v = quote_plus(v.encode("ASCII","replace")) l.append(k + '=' + v) else: try: x = len(v) except TypeError: v = quote_plus(str(v)) l.append(k + '=' + v) else: for elt in v: l.append(k + '=' + quote_plus(str(elt)))
def urlencode(dict): """Encode a dictionary of form entries into a URL query string.""" l = [] for k, v in dict.items(): k = quote_plus(str(k)) v = quote_plus(str(v)) l.append(k + '=' + v) return '&'.join(l)
a5d23a19e6685f7c754e459d4442242bac8dc84d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a5d23a19e6685f7c754e459d4442242bac8dc84d/urllib.py
'DocTestTestFailure',
>>> def f(x):
a643b658a7cd1d820fd561665402705f0f76b1d0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a643b658a7cd1d820fd561665402705f0f76b1d0/doctest.py
def _utest(tester, name, doc, filename, lineno): import sys from StringIO import StringIO old = sys.stdout sys.stdout = new = StringIO() try: failures, tries = tester.runstring(doc, name) finally: sys.stdout = old if failures: msg = new.getvalue() lname = '.'.join(name.split('.')[-1:]) if not lineno: lineno = "0 (don't know line number)" raise DocTestTestFailure('Failed doctest test for %s\n' ' File "%s", line %s, in %s\n\n%s' % (name, filename, lineno, lname, msg)) class DocTestTestFailure(Exception): """A doctest test failed""" def DocTestSuite(module=None): """Convert doctest tests for a module to a unittest TestSuite. The returned TestSuite is to be run by the unittest framework, and runs each doctest in the module. If any of the doctests fail, then the synthesized unit test fails, and an error is raised showing the name of the file containing the test and a (sometimes approximate) line number. The optional module argument provides the module to be tested. It can be a module object or a (possibly dotted) module name. If not specified, the module calling DocTestSuite() is used. Example (although note that unittest supplies many ways to use the TestSuite returned; see the unittest docs): import unittest import doctest import my_module_with_doctests suite = doctest.DocTestSuite(my_module_with_doctests) runner = unittest.TextTestRunner() runner.run(suite)
from StringIO import StringIO import os import sys import tempfile import unittest class DocTestTestCase(unittest.TestCase): """A test case that wraps a test function. This is useful for slipping pre-existing test functions into the PyUnit framework. Optionally, set-up and tidy-up functions can be supplied. As with TestCase, the tidy-up ('tearDown') function will always be called if the set-up ('setUp') function ran successfully.
def _find_tests(module, prefix=None): if prefix is None: prefix = module.__name__ mdict = module.__dict__ tests = [] # Get the module-level doctest (if any). _get_doctest(prefix, module, tests, '', lineno="1 (or above)") # Recursively search the module __dict__ for doctests. if prefix: prefix += "." _extract_doctests(mdict.items(), module, mdict, tests, prefix) return tests
a643b658a7cd1d820fd561665402705f0f76b1d0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a643b658a7cd1d820fd561665402705f0f76b1d0/doctest.py
import unittest module = _normalize_module(module) tests = _find_tests(module)
def __init__(self, tester, name, doc, filename, lineno, setUp=None, tearDown=None): unittest.TestCase.__init__(self) (self.__tester, self.__name, self.__doc, self.__filename, self.__lineno, self.__setUp, self.__tearDown ) = tester, name, doc, filename, lineno, setUp, tearDown def setUp(self): if self.__setUp is not None: self.__setUp() def tearDown(self): if self.__tearDown is not None: self.__tearDown() def runTest(self): old = sys.stdout new = StringIO() try: sys.stdout = new failures, tries = self.__tester.runstring(self.__doc, self.__name) finally: sys.stdout = old if failures: lname = '.'.join(self.__name.split('.')[-1:]) lineno = self.__lineno or "0 (don't know line no)" raise self.failureException( 'Failed doctest test for %s\n' ' File "%s", line %s, in %s\n\n%s' % (self.__name, self.__filename, lineno, lname, new.getvalue()) ) def id(self): return self.__name def __repr__(self): name = self.__name.split('.') return "%s (%s)" % (name[-1], '.'.join(name[:-1])) __str__ = __repr__ def shortDescription(self): return "Doctest: " + self.__name def DocTestSuite(module=None, setUp=lambda: None, tearDown=lambda: None, ): """Convert doctest tests for a mudule to a unittest test suite This tests convers 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 error is raised showing the name of the file containing the test and a (sometimes approximate) line number. A 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. """ module = _normalizeModule(module) tests = _findTests(module)
def DocTestSuite(module=None): """Convert doctest tests for a module to a unittest TestSuite. The returned TestSuite is to be run by the unittest framework, and runs each doctest in the module. If any of the doctests fail, then the synthesized unit test fails, and an error is raised showing the name of the file containing the test and a (sometimes approximate) line number. The optional module argument provides the module to be tested. It can be a module object or a (possibly dotted) module name. If not specified, the module calling DocTestSuite() is used. Example (although note that unittest supplies many ways to use the TestSuite returned; see the unittest docs): import unittest import doctest import my_module_with_doctests suite = doctest.DocTestSuite(my_module_with_doctests) runner = unittest.TextTestRunner() runner.run(suite) """ import unittest module = _normalize_module(module) tests = _find_tests(module) if not tests: raise ValueError(module, "has no tests") tests.sort() suite = unittest.TestSuite() tester = Tester(module) for name, doc, filename, lineno in tests: if not filename: filename = module.__file__ if filename.endswith(".pyc"): filename = filename[:-1] elif filename.endswith(".pyo"): filename = filename[:-1] def runit(name=name, doc=doc, filename=filename, lineno=lineno): _utest(tester, name, doc, filename, lineno) suite.addTest(unittest.FunctionTestCase( runit, description="doctest of " + name)) return suite
a643b658a7cd1d820fd561665402705f0f76b1d0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a643b658a7cd1d820fd561665402705f0f76b1d0/doctest.py
def runit(name=name, doc=doc, filename=filename, lineno=lineno): _utest(tester, name, doc, filename, lineno) suite.addTest(unittest.FunctionTestCase( runit, description="doctest of " + name))
suite.addTest(DocTestTestCase( tester, name, doc, filename, lineno, setUp, tearDown))
def runit(name=name, doc=doc, filename=filename, lineno=lineno): _utest(tester, name, doc, filename, lineno)
a643b658a7cd1d820fd561665402705f0f76b1d0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a643b658a7cd1d820fd561665402705f0f76b1d0/doctest.py
def _normalizeModule(module): if module is None: module = sys._getframe(2).f_globals['__name__'] module = sys.modules[module] elif isinstance(module, (str, unicode)): module = __import__(module, globals(), locals(), ["*"]) return module def _doc(name, object, tests, prefix, filename='', lineno=''): doc = getattr(object, '__doc__', '') if doc and doc.find('>>>') >= 0: tests.append((prefix+name, doc, filename, lineno)) def _findTests(module, prefix=None): if prefix is None: prefix = module.__name__ dict = module.__dict__ tests = [] _doc(prefix, module, tests, '', lineno="1 (or below)") prefix = prefix and (prefix + ".") _find(dict.items(), module, dict, tests, prefix) return tests def _find(items, module, dict, tests, prefix, minlineno=0): for name, object in items: if not hasattr(object, '__name__'): continue if hasattr(object, 'func_globals'): if object.func_globals is not dict: continue code = getattr(object, 'func_code', None) filename = getattr(code, 'co_filename', '') lineno = getattr(code, 'co_firstlineno', -1) + 1 if minlineno: minlineno = min(lineno, minlineno) else: minlineno = lineno _doc(name, object, tests, prefix, filename, lineno) elif hasattr(object, "__module__"): if object.__module__ != module.__name__: continue if not (hasattr(object, '__dict__') and hasattr(object, '__bases__')): continue lineno = _find(object.__dict__.items(), module, dict, tests, prefix+name+".") _doc(name, object, tests, prefix, lineno="%s (or above)" % (lineno-3)) return minlineno
def runit(name=name, doc=doc, filename=filename, lineno=lineno): _utest(tester, name, doc, filename, lineno)
a643b658a7cd1d820fd561665402705f0f76b1d0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a643b658a7cd1d820fd561665402705f0f76b1d0/doctest.py
def _expect(expect): # Return the expected output (if any), formatted as a Python # comment block. if expect: expect = "\n# ".join(expect.split("\n")) expect = "\n# Expect:\n# %s" % expect return expect
a643b658a7cd1d820fd561665402705f0f76b1d0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a643b658a7cd1d820fd561665402705f0f76b1d0/doctest.py
"""Extract the doctest examples from a docstring.
"""Extract the test sources from a doctest test docstring as a script
def testsource(module, name): """Extract the doctest examples from a docstring. Provide the module (or dotted name of the module) containing the tests to be extracted, and the name (within the module) of the object with the docstring containing the tests to be extracted. The doctest examples are returned as a string containing Python code. The expected output blocks in the examples are converted to Python comments. """ module = _normalize_module(module) tests = _find_tests(module, "") test = [doc for (tname, doc, dummy, dummy) in tests if tname == name] if not test: raise ValueError(name, "not found in tests") test = test[0] examples = [source + _expect(expect) for source, expect, dummy in _extract_examples(test)] return '\n'.join(examples)
a643b658a7cd1d820fd561665402705f0f76b1d0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a643b658a7cd1d820fd561665402705f0f76b1d0/doctest.py
tests to be extracted, and the name (within the module) of the object with the docstring containing the tests to be extracted. The doctest examples are returned as a string containing Python code. The expected output blocks in the examples are converted to Python comments.
test to be debugged and the name (within the module) of the object with the doc string with tests to be debugged.
def testsource(module, name): """Extract the doctest examples from a docstring. Provide the module (or dotted name of the module) containing the tests to be extracted, and the name (within the module) of the object with the docstring containing the tests to be extracted. The doctest examples are returned as a string containing Python code. The expected output blocks in the examples are converted to Python comments. """ module = _normalize_module(module) tests = _find_tests(module, "") test = [doc for (tname, doc, dummy, dummy) in tests if tname == name] if not test: raise ValueError(name, "not found in tests") test = test[0] examples = [source + _expect(expect) for source, expect, dummy in _extract_examples(test)] return '\n'.join(examples)
a643b658a7cd1d820fd561665402705f0f76b1d0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a643b658a7cd1d820fd561665402705f0f76b1d0/doctest.py
module = _normalize_module(module) tests = _find_tests(module, "") test = [doc for (tname, doc, dummy, dummy) in tests if tname == name]
module = _normalizeModule(module) tests = _findTests(module, "") test = [doc for (tname, doc, f, l) in tests if tname == name]
def testsource(module, name): """Extract the doctest examples from a docstring. Provide the module (or dotted name of the module) containing the tests to be extracted, and the name (within the module) of the object with the docstring containing the tests to be extracted. The doctest examples are returned as a string containing Python code. The expected output blocks in the examples are converted to Python comments. """ module = _normalize_module(module) tests = _find_tests(module, "") test = [doc for (tname, doc, dummy, dummy) in tests if tname == name] if not test: raise ValueError(name, "not found in tests") test = test[0] examples = [source + _expect(expect) for source, expect, dummy in _extract_examples(test)] return '\n'.join(examples)
a643b658a7cd1d820fd561665402705f0f76b1d0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a643b658a7cd1d820fd561665402705f0f76b1d0/doctest.py
examples = [source + _expect(expect) for source, expect, dummy in _extract_examples(test)] return '\n'.join(examples) def debug(module, name): """Debug a single docstring containing doctests. Provide the module (or dotted name of the module) containing the docstring to be debugged, and the name (within the module) of the object with the docstring to be debugged. The doctest examples are extracted (see function testsource()), and written to a temp file. The Python debugger (pdb) is then invoked on that file.
examples = _extract_examples(test) testsrc = '\n'.join([ "%s%s" % (source, _expect(expect)) for (source, expect, lineno) in examples ]) return testsrc def debug_src(src, pm=False, globs=None): """Debug a single doctest test doc string The string is provided directly
def testsource(module, name): """Extract the doctest examples from a docstring. Provide the module (or dotted name of the module) containing the tests to be extracted, and the name (within the module) of the object with the docstring containing the tests to be extracted. The doctest examples are returned as a string containing Python code. The expected output blocks in the examples are converted to Python comments. """ module = _normalize_module(module) tests = _find_tests(module, "") test = [doc for (tname, doc, dummy, dummy) in tests if tname == name] if not test: raise ValueError(name, "not found in tests") test = test[0] examples = [source + _expect(expect) for source, expect, dummy in _extract_examples(test)] return '\n'.join(examples)
a643b658a7cd1d820fd561665402705f0f76b1d0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a643b658a7cd1d820fd561665402705f0f76b1d0/doctest.py
import os
examples = _extract_examples(src) src = '\n'.join([ "%s%s" % (source, _expect(expect)) for (source, expect, lineno) in examples ]) debug_script(src, pm, globs) def debug_script(src, pm=False, globs=None): "Debug a test script"
def debug(module, name): """Debug a single docstring containing doctests. Provide the module (or dotted name of the module) containing the docstring to be debugged, and the name (within the module) of the object with the docstring to be debugged. The doctest examples are extracted (see function testsource()), and written to a temp file. The Python debugger (pdb) is then invoked on that file. """ import os import pdb import tempfile module = _normalize_module(module) testsrc = testsource(module, name) srcfilename = tempfile.mktemp("doctestdebug.py") f = file(srcfilename, 'w') f.write(testsrc) f.close() globs = {} globs.update(module.__dict__) try: # Note that %r is vital here. '%s' instead can, e.g., cause # backslashes to get treated as metacharacters on Windows. pdb.run("execfile(%r)" % srcfilename, globs, globs) finally: os.remove(srcfilename)
a643b658a7cd1d820fd561665402705f0f76b1d0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a643b658a7cd1d820fd561665402705f0f76b1d0/doctest.py
import tempfile module = _normalize_module(module) testsrc = testsource(module, name)
def debug(module, name): """Debug a single docstring containing doctests. Provide the module (or dotted name of the module) containing the docstring to be debugged, and the name (within the module) of the object with the docstring to be debugged. The doctest examples are extracted (see function testsource()), and written to a temp file. The Python debugger (pdb) is then invoked on that file. """ import os import pdb import tempfile module = _normalize_module(module) testsrc = testsource(module, name) srcfilename = tempfile.mktemp("doctestdebug.py") f = file(srcfilename, 'w') f.write(testsrc) f.close() globs = {} globs.update(module.__dict__) try: # Note that %r is vital here. '%s' instead can, e.g., cause # backslashes to get treated as metacharacters on Windows. pdb.run("execfile(%r)" % srcfilename, globs, globs) finally: os.remove(srcfilename)
a643b658a7cd1d820fd561665402705f0f76b1d0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a643b658a7cd1d820fd561665402705f0f76b1d0/doctest.py
f = file(srcfilename, 'w') f.write(testsrc) f.close() globs = {} globs.update(module.__dict__)
open(srcfilename, 'w').write(src) if globs: globs = globs.copy() else: globs = {}
def debug(module, name): """Debug a single docstring containing doctests. Provide the module (or dotted name of the module) containing the docstring to be debugged, and the name (within the module) of the object with the docstring to be debugged. The doctest examples are extracted (see function testsource()), and written to a temp file. The Python debugger (pdb) is then invoked on that file. """ import os import pdb import tempfile module = _normalize_module(module) testsrc = testsource(module, name) srcfilename = tempfile.mktemp("doctestdebug.py") f = file(srcfilename, 'w') f.write(testsrc) f.close() globs = {} globs.update(module.__dict__) try: # Note that %r is vital here. '%s' instead can, e.g., cause # backslashes to get treated as metacharacters on Windows. pdb.run("execfile(%r)" % srcfilename, globs, globs) finally: os.remove(srcfilename)
a643b658a7cd1d820fd561665402705f0f76b1d0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a643b658a7cd1d820fd561665402705f0f76b1d0/doctest.py
pdb.run("execfile(%r)" % srcfilename, globs, globs)
if pm: try: execfile(srcfilename, globs, globs) except: print sys.exc_info()[1] pdb.post_mortem(sys.exc_info()[2]) else: pdb.run("execfile(%r)" % srcfilename, globs, globs)
def debug(module, name): """Debug a single docstring containing doctests. Provide the module (or dotted name of the module) containing the docstring to be debugged, and the name (within the module) of the object with the docstring to be debugged. The doctest examples are extracted (see function testsource()), and written to a temp file. The Python debugger (pdb) is then invoked on that file. """ import os import pdb import tempfile module = _normalize_module(module) testsrc = testsource(module, name) srcfilename = tempfile.mktemp("doctestdebug.py") f = file(srcfilename, 'w') f.write(testsrc) f.close() globs = {} globs.update(module.__dict__) try: # Note that %r is vital here. '%s' instead can, e.g., cause # backslashes to get treated as metacharacters on Windows. pdb.run("execfile(%r)" % srcfilename, globs, globs) finally: os.remove(srcfilename)
a643b658a7cd1d820fd561665402705f0f76b1d0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a643b658a7cd1d820fd561665402705f0f76b1d0/doctest.py
print 'shlex: reading from %s, line %d' % (self.instream,self.lineno)
print 'shlex: reading from %s, line %d' \ % (self.instream, self.lineno)
def __init__(self, instream=None, infile=None): if instream: self.instream = instream self.infile = infile else: self.instream = sys.stdin self.infile = None self.commenters = '#' self.wordchars = 'abcdfeghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_' self.whitespace = ' \t\r\n' self.quotes = '\'"' self.state = ' ' self.pushback = []; self.lineno = 1 self.debug = 0 self.token = ''
52dc76c81fffa709fae35af92538723d23ad18d6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/52dc76c81fffa709fae35af92538723d23ad18d6/shlex.py
self.filestack = [(self.infile,self.instream,self.lineno)] + self.filestack
self.filestack.insert(0, (self.infile, self.instream, self.lineno))
def get_token(self): "Get a token from the input stream (or from stack if it's nonempty)" if self.pushback: tok = self.pushback[0] self.pushback = self.pushback[1:] if self.debug >= 1: print "shlex: popping token " + `tok` return tok
52dc76c81fffa709fae35af92538723d23ad18d6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/52dc76c81fffa709fae35af92538723d23ad18d6/shlex.py
print 'shlex: popping to %s, line %d' % (self.instream, self.lineno)
print 'shlex: popping to %s, line %d' \ % (self.instream, self.lineno)
def get_token(self): "Get a token from the input stream (or from stack if it's nonempty)" if self.pushback: tok = self.pushback[0] self.pushback = self.pushback[1:] if self.debug >= 1: print "shlex: popping token " + `tok` return tok
52dc76c81fffa709fae35af92538723d23ad18d6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/52dc76c81fffa709fae35af92538723d23ad18d6/shlex.py
print "shlex: in state " + repr(self.state) + " I see character: " + repr(nextchar)
print "shlex: in state", repr(self.state), \ "I see character:", repr(nextchar)
def read_token(self): "Read a token from the input stream (no pushback or inclusions)" tok = '' while 1: nextchar = self.instream.read(1); if nextchar == '\n': self.lineno = self.lineno + 1 if self.debug >= 3: print "shlex: in state " + repr(self.state) + " I see character: " + repr(nextchar) if self.state == None: self.token = ''; # past end of file break elif self.state == ' ': if not nextchar: self.state = None; # end of file break elif nextchar in self.whitespace: if self.debug >= 2: print "shlex: I see whitespace in whitespace state" if self.token: break # emit current token else: continue elif nextchar in self.commenters: self.instream.readline() self.lineno = self.lineno + 1 elif nextchar in self.wordchars: self.token = nextchar self.state = 'a' elif nextchar in self.quotes: self.token = nextchar self.state = nextchar else: self.token = nextchar if self.token: break # emit current token else: continue elif self.state in self.quotes: self.token = self.token + nextchar if nextchar == self.state: self.state = ' ' break elif self.state == 'a': if not nextchar: self.state = None; # end of file break elif nextchar in self.whitespace: if self.debug >= 2: print "shlex: I see whitespace in word state" self.state = ' ' if self.token: break # emit current token else: continue elif nextchar in self.commenters: self.instream.readline() self.lineno = self.lineno + 1 elif nextchar in self.wordchars or nextchar in self.quotes: self.token = self.token + nextchar else: self.pushback = [nextchar] + self.pushback if self.debug >= 2: print "shlex: I see punctuation in word state" self.state = ' ' if self.token: break # emit current token else: continue result = self.token self.token = '' if self.debug > 1: if result: print "shlex: raw token=" + `result` else: print "shlex: raw token=EOF" return result
52dc76c81fffa709fae35af92538723d23ad18d6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/52dc76c81fffa709fae35af92538723d23ad18d6/shlex.py
lexer = shlex()
if len(sys.argv) == 1: lexer = shlex() else: file = sys.argv[1] lexer = shlex(open(file), file)
def error_leader(self, infile=None, lineno=None): "Emit a C-compiler-like, Emacs-friendly error-message leader." if not infile: infile = self.infile if not lineno: lineno = self.lineno return "\"%s\", line %d: " % (infile, lineno)
52dc76c81fffa709fae35af92538723d23ad18d6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/52dc76c81fffa709fae35af92538723d23ad18d6/shlex.py
print "Token: " + repr(tt) if not tt:
if tt: print "Token: " + repr(tt) else:
def error_leader(self, infile=None, lineno=None): "Emit a C-compiler-like, Emacs-friendly error-message leader." if not infile: infile = self.infile if not lineno: lineno = self.lineno return "\"%s\", line %d: " % (infile, lineno)
52dc76c81fffa709fae35af92538723d23ad18d6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/52dc76c81fffa709fae35af92538723d23ad18d6/shlex.py
def error_leader(self, infile=None, lineno=None): "Emit a C-compiler-like, Emacs-friendly error-message leader." if not infile: infile = self.infile if not lineno: lineno = self.lineno return "\"%s\", line %d: " % (infile, lineno)
52dc76c81fffa709fae35af92538723d23ad18d6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/52dc76c81fffa709fae35af92538723d23ad18d6/shlex.py
self.bg="
self.bg="
def __init__(self,parent,title): Toplevel.__init__(self, parent) self.configure(borderwidth=5) self.geometry("+%d+%d" % (parent.winfo_rootx()+30, parent.winfo_rooty()+30)) #elguavas - config placeholders til config stuff completed self.bg="#555555" self.fg="#ffffff" #no ugly bold default font on *nix font=tkFont.Font(self,Label().cget('font')) if os.name=='posix': font.config(weight=NORMAL) self.textFont=font self.CreateWidgets() self.resizable(height=FALSE,width=FALSE) self.title(title) self.transient(parent) self.grab_set() self.protocol("WM_DELETE_WINDOW", self.Ok) self.parent = parent self.buttonOk.focus_set() #key bindings for this dialog self.bind('<Alt-c>',self.CreditsButtonBinding) #credits button #self.bind('<Alt-l>',self.LicenseButtonBinding) #license button self.bind('<Alt-r>',self.LicenseButtonBinding) #readme button self.bind('<Return>',self.Ok) #dismiss dialog self.bind('<Escape>',self.Ok) #dismiss dialog self.wait_window()
8c1ab14adac10799dc3defcb50f3976c74e85bbf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8c1ab14adac10799dc3defcb50f3976c74e85bbf/aboutDialog.py
font=tkFont.Font(self,Label().cget('font'))
font=tkFont.Font(self,Label(self).cget('font'))
def __init__(self,parent,title): Toplevel.__init__(self, parent) self.configure(borderwidth=5) self.geometry("+%d+%d" % (parent.winfo_rootx()+30, parent.winfo_rooty()+30)) #elguavas - config placeholders til config stuff completed self.bg="#555555" self.fg="#ffffff" #no ugly bold default font on *nix font=tkFont.Font(self,Label().cget('font')) if os.name=='posix': font.config(weight=NORMAL) self.textFont=font self.CreateWidgets() self.resizable(height=FALSE,width=FALSE) self.title(title) self.transient(parent) self.grab_set() self.protocol("WM_DELETE_WINDOW", self.Ok) self.parent = parent self.buttonOk.focus_set() #key bindings for this dialog self.bind('<Alt-c>',self.CreditsButtonBinding) #credits button #self.bind('<Alt-l>',self.LicenseButtonBinding) #license button self.bind('<Alt-r>',self.LicenseButtonBinding) #readme button self.bind('<Return>',self.Ok) #dismiss dialog self.bind('<Escape>',self.Ok) #dismiss dialog self.wait_window()
8c1ab14adac10799dc3defcb50f3976c74e85bbf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8c1ab14adac10799dc3defcb50f3976c74e85bbf/aboutDialog.py
self.bind('<Alt-r>',self.LicenseButtonBinding)
self.bind('<Alt-l>',self.LicenseButtonBinding)
def __init__(self,parent,title): Toplevel.__init__(self, parent) self.configure(borderwidth=5) self.geometry("+%d+%d" % (parent.winfo_rootx()+30, parent.winfo_rooty()+30)) #elguavas - config placeholders til config stuff completed self.bg="#555555" self.fg="#ffffff" #no ugly bold default font on *nix font=tkFont.Font(self,Label().cget('font')) if os.name=='posix': font.config(weight=NORMAL) self.textFont=font self.CreateWidgets() self.resizable(height=FALSE,width=FALSE) self.title(title) self.transient(parent) self.grab_set() self.protocol("WM_DELETE_WINDOW", self.Ok) self.parent = parent self.buttonOk.focus_set() #key bindings for this dialog self.bind('<Alt-c>',self.CreditsButtonBinding) #credits button #self.bind('<Alt-l>',self.LicenseButtonBinding) #license button self.bind('<Alt-r>',self.LicenseButtonBinding) #readme button self.bind('<Return>',self.Ok) #dismiss dialog self.bind('<Escape>',self.Ok) #dismiss dialog self.wait_window()
8c1ab14adac10799dc3defcb50f3976c74e85bbf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8c1ab14adac10799dc3defcb50f3976c74e85bbf/aboutDialog.py
Assume y1 <= y2 and no funny (non-leap century) years."""
Assume y1 <= y2 and no funny (non-leap century) years."""
def leapdays(y1, y2): """Return number of leap years in range [y1, y2). Assume y1 <= y2 and no funny (non-leap century) years.""" return (y2+3)/4 - (y1+3)/4
ad3bc44d52b9b9c1f1c7449d0991138fed5fe978 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ad3bc44d52b9b9c1f1c7449d0991138fed5fe978/calendar.py
"""Return weekday (0-6 ~ Mon-Sun) for year (1970-...), month (1-12), day (1-31)."""
"""Return weekday (0-6 ~ Mon-Sun) for year (1970-...), month (1-12), day (1-31)."""
def weekday(year, month, day): """Return weekday (0-6 ~ Mon-Sun) for year (1970-...), month (1-12), day (1-31).""" secs = mktime((year, month, day, 0, 0, 0, 0, 0, 0)) tuple = localtime(secs) return tuple[6]
ad3bc44d52b9b9c1f1c7449d0991138fed5fe978 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ad3bc44d52b9b9c1f1c7449d0991138fed5fe978/calendar.py
"""Return weekday (0-6 ~ Mon-Sun) and number of days (28-31) for year, month.""" if not 1 <= month <= 12: raise ValueError, 'bad month number'
"""Return weekday (0-6 ~ Mon-Sun) and number of days (28-31) for year, month.""" if not 1 <= month <= 12: raise ValueError, 'bad month number'
def monthrange(year, month): """Return weekday (0-6 ~ Mon-Sun) and number of days (28-31) for year, month.""" if not 1 <= month <= 12: raise ValueError, 'bad month number' day1 = weekday(year, month, 1) ndays = mdays[month] + (month == February and isleap(year)) return day1, ndays
ad3bc44d52b9b9c1f1c7449d0991138fed5fe978 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ad3bc44d52b9b9c1f1c7449d0991138fed5fe978/calendar.py
def _monthcalendar(year, month):
def monthcalendar(year, month):
def _monthcalendar(year, month): """Return a matrix representing a month's calendar. Each row represents a week; days outside this month are zero.""" day1, ndays = monthrange(year, month) rows = [] r7 = range(7) day = 1 - day1 while day <= ndays: row = [0, 0, 0, 0, 0, 0, 0] for i in r7: if 1 <= day <= ndays: row[i] = day day = day + 1 rows.append(row) return rows
ad3bc44d52b9b9c1f1c7449d0991138fed5fe978 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ad3bc44d52b9b9c1f1c7449d0991138fed5fe978/calendar.py
Each row represents a week; days outside this month are zero."""
Each row represents a week; days outside this month are zero."""
def _monthcalendar(year, month): """Return a matrix representing a month's calendar. Each row represents a week; days outside this month are zero.""" day1, ndays = monthrange(year, month) rows = [] r7 = range(7) day = 1 - day1 while day <= ndays: row = [0, 0, 0, 0, 0, 0, 0] for i in r7: if 1 <= day <= ndays: row[i] = day day = day + 1 rows.append(row) return rows
ad3bc44d52b9b9c1f1c7449d0991138fed5fe978 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ad3bc44d52b9b9c1f1c7449d0991138fed5fe978/calendar.py
day = 1 - day1
day = (_firstweekday - day1 + 6) % 7 - 5
def _monthcalendar(year, month): """Return a matrix representing a month's calendar. Each row represents a week; days outside this month are zero.""" day1, ndays = monthrange(year, month) rows = [] r7 = range(7) day = 1 - day1 while day <= ndays: row = [0, 0, 0, 0, 0, 0, 0] for i in r7: if 1 <= day <= ndays: row[i] = day day = day + 1 rows.append(row) return rows
ad3bc44d52b9b9c1f1c7449d0991138fed5fe978 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ad3bc44d52b9b9c1f1c7449d0991138fed5fe978/calendar.py
_mc_cache = {} def monthcalendar(year, month): """Caching interface to _monthcalendar.""" key = (year, month) if _mc_cache.has_key(key): return _mc_cache[key] else: _mc_cache[key] = ret = _monthcalendar(year, month) return ret
def _monthcalendar(year, month): """Return a matrix representing a month's calendar. Each row represents a week; days outside this month are zero.""" day1, ndays = monthrange(year, month) rows = [] r7 = range(7) day = 1 - day1 while day <= ndays: row = [0, 0, 0, 0, 0, 0, 0] for i in r7: if 1 <= day <= ndays: row[i] = day day = day + 1 rows.append(row) return rows
ad3bc44d52b9b9c1f1c7449d0991138fed5fe978 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ad3bc44d52b9b9c1f1c7449d0991138fed5fe978/calendar.py
if n <= 0: return str
if n <= 0: return str
def _center(str, width): """Center a string in a field.""" n = width - len(str) if n <= 0: return str return ' '*((n+1)/2) + str + ' '*((n)/2)
ad3bc44d52b9b9c1f1c7449d0991138fed5fe978 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ad3bc44d52b9b9c1f1c7449d0991138fed5fe978/calendar.py
def prweek(week, width):
def prweek(theweek, width):
def _center(str, width): """Center a string in a field.""" n = width - len(str) if n <= 0: return str return ' '*((n+1)/2) + str + ' '*((n)/2)
ad3bc44d52b9b9c1f1c7449d0991138fed5fe978 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ad3bc44d52b9b9c1f1c7449d0991138fed5fe978/calendar.py
for day in week: if day == 0: s = '' else: s = `day` print _center(s, width),
print week(theweek, width), def week(theweek, width): """Returns a single week in a string (no newline).""" days = [] for day in theweek: if day == 0: s = '' else: s = '%2i' % day days.append(_center(s, width)) return ' '.join(days)
def prweek(week, width): """Print a single week (no newline).""" for day in week: if day == 0: s = '' else: s = `day` print _center(s, width),
ad3bc44d52b9b9c1f1c7449d0991138fed5fe978 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ad3bc44d52b9b9c1f1c7449d0991138fed5fe978/calendar.py
str = '' if width >= 9: names = day_name else: names = day_abbr for i in range(7): if str: str = str + ' ' str = str + _center(names[i%7][:width], width) return str def prmonth(year, month, w = 0, l = 0):
if width >= 9: names = day_name else: names = day_abbr days = [] for i in range(_firstweekday, _firstweekday + 7): days.append(_center(names[i%7][:width], width)) return ' '.join(days) def prmonth(theyear, themonth, w=0, l=0):
def weekheader(width): """Return a header for a week.""" str = '' if width >= 9: names = day_name else: names = day_abbr for i in range(7): if str: str = str + ' ' str = str + _center(names[i%7][:width], width) return str
ad3bc44d52b9b9c1f1c7449d0991138fed5fe978 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ad3bc44d52b9b9c1f1c7449d0991138fed5fe978/calendar.py
print _center(month_name[month] + ' ' + `year`, 7*(w+1) - 1), print '\n'*l, print weekheader(w), print '\n'*l, for week in monthcalendar(year, month): prweek(week, w) print '\n'*l,
s = (_center(month_name[themonth] + ' ' + `theyear`, 7 * (w + 1) - 1).rstrip() + '\n' * l + weekheader(w).rstrip() + '\n' * l) for aweek in monthcalendar(theyear, themonth): s = s + week(aweek, w).rstrip() + '\n' * l return s[:-l] + '\n'
def prmonth(year, month, w = 0, l = 0): """Print a month's calendar.""" w = max(2, w) l = max(1, l) print _center(month_name[month] + ' ' + `year`, 7*(w+1) - 1), print '\n'*l, print weekheader(w), print '\n'*l, for week in monthcalendar(year, month): prweek(week, w) print '\n'*l,
ad3bc44d52b9b9c1f1c7449d0991138fed5fe978 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ad3bc44d52b9b9c1f1c7449d0991138fed5fe978/calendar.py
_spacing = ' '*4 def format3c(a, b, c): """3-column formatting for year calendars""" print _center(a, _colwidth), print _spacing, print _center(b, _colwidth), print _spacing, print _center(c, _colwidth) def prcal(year):
_spacing = 6 def format3c(a, b, c, colwidth=_colwidth, spacing=_spacing): """Prints 3-column formatting for year calendars""" print format3cstring(a, b, c, colwidth, spacing) def format3cstring(a, b, c, colwidth=_colwidth, spacing=_spacing): """Returns a string formatted from 3 strings, centered within 3 columns.""" return (_center(a, colwidth) + ' ' * spacing + _center(b, colwidth) + ' ' * spacing + _center(c, colwidth)) def prcal(year, w=0, l=0, c=_spacing):
def prmonth(year, month, w = 0, l = 0): """Print a month's calendar.""" w = max(2, w) l = max(1, l) print _center(month_name[month] + ' ' + `year`, 7*(w+1) - 1), print '\n'*l, print weekheader(w), print '\n'*l, for week in monthcalendar(year, month): prweek(week, w) print '\n'*l,
ad3bc44d52b9b9c1f1c7449d0991138fed5fe978 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ad3bc44d52b9b9c1f1c7449d0991138fed5fe978/calendar.py
header = weekheader(2) format3c('', `year`, '')
print calendar(year, w, l, c), def calendar(year, w=0, l=0, c=_spacing): """Returns a year's calendar as a multi-line string.""" w = max(2, w) l = max(1, l) c = max(2, c) colwidth = (w + 1) * 7 - 1 s = _center(`year`, colwidth * 3 + c * 2).rstrip() + '\n' * l header = weekheader(w) header = format3cstring(header, header, header, colwidth, c).rstrip()
def prcal(year): """Print a year's calendar.""" header = weekheader(2) format3c('', `year`, '') for q in range(January, January+12, 3): print format3c(month_name[q], month_name[q+1], month_name[q+2]) format3c(header, header, header) data = [] height = 0 for month in range(q, q+3): cal = monthcalendar(year, month) if len(cal) > height: height = len(cal) data.append(cal) for i in range(height): for cal in data: if i >= len(cal): print ' '*_colwidth, else: prweek(cal[i], 2) print _spacing, print
ad3bc44d52b9b9c1f1c7449d0991138fed5fe978 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ad3bc44d52b9b9c1f1c7449d0991138fed5fe978/calendar.py
print format3c(month_name[q], month_name[q+1], month_name[q+2]) format3c(header, header, header)
s = (s + '\n' * l + format3cstring(month_name[q], month_name[q+1], month_name[q+2], colwidth, c).rstrip() + '\n' * l + header + '\n' * l)
def prcal(year): """Print a year's calendar.""" header = weekheader(2) format3c('', `year`, '') for q in range(January, January+12, 3): print format3c(month_name[q], month_name[q+1], month_name[q+2]) format3c(header, header, header) data = [] height = 0 for month in range(q, q+3): cal = monthcalendar(year, month) if len(cal) > height: height = len(cal) data.append(cal) for i in range(height): for cal in data: if i >= len(cal): print ' '*_colwidth, else: prweek(cal[i], 2) print _spacing, print
ad3bc44d52b9b9c1f1c7449d0991138fed5fe978 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ad3bc44d52b9b9c1f1c7449d0991138fed5fe978/calendar.py
for month in range(q, q+3): cal = monthcalendar(year, month) if len(cal) > height: height = len(cal)
for amonth in range(q, q + 3): cal = monthcalendar(year, amonth) if len(cal) > height: height = len(cal)
def prcal(year): """Print a year's calendar.""" header = weekheader(2) format3c('', `year`, '') for q in range(January, January+12, 3): print format3c(month_name[q], month_name[q+1], month_name[q+2]) format3c(header, header, header) data = [] height = 0 for month in range(q, q+3): cal = monthcalendar(year, month) if len(cal) > height: height = len(cal) data.append(cal) for i in range(height): for cal in data: if i >= len(cal): print ' '*_colwidth, else: prweek(cal[i], 2) print _spacing, print
ad3bc44d52b9b9c1f1c7449d0991138fed5fe978 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ad3bc44d52b9b9c1f1c7449d0991138fed5fe978/calendar.py
print ' '*_colwidth,
weeks.append('')
def prcal(year): """Print a year's calendar.""" header = weekheader(2) format3c('', `year`, '') for q in range(January, January+12, 3): print format3c(month_name[q], month_name[q+1], month_name[q+2]) format3c(header, header, header) data = [] height = 0 for month in range(q, q+3): cal = monthcalendar(year, month) if len(cal) > height: height = len(cal) data.append(cal) for i in range(height): for cal in data: if i >= len(cal): print ' '*_colwidth, else: prweek(cal[i], 2) print _spacing, print
ad3bc44d52b9b9c1f1c7449d0991138fed5fe978 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ad3bc44d52b9b9c1f1c7449d0991138fed5fe978/calendar.py
prweek(cal[i], 2) print _spacing, print
weeks.append(week(cal[i], w)) s = s + format3cstring(weeks[0], weeks[1], weeks[2], colwidth, c).rstrip() + '\n' * l return s[:-l] + '\n'
def prcal(year): """Print a year's calendar.""" header = weekheader(2) format3c('', `year`, '') for q in range(January, January+12, 3): print format3c(month_name[q], month_name[q+1], month_name[q+2]) format3c(header, header, header) data = [] height = 0 for month in range(q, q+3): cal = monthcalendar(year, month) if len(cal) > height: height = len(cal) data.append(cal) for i in range(height): for cal in data: if i >= len(cal): print ' '*_colwidth, else: prweek(cal[i], 2) print _spacing, print
ad3bc44d52b9b9c1f1c7449d0991138fed5fe978 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ad3bc44d52b9b9c1f1c7449d0991138fed5fe978/calendar.py
try: obj.handle_read_event() except ExitNow: raise ExitNow except: obj.handle_error()
def poll (timeout=0.0, map=None): global DEBUG if map is None: map = socket_map if map: r = []; w = []; e = [] for fd, obj in map.items(): if obj.readable(): r.append (fd) if obj.writable(): w.append (fd) r,w,e = select.select (r,w,e, timeout) if DEBUG: print r,w,e for fd in r: try: obj = map[fd] try: obj.handle_read_event() except ExitNow: raise ExitNow except: obj.handle_error() except KeyError: pass for fd in w: try: obj = map[fd] try: obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error() except KeyError: pass
6ec9a36faf1d29062539bc654358e730395c377e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6ec9a36faf1d29062539bc654358e730395c377e/asyncore.py
pass
continue try: obj.handle_read_event() except ExitNow: raise ExitNow except: obj.handle_error()
def poll (timeout=0.0, map=None): global DEBUG if map is None: map = socket_map if map: r = []; w = []; e = [] for fd, obj in map.items(): if obj.readable(): r.append (fd) if obj.writable(): w.append (fd) r,w,e = select.select (r,w,e, timeout) if DEBUG: print r,w,e for fd in r: try: obj = map[fd] try: obj.handle_read_event() except ExitNow: raise ExitNow except: obj.handle_error() except KeyError: pass for fd in w: try: obj = map[fd] try: obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error() except KeyError: pass
6ec9a36faf1d29062539bc654358e730395c377e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6ec9a36faf1d29062539bc654358e730395c377e/asyncore.py
try: obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error()
def poll (timeout=0.0, map=None): global DEBUG if map is None: map = socket_map if map: r = []; w = []; e = [] for fd, obj in map.items(): if obj.readable(): r.append (fd) if obj.writable(): w.append (fd) r,w,e = select.select (r,w,e, timeout) if DEBUG: print r,w,e for fd in r: try: obj = map[fd] try: obj.handle_read_event() except ExitNow: raise ExitNow except: obj.handle_error() except KeyError: pass for fd in w: try: obj = map[fd] try: obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error() except KeyError: pass
6ec9a36faf1d29062539bc654358e730395c377e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6ec9a36faf1d29062539bc654358e730395c377e/asyncore.py
pass
continue try: obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error()
def poll (timeout=0.0, map=None): global DEBUG if map is None: map = socket_map if map: r = []; w = []; e = [] for fd, obj in map.items(): if obj.readable(): r.append (fd) if obj.writable(): w.append (fd) r,w,e = select.select (r,w,e, timeout) if DEBUG: print r,w,e for fd in r: try: obj = map[fd] try: obj.handle_read_event() except ExitNow: raise ExitNow except: obj.handle_error() except KeyError: pass for fd in w: try: obj = map[fd] try: obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error() except KeyError: pass
6ec9a36faf1d29062539bc654358e730395c377e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6ec9a36faf1d29062539bc654358e730395c377e/asyncore.py
try: if (flags & poll.POLLIN): obj.handle_read_event() if (flags & poll.POLLOUT): obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error()
def poll2 (timeout=0.0, map=None): import poll if map is None: map=socket_map if timeout is not None: # timeout is in milliseconds timeout = int(timeout*1000) if map: l = [] for fd, obj in map.items(): flags = 0 if obj.readable(): flags = poll.POLLIN if obj.writable(): flags = flags | poll.POLLOUT if flags: l.append ((fd, flags)) r = poll.poll (l, timeout) for fd, flags in r: try: obj = map[fd] try: if (flags & poll.POLLIN): obj.handle_read_event() if (flags & poll.POLLOUT): obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error() except KeyError: pass
6ec9a36faf1d29062539bc654358e730395c377e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6ec9a36faf1d29062539bc654358e730395c377e/asyncore.py
pass
continue try: if (flags & poll.POLLIN): obj.handle_read_event() if (flags & poll.POLLOUT): obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error()
def poll2 (timeout=0.0, map=None): import poll if map is None: map=socket_map if timeout is not None: # timeout is in milliseconds timeout = int(timeout*1000) if map: l = [] for fd, obj in map.items(): flags = 0 if obj.readable(): flags = poll.POLLIN if obj.writable(): flags = flags | poll.POLLOUT if flags: l.append ((fd, flags)) r = poll.poll (l, timeout) for fd, flags in r: try: obj = map[fd] try: if (flags & poll.POLLIN): obj.handle_read_event() if (flags & poll.POLLOUT): obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error() except KeyError: pass
6ec9a36faf1d29062539bc654358e730395c377e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6ec9a36faf1d29062539bc654358e730395c377e/asyncore.py
try: if (flags & select.POLLIN): obj.handle_read_event() if (flags & select.POLLOUT): obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error()
def poll3 (timeout=0.0, map=None): # Use the poll() support added to the select module in Python 2.0 if map is None: map=socket_map if timeout is not None: # timeout is in milliseconds timeout = int(timeout*1000) pollster = select.poll() if map: for fd, obj in map.items(): flags = 0 if obj.readable(): flags = select.POLLIN if obj.writable(): flags = flags | select.POLLOUT if flags: pollster.register(fd, flags) r = pollster.poll (timeout) for fd, flags in r: try: obj = map[fd] try: if (flags & select.POLLIN): obj.handle_read_event() if (flags & select.POLLOUT): obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error() except KeyError: pass
6ec9a36faf1d29062539bc654358e730395c377e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6ec9a36faf1d29062539bc654358e730395c377e/asyncore.py
pass
continue try: if (flags & select.POLLIN): obj.handle_read_event() if (flags & select.POLLOUT): obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error()
def poll3 (timeout=0.0, map=None): # Use the poll() support added to the select module in Python 2.0 if map is None: map=socket_map if timeout is not None: # timeout is in milliseconds timeout = int(timeout*1000) pollster = select.poll() if map: for fd, obj in map.items(): flags = 0 if obj.readable(): flags = select.POLLIN if obj.writable(): flags = flags | select.POLLOUT if flags: pollster.register(fd, flags) r = pollster.poll (timeout) for fd, flags in r: try: obj = map[fd] try: if (flags & select.POLLIN): obj.handle_read_event() if (flags & select.POLLOUT): obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error() except KeyError: pass
6ec9a36faf1d29062539bc654358e730395c377e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6ec9a36faf1d29062539bc654358e730395c377e/asyncore.py
self.dispatch = { \ 'call' : self.trace_dispatch_call, \ 'return' : self.trace_dispatch_return, \ 'exception': self.trace_dispatch_exception, \ }
def __init__(self, timer=None): self.timings = {} self.cur = None self.cmd = ""
edb5ffb2c145fc52df2195c22688db51034b08d5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/edb5ffb2c145fc52df2195c22688db51034b08d5/profile.py
self.get_time = self.get_time_mac
self.get_time = _get_time_mac
def __init__(self, timer=None): self.timings = {} self.cur = None self.cmd = ""
edb5ffb2c145fc52df2195c22688db51034b08d5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/edb5ffb2c145fc52df2195c22688db51034b08d5/profile.py
self.timer = time.clock
self.timer = self.get_time = time.clock
def __init__(self, timer=None): self.timings = {} self.cur = None self.cmd = ""
edb5ffb2c145fc52df2195c22688db51034b08d5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/edb5ffb2c145fc52df2195c22688db51034b08d5/profile.py
self.timer = time.time
self.timer = self.get_time = time.time
def __init__(self, timer=None): self.timings = {} self.cur = None self.cmd = ""
edb5ffb2c145fc52df2195c22688db51034b08d5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/edb5ffb2c145fc52df2195c22688db51034b08d5/profile.py
if len(t) == 2:
length = len(t) except TypeError: self.get_time = timer self.dispatcher = self.trace_dispatch_i else: if length == 2:
def __init__(self, timer=None): self.timings = {} self.cur = None self.cmd = ""
edb5ffb2c145fc52df2195c22688db51034b08d5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/edb5ffb2c145fc52df2195c22688db51034b08d5/profile.py
except TypeError: self.dispatcher = self.trace_dispatch_i
def get_time_timer(timer=timer, reduce=reduce, reducer=operator.add): return reduce(reducer, timer(), 0) self.get_time = get_time_timer
def __init__(self, timer=None): self.timings = {} self.cur = None self.cmd = ""
edb5ffb2c145fc52df2195c22688db51034b08d5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/edb5ffb2c145fc52df2195c22688db51034b08d5/profile.py
def get_time(self): t = self.timer() if type(t) == type(()) or type(t) == type([]): t = reduce(lambda x,y: x+y, t, 0) return t def get_time_mac(self): return self.timer()/60.0
def __init__(self, timer=None): self.timings = {} self.cur = None self.cmd = ""
edb5ffb2c145fc52df2195c22688db51034b08d5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/edb5ffb2c145fc52df2195c22688db51034b08d5/profile.py
t = self.timer()
timer = self.timer t = timer()
def trace_dispatch(self, frame, event, arg): t = self.timer() t = t[0] + t[1] - self.t # No Calibration constant # t = t[0] + t[1] - self.t - .00053 # Calibration constant
edb5ffb2c145fc52df2195c22688db51034b08d5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/edb5ffb2c145fc52df2195c22688db51034b08d5/profile.py
if self.dispatch[event](frame,t): t = self.timer()
if self.dispatch[event](self, frame,t): t = timer()
def trace_dispatch(self, frame, event, arg): t = self.timer() t = t[0] + t[1] - self.t # No Calibration constant # t = t[0] + t[1] - self.t - .00053 # Calibration constant
edb5ffb2c145fc52df2195c22688db51034b08d5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/edb5ffb2c145fc52df2195c22688db51034b08d5/profile.py
r = self.timer()
r = timer()
def trace_dispatch(self, frame, event, arg): t = self.timer() t = t[0] + t[1] - self.t # No Calibration constant # t = t[0] + t[1] - self.t - .00053 # Calibration constant
edb5ffb2c145fc52df2195c22688db51034b08d5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/edb5ffb2c145fc52df2195c22688db51034b08d5/profile.py
t = self.timer() - self.t if self.dispatch[event](frame,t): self.t = self.timer() else: self.t = self.timer() - t
timer = self.timer t = timer() - self.t if self.dispatch[event](self, frame,t): self.t = timer() else: self.t = timer() - t
def trace_dispatch_i(self, frame, event, arg): t = self.timer() - self.t # - 1 # Integer calibration constant if self.dispatch[event](frame,t): self.t = self.timer() else: self.t = self.timer() - t # put back unrecorded delta return
edb5ffb2c145fc52df2195c22688db51034b08d5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/edb5ffb2c145fc52df2195c22688db51034b08d5/profile.py
def trace_dispatch_i(self, frame, event, arg): t = self.timer() - self.t # - 1 # Integer calibration constant if self.dispatch[event](frame,t): self.t = self.timer() else: self.t = self.timer() - t # put back unrecorded delta return
edb5ffb2c145fc52df2195c22688db51034b08d5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/edb5ffb2c145fc52df2195c22688db51034b08d5/profile.py
t = self.timer()/60.0 - self.t if self.dispatch[event](frame,t): self.t = self.timer()/60.0 else: self.t = self.timer()/60.0 - t
timer = self.timer t = timer()/60.0 - self.t if self.dispatch[event](self, frame,t): self.t = timer()/60.0 else: self.t = timer()/60.0 - t
def trace_dispatch_mac(self, frame, event, arg): t = self.timer()/60.0 - self.t # - 1 # Integer calibration constant if self.dispatch[event](frame,t): self.t = self.timer()/60.0 else: self.t = self.timer()/60.0 - t # put back unrecorded delta return
edb5ffb2c145fc52df2195c22688db51034b08d5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/edb5ffb2c145fc52df2195c22688db51034b08d5/profile.py
t = self.get_time() - self.t if self.dispatch[event](frame,t): self.t = self.get_time() else: self.t = self.get_time()-t
get_time = self.get_time t = get_time() - self.t if self.dispatch[event](self, frame,t): self.t = get_time() else: self.t = get_time() - t
def trace_dispatch_l(self, frame, event, arg): t = self.get_time() - self.t
edb5ffb2c145fc52df2195c22688db51034b08d5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/edb5ffb2c145fc52df2195c22688db51034b08d5/profile.py
if self.timings.has_key(fn): cc, ns, tt, ct, callers = self.timings[fn] self.timings[fn] = cc, ns + 1, tt, ct, callers else: self.timings[fn] = 0, 0, 0, 0, {}
timings = self.timings if timings.has_key(fn): cc, ns, tt, ct, callers = timings[fn] timings[fn] = cc, ns + 1, tt, ct, callers else: timings[fn] = 0, 0, 0, 0, {}
def trace_dispatch_call(self, frame, t): fcode = frame.f_code fn = (fcode.co_filename, fcode.co_firstlineno, fcode.co_name) self.cur = (t, 0, 0, fn, frame, self.cur) if self.timings.has_key(fn): cc, ns, tt, ct, callers = self.timings[fn] self.timings[fn] = cc, ns + 1, tt, ct, callers else: self.timings[fn] = 0, 0, 0, 0, {} return 1
edb5ffb2c145fc52df2195c22688db51034b08d5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/edb5ffb2c145fc52df2195c22688db51034b08d5/profile.py
cc, ns, tt, ct, callers = self.timings[rfn]
timings = self.timings cc, ns, tt, ct, callers = timings[rfn]
def trace_dispatch_return(self, frame, t): # if not frame is self.cur[-2]: raise "Bad return", self.cur[3]
edb5ffb2c145fc52df2195c22688db51034b08d5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/edb5ffb2c145fc52df2195c22688db51034b08d5/profile.py
self.timings[rfn] = cc, ns - 1, tt+rtt, ct, callers
timings[rfn] = cc, ns - 1, tt+rtt, ct, callers
def trace_dispatch_return(self, frame, t): # if not frame is self.cur[-2]: raise "Bad return", self.cur[3]
edb5ffb2c145fc52df2195c22688db51034b08d5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/edb5ffb2c145fc52df2195c22688db51034b08d5/profile.py
a = self.dispatch['call'](frame, 0)
a = self.dispatch['call'](self, frame, 0)
def simulate_call(self, name): code = self.fake_code('profile', 0, name) if self.cur: pframe = self.cur[-2] else: pframe = None frame = self.fake_frame(code, pframe) a = self.dispatch['call'](frame, 0) return
edb5ffb2c145fc52df2195c22688db51034b08d5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/edb5ffb2c145fc52df2195c22688db51034b08d5/profile.py
t = self.get_time() - self.t
get_time = self.get_time t = get_time() - self.t
def simulate_cmd_complete(self): t = self.get_time() - self.t while self.cur[-1]: # We *can* cause assertion errors here if # dispatch_trace_return checks for a frame match! a = self.dispatch['return'](self.cur[-2], t) t = 0 self.t = self.get_time() - t
edb5ffb2c145fc52df2195c22688db51034b08d5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/edb5ffb2c145fc52df2195c22688db51034b08d5/profile.py
a = self.dispatch['return'](self.cur[-2], t)
a = self.dispatch['return'](self, self.cur[-2], t)
def simulate_cmd_complete(self): t = self.get_time() - self.t while self.cur[-1]: # We *can* cause assertion errors here if # dispatch_trace_return checks for a frame match! a = self.dispatch['return'](self.cur[-2], t) t = 0 self.t = self.get_time() - t
edb5ffb2c145fc52df2195c22688db51034b08d5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/edb5ffb2c145fc52df2195c22688db51034b08d5/profile.py
self.t = self.get_time() - t
self.t = get_time() - t
def simulate_cmd_complete(self): t = self.get_time() - self.t while self.cur[-1]: # We *can* cause assertion errors here if # dispatch_trace_return checks for a frame match! a = self.dispatch['return'](self.cur[-2], t) t = 0 self.t = self.get_time() - t
edb5ffb2c145fc52df2195c22688db51034b08d5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/edb5ffb2c145fc52df2195c22688db51034b08d5/profile.py
def runcall(self, func, *args):
def runcall(self, func, *args, **kw):
def runcall(self, func, *args): self.set_cmd(`func`) sys.setprofile(self.dispatcher) try: return apply(func, args) finally: sys.setprofile(None)
edb5ffb2c145fc52df2195c22688db51034b08d5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/edb5ffb2c145fc52df2195c22688db51034b08d5/profile.py
return apply(func, args)
return apply(func, args, kw)
def runcall(self, func, *args): self.set_cmd(`func`) sys.setprofile(self.dispatcher) try: return apply(func, args) finally: sys.setprofile(None)
edb5ffb2c145fc52df2195c22688db51034b08d5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/edb5ffb2c145fc52df2195c22688db51034b08d5/profile.py
s = self.get_time()
s = get_time()
def calibrate(self, m): # Modified by Tim Peters n = m s = self.get_time() while n: self.simple() n = n - 1 f = self.get_time() my_simple = f - s #print "Simple =", my_simple,
edb5ffb2c145fc52df2195c22688db51034b08d5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/edb5ffb2c145fc52df2195c22688db51034b08d5/profile.py
f = self.get_time()
f = get_time()
def calibrate(self, m): # Modified by Tim Peters n = m s = self.get_time() while n: self.simple() n = n - 1 f = self.get_time() my_simple = f - s #print "Simple =", my_simple,
edb5ffb2c145fc52df2195c22688db51034b08d5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/edb5ffb2c145fc52df2195c22688db51034b08d5/profile.py
s = self.get_time()
s = get_time()
def calibrate(self, m): # Modified by Tim Peters n = m s = self.get_time() while n: self.simple() n = n - 1 f = self.get_time() my_simple = f - s #print "Simple =", my_simple,
edb5ffb2c145fc52df2195c22688db51034b08d5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/edb5ffb2c145fc52df2195c22688db51034b08d5/profile.py
f = self.get_time()
f = get_time()
def calibrate(self, m): # Modified by Tim Peters n = m s = self.get_time() while n: self.simple() n = n - 1 f = self.get_time() my_simple = f - s #print "Simple =", my_simple,
edb5ffb2c145fc52df2195c22688db51034b08d5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/edb5ffb2c145fc52df2195c22688db51034b08d5/profile.py
import sys import os
def Stats(*args): print 'Report generating functions are in the "pstats" module\a'
edb5ffb2c145fc52df2195c22688db51034b08d5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/edb5ffb2c145fc52df2195c22688db51034b08d5/profile.py
self.data[k] = v
self[k] = v
def update(self, dict): if isinstance(dict, UserDict): self.data.update(dict.data) elif isinstance(dict, type(self.data)): self.data.update(dict) else: for k, v in dict.items(): self.data[k] = v
f3b30747d660f3cecfbb5a8136d5dc30770c0882 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f3b30747d660f3cecfbb5a8136d5dc30770c0882/UserDict.py
return self.data.get(key, failobj)
if not self.has_key(key): return failobj return self[key]
def get(self, key, failobj=None): return self.data.get(key, failobj)
f3b30747d660f3cecfbb5a8136d5dc30770c0882 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f3b30747d660f3cecfbb5a8136d5dc30770c0882/UserDict.py
if not self.data.has_key(key): self.data[key] = failobj return self.data[key]
if not self.has_key(key): self[key] = failobj return self[key]
def setdefault(self, key, failobj=None): if not self.data.has_key(key): self.data[key] = failobj return self.data[key]
f3b30747d660f3cecfbb5a8136d5dc30770c0882 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f3b30747d660f3cecfbb5a8136d5dc30770c0882/UserDict.py
del self._data[element]
self.remove(element)
def discard(self, element): """Remove an element from a set if it is a member.
e399d08a4a64674761ccbdb102bc803d1d3b06d0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e399d08a4a64674761ccbdb102bc803d1d3b06d0/sets.py
'debug_script',
def _test(): import doctest doctest.testmod()
3afaaf24872d534e5782dbe6214fc7027a9d074a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3afaaf24872d534e5782dbe6214fc7027a9d074a/doctest.py
default_compiler = { 'posix': 'unix', 'nt': 'msvc', 'mac': 'mwerks', }
_default_compilers = ( ('cygwin.*', 'cygwin'), ('posix', 'unix'), ('nt', 'msvc'), ('mac', 'mwerks'), ) def get_default_compiler(osname=None, platform=None): """ Determine the default compiler to use for the given platform. osname should be one of the standard Python OS names (i.e. the ones returned by os.name) and platform the common value returned by sys.platform for the platform in question. The default values are os.name and sys.platform in case the parameters are not given. """ if osname is None: osname = os.name if platform is None: platform = sys.platform for pattern, compiler in _default_compilers: if re.match(pattern, platform) is not None or \ re.match(pattern, osname) is not None: return compiler return 'unix'
def mkpath (self, name, mode=0777): mkpath (name, mode, self.verbose, self.dry_run)
636b90638a0b26331bf0dc8bd3d16b334126cbb1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/636b90638a0b26331bf0dc8bd3d16b334126cbb1/ccompiler.py
compiler = default_compiler[plat]
compiler = get_default_compiler(plat)
def new_compiler (plat=None, compiler=None, verbose=0, dry_run=0, force=0): """Generate an instance of some CCompiler subclass for the supplied platform/compiler combination. 'plat' defaults to 'os.name' (eg. 'posix', 'nt'), and 'compiler' defaults to the default compiler for that platform. Currently only 'posix' and 'nt' are supported, and the default compilers are "traditional Unix interface" (UnixCCompiler class) and Visual C++ (MSVCCompiler class). Note that it's perfectly possible to ask for a Unix compiler object under Windows, and a Microsoft compiler object under Unix -- if you supply a value for 'compiler', 'plat' is ignored. """ if plat is None: plat = os.name try: if compiler is None: compiler = default_compiler[plat] (module_name, class_name, long_description) = compiler_class[compiler] except KeyError: msg = "don't know how to compile C/C++ code on platform '%s'" % plat if compiler is not None: msg = msg + " with '%s' compiler" % compiler raise DistutilsPlatformError, msg try: module_name = "distutils." + module_name __import__ (module_name) module = sys.modules[module_name] klass = vars(module)[class_name] except ImportError: raise DistutilsModuleError, \ "can't compile C/C++ code: unable to load module '%s'" % \ module_name except KeyError: raise DistutilsModuleError, \ ("can't compile C/C++ code: unable to find class '%s' " + "in module '%s'") % (class_name, module_name) return klass (verbose, dry_run, force)
636b90638a0b26331bf0dc8bd3d16b334126cbb1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/636b90638a0b26331bf0dc8bd3d16b334126cbb1/ccompiler.py
assert self.type is not None, self.__original
if self.type is None: raise ValueError, "unknown url type: %s" % self.__original
def get_type(self): if self.type is None: self.type, self.__r_type = splittype(self.__original) assert self.type is not None, self.__original return self.type
78cae61ad47f70208468a77d665b009601fac2be /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/78cae61ad47f70208468a77d665b009601fac2be/urllib2.py
if isinstance(s, StringType): unicode(s, charset.get_output_charset()) elif isinstance(s, UnicodeType): for charset in USASCII, charset, UTF8: try: s = s.encode(charset.get_output_charset()) break except UnicodeError: pass else: assert False, 'Could not encode to utf-8'
if charset <> '8bit': if isinstance(s, StringType): incodec = charset.input_codec or 'us-ascii' ustr = unicode(s, incodec) outcodec = charset.output_codec or 'us-ascii' ustr.encode(outcodec) elif isinstance(s, UnicodeType): for charset in USASCII, charset, UTF8: try: outcodec = charset.output_codec or 'us-ascii' s = s.encode(outcodec) break except UnicodeError: pass else: assert False, 'utf-8 conversion failed'
def append(self, s, charset=None): """Append a string to the MIME header.
67f8f2fe2a93081aaac8ddc1409df4b05daf4fab /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/67f8f2fe2a93081aaac8ddc1409df4b05daf4fab/Header.py
g = {'c': 0, '__builtins__': __builtins__}
import __builtin__ g = {'c': 0, '__builtins__': __builtin__}
def break_yolks(self): self.yolks = self.yolks - 2
dfdac1af4d323f4f69775794777197ea31d804ef /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/dfdac1af4d323f4f69775794777197ea31d804ef/test_new.py
print 'new.code()' d = new.code(3, 3, 3, 3, codestr, (), (), (), "<string>", "<name>", 1, "", (), ()) d = new.code(3, 3, 3, 3, codestr, (), (), (), "<string>", "<name>", 1, "") if verbose: print d
if hasattr(new, 'code'): print 'new.code()' d = new.code(3, 3, 3, 3, codestr, (), (), (), "<string>", "<name>", 1, "", (), ()) d = new.code(3, 3, 3, 3, codestr, (), (), (), "<string>", "<name>", 1, "") if verbose: print d
def break_yolks(self): self.yolks = self.yolks - 2
dfdac1af4d323f4f69775794777197ea31d804ef /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/dfdac1af4d323f4f69775794777197ea31d804ef/test_new.py
return self.socket.recvfrom(self.max_packet_size)
data, client_addr = self.socket.recvfrom(self.max_packet_size) return (data, self.socket), client_addr def server_activate(self): pass
def get_request(self): return self.socket.recvfrom(self.max_packet_size)
32490824b6d5765a72662229d46e48ee34377b2f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/32490824b6d5765a72662229d46e48ee34377b2f/SocketServer.py
bytes = "" while 1: line = self.rfile.readline() bytes = bytes + line if line == '\r\n' or line == '\n' or line == '': break
def parse_request(self): """Parse a request (internal).
cffb9dee673cd00ee341bdd504066af67e49f09b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/cffb9dee673cd00ee341bdd504066af67e49f09b/BaseHTTPServer.py
hfile = cStringIO.StringIO(bytes) self.headers = self.MessageClass(hfile)
self.headers = self.MessageClass(self.rfile, 0)
def parse_request(self): """Parse a request (internal).
cffb9dee673cd00ee341bdd504066af67e49f09b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/cffb9dee673cd00ee341bdd504066af67e49f09b/BaseHTTPServer.py
seq, request = rpc.request_queue.get(0)
seq, request = rpc.request_queue.get(block=True, timeout=0.05)
def main(del_exitfunc=False): """Start the Python execution server in a subprocess In the Python subprocess, RPCServer is instantiated with handlerclass MyHandler, which inherits register/unregister methods from RPCHandler via the mix-in class SocketIO. When the RPCServer 'server' is instantiated, the TCPServer initialization creates an instance of run.MyHandler and calls its handle() method. handle() instantiates a run.Executive object, passing it a reference to the MyHandler object. That reference is saved as attribute rpchandler of the Executive instance. The Executive methods have access to the reference and can pass it on to entities that they command (e.g. RemoteDebugger.Debugger.start_debugger()). The latter, in turn, can call MyHandler(SocketIO) register/unregister methods via the reference to register and unregister themselves. """ global exit_now global quitting global no_exitfunc no_exitfunc = del_exitfunc port = 8833 #time.sleep(15) # test subprocess not responding if sys.argv[1:]: port = int(sys.argv[1]) sys.argv[:] = [""] sockthread = threading.Thread(target=manage_socket, name='SockThread', args=((LOCALHOST, port),)) sockthread.setDaemon(True) sockthread.start() while 1: try: if exit_now: try: exit() except KeyboardInterrupt: # exiting but got an extra KBI? Try again! continue try: seq, request = rpc.request_queue.get(0) except Queue.Empty: time.sleep(0.05) continue method, args, kwargs = request ret = method(*args, **kwargs) rpc.response_queue.put((seq, ret)) except KeyboardInterrupt: if quitting: exit_now = True continue except SystemExit: raise except: type, value, tb = sys.exc_info() try: print_exception() rpc.response_queue.put((seq, None)) except: # Link didn't work, print same exception to __stderr__ traceback.print_exception(type, value, tb, file=sys.__stderr__) exit() else: continue
20345fb8aada23ff3b02f4bd54ff9a96b994dd5b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/20345fb8aada23ff3b02f4bd54ff9a96b994dd5b/run.py
time.sleep(0.05)
def main(del_exitfunc=False): """Start the Python execution server in a subprocess In the Python subprocess, RPCServer is instantiated with handlerclass MyHandler, which inherits register/unregister methods from RPCHandler via the mix-in class SocketIO. When the RPCServer 'server' is instantiated, the TCPServer initialization creates an instance of run.MyHandler and calls its handle() method. handle() instantiates a run.Executive object, passing it a reference to the MyHandler object. That reference is saved as attribute rpchandler of the Executive instance. The Executive methods have access to the reference and can pass it on to entities that they command (e.g. RemoteDebugger.Debugger.start_debugger()). The latter, in turn, can call MyHandler(SocketIO) register/unregister methods via the reference to register and unregister themselves. """ global exit_now global quitting global no_exitfunc no_exitfunc = del_exitfunc port = 8833 #time.sleep(15) # test subprocess not responding if sys.argv[1:]: port = int(sys.argv[1]) sys.argv[:] = [""] sockthread = threading.Thread(target=manage_socket, name='SockThread', args=((LOCALHOST, port),)) sockthread.setDaemon(True) sockthread.start() while 1: try: if exit_now: try: exit() except KeyboardInterrupt: # exiting but got an extra KBI? Try again! continue try: seq, request = rpc.request_queue.get(0) except Queue.Empty: time.sleep(0.05) continue method, args, kwargs = request ret = method(*args, **kwargs) rpc.response_queue.put((seq, ret)) except KeyboardInterrupt: if quitting: exit_now = True continue except SystemExit: raise except: type, value, tb = sys.exc_info() try: print_exception() rpc.response_queue.put((seq, None)) except: # Link didn't work, print same exception to __stderr__ traceback.print_exception(type, value, tb, file=sys.__stderr__) exit() else: continue
20345fb8aada23ff3b02f4bd54ff9a96b994dd5b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/20345fb8aada23ff3b02f4bd54ff9a96b994dd5b/run.py
import pprint pprint.pprint(self.__dict__)
pass
def report(self): # XXX something decent import pprint pprint.pprint(self.__dict__)
74bdca8a207af74796b7e4a117886be92818f6cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/74bdca8a207af74796b7e4a117886be92818f6cb/bundlebuilder.py