rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
testformat("One million is %i", 1000000, grouping=1, output='One million is 1,000,000',
testformat("One million is %i", 1000000, grouping=1, output='One million is 1%s000%s000' % (sep, sep),
def testformat(formatstr, value, grouping = 0, output=None, func=locale.format): if verbose: if output: print "%s %% %s =? %s ..." %\ (repr(formatstr), repr(value), repr(output)), else: print "%s %% %s works? ..." % (repr(formatstr), repr(value)), result = func(formatstr, value, grouping = grouping) if output and result != output: if verbose: print 'no' print "%s %% %s == %s != %s" %\ (repr(formatstr), repr(value), repr(result), repr(output)) else: if verbose: print "yes"
3173101aa34aee8b9fe17db6efcad0224c46775b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/3173101aa34aee8b9fe17db6efcad0224c46775b/test_locale.py
testformat("One million is %i", 1000000, grouping=1, output='One million is 1,000,000',
testformat("One million is %i", 1000000, grouping=1, output='One million is 1%s000%s000' % (sep, sep),
def testformat(formatstr, value, grouping = 0, output=None, func=locale.format): if verbose: if output: print "%s %% %s =? %s ..." %\ (repr(formatstr), repr(value), repr(output)), else: print "%s %% %s works? ..." % (repr(formatstr), repr(value)), result = func(formatstr, value, grouping = grouping) if output and result != output: if verbose: print 'no' print "%s %% %s == %s != %s" %\ (repr(formatstr), repr(value), repr(result), repr(output)) else: if verbose: print "yes"
3173101aa34aee8b9fe17db6efcad0224c46775b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/3173101aa34aee8b9fe17db6efcad0224c46775b/test_locale.py
testformat("--> %10.2f", 1000.0, grouping=1, output='--> 1,000.00',
testformat("--> %10.2f", 1000.0, grouping=1, output='--> 1%s000.00' % sep,
def testformat(formatstr, value, grouping = 0, output=None, func=locale.format): if verbose: if output: print "%s %% %s =? %s ..." %\ (repr(formatstr), repr(value), repr(output)), else: print "%s %% %s works? ..." % (repr(formatstr), repr(value)), result = func(formatstr, value, grouping = grouping) if output and result != output: if verbose: print 'no' print "%s %% %s == %s != %s" %\ (repr(formatstr), repr(value), repr(result), repr(output)) else: if verbose: print "yes"
3173101aa34aee8b9fe17db6efcad0224c46775b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/3173101aa34aee8b9fe17db6efcad0224c46775b/test_locale.py
testformat("%*.*f", (10, 2, 1000.0), grouping=1, output=' 1,000.00',
testformat("%*.*f", (10, 2, 1000.0), grouping=1, output=' 1%s000.00' % sep,
def testformat(formatstr, value, grouping = 0, output=None, func=locale.format): if verbose: if output: print "%s %% %s =? %s ..." %\ (repr(formatstr), repr(value), repr(output)), else: print "%s %% %s works? ..." % (repr(formatstr), repr(value)), result = func(formatstr, value, grouping = grouping) if output and result != output: if verbose: print 'no' print "%s %% %s == %s != %s" %\ (repr(formatstr), repr(value), repr(result), repr(output)) else: if verbose: print "yes"
3173101aa34aee8b9fe17db6efcad0224c46775b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/3173101aa34aee8b9fe17db6efcad0224c46775b/test_locale.py
output='int 1,000 float 1,000.00 str str', func=locale.format_string)
output='int 1%s000 float 1%s000.00 str str' % (sep, sep), func=locale.format_string)
def testformat(formatstr, value, grouping = 0, output=None, func=locale.format): if verbose: if output: print "%s %% %s =? %s ..." %\ (repr(formatstr), repr(value), repr(output)), else: print "%s %% %s works? ..." % (repr(formatstr), repr(value)), result = func(formatstr, value, grouping = grouping) if output and result != output: if verbose: print 'no' print "%s %% %s == %s != %s" %\ (repr(formatstr), repr(value), repr(result), repr(output)) else: if verbose: print "yes"
3173101aa34aee8b9fe17db6efcad0224c46775b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/3173101aa34aee8b9fe17db6efcad0224c46775b/test_locale.py
def __init__(self, sock=None): dispatcher.__init__(self, sock)
def __init__(self, sock=None, map=None): dispatcher.__init__(self, sock, map)
def __init__(self, sock=None): dispatcher.__init__(self, sock) self.out_buffer = ''
e3c8d68c2d1389be47d47dbf4268cce31b3a8d6a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/e3c8d68c2d1389be47d47dbf4268cce31b3a8d6a/asyncore.py
def __init__(self, fd): dispatcher.__init__(self)
def __init__(self, fd, map=None): dispatcher.__init__(self, None, map)
def __init__(self, fd): dispatcher.__init__(self) self.connected = True # set it to non-blocking mode flags = fcntl.fcntl(fd, fcntl.F_GETFL, 0) flags = flags | os.O_NONBLOCK fcntl.fcntl(fd, fcntl.F_SETFL, flags) self.set_file(fd)
e3c8d68c2d1389be47d47dbf4268cce31b3a8d6a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/e3c8d68c2d1389be47d47dbf4268cce31b3a8d6a/asyncore.py
self.assertRaises(TypeError, islice, xrange(10))
self.assertEqual(list(islice(xrange(10))), range(10)) self.assertEqual(list(islice(xrange(10), None)), range(10)) self.assertEqual(list(islice(xrange(10), 2, None)), range(2, 10)) self.assertEqual(list(islice(xrange(10), 1, None, 2)), range(1, 10, 2))
def test_islice(self): for args in [ # islice(args) should agree with range(args) (10, 20, 3), (10, 3, 20), (10, 20), (10, 3), (20,) ]: self.assertEqual(list(islice(xrange(100), *args)), range(*args))
43a41b7f3cbe362bd5552430b136fedef1d0ce98 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/43a41b7f3cbe362bd5552430b136fedef1d0ce98/test_itertools.py
import test_itertools
def test_main(verbose=None): import test_itertools suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(TestBasicOps)) test_support.run_suite(suite) test_support.run_doctest(test_itertools, verbose) # verify reference counting import sys if verbose and hasattr(sys, "gettotalrefcount"): counts = [] for i in xrange(5): test_support.run_suite(suite) counts.append(sys.gettotalrefcount()-i) print counts
43a41b7f3cbe362bd5552430b136fedef1d0ce98 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/43a41b7f3cbe362bd5552430b136fedef1d0ce98/test_itertools.py
test_support.run_doctest(test_itertools, verbose)
def test_main(verbose=None): import test_itertools suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(TestBasicOps)) test_support.run_suite(suite) test_support.run_doctest(test_itertools, verbose) # verify reference counting import sys if verbose and hasattr(sys, "gettotalrefcount"): counts = [] for i in xrange(5): test_support.run_suite(suite) counts.append(sys.gettotalrefcount()-i) print counts
43a41b7f3cbe362bd5552430b136fedef1d0ce98 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/43a41b7f3cbe362bd5552430b136fedef1d0ce98/test_itertools.py
exts.append( Extension('nis', ['nismodule.c'], libraries = ['nsl']) )
libs = ['nsl'] else: libs = [] exts.append( Extension('nis', ['nismodule.c'], libraries = libs) )
def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.append('/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.append( '/usr/local/include' )
e98b82c9e287c91a53020cb0b5e25d55f0874f8c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/e98b82c9e287c91a53020cb0b5e25d55f0874f8c/setup.py
if _arguments.has_key('errn'):
if _arguments.get('errn', 0):
def run(self, _no_object=None, _attributes={}, **_arguments): """run: Run the Terminal application Keyword argument _attributes: AppleEvent attribute dictionary """ _code = 'core' _subcode = 'oapp'
0742bcf16b9bddb254aefb46a0ecc36325eddd4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/0742bcf16b9bddb254aefb46a0ecc36325eddd4f/Terminal_Suite.py
if _arguments.has_key('errn'):
if _arguments.get('errn', 0):
def quit(self, _no_object=None, _attributes={}, **_arguments): """quit: Quit the Terminal application Keyword argument _attributes: AppleEvent attribute dictionary """ _code = 'core' _subcode = 'quit'
0742bcf16b9bddb254aefb46a0ecc36325eddd4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/0742bcf16b9bddb254aefb46a0ecc36325eddd4f/Terminal_Suite.py
if _arguments.has_key('errn'):
if _arguments.get('errn', 0):
def count(self, _object=None, _attributes={}, **_arguments): """count: Return the number of elements of a particular class within an object Required argument: a reference to the objects to be counted Keyword argument _attributes: AppleEvent attribute dictionary Returns: the number of objects counted """ _code = 'core' _subcode = 'cnte'
0742bcf16b9bddb254aefb46a0ecc36325eddd4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/0742bcf16b9bddb254aefb46a0ecc36325eddd4f/Terminal_Suite.py
if _arguments.has_key('errn'):
if _arguments.get('errn', 0):
def do_script(self, _no_object=None, _attributes={}, **_arguments): """do script: Run a UNIX shell script or command Keyword argument with_command: data to be passed to the Terminal application as the command line Keyword argument _attributes: AppleEvent attribute dictionary """ _code = 'core' _subcode = 'dosc'
0742bcf16b9bddb254aefb46a0ecc36325eddd4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/0742bcf16b9bddb254aefb46a0ecc36325eddd4f/Terminal_Suite.py
test(r"""sre.match("\%03o" % i, chr(i)) != None""", 1) test(r"""sre.match("\%03o0" % i, chr(i)+"0") != None""", 1) test(r"""sre.match("\%03o8" % i, chr(i)+"8") != None""", 1)
test(r"""sre.match(r"\%03o" % i, chr(i)) != None""", 1) test(r"""sre.match(r"\%03o0" % i, chr(i)+"0") != None""", 1) test(r"""sre.match(r"\%03o8" % i, chr(i)+"8") != None""", 1)
def test(expression, result, exception=None): try: r = eval(expression) except: if exception: if not isinstance(sys.exc_value, exception): print expression, "FAILED" # display name, not actual value if exception is sre.error: print "expected", "sre.error" else: print "expected", exception.__name__ print "got", sys.exc_type.__name__, str(sys.exc_value) else: print expression, "FAILED" traceback.print_exc(file=sys.stdout) else: if exception: print expression, "FAILED" if exception is sre.error: print "expected", "sre.error" else: print "expected", exception.__name__ print "got result", repr(r) else: if r != result: print expression, "FAILED" print "expected", repr(result) print "got result", repr(r)
75e4f162be784b94ba0d3df4014079efb836f46b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/75e4f162be784b94ba0d3df4014079efb836f46b/test_sre.py
test(r"""sre.search('x*', 'axx').span(0)""", (0, 0)) test(r"""sre.search('x*', 'axx').span()""", (0, 0)) test(r"""sre.search('x+', 'axx').span(0)""", (1, 3)) test(r"""sre.search('x+', 'axx').span()""", (1, 3)) test(r"""sre.search('x', 'aaa')""", None) test(r"""sre.match('a*', 'xxx').span(0)""", (0, 0)) test(r"""sre.match('a*', 'xxx').span()""", (0, 0)) test(r"""sre.match('x*', 'xxxa').span(0)""", (0, 3)) test(r"""sre.match('x*', 'xxxa').span()""", (0, 3)) test(r"""sre.match('a+', 'xxx')""", None)
test(r"""sre.search(r'x*', 'axx').span(0)""", (0, 0)) test(r"""sre.search(r'x*', 'axx').span()""", (0, 0)) test(r"""sre.search(r'x+', 'axx').span(0)""", (1, 3)) test(r"""sre.search(r'x+', 'axx').span()""", (1, 3)) test(r"""sre.search(r'x', 'aaa')""", None) test(r"""sre.match(r'a*', 'xxx').span(0)""", (0, 0)) test(r"""sre.match(r'a*', 'xxx').span()""", (0, 0)) test(r"""sre.match(r'x*', 'xxxa').span(0)""", (0, 3)) test(r"""sre.match(r'x*', 'xxxa').span()""", (0, 3)) test(r"""sre.match(r'a+', 'xxx')""", None)
def test(expression, result, exception=None): try: r = eval(expression) except: if exception: if not isinstance(sys.exc_value, exception): print expression, "FAILED" # display name, not actual value if exception is sre.error: print "expected", "sre.error" else: print "expected", exception.__name__ print "got", sys.exc_type.__name__, str(sys.exc_value) else: print expression, "FAILED" traceback.print_exc(file=sys.stdout) else: if exception: print expression, "FAILED" if exception is sre.error: print "expected", "sre.error" else: print "expected", exception.__name__ print "got result", repr(r) else: if r != result: print expression, "FAILED" print "expected", repr(result) print "got result", repr(r)
75e4f162be784b94ba0d3df4014079efb836f46b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/75e4f162be784b94ba0d3df4014079efb836f46b/test_sre.py
test(r"""sre.match('(a)|(b)', 'b').start(1)""", -1) test(r"""sre.match('(a)|(b)', 'b').end(1)""", -1) test(r"""sre.match('(a)|(b)', 'b').span(1)""", (-1, -1))
test(r"""sre.match(r'(a)|(b)', 'b').start(1)""", -1) test(r"""sre.match(r'(a)|(b)', 'b').end(1)""", -1) test(r"""sre.match(r'(a)|(b)', 'b').span(1)""", (-1, -1))
def test(expression, result, exception=None): try: r = eval(expression) except: if exception: if not isinstance(sys.exc_value, exception): print expression, "FAILED" # display name, not actual value if exception is sre.error: print "expected", "sre.error" else: print "expected", exception.__name__ print "got", sys.exc_type.__name__, str(sys.exc_value) else: print expression, "FAILED" traceback.print_exc(file=sys.stdout) else: if exception: print expression, "FAILED" if exception is sre.error: print "expected", "sre.error" else: print "expected", exception.__name__ print "got result", repr(r) else: if r != result: print expression, "FAILED" print "expected", repr(result) print "got result", repr(r)
75e4f162be784b94ba0d3df4014079efb836f46b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/75e4f162be784b94ba0d3df4014079efb836f46b/test_sre.py
test(r"""sre.sub("(?i)b+", "x", "bbbb BBBB")""", 'x x')
test(r"""sre.sub(r"(?i)b+", "x", "bbbb BBBB")""", 'x x')
def test(expression, result, exception=None): try: r = eval(expression) except: if exception: if not isinstance(sys.exc_value, exception): print expression, "FAILED" # display name, not actual value if exception is sre.error: print "expected", "sre.error" else: print "expected", exception.__name__ print "got", sys.exc_type.__name__, str(sys.exc_value) else: print expression, "FAILED" traceback.print_exc(file=sys.stdout) else: if exception: print expression, "FAILED" if exception is sre.error: print "expected", "sre.error" else: print "expected", exception.__name__ print "got result", repr(r) else: if r != result: print expression, "FAILED" print "expected", repr(result) print "got result", repr(r)
75e4f162be784b94ba0d3df4014079efb836f46b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/75e4f162be784b94ba0d3df4014079efb836f46b/test_sre.py
test(r"""sre.sub('.', lambda m: r"\n", 'x')""", '\\n') test(r"""sre.sub('.', r"\n", 'x')""", '\n')
test(r"""sre.sub(r'.', lambda m: r"\n", 'x')""", '\\n') test(r"""sre.sub(r'.', r"\n", 'x')""", '\n')
def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1)
75e4f162be784b94ba0d3df4014079efb836f46b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/75e4f162be784b94ba0d3df4014079efb836f46b/test_sre.py
test(r"""sre.sub('(.)', s, 'x')""", 'xx') test(r"""sre.sub('(.)', sre.escape(s), 'x')""", s) test(r"""sre.sub('(.)', lambda m: s, 'x')""", s) test(r"""sre.sub('(?P<a>x)', '\g<a>\g<a>', 'xx')""", 'xxxx') test(r"""sre.sub('(?P<a>x)', '\g<a>\g<1>', 'xx')""", 'xxxx') test(r"""sre.sub('(?P<unk>x)', '\g<unk>\g<unk>', 'xx')""", 'xxxx') test(r"""sre.sub('(?P<unk>x)', '\g<1>\g<1>', 'xx')""", 'xxxx') test(r"""sre.sub('a', r'\t\n\v\r\f\a\b\B\Z\a\A\w\W\s\S\d\D', 'a')""", '\t\n\v\r\f\a\b\\B\\Z\a\\A\\w\\W\\s\\S\\d\\D') test(r"""sre.sub('a', '\t\n\v\r\f\a', 'a')""", '\t\n\v\r\f\a') test(r"""sre.sub('a', '\t\n\v\r\f\a', 'a')""", (chr(9)+chr(10)+chr(11)+chr(13)+chr(12)+chr(7))) test(r"""sre.sub('^\s*', 'X', 'test')""", 'Xtest')
test(r"""sre.sub(r'(.)', s, 'x')""", 'xx') test(r"""sre.sub(r'(.)', sre.escape(s), 'x')""", s) test(r"""sre.sub(r'(.)', lambda m: s, 'x')""", s) test(r"""sre.sub(r'(?P<a>x)', '\g<a>\g<a>', 'xx')""", 'xxxx') test(r"""sre.sub(r'(?P<a>x)', '\g<a>\g<1>', 'xx')""", 'xxxx') test(r"""sre.sub(r'(?P<unk>x)', '\g<unk>\g<unk>', 'xx')""", 'xxxx') test(r"""sre.sub(r'(?P<unk>x)', '\g<1>\g<1>', 'xx')""", 'xxxx') test(r"""sre.sub(r'a', r'\t\n\v\r\f\a\b\B\Z\a\A\w\W\s\S\d\D', 'a')""", '\t\n\v\r\f\a\b\\B\\Z\a\\A\\w\\W\\s\\S\\d\\D') test(r"""sre.sub(r'a', '\t\n\v\r\f\a', 'a')""", '\t\n\v\r\f\a') test(r"""sre.sub(r'a', '\t\n\v\r\f\a', 'a')""", (chr(9)+chr(10)+chr(11)+chr(13)+chr(12)+chr(7))) test(r"""sre.sub(r'^\s*', 'X', 'test')""", 'Xtest')
def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1)
75e4f162be784b94ba0d3df4014079efb836f46b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/75e4f162be784b94ba0d3df4014079efb836f46b/test_sre.py
test(r"""sre.sub('a', 'b', 'aaaaa')""", 'bbbbb') test(r"""sre.sub('a', 'b', 'aaaaa', 1)""", 'baaaa')
test(r"""sre.sub(r'a', 'b', 'aaaaa')""", 'bbbbb') test(r"""sre.sub(r'a', 'b', 'aaaaa', 1)""", 'baaaa')
def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1)
75e4f162be784b94ba0d3df4014079efb836f46b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/75e4f162be784b94ba0d3df4014079efb836f46b/test_sre.py
test(r"""sre.sub('(?P<a>x)', '\g<a', 'xx')""", None, sre.error) test(r"""sre.sub('(?P<a>x)', '\g<', 'xx')""", None, sre.error) test(r"""sre.sub('(?P<a>x)', '\g', 'xx')""", None, sre.error) test(r"""sre.sub('(?P<a>x)', '\g<a a>', 'xx')""", None, sre.error) test(r"""sre.sub('(?P<a>x)', '\g<1a1>', 'xx')""", None, sre.error) test(r"""sre.sub('(?P<a>x)', '\g<ab>', 'xx')""", None, IndexError) test(r"""sre.sub('(?P<a>x)|(?P<b>y)', '\g<b>', 'xx')""", None, sre.error) test(r"""sre.sub('(?P<a>x)|(?P<b>y)', '\\2', 'xx')""", None, sre.error)
test(r"""sre.sub(r'(?P<a>x)', '\g<a', 'xx')""", None, sre.error) test(r"""sre.sub(r'(?P<a>x)', '\g<', 'xx')""", None, sre.error) test(r"""sre.sub(r'(?P<a>x)', '\g', 'xx')""", None, sre.error) test(r"""sre.sub(r'(?P<a>x)', '\g<a a>', 'xx')""", None, sre.error) test(r"""sre.sub(r'(?P<a>x)', '\g<1a1>', 'xx')""", None, sre.error) test(r"""sre.sub(r'(?P<a>x)', '\g<ab>', 'xx')""", None, IndexError) test(r"""sre.sub(r'(?P<a>x)|(?P<b>y)', '\g<b>', 'xx')""", None, sre.error) test(r"""sre.sub(r'(?P<a>x)|(?P<b>y)', '\\2', 'xx')""", None, sre.error)
def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1)
75e4f162be784b94ba0d3df4014079efb836f46b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/75e4f162be784b94ba0d3df4014079efb836f46b/test_sre.py
test(r"""sre.subn("(?i)b+", "x", "bbbb BBBB")""", ('x x', 2)) test(r"""sre.subn("b+", "x", "bbbb BBBB")""", ('x BBBB', 1)) test(r"""sre.subn("b+", "x", "xyz")""", ('xyz', 0)) test(r"""sre.subn("b*", "x", "xyz")""", ('xxxyxzx', 4)) test(r"""sre.subn("b*", "x", "xyz", 2)""", ('xxxyz', 2))
test(r"""sre.subn(r"(?i)b+", "x", "bbbb BBBB")""", ('x x', 2)) test(r"""sre.subn(r"b+", "x", "bbbb BBBB")""", ('x BBBB', 1)) test(r"""sre.subn(r"b+", "x", "xyz")""", ('xyz', 0)) test(r"""sre.subn(r"b*", "x", "xyz")""", ('xxxyxzx', 4)) test(r"""sre.subn(r"b*", "x", "xyz", 2)""", ('xxxyz', 2))
def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1)
75e4f162be784b94ba0d3df4014079efb836f46b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/75e4f162be784b94ba0d3df4014079efb836f46b/test_sre.py
test(r"""sre.split(":", ":a:b::c")""", ['', 'a', 'b', '', 'c']) test(r"""sre.split(":*", ":a:b::c")""", ['', 'a', 'b', 'c']) test(r"""sre.split("(:*)", ":a:b::c")""", ['', ':', 'a', ':', 'b', '::', 'c']) test(r"""sre.split("(?::*)", ":a:b::c")""", ['', 'a', 'b', 'c']) test(r"""sre.split("(:)*", ":a:b::c")""", ['', ':', 'a', ':', 'b', ':', 'c']) test(r"""sre.split("([b:]+)", ":a:b::c")""", ['', ':', 'a', ':b::', 'c']) test(r"""sre.split("(b)|(:+)", ":a:b::c")""",
test(r"""sre.split(r":", ":a:b::c")""", ['', 'a', 'b', '', 'c']) test(r"""sre.split(r":*", ":a:b::c")""", ['', 'a', 'b', 'c']) test(r"""sre.split(r"(:*)", ":a:b::c")""", ['', ':', 'a', ':', 'b', '::', 'c']) test(r"""sre.split(r"(?::*)", ":a:b::c")""", ['', 'a', 'b', 'c']) test(r"""sre.split(r"(:)*", ":a:b::c")""", ['', ':', 'a', ':', 'b', ':', 'c']) test(r"""sre.split(r"([b:]+)", ":a:b::c")""", ['', ':', 'a', ':b::', 'c']) test(r"""sre.split(r"(b)|(:+)", ":a:b::c")""",
def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1)
75e4f162be784b94ba0d3df4014079efb836f46b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/75e4f162be784b94ba0d3df4014079efb836f46b/test_sre.py
test(r"""sre.split("(?:b)|(?::+)", ":a:b::c")""", ['', 'a', '', '', 'c']) test(r"""sre.split(":", ":a:b::c", 2)""", ['', 'a', 'b::c']) test(r"""sre.split(':', 'a:b:c:d', 2)""", ['a', 'b', 'c:d']) test(r"""sre.split("(:)", ":a:b::c", 2)""", ['', ':', 'a', ':', 'b::c']) test(r"""sre.split("(:*)", ":a:b::c", 2)""", ['', ':', 'a', ':', 'b::c'])
test(r"""sre.split(r"(?:b)|(?::+)", ":a:b::c")""", ['', 'a', '', '', 'c']) test(r"""sre.split(r":", ":a:b::c", 2)""", ['', 'a', 'b::c']) test(r"""sre.split(r':', 'a:b:c:d', 2)""", ['a', 'b', 'c:d']) test(r"""sre.split(r"(:)", ":a:b::c", 2)""", ['', ':', 'a', ':', 'b::c']) test(r"""sre.split(r"(:*)", ":a:b::c", 2)""", ['', ':', 'a', ':', 'b::c'])
def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1)
75e4f162be784b94ba0d3df4014079efb836f46b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/75e4f162be784b94ba0d3df4014079efb836f46b/test_sre.py
test(r"""sre.findall(":+", "abc")""", []) test(r"""sre.findall(":+", "a:b::c:::d")""", [":", "::", ":::"]) test(r"""sre.findall("(:+)", "a:b::c:::d")""", [":", "::", ":::"]) test(r"""sre.findall("(:)(:*)", "a:b::c:::d")""",
test(r"""sre.findall(r":+", "abc")""", []) test(r"""sre.findall(r":+", "a:b::c:::d")""", [":", "::", ":::"]) test(r"""sre.findall(r"(:+)", "a:b::c:::d")""", [":", "::", ":::"]) test(r"""sre.findall(r"(:)(:*)", "a:b::c:::d")""",
def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1)
75e4f162be784b94ba0d3df4014079efb836f46b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/75e4f162be784b94ba0d3df4014079efb836f46b/test_sre.py
test(r"""sre.findall("(a)|(b)", "abc")""", [("a", ""), ("", "b")])
test(r"""sre.findall(r"(a)|(b)", "abc")""", [("a", ""), ("", "b")])
def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1)
75e4f162be784b94ba0d3df4014079efb836f46b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/75e4f162be784b94ba0d3df4014079efb836f46b/test_sre.py
test(r"""sre.match('a', 'a').groups()""", ()) test(r"""sre.match('(a)', 'a').groups()""", ('a',)) test(r"""sre.match('(a)', 'a').group(0)""", 'a') test(r"""sre.match('(a)', 'a').group(1)""", 'a') test(r"""sre.match('(a)', 'a').group(1, 1)""", ('a', 'a')) pat = sre.compile('((a)|(b))(c)?')
test(r"""sre.match(r'a', 'a').groups()""", ()) test(r"""sre.match(r'(a)', 'a').groups()""", ('a',)) test(r"""sre.match(r'(a)', 'a').group(0)""", 'a') test(r"""sre.match(r'(a)', 'a').group(1)""", 'a') test(r"""sre.match(r'(a)', 'a').group(1, 1)""", ('a', 'a')) pat = sre.compile(r'((a)|(b))(c)?')
def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1)
75e4f162be784b94ba0d3df4014079efb836f46b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/75e4f162be784b94ba0d3df4014079efb836f46b/test_sre.py
pat = sre.compile('(?:(?P<a1>a)|(?P<b2>b))(?P<c3>c)?')
pat = sre.compile(r'(?:(?P<a1>a)|(?P<b2>b))(?P<c3>c)?')
def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1)
75e4f162be784b94ba0d3df4014079efb836f46b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/75e4f162be784b94ba0d3df4014079efb836f46b/test_sre.py
pat = sre.compile('a(?:b|(c|e){1,2}?|d)+?(.)')
pat = sre.compile(r'a(?:b|(c|e){1,2}?|d)+?(.)')
def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1)
75e4f162be784b94ba0d3df4014079efb836f46b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/75e4f162be784b94ba0d3df4014079efb836f46b/test_sre.py
pat = sre.compile('a(?:b|(c|e){1,2}?|d)+?(.)')
pat = sre.compile(r'a(?:b|(c|e){1,2}?|d)+?(.)')
def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1)
75e4f162be784b94ba0d3df4014079efb836f46b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/75e4f162be784b94ba0d3df4014079efb836f46b/test_sre.py
test(r"""sre.match('(x)*', 50000*'x').span()""", (0, 50000), RuntimeError) test(r"""sre.match('(x)*y', 50000*'x'+'y').span()""", (0, 50001), RuntimeError) test(r"""sre.match('(x)*?y', 50000*'x'+'y').span()""", (0, 50001), RuntimeError)
test(r"""sre.match(r'(x)*', 50000*'x').span()""", (0, 50000), RuntimeError) test(r"""sre.match(r'(x)*y', 50000*'x'+'y').span()""", (0, 50001), RuntimeError) test(r"""sre.match(r'(x)*?y', 50000*'x'+'y').span()""", (0, 50001), RuntimeError)
def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1)
75e4f162be784b94ba0d3df4014079efb836f46b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/75e4f162be784b94ba0d3df4014079efb836f46b/test_sre.py
pass
print '=== Compiled incorrectly', t
def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1)
75e4f162be784b94ba0d3df4014079efb836f46b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/75e4f162be784b94ba0d3df4014079efb836f46b/test_sre.py
try: r, w, e = select.select(r, w, e, timeout) except select.error, err: if err[0] != EINTR: raise
if [] == r == w == e: time.sleep(timeout) else: try: r, w, e = select.select(r, w, e, timeout) except select.error, err: if err[0] not in (EINTR, ENOENT): raise
def poll(timeout=0.0, map=None): 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) try: r, w, e = select.select(r, w, e, timeout) except select.error, err: if err[0] != EINTR: raise for fd in r: obj = map.get(fd) if obj is None: continue read(obj) for fd in w: obj = map.get(fd) if obj is None: continue write(obj)
648b44d928dd88ae51f7594bd74976d3fa7bbf38 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/648b44d928dd88ae51f7594bd74976d3fa7bbf38/asyncore.py
('%w', '%d' % ((1+now[6]) % 7), 'weekday as a number (Sun 1st)'),
('%w', '0?%d' % ((1+now[6]) % 7), 'weekday as a number (Sun 1st)'),
def strftest(now): if verbose: print "strftime test for", time.ctime(now) nowsecs = str(long(now))[:-1] gmt = time.gmtime(now) now = time.localtime(now) if now[3] < 12: ampm='AM' else: ampm='PM' jan1 = time.localtime(time.mktime((now[0], 1, 1) + (0,)*6)) try: if now[8]: tz = time.tzname[1] else: tz = time.tzname[0] except AttributeError: tz = '' if now[3] > 12: clock12 = now[3] - 12 elif now[3] > 0: clock12 = now[3] else: clock12 = 12 expectations = ( ('%a', calendar.day_abbr[now[6]], 'abbreviated weekday name'), ('%A', calendar.day_name[now[6]], 'full weekday name'), ('%b', calendar.month_abbr[now[1]], 'abbreviated month name'), ('%B', calendar.month_name[now[1]], 'full month name'), # %c see below ('%d', '%02d' % now[2], 'day of month as number (00-31)'), ('%H', '%02d' % now[3], 'hour (00-23)'), ('%I', '%02d' % clock12, 'hour (01-12)'), ('%j', '%03d' % now[7], 'julian day (001-366)'), ('%m', '%02d' % now[1], 'month as number (01-12)'), ('%M', '%02d' % now[4], 'minute, (00-59)'), ('%p', ampm, 'AM or PM as appropriate'), ('%S', '%02d' % now[5], 'seconds of current time (00-60)'), ('%U', '%02d' % ((now[7] + jan1[6])/7), 'week number of the year (Sun 1st)'), ('%w', '%d' % ((1+now[6]) % 7), 'weekday as a number (Sun 1st)'), ('%W', '%02d' % ((now[7] + (jan1[6] - 1)%7)/7), 'week number of the year (Mon 1st)'), # %x see below ('%X', '%02d:%02d:%02d' % (now[3], now[4], now[5]), '%H:%M:%S'), ('%y', '%02d' % (now[0]%100), 'year without century'), ('%Y', '%d' % now[0], 'year with century'), # %Z see below ('%%', '%', 'single percent sign'), ) nonstandard_expectations = ( # These are standard but don't have predictable output ('%c', fixasctime(time.asctime(now)), 'near-asctime() format'), ('%x', '%02d/%02d/%02d' % (now[1], now[2], (now[0]%100)), '%m/%d/%y %H:%M:%S'), ('(%Z)', '(%s)' % tz, 'time zone name'), # These are some platform specific extensions ('%D', '%02d/%02d/%02d' % (now[1], now[2], (now[0]%100)), 'mm/dd/yy'), ('%e', '%2d' % now[2], 'day of month as number, blank padded ( 0-31)'), ('%h', calendar.month_abbr[now[1]], 'abbreviated month name'), ('%k', '%2d' % now[3], 'hour, blank padded ( 0-23)'), ('%n', '\n', 'newline character'), ('%r', '%02d:%02d:%02d %s' % (clock12, now[4], now[5], ampm), '%I:%M:%S %p'), ('%R', '%02d:%02d' % (now[3], now[4]), '%H:%M'), ('%s', nowsecs, 'seconds since the Epoch in UCT'), ('%t', '\t', 'tab character'), ('%T', '%02d:%02d:%02d' % (now[3], now[4], now[5]), '%H:%M:%S'), ('%3y', '%03d' % (now[0]%100), 'year without century rendered using fieldwidth'), ) if verbose: print "Strftime test, platform: %s, Python version: %s" % \ (sys.platform, string.split(sys.version)[0]) for e in expectations: try: result = time.strftime(e[0], now) except ValueError, error: print "Standard '%s' format gave error:" % e[0], error continue if result == e[1]: continue if result[0] == '%': print "Does not support standard '%s' format (%s)" % (e[0], e[2]) else: print "Conflict for %s (%s):" % (e[0], e[2]) print " Expected %s, but got %s" % (e[1], result) for e in nonstandard_expectations: try: result = time.strftime(e[0], now) except ValueError, result: if verbose: print "Error for nonstandard '%s' format (%s): %s" % \ (e[0], e[2], str(result)) continue if result == e[1]: if verbose: print "Supports nonstandard '%s' format (%s)" % (e[0], e[2]) elif result[0] == '%': if verbose: print "Does not appear to support '%s' format (%s)" % (e[0], e[2]) else: if verbose: print "Conflict for nonstandard '%s' format (%s):" % (e[0], e[2]) print " Expected %s, but got %s" % (e[1], result)
b6d075a4c9e64b4f0dc9adec846ababbabe32686 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b6d075a4c9e64b4f0dc9adec846ababbabe32686/test_strftime.py
('(%Z)', '(%s)' % tz, 'time zone name'),
('%Z', '%s' % tz, 'time zone name'),
def strftest(now): if verbose: print "strftime test for", time.ctime(now) nowsecs = str(long(now))[:-1] gmt = time.gmtime(now) now = time.localtime(now) if now[3] < 12: ampm='AM' else: ampm='PM' jan1 = time.localtime(time.mktime((now[0], 1, 1) + (0,)*6)) try: if now[8]: tz = time.tzname[1] else: tz = time.tzname[0] except AttributeError: tz = '' if now[3] > 12: clock12 = now[3] - 12 elif now[3] > 0: clock12 = now[3] else: clock12 = 12 expectations = ( ('%a', calendar.day_abbr[now[6]], 'abbreviated weekday name'), ('%A', calendar.day_name[now[6]], 'full weekday name'), ('%b', calendar.month_abbr[now[1]], 'abbreviated month name'), ('%B', calendar.month_name[now[1]], 'full month name'), # %c see below ('%d', '%02d' % now[2], 'day of month as number (00-31)'), ('%H', '%02d' % now[3], 'hour (00-23)'), ('%I', '%02d' % clock12, 'hour (01-12)'), ('%j', '%03d' % now[7], 'julian day (001-366)'), ('%m', '%02d' % now[1], 'month as number (01-12)'), ('%M', '%02d' % now[4], 'minute, (00-59)'), ('%p', ampm, 'AM or PM as appropriate'), ('%S', '%02d' % now[5], 'seconds of current time (00-60)'), ('%U', '%02d' % ((now[7] + jan1[6])/7), 'week number of the year (Sun 1st)'), ('%w', '%d' % ((1+now[6]) % 7), 'weekday as a number (Sun 1st)'), ('%W', '%02d' % ((now[7] + (jan1[6] - 1)%7)/7), 'week number of the year (Mon 1st)'), # %x see below ('%X', '%02d:%02d:%02d' % (now[3], now[4], now[5]), '%H:%M:%S'), ('%y', '%02d' % (now[0]%100), 'year without century'), ('%Y', '%d' % now[0], 'year with century'), # %Z see below ('%%', '%', 'single percent sign'), ) nonstandard_expectations = ( # These are standard but don't have predictable output ('%c', fixasctime(time.asctime(now)), 'near-asctime() format'), ('%x', '%02d/%02d/%02d' % (now[1], now[2], (now[0]%100)), '%m/%d/%y %H:%M:%S'), ('(%Z)', '(%s)' % tz, 'time zone name'), # These are some platform specific extensions ('%D', '%02d/%02d/%02d' % (now[1], now[2], (now[0]%100)), 'mm/dd/yy'), ('%e', '%2d' % now[2], 'day of month as number, blank padded ( 0-31)'), ('%h', calendar.month_abbr[now[1]], 'abbreviated month name'), ('%k', '%2d' % now[3], 'hour, blank padded ( 0-23)'), ('%n', '\n', 'newline character'), ('%r', '%02d:%02d:%02d %s' % (clock12, now[4], now[5], ampm), '%I:%M:%S %p'), ('%R', '%02d:%02d' % (now[3], now[4]), '%H:%M'), ('%s', nowsecs, 'seconds since the Epoch in UCT'), ('%t', '\t', 'tab character'), ('%T', '%02d:%02d:%02d' % (now[3], now[4], now[5]), '%H:%M:%S'), ('%3y', '%03d' % (now[0]%100), 'year without century rendered using fieldwidth'), ) if verbose: print "Strftime test, platform: %s, Python version: %s" % \ (sys.platform, string.split(sys.version)[0]) for e in expectations: try: result = time.strftime(e[0], now) except ValueError, error: print "Standard '%s' format gave error:" % e[0], error continue if result == e[1]: continue if result[0] == '%': print "Does not support standard '%s' format (%s)" % (e[0], e[2]) else: print "Conflict for %s (%s):" % (e[0], e[2]) print " Expected %s, but got %s" % (e[1], result) for e in nonstandard_expectations: try: result = time.strftime(e[0], now) except ValueError, result: if verbose: print "Error for nonstandard '%s' format (%s): %s" % \ (e[0], e[2], str(result)) continue if result == e[1]: if verbose: print "Supports nonstandard '%s' format (%s)" % (e[0], e[2]) elif result[0] == '%': if verbose: print "Does not appear to support '%s' format (%s)" % (e[0], e[2]) else: if verbose: print "Conflict for nonstandard '%s' format (%s):" % (e[0], e[2]) print " Expected %s, but got %s" % (e[1], result)
b6d075a4c9e64b4f0dc9adec846ababbabe32686 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b6d075a4c9e64b4f0dc9adec846ababbabe32686/test_strftime.py
if result == e[1]: continue
if re.match(e[1], result): continue
def strftest(now): if verbose: print "strftime test for", time.ctime(now) nowsecs = str(long(now))[:-1] gmt = time.gmtime(now) now = time.localtime(now) if now[3] < 12: ampm='AM' else: ampm='PM' jan1 = time.localtime(time.mktime((now[0], 1, 1) + (0,)*6)) try: if now[8]: tz = time.tzname[1] else: tz = time.tzname[0] except AttributeError: tz = '' if now[3] > 12: clock12 = now[3] - 12 elif now[3] > 0: clock12 = now[3] else: clock12 = 12 expectations = ( ('%a', calendar.day_abbr[now[6]], 'abbreviated weekday name'), ('%A', calendar.day_name[now[6]], 'full weekday name'), ('%b', calendar.month_abbr[now[1]], 'abbreviated month name'), ('%B', calendar.month_name[now[1]], 'full month name'), # %c see below ('%d', '%02d' % now[2], 'day of month as number (00-31)'), ('%H', '%02d' % now[3], 'hour (00-23)'), ('%I', '%02d' % clock12, 'hour (01-12)'), ('%j', '%03d' % now[7], 'julian day (001-366)'), ('%m', '%02d' % now[1], 'month as number (01-12)'), ('%M', '%02d' % now[4], 'minute, (00-59)'), ('%p', ampm, 'AM or PM as appropriate'), ('%S', '%02d' % now[5], 'seconds of current time (00-60)'), ('%U', '%02d' % ((now[7] + jan1[6])/7), 'week number of the year (Sun 1st)'), ('%w', '%d' % ((1+now[6]) % 7), 'weekday as a number (Sun 1st)'), ('%W', '%02d' % ((now[7] + (jan1[6] - 1)%7)/7), 'week number of the year (Mon 1st)'), # %x see below ('%X', '%02d:%02d:%02d' % (now[3], now[4], now[5]), '%H:%M:%S'), ('%y', '%02d' % (now[0]%100), 'year without century'), ('%Y', '%d' % now[0], 'year with century'), # %Z see below ('%%', '%', 'single percent sign'), ) nonstandard_expectations = ( # These are standard but don't have predictable output ('%c', fixasctime(time.asctime(now)), 'near-asctime() format'), ('%x', '%02d/%02d/%02d' % (now[1], now[2], (now[0]%100)), '%m/%d/%y %H:%M:%S'), ('(%Z)', '(%s)' % tz, 'time zone name'), # These are some platform specific extensions ('%D', '%02d/%02d/%02d' % (now[1], now[2], (now[0]%100)), 'mm/dd/yy'), ('%e', '%2d' % now[2], 'day of month as number, blank padded ( 0-31)'), ('%h', calendar.month_abbr[now[1]], 'abbreviated month name'), ('%k', '%2d' % now[3], 'hour, blank padded ( 0-23)'), ('%n', '\n', 'newline character'), ('%r', '%02d:%02d:%02d %s' % (clock12, now[4], now[5], ampm), '%I:%M:%S %p'), ('%R', '%02d:%02d' % (now[3], now[4]), '%H:%M'), ('%s', nowsecs, 'seconds since the Epoch in UCT'), ('%t', '\t', 'tab character'), ('%T', '%02d:%02d:%02d' % (now[3], now[4], now[5]), '%H:%M:%S'), ('%3y', '%03d' % (now[0]%100), 'year without century rendered using fieldwidth'), ) if verbose: print "Strftime test, platform: %s, Python version: %s" % \ (sys.platform, string.split(sys.version)[0]) for e in expectations: try: result = time.strftime(e[0], now) except ValueError, error: print "Standard '%s' format gave error:" % e[0], error continue if result == e[1]: continue if result[0] == '%': print "Does not support standard '%s' format (%s)" % (e[0], e[2]) else: print "Conflict for %s (%s):" % (e[0], e[2]) print " Expected %s, but got %s" % (e[1], result) for e in nonstandard_expectations: try: result = time.strftime(e[0], now) except ValueError, result: if verbose: print "Error for nonstandard '%s' format (%s): %s" % \ (e[0], e[2], str(result)) continue if result == e[1]: if verbose: print "Supports nonstandard '%s' format (%s)" % (e[0], e[2]) elif result[0] == '%': if verbose: print "Does not appear to support '%s' format (%s)" % (e[0], e[2]) else: if verbose: print "Conflict for nonstandard '%s' format (%s):" % (e[0], e[2]) print " Expected %s, but got %s" % (e[1], result)
b6d075a4c9e64b4f0dc9adec846ababbabe32686 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b6d075a4c9e64b4f0dc9adec846ababbabe32686/test_strftime.py
if result == e[1]:
if re.match(e[1], result):
def strftest(now): if verbose: print "strftime test for", time.ctime(now) nowsecs = str(long(now))[:-1] gmt = time.gmtime(now) now = time.localtime(now) if now[3] < 12: ampm='AM' else: ampm='PM' jan1 = time.localtime(time.mktime((now[0], 1, 1) + (0,)*6)) try: if now[8]: tz = time.tzname[1] else: tz = time.tzname[0] except AttributeError: tz = '' if now[3] > 12: clock12 = now[3] - 12 elif now[3] > 0: clock12 = now[3] else: clock12 = 12 expectations = ( ('%a', calendar.day_abbr[now[6]], 'abbreviated weekday name'), ('%A', calendar.day_name[now[6]], 'full weekday name'), ('%b', calendar.month_abbr[now[1]], 'abbreviated month name'), ('%B', calendar.month_name[now[1]], 'full month name'), # %c see below ('%d', '%02d' % now[2], 'day of month as number (00-31)'), ('%H', '%02d' % now[3], 'hour (00-23)'), ('%I', '%02d' % clock12, 'hour (01-12)'), ('%j', '%03d' % now[7], 'julian day (001-366)'), ('%m', '%02d' % now[1], 'month as number (01-12)'), ('%M', '%02d' % now[4], 'minute, (00-59)'), ('%p', ampm, 'AM or PM as appropriate'), ('%S', '%02d' % now[5], 'seconds of current time (00-60)'), ('%U', '%02d' % ((now[7] + jan1[6])/7), 'week number of the year (Sun 1st)'), ('%w', '%d' % ((1+now[6]) % 7), 'weekday as a number (Sun 1st)'), ('%W', '%02d' % ((now[7] + (jan1[6] - 1)%7)/7), 'week number of the year (Mon 1st)'), # %x see below ('%X', '%02d:%02d:%02d' % (now[3], now[4], now[5]), '%H:%M:%S'), ('%y', '%02d' % (now[0]%100), 'year without century'), ('%Y', '%d' % now[0], 'year with century'), # %Z see below ('%%', '%', 'single percent sign'), ) nonstandard_expectations = ( # These are standard but don't have predictable output ('%c', fixasctime(time.asctime(now)), 'near-asctime() format'), ('%x', '%02d/%02d/%02d' % (now[1], now[2], (now[0]%100)), '%m/%d/%y %H:%M:%S'), ('(%Z)', '(%s)' % tz, 'time zone name'), # These are some platform specific extensions ('%D', '%02d/%02d/%02d' % (now[1], now[2], (now[0]%100)), 'mm/dd/yy'), ('%e', '%2d' % now[2], 'day of month as number, blank padded ( 0-31)'), ('%h', calendar.month_abbr[now[1]], 'abbreviated month name'), ('%k', '%2d' % now[3], 'hour, blank padded ( 0-23)'), ('%n', '\n', 'newline character'), ('%r', '%02d:%02d:%02d %s' % (clock12, now[4], now[5], ampm), '%I:%M:%S %p'), ('%R', '%02d:%02d' % (now[3], now[4]), '%H:%M'), ('%s', nowsecs, 'seconds since the Epoch in UCT'), ('%t', '\t', 'tab character'), ('%T', '%02d:%02d:%02d' % (now[3], now[4], now[5]), '%H:%M:%S'), ('%3y', '%03d' % (now[0]%100), 'year without century rendered using fieldwidth'), ) if verbose: print "Strftime test, platform: %s, Python version: %s" % \ (sys.platform, string.split(sys.version)[0]) for e in expectations: try: result = time.strftime(e[0], now) except ValueError, error: print "Standard '%s' format gave error:" % e[0], error continue if result == e[1]: continue if result[0] == '%': print "Does not support standard '%s' format (%s)" % (e[0], e[2]) else: print "Conflict for %s (%s):" % (e[0], e[2]) print " Expected %s, but got %s" % (e[1], result) for e in nonstandard_expectations: try: result = time.strftime(e[0], now) except ValueError, result: if verbose: print "Error for nonstandard '%s' format (%s): %s" % \ (e[0], e[2], str(result)) continue if result == e[1]: if verbose: print "Supports nonstandard '%s' format (%s)" % (e[0], e[2]) elif result[0] == '%': if verbose: print "Does not appear to support '%s' format (%s)" % (e[0], e[2]) else: if verbose: print "Conflict for nonstandard '%s' format (%s):" % (e[0], e[2]) print " Expected %s, but got %s" % (e[1], result)
b6d075a4c9e64b4f0dc9adec846ababbabe32686 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b6d075a4c9e64b4f0dc9adec846ababbabe32686/test_strftime.py
text.bind('<<close-window', self.close_event)
text.bind('<<close-window>>', self.close_event)
def __init__(self, flist=None, filename=None, key=None, root=None): if EditorWindow.help_url is None: dochome = os.path.join(sys.prefix, 'Doc', 'index.html') if sys.platform.count('linux'): # look for html docs in a couple of standard places pyver = 'python-docs-' + '%s.%s.%s' % sys.version_info[:3] if os.path.isdir('/var/www/html/python/'): # "python2" rpm dochome = '/var/www/html/python/index.html' else: basepath = '/usr/share/doc/' # standard location dochome = os.path.join(basepath, pyver, 'Doc', 'index.html') elif sys.platform[:3] == 'win': chmfile = os.path.join(sys.prefix, 'Doc', 'Python%d%d.chm' % sys.version_info[:2]) if os.path.isfile(chmfile): dochome = chmfile
fadef043ba43ada57986b6ee114abadb5fb49487 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/fadef043ba43ada57986b6ee114abadb5fb49487/EditorWindow.py
def urlparse(url, scheme = '', allow_fragments = 1):
def urlparse(url, scheme='', allow_fragments=1):
def urlparse(url, scheme = '', allow_fragments = 1): """Parse a URL into 6 components: <scheme>://<netloc>/<path>;<params>?<query>#<fragment> Return a 6-tuple: (scheme, netloc, path, params, query, fragment). Note that we don't break the components up in smaller bits (e.g. netloc is a single string) and we don't expand % escapes.""" key = url, scheme, allow_fragments cached = _parse_cache.get(key, None) if cached: return cached if len(_parse_cache) >= MAX_CACHE_SIZE: # avoid runaway growth clear_cache() netloc = params = query = fragment = '' i = url.find(':') if i > 0: if url[:i] == 'http': # optimize the common case scheme = url[:i].lower() url = url[i+1:] if url[:2] == '//': i = url.find('/', 2) if i < 0: i = len(url) netloc = url[2:i] url = url[i:] if allow_fragments: i = url.rfind('#') if i >= 0: fragment = url[i+1:] url = url[:i] i = url.find('?') if i >= 0: query = url[i+1:] url = url[:i] i = url.find(';') if i >= 0: params = url[i+1:] url = url[:i] tuple = scheme, netloc, url, params, query, fragment _parse_cache[key] = tuple return tuple for c in url[:i]: if c not in scheme_chars: break else: scheme, url = url[:i].lower(), url[i+1:] if scheme in uses_netloc: if url[:2] == '//': i = url.find('/', 2) if i < 0: i = len(url) netloc, url = url[2:i], url[i:] if allow_fragments and scheme in uses_fragment: i = url.rfind('#') if i >= 0: url, fragment = url[:i], url[i+1:] if scheme in uses_query: i = url.find('?') if i >= 0: url, query = url[:i], url[i+1:] if scheme in uses_params: i = url.find(';') if i >= 0: url, params = url[:i], url[i+1:] tuple = scheme, netloc, url, params, query, fragment _parse_cache[key] = tuple return tuple
25350d7d3dc12d7365aaee887c8eb007dd4b7826 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/25350d7d3dc12d7365aaee887c8eb007dd4b7826/urlparse.py
netloc = params = query = fragment = ''
netloc = query = fragment = ''
def urlparse(url, scheme = '', allow_fragments = 1): """Parse a URL into 6 components: <scheme>://<netloc>/<path>;<params>?<query>#<fragment> Return a 6-tuple: (scheme, netloc, path, params, query, fragment). Note that we don't break the components up in smaller bits (e.g. netloc is a single string) and we don't expand % escapes.""" key = url, scheme, allow_fragments cached = _parse_cache.get(key, None) if cached: return cached if len(_parse_cache) >= MAX_CACHE_SIZE: # avoid runaway growth clear_cache() netloc = params = query = fragment = '' i = url.find(':') if i > 0: if url[:i] == 'http': # optimize the common case scheme = url[:i].lower() url = url[i+1:] if url[:2] == '//': i = url.find('/', 2) if i < 0: i = len(url) netloc = url[2:i] url = url[i:] if allow_fragments: i = url.rfind('#') if i >= 0: fragment = url[i+1:] url = url[:i] i = url.find('?') if i >= 0: query = url[i+1:] url = url[:i] i = url.find(';') if i >= 0: params = url[i+1:] url = url[:i] tuple = scheme, netloc, url, params, query, fragment _parse_cache[key] = tuple return tuple for c in url[:i]: if c not in scheme_chars: break else: scheme, url = url[:i].lower(), url[i+1:] if scheme in uses_netloc: if url[:2] == '//': i = url.find('/', 2) if i < 0: i = len(url) netloc, url = url[2:i], url[i:] if allow_fragments and scheme in uses_fragment: i = url.rfind('#') if i >= 0: url, fragment = url[:i], url[i+1:] if scheme in uses_query: i = url.find('?') if i >= 0: url, query = url[:i], url[i+1:] if scheme in uses_params: i = url.find(';') if i >= 0: url, params = url[:i], url[i+1:] tuple = scheme, netloc, url, params, query, fragment _parse_cache[key] = tuple return tuple
25350d7d3dc12d7365aaee887c8eb007dd4b7826 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/25350d7d3dc12d7365aaee887c8eb007dd4b7826/urlparse.py
if allow_fragments: i = url.rfind(' if i >= 0: fragment = url[i+1:] url = url[:i] i = url.find('?') if i >= 0: query = url[i+1:] url = url[:i] i = url.find(';') if i >= 0: params = url[i+1:] url = url[:i] tuple = scheme, netloc, url, params, query, fragment
if allow_fragments and ' url, fragment = url.split(' if '?' in url: url, query = url.split('?', 1) tuple = scheme, netloc, url, query, fragment
def urlparse(url, scheme = '', allow_fragments = 1): """Parse a URL into 6 components: <scheme>://<netloc>/<path>;<params>?<query>#<fragment> Return a 6-tuple: (scheme, netloc, path, params, query, fragment). Note that we don't break the components up in smaller bits (e.g. netloc is a single string) and we don't expand % escapes.""" key = url, scheme, allow_fragments cached = _parse_cache.get(key, None) if cached: return cached if len(_parse_cache) >= MAX_CACHE_SIZE: # avoid runaway growth clear_cache() netloc = params = query = fragment = '' i = url.find(':') if i > 0: if url[:i] == 'http': # optimize the common case scheme = url[:i].lower() url = url[i+1:] if url[:2] == '//': i = url.find('/', 2) if i < 0: i = len(url) netloc = url[2:i] url = url[i:] if allow_fragments: i = url.rfind('#') if i >= 0: fragment = url[i+1:] url = url[:i] i = url.find('?') if i >= 0: query = url[i+1:] url = url[:i] i = url.find(';') if i >= 0: params = url[i+1:] url = url[:i] tuple = scheme, netloc, url, params, query, fragment _parse_cache[key] = tuple return tuple for c in url[:i]: if c not in scheme_chars: break else: scheme, url = url[:i].lower(), url[i+1:] if scheme in uses_netloc: if url[:2] == '//': i = url.find('/', 2) if i < 0: i = len(url) netloc, url = url[2:i], url[i:] if allow_fragments and scheme in uses_fragment: i = url.rfind('#') if i >= 0: url, fragment = url[:i], url[i+1:] if scheme in uses_query: i = url.find('?') if i >= 0: url, query = url[:i], url[i+1:] if scheme in uses_params: i = url.find(';') if i >= 0: url, params = url[:i], url[i+1:] tuple = scheme, netloc, url, params, query, fragment _parse_cache[key] = tuple return tuple
25350d7d3dc12d7365aaee887c8eb007dd4b7826 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/25350d7d3dc12d7365aaee887c8eb007dd4b7826/urlparse.py
if allow_fragments and scheme in uses_fragment: i = url.rfind(' if i >= 0: url, fragment = url[:i], url[i+1:] if scheme in uses_query: i = url.find('?') if i >= 0: url, query = url[:i], url[i+1:] if scheme in uses_params: i = url.find(';') if i >= 0: url, params = url[:i], url[i+1:] tuple = scheme, netloc, url, params, query, fragment
if allow_fragments and scheme in uses_fragment and ' url, fragment = url.split(' if scheme in uses_query and '?' in url: url, query = url.split('?', 1) tuple = scheme, netloc, url, query, fragment
def urlparse(url, scheme = '', allow_fragments = 1): """Parse a URL into 6 components: <scheme>://<netloc>/<path>;<params>?<query>#<fragment> Return a 6-tuple: (scheme, netloc, path, params, query, fragment). Note that we don't break the components up in smaller bits (e.g. netloc is a single string) and we don't expand % escapes.""" key = url, scheme, allow_fragments cached = _parse_cache.get(key, None) if cached: return cached if len(_parse_cache) >= MAX_CACHE_SIZE: # avoid runaway growth clear_cache() netloc = params = query = fragment = '' i = url.find(':') if i > 0: if url[:i] == 'http': # optimize the common case scheme = url[:i].lower() url = url[i+1:] if url[:2] == '//': i = url.find('/', 2) if i < 0: i = len(url) netloc = url[2:i] url = url[i:] if allow_fragments: i = url.rfind('#') if i >= 0: fragment = url[i+1:] url = url[:i] i = url.find('?') if i >= 0: query = url[i+1:] url = url[:i] i = url.find(';') if i >= 0: params = url[i+1:] url = url[:i] tuple = scheme, netloc, url, params, query, fragment _parse_cache[key] = tuple return tuple for c in url[:i]: if c not in scheme_chars: break else: scheme, url = url[:i].lower(), url[i+1:] if scheme in uses_netloc: if url[:2] == '//': i = url.find('/', 2) if i < 0: i = len(url) netloc, url = url[2:i], url[i:] if allow_fragments and scheme in uses_fragment: i = url.rfind('#') if i >= 0: url, fragment = url[:i], url[i+1:] if scheme in uses_query: i = url.find('?') if i >= 0: url, query = url[:i], url[i+1:] if scheme in uses_params: i = url.find(';') if i >= 0: url, params = url[:i], url[i+1:] tuple = scheme, netloc, url, params, query, fragment _parse_cache[key] = tuple return tuple
25350d7d3dc12d7365aaee887c8eb007dd4b7826 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/25350d7d3dc12d7365aaee887c8eb007dd4b7826/urlparse.py
if params: url = url + ';' + params
def urlunparse((scheme, netloc, url, params, query, fragment)): """Put a parsed URL back together again. This may result in a slightly different, but equivalent URL, if the URL that was parsed originally had redundant delimiters, e.g. a ? with an empty query (the draft states that these are equivalent).""" if netloc or (scheme in uses_netloc and url[:2] == '//'): if url and url[:1] != '/': url = '/' + url url = '//' + (netloc or '') + url if scheme: url = scheme + ':' + url if params: url = url + ';' + params if query: url = url + '?' + query if fragment: url = url + '#' + fragment return url
25350d7d3dc12d7365aaee887c8eb007dd4b7826 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/25350d7d3dc12d7365aaee887c8eb007dd4b7826/urlparse.py
s, n, p, a, q, frag = urlparse(url) defrag = urlunparse((s, n, p, a, q, '')) return defrag, frag
if ' s, n, p, a, q, frag = urlparse(url) defrag = urlunparse((s, n, p, a, q, '')) return defrag, frag else: return url, ''
def urldefrag(url): """Removes any existing fragment from URL. Returns a tuple of the defragmented URL and the fragment. If the URL contained no fragments, the second element is the empty string. """ s, n, p, a, q, frag = urlparse(url) defrag = urlunparse((s, n, p, a, q, '')) return defrag, frag
25350d7d3dc12d7365aaee887c8eb007dd4b7826 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/25350d7d3dc12d7365aaee887c8eb007dd4b7826/urlparse.py
verify(f4.func_code.co_varnames == ('two', '.2', 'compound', 'argument', 'list')) verify(f5.func_code.co_varnames == ('.0', 'two', 'compound', 'first'))
if sys.platform.startswith('java'): verify(f4.func_code.co_varnames == ('two', '(compound, (argument, list))',)) verify(f5.func_code.co_varnames == ('(compound, first)', 'two', 'compound', 'first')) else: verify(f4.func_code.co_varnames == ('two', '.2', 'compound', 'argument', 'list')) verify(f5.func_code.co_varnames == ('.0', 'two', 'compound', 'first'))
def f5((compound, first), two): pass
bf3fa7b64c1804fdf2181e6768aba7e5324b9339 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/bf3fa7b64c1804fdf2181e6768aba7e5324b9339/test_grammar.py
verify(v3.func_code.co_varnames == ('a', '.2', 'rest', 'b', 'c'))
if sys.platform.startswith('java'): verify(v3.func_code.co_varnames == ('a', '(b, c)', 'rest', 'b', 'c')) else: verify(v3.func_code.co_varnames == ('a', '.2', 'rest', 'b', 'c'))
def v3(a, (b, c), *rest): return a, b, c, rest
bf3fa7b64c1804fdf2181e6768aba7e5324b9339 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/bf3fa7b64c1804fdf2181e6768aba7e5324b9339/test_grammar.py
def seek(self, pos, mode = 0):
def seek(self, pos, whence = 0):
def seek(self, pos, mode = 0): """Seek to specified position into the chunk. Default position is 0 (start of chunk). If the file is not seekable, this will result in an error.
5a7366b04bc08ce390da13b10c3438b378eab380 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/5a7366b04bc08ce390da13b10c3438b378eab380/chunk.py
if mode == 1:
if whence == 1:
def seek(self, pos, mode = 0): """Seek to specified position into the chunk. Default position is 0 (start of chunk). If the file is not seekable, this will result in an error.
5a7366b04bc08ce390da13b10c3438b378eab380 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/5a7366b04bc08ce390da13b10c3438b378eab380/chunk.py
elif mode == 2:
elif whence == 2:
def seek(self, pos, mode = 0): """Seek to specified position into the chunk. Default position is 0 (start of chunk). If the file is not seekable, this will result in an error.
5a7366b04bc08ce390da13b10c3438b378eab380 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/5a7366b04bc08ce390da13b10c3438b378eab380/chunk.py
def read(self, n = -1): """Read at most n bytes from the chunk. If n is omitted or negative, read until the end
def read(self, size = -1): """Read at most size bytes from the chunk. If size is omitted or negative, read until the end
def read(self, n = -1): """Read at most n bytes from the chunk. If n is omitted or negative, read until the end of the chunk.
5a7366b04bc08ce390da13b10c3438b378eab380 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/5a7366b04bc08ce390da13b10c3438b378eab380/chunk.py
if n < 0: n = self.chunksize - self.size_read if n > self.chunksize - self.size_read: n = self.chunksize - self.size_read data = self.file.read(n)
if size < 0: size = self.chunksize - self.size_read if size > self.chunksize - self.size_read: size = self.chunksize - self.size_read data = self.file.read(size)
def read(self, n = -1): """Read at most n bytes from the chunk. If n is omitted or negative, read until the end of the chunk.
5a7366b04bc08ce390da13b10c3438b378eab380 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/5a7366b04bc08ce390da13b10c3438b378eab380/chunk.py
"Handle a recoverable error."
"Handle a recoverable error."
def error(self, exception):
b4ddcbb335f9ba6ca401057d36afe05f6fd01541 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b4ddcbb335f9ba6ca401057d36afe05f6fd01541/handler.py
"Handle a non-recoverable error."
"Handle a non-recoverable error."
def fatalError(self, exception):
b4ddcbb335f9ba6ca401057d36afe05f6fd01541 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b4ddcbb335f9ba6ca401057d36afe05f6fd01541/handler.py
"Handle a warning."
"Handle a warning."
def warning(self, exception):
b4ddcbb335f9ba6ca401057d36afe05f6fd01541 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b4ddcbb335f9ba6ca401057d36afe05f6fd01541/handler.py
'/usr/include/db3',
'/usr/local/include/db3',
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
141cd423f5039b9efe4d6fa7280d4d98d607e1ba /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/141cd423f5039b9efe4d6fa7280d4d98d607e1ba/setup.py
'/usr/local/include/db3',
'/usr/include/db3',
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
141cd423f5039b9efe4d6fa7280d4d98d607e1ba /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/141cd423f5039b9efe4d6fa7280d4d98d607e1ba/setup.py
'/usr/lib',
'/usr/local/lib',
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
141cd423f5039b9efe4d6fa7280d4d98d607e1ba /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/141cd423f5039b9efe4d6fa7280d4d98d607e1ba/setup.py
'/usr/include/db3',
'/usr/local/include/db3',
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
141cd423f5039b9efe4d6fa7280d4d98d607e1ba /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/141cd423f5039b9efe4d6fa7280d4d98d607e1ba/setup.py
'/usr/local/include/db3',
'/usr/include/db3',
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
141cd423f5039b9efe4d6fa7280d4d98d607e1ba /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/141cd423f5039b9efe4d6fa7280d4d98d607e1ba/setup.py
'libdirs': ('/usr/lib', '/sw/lib', '/lib'), 'incdirs': ('/usr/include/db2', '/usr/local/include/db2', '/sw/include/db2'),
'libdirs': ('/usr/local/lib', '/sw/lib', '/usr/lib', '/lib'), 'incdirs': ('/usr/local/include/db2', '/sw/include/db2', '/usr/include/db2'),
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
141cd423f5039b9efe4d6fa7280d4d98d607e1ba /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/141cd423f5039b9efe4d6fa7280d4d98d607e1ba/setup.py
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
141cd423f5039b9efe4d6fa7280d4d98d607e1ba /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/141cd423f5039b9efe4d6fa7280d4d98d607e1ba/setup.py
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
141cd423f5039b9efe4d6fa7280d4d98d607e1ba /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/141cd423f5039b9efe4d6fa7280d4d98d607e1ba/setup.py
try: port = int(host[i+1:]) except ValueError, msg: raise socket.error, str(msg)
port = int(host[i+1:])
def _set_hostport(self, host, port): if port is None: i = host.find(':') if i >= 0: try: port = int(host[i+1:]) except ValueError, msg: raise socket.error, str(msg) host = host[:i] else: port = self.default_port self.host = host self.port = port
765e8a6bd9503465dc8e1a47d191eff0c511bff4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/765e8a6bd9503465dc8e1a47d191eff0c511bff4/httplib.py
add_dir_to_list(self.compiler.library_dirs, sysconfig.get_config_var("LIBDIR")) add_dir_to_list(self.compiler.include_dirs, sysconfig.get_config_var("INCLUDEDIR"))
if os.path.normpath(sys.prefix) != '/usr': add_dir_to_list(self.compiler.library_dirs, sysconfig.get_config_var("LIBDIR")) add_dir_to_list(self.compiler.include_dirs, sysconfig.get_config_var("INCLUDEDIR"))
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
2d8ecaf16ed93ece62446c5520e39597f5241068 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2d8ecaf16ed93ece62446c5520e39597f5241068/setup.py
def check_split(self, wrapper, text, expect): result = wrapper._split(text)
def check_split(self, text, expect): result = self.wrapper._split(text)
def check_split(self, wrapper, text, expect): result = wrapper._split(text) self.assertEquals(result, expect, "\nexpected %r\n" "but got %r" % (expect, result))
08071b794b13ced20be2ca3d2774957575a42ca7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/08071b794b13ced20be2ca3d2774957575a42ca7/test_textwrap.py
self.check_split(self.wrapper, text, expect)
self.check_split(text, expect)
def test_em_dash(self): # Test text with em-dashes text = "Em-dashes should be written -- thus." self.check_wrap(text, 25, ["Em-dashes should be", "written -- thus."])
08071b794b13ced20be2ca3d2774957575a42ca7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/08071b794b13ced20be2ca3d2774957575a42ca7/test_textwrap.py
self.check_split(self.wrapper, text, expect)
self.check_split(text, expect)
def test_em_dash(self): # Test text with em-dashes text = "Em-dashes should be written -- thus." self.check_wrap(text, 25, ["Em-dashes should be", "written -- thus."])
08071b794b13ced20be2ca3d2774957575a42ca7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/08071b794b13ced20be2ca3d2774957575a42ca7/test_textwrap.py
self.check_split(self.wrapper, text, expect)
self.check_split(text, expect) def test_funky_hyphens (self): self.check_split("what the--hey!", ["what", " ", "the", "--", "hey!"]) self.check_split("what the--", ["what", " ", "the--"]) self.check_split("what the--.", ["what", " ", "the--."]) self.check_split("--text--.", ["--text--."]) self.check_split("--option", ["--option"]) self.check_split("--option-opt", ["--option-", "opt"])
def test_unix_options (self): # Test that Unix-style command-line options are wrapped correctly. # Both Optik (OptionParser) and Docutils rely on this behaviour!
08071b794b13ced20be2ca3d2774957575a42ca7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/08071b794b13ced20be2ca3d2774957575a42ca7/test_textwrap.py
l.grid(row=self.row, col=0, sticky="w")
l.grid(row=self.row, column=0, sticky="w")
def make_entry(self, label, var): l = Label(self.top, text=label) l.grid(row=self.row, col=0, sticky="w") e = Entry(self.top, textvariable=var, exportselection=0) e.grid(row=self.row, col=1, sticky="we") self.row = self.row + 1 return e
1447bedc4b43ef99799e4150714e4555ffe7168e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1447bedc4b43ef99799e4150714e4555ffe7168e/SearchDialogBase.py
e.grid(row=self.row, col=1, sticky="we")
e.grid(row=self.row, column=1, sticky="we")
def make_entry(self, label, var): l = Label(self.top, text=label) l.grid(row=self.row, col=0, sticky="w") e = Entry(self.top, textvariable=var, exportselection=0) e.grid(row=self.row, col=1, sticky="we") self.row = self.row + 1 return e
1447bedc4b43ef99799e4150714e4555ffe7168e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1447bedc4b43ef99799e4150714e4555ffe7168e/SearchDialogBase.py
f.grid(row=self.row, col=0, columnspan=2, sticky="we")
f.grid(row=self.row, column=0, columnspan=2, sticky="we")
def make_frame(self): f = Frame(self.top) f.grid(row=self.row, col=0, columnspan=2, sticky="we") self.row = self.row + 1 return f
1447bedc4b43ef99799e4150714e4555ffe7168e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1447bedc4b43ef99799e4150714e4555ffe7168e/SearchDialogBase.py
s = "\\pdfoutline goto name{page.%dx}" % pageno
s = "\\pdfoutline goto name{page%03d}" % pageno
def write_toc_entry(entry, fp, layer): stype, snum, title, pageno, toc = entry s = "\\pdfoutline goto name{page.%dx}" % pageno if toc: s = "%s count -%d" % (s, len(toc)) if snum: title = "%s %s" % (snum, title) s = "%s {%s}\n" % (s, title) fp.write(s) for entry in toc: write_toc_entry(entry, fp, layer + 1)
8bda026cb1e8ccf817180aea65945790d106882a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8bda026cb1e8ccf817180aea65945790d106882a/toc2bkm.py
self.installaehandler('aevt', '****', self.other)
self.installaehandler('****', '****', self.other)
def __init__(self): MiniApplication.__init__(self) AEServer.__init__(self) self.installaehandler('aevt', 'oapp', self.open_app) self.installaehandler('aevt', 'quit', self.quit) self.installaehandler('aevt', '****', self.other) self.mainloop()
671c679c88c72cb7f3362574d8bb3ed6dc1fda06 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/671c679c88c72cb7f3362574d8bb3ed6dc1fda06/MiniAEFrame.py
def parse(filename_or_stream, handler, errorHandler=ErrorHandler()): parser = ExpatParser() parser.setContentHandler(handler) parser.setErrorHandler(errorHandler) parser.parse(filename_or_stream)
3a9c517e196af58abc368eb6d73e9b9c88d00a3b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/3a9c517e196af58abc368eb6d73e9b9c88d00a3b/__init__.py
user_passwd, host = splituser(host)
if host: user_passwd, host = splituser(host) host = unquote(host) realhost = host
def open_https(self, url, data=None): """Use HTTPS protocol.""" import httplib if type(url) is type(""): host, selector = splithost(url) user_passwd, host = splituser(host) else: host, selector = url urltype, rest = splittype(selector) if string.lower(urltype) == 'https': realhost, rest = splithost(rest) user_passwd, realhost = splituser(realhost) if user_passwd: selector = "%s://%s%s" % (urltype, realhost, rest) #print "proxy via https:", host, selector if not host: raise IOError, ('https error', 'no host given') if user_passwd: import base64 auth = string.strip(base64.encodestring(user_passwd)) else: auth = None h = httplib.HTTPS(host, 0, key_file=self.key_file, cert_file=self.cert_file) if data is not None: h.putrequest('POST', selector) h.putheader('Content-type', 'application/x-www-form-urlencoded') h.putheader('Content-length', '%d' % len(data)) else: h.putrequest('GET', selector) if auth: h.putheader('Authorization: Basic %s' % auth) for args in self.addheaders: apply(h.putheader, args) h.endheaders() if data is not None: h.send(data + '\r\n') errcode, errmsg, headers = h.getreply() fp = h.getfile() if errcode == 200: return addinfourl(fp, headers, url) else: return self.http_error(url, fp, errcode, errmsg, headers)
312931759ee50f89c550019fac39032b3f4b4775 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/312931759ee50f89c550019fac39032b3f4b4775/urllib.py
if string.lower(urltype) == 'https':
url = rest user_passwd = None if string.lower(urltype) != 'https': realhost = None else:
def open_https(self, url, data=None): """Use HTTPS protocol.""" import httplib if type(url) is type(""): host, selector = splithost(url) user_passwd, host = splituser(host) else: host, selector = url urltype, rest = splittype(selector) if string.lower(urltype) == 'https': realhost, rest = splithost(rest) user_passwd, realhost = splituser(realhost) if user_passwd: selector = "%s://%s%s" % (urltype, realhost, rest) #print "proxy via https:", host, selector if not host: raise IOError, ('https error', 'no host given') if user_passwd: import base64 auth = string.strip(base64.encodestring(user_passwd)) else: auth = None h = httplib.HTTPS(host, 0, key_file=self.key_file, cert_file=self.cert_file) if data is not None: h.putrequest('POST', selector) h.putheader('Content-type', 'application/x-www-form-urlencoded') h.putheader('Content-length', '%d' % len(data)) else: h.putrequest('GET', selector) if auth: h.putheader('Authorization: Basic %s' % auth) for args in self.addheaders: apply(h.putheader, args) h.endheaders() if data is not None: h.send(data + '\r\n') errcode, errmsg, headers = h.getreply() fp = h.getfile() if errcode == 200: return addinfourl(fp, headers, url) else: return self.http_error(url, fp, errcode, errmsg, headers)
312931759ee50f89c550019fac39032b3f4b4775 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/312931759ee50f89c550019fac39032b3f4b4775/urllib.py
user_passwd, realhost = splituser(realhost)
if realhost: user_passwd, realhost = splituser(realhost)
def open_https(self, url, data=None): """Use HTTPS protocol.""" import httplib if type(url) is type(""): host, selector = splithost(url) user_passwd, host = splituser(host) else: host, selector = url urltype, rest = splittype(selector) if string.lower(urltype) == 'https': realhost, rest = splithost(rest) user_passwd, realhost = splituser(realhost) if user_passwd: selector = "%s://%s%s" % (urltype, realhost, rest) #print "proxy via https:", host, selector if not host: raise IOError, ('https error', 'no host given') if user_passwd: import base64 auth = string.strip(base64.encodestring(user_passwd)) else: auth = None h = httplib.HTTPS(host, 0, key_file=self.key_file, cert_file=self.cert_file) if data is not None: h.putrequest('POST', selector) h.putheader('Content-type', 'application/x-www-form-urlencoded') h.putheader('Content-length', '%d' % len(data)) else: h.putrequest('GET', selector) if auth: h.putheader('Authorization: Basic %s' % auth) for args in self.addheaders: apply(h.putheader, args) h.endheaders() if data is not None: h.send(data + '\r\n') errcode, errmsg, headers = h.getreply() fp = h.getfile() if errcode == 200: return addinfourl(fp, headers, url) else: return self.http_error(url, fp, errcode, errmsg, headers)
312931759ee50f89c550019fac39032b3f4b4775 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/312931759ee50f89c550019fac39032b3f4b4775/urllib.py
return self.http_error(url, fp, errcode, errmsg, headers)
if data is None: return self.http_error(url, fp, errcode, errmsg, headers) else: return self.http_error(url, fp, errcode, errmsg, headers, data)
def open_https(self, url, data=None): """Use HTTPS protocol.""" import httplib if type(url) is type(""): host, selector = splithost(url) user_passwd, host = splituser(host) else: host, selector = url urltype, rest = splittype(selector) if string.lower(urltype) == 'https': realhost, rest = splithost(rest) user_passwd, realhost = splituser(realhost) if user_passwd: selector = "%s://%s%s" % (urltype, realhost, rest) #print "proxy via https:", host, selector if not host: raise IOError, ('https error', 'no host given') if user_passwd: import base64 auth = string.strip(base64.encodestring(user_passwd)) else: auth = None h = httplib.HTTPS(host, 0, key_file=self.key_file, cert_file=self.cert_file) if data is not None: h.putrequest('POST', selector) h.putheader('Content-type', 'application/x-www-form-urlencoded') h.putheader('Content-length', '%d' % len(data)) else: h.putrequest('GET', selector) if auth: h.putheader('Authorization: Basic %s' % auth) for args in self.addheaders: apply(h.putheader, args) h.endheaders() if data is not None: h.send(data + '\r\n') errcode, errmsg, headers = h.getreply() fp = h.getfile() if errcode == 200: return addinfourl(fp, headers, url) else: return self.http_error(url, fp, errcode, errmsg, headers)
312931759ee50f89c550019fac39032b3f4b4775 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/312931759ee50f89c550019fac39032b3f4b4775/urllib.py
if match: return match.group(1, 2)
if match: return map(unquote, match.group(1, 2))
def splituser(host): """splituser('user[:passwd]@host[:port]') --> 'user[:passwd]', 'host[:port]'.""" global _userprog if _userprog is None: import re _userprog = re.compile('^([^@]*)@(.*)$') match = _userprog.match(host) if match: return match.group(1, 2) return None, host
312931759ee50f89c550019fac39032b3f4b4775 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/312931759ee50f89c550019fac39032b3f4b4775/urllib.py
os.fsync(f.fileno())
if hasattr(os, 'fsync'): os.fsync(f.fileno())
def _sync_flush(f): """Ensure changes to file f are physically on disk.""" f.flush() os.fsync(f.fileno())
792e7dea94e245c5593bc05ca32168a12997c02f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/792e7dea94e245c5593bc05ca32168a12997c02f/mailbox.py
u2 = random()
u2 = 1.0 - random()
def normalvariate(self, mu, sigma): """Normal distribution.
72354f9f4eb9ba40dba8bc67a76cfaec33d057ed /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/72354f9f4eb9ba40dba8bc67a76cfaec33d057ed/random.py
u2 = random()
if not 1e-7 < u1 < .9999999: continue u2 = 1.0 - random()
def gammavariate(self, alpha, beta): """Gamma distribution. Not the gamma function!
72354f9f4eb9ba40dba8bc67a76cfaec33d057ed /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/72354f9f4eb9ba40dba8bc67a76cfaec33d057ed/random.py
u = self.random()
u = 1.0 - self.random()
def paretovariate(self, alpha): """Pareto distribution. alpha is the shape parameter.""" # Jain, pg. 495
72354f9f4eb9ba40dba8bc67a76cfaec33d057ed /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/72354f9f4eb9ba40dba8bc67a76cfaec33d057ed/random.py
u = self.random()
u = 1.0 - self.random()
def weibullvariate(self, alpha, beta): """Weibull distribution.
72354f9f4eb9ba40dba8bc67a76cfaec33d057ed /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/72354f9f4eb9ba40dba8bc67a76cfaec33d057ed/random.py
if self.runtime_library_dirs:
if runtime_library_dirs:
def link_shared_object (self, objects, output_filename, output_dir=None, libraries=None, library_dirs=None, runtime_library_dirs=None, debug=0, extra_preargs=None, extra_postargs=None):
12bd997b657170c03a0b5e274dab16be62a41a0e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/12bd997b657170c03a0b5e274dab16be62a41a0e/msvccompiler.py
if type (output_dir) not in (StringType, NoneType): raise TypeError, "'output_dir' must be a string or None"
def link_shared_object (self, objects, output_filename, output_dir=None, libraries=None, library_dirs=None, runtime_library_dirs=None, debug=0, extra_preargs=None, extra_postargs=None):
12bd997b657170c03a0b5e274dab16be62a41a0e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/12bd997b657170c03a0b5e274dab16be62a41a0e/msvccompiler.py
log.warn("'%s' does not exist -- can't clean it", self.build_temp)
log.debug("'%s' does not exist -- can't clean it", self.build_temp)
def run(self): # remove the build/temp.<plat> directory (unless it's already # gone) if os.path.exists(self.build_temp): remove_tree(self.build_temp, dry_run=self.dry_run) else: log.warn("'%s' does not exist -- can't clean it", self.build_temp)
c94272728f787a73b42bcb7c60215e0c2a41a071 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/c94272728f787a73b42bcb7c60215e0c2a41a071/clean.py
self.create_system = 0
if sys.platform == 'win32': self.create_system = 0 else: self.create_system = 3
def __init__(self, filename="NoName", date_time=(1980,1,1,0,0,0)): self.orig_filename = filename # Original file name in archive
831a52d3b1663c3ce8ed088f8e40e9ef25e1ab28 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/831a52d3b1663c3ce8ed088f8e40e9ef25e1ab28/zipfile.py
assert sCursor.set('red')
tmp = sCursor.set('red') assert tmp
def test01_join(self): if verbose: print '\n', '-=' * 30 print "Running %s.test01_join..." % \ self.__class__.__name__
d9f5a5ecd72b33371221c2f2923ce5887eba94c8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d9f5a5ecd72b33371221c2f2923ce5887eba94c8/test_join.py
def hexrepr(t):
def hexrepr(t, precision=4):
def hexrepr(t): if t is None: return 'None' try: len(t) except: return '0x%04x' % t try: return '(' + ', '.join(map(lambda t: '0x%04x' % t, t)) + ')' except TypeError, why: print '* failed to convert %r: %s' % (t, why) raise
88a416f24d864b5c6b03a1e6abf27f80832face9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/88a416f24d864b5c6b03a1e6abf27f80832face9/gencodec.py
return '0x%04x' % t
return '0x%0*X' % (precision, t)
def hexrepr(t): if t is None: return 'None' try: len(t) except: return '0x%04x' % t try: return '(' + ', '.join(map(lambda t: '0x%04x' % t, t)) + ')' except TypeError, why: print '* failed to convert %r: %s' % (t, why) raise
88a416f24d864b5c6b03a1e6abf27f80832face9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/88a416f24d864b5c6b03a1e6abf27f80832face9/gencodec.py
return '(' + ', '.join(map(lambda t: '0x%04x' % t, t)) + ')'
return '(' + ', '.join(['0x%0*X' % (precision, item) for item in t]) + ')'
def hexrepr(t): if t is None: return 'None' try: len(t) except: return '0x%04x' % t try: return '(' + ', '.join(map(lambda t: '0x%04x' % t, t)) + ')' except TypeError, why: print '* failed to convert %r: %s' % (t, why) raise
88a416f24d864b5c6b03a1e6abf27f80832face9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/88a416f24d864b5c6b03a1e6abf27f80832face9/gencodec.py
def python_mapdef_code(varname, map, comments=1):
def python_mapdef_code(varname, map, comments=1, precisions=(2, 4)):
def python_mapdef_code(varname, map, comments=1): l = [] append = l.append if map.has_key("IDENTITY"): append("%s = codecs.make_identity_dict(range(%d))" % (varname, map["IDENTITY"])) append("%s.update({" % varname) splits = 1 del map["IDENTITY"] identity = 1 else: append("%s = {" % varname) splits = 0 identity = 0 mappings = map.items() mappings.sort() i = 0 for mapkey, mapvalue in mappings: mapcomment = '' if isinstance(mapkey, tuple): (mapkey, mapcomment) = mapkey if isinstance(mapvalue, tuple): (mapvalue, mapcomment) = mapvalue if mapkey is None: continue if (identity and mapkey == mapvalue and mapkey < 256): # No need to include identity mappings, since these # are already set for the first 256 code points. continue key = hexrepr(mapkey) value = hexrepr(mapvalue) if mapcomment and comments: append(' %s: %s,\t# %s' % (key, value, mapcomment)) else: append(' %s: %s,' % (key, value)) i += 1 if i == 4096: # Split the definition into parts to that the Python # parser doesn't dump core if splits == 0: append('}') else: append('})') append('%s.update({' % varname) i = 0 splits = splits + 1 if splits == 0: append('}') else: append('})') return l
88a416f24d864b5c6b03a1e6abf27f80832face9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/88a416f24d864b5c6b03a1e6abf27f80832face9/gencodec.py
key = hexrepr(mapkey) value = hexrepr(mapvalue)
key = hexrepr(mapkey, key_precision) value = hexrepr(mapvalue, value_precision)
def python_mapdef_code(varname, map, comments=1): l = [] append = l.append if map.has_key("IDENTITY"): append("%s = codecs.make_identity_dict(range(%d))" % (varname, map["IDENTITY"])) append("%s.update({" % varname) splits = 1 del map["IDENTITY"] identity = 1 else: append("%s = {" % varname) splits = 0 identity = 0 mappings = map.items() mappings.sort() i = 0 for mapkey, mapvalue in mappings: mapcomment = '' if isinstance(mapkey, tuple): (mapkey, mapcomment) = mapkey if isinstance(mapvalue, tuple): (mapvalue, mapcomment) = mapvalue if mapkey is None: continue if (identity and mapkey == mapvalue and mapkey < 256): # No need to include identity mappings, since these # are already set for the first 256 code points. continue key = hexrepr(mapkey) value = hexrepr(mapvalue) if mapcomment and comments: append(' %s: %s,\t# %s' % (key, value, mapcomment)) else: append(' %s: %s,' % (key, value)) i += 1 if i == 4096: # Split the definition into parts to that the Python # parser doesn't dump core if splits == 0: append('}') else: append('})') append('%s.update({' % varname) i = 0 splits = splits + 1 if splits == 0: append('}') else: append('})') return l
88a416f24d864b5c6b03a1e6abf27f80832face9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/88a416f24d864b5c6b03a1e6abf27f80832face9/gencodec.py
def python_tabledef_code(varname, map, comments=1):
def python_tabledef_code(varname, map, comments=1, key_precision=2):
def python_tabledef_code(varname, map, comments=1): l = [] append = l.append append('%s = (' % varname) # Analyze map and create table dict mappings = map.items() mappings.sort() table = {} maxkey = 0 if map.has_key('IDENTITY'): for key in range(256): table[key] = (key, '') maxkey = 255 del map['IDENTITY'] for mapkey, mapvalue in mappings: mapcomment = '' if isinstance(mapkey, tuple): (mapkey, mapcomment) = mapkey if isinstance(mapvalue, tuple): (mapvalue, mapcomment) = mapvalue if mapkey is None: continue table[mapkey] = (mapvalue, mapcomment) if mapkey > maxkey: maxkey = mapkey if maxkey > MAX_TABLE_SIZE: # Table too large return None # Create table code for key in range(maxkey + 1): if key not in table: mapvalue = None mapcomment = 'UNDEFINED' else: mapvalue, mapcomment = table[key] if mapvalue is None: mapchar = UNI_UNDEFINED else: if isinstance(mapvalue, tuple): # 1-n mappings not supported return None else: mapchar = unichr(mapvalue) if mapcomment and comments: append(' %r\t# %s -> %s' % (mapchar, hexrepr(key), mapcomment)) else: append(' %r' % mapchar) append(')') return l
88a416f24d864b5c6b03a1e6abf27f80832face9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/88a416f24d864b5c6b03a1e6abf27f80832face9/gencodec.py
hexrepr(key),
hexrepr(key, key_precision),
def python_tabledef_code(varname, map, comments=1): l = [] append = l.append append('%s = (' % varname) # Analyze map and create table dict mappings = map.items() mappings.sort() table = {} maxkey = 0 if map.has_key('IDENTITY'): for key in range(256): table[key] = (key, '') maxkey = 255 del map['IDENTITY'] for mapkey, mapvalue in mappings: mapcomment = '' if isinstance(mapkey, tuple): (mapkey, mapcomment) = mapkey if isinstance(mapvalue, tuple): (mapvalue, mapcomment) = mapvalue if mapkey is None: continue table[mapkey] = (mapvalue, mapcomment) if mapkey > maxkey: maxkey = mapkey if maxkey > MAX_TABLE_SIZE: # Table too large return None # Create table code for key in range(maxkey + 1): if key not in table: mapvalue = None mapcomment = 'UNDEFINED' else: mapvalue, mapcomment = table[key] if mapvalue is None: mapchar = UNI_UNDEFINED else: if isinstance(mapvalue, tuple): # 1-n mappings not supported return None else: mapchar = unichr(mapvalue) if mapcomment and comments: append(' %r\t# %s -> %s' % (mapchar, hexrepr(key), mapcomment)) else: append(' %r' % mapchar) append(')') return l
88a416f24d864b5c6b03a1e6abf27f80832face9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/88a416f24d864b5c6b03a1e6abf27f80832face9/gencodec.py
comments=comments)
comments=comments, precisions=(4, 2))
def codegen(name, map, comments=1): """ Returns Python source for the given map. Comments are included in the source, if comments is true (default). """ # Generate code decoding_map_code = python_mapdef_code( 'decoding_map', map, comments=comments) decoding_table_code = python_tabledef_code( 'decoding_table', map, comments=comments) encoding_map_code = python_mapdef_code( 'encoding_map', codecs.make_encoding_map(map), comments=comments) l = [ '''\
88a416f24d864b5c6b03a1e6abf27f80832face9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/88a416f24d864b5c6b03a1e6abf27f80832face9/gencodec.py
''') if not decoding_table_code: l.append('''
def getregentry(): return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
88a416f24d864b5c6b03a1e6abf27f80832face9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/88a416f24d864b5c6b03a1e6abf27f80832face9/gencodec.py