rem
stringlengths 1
322k
| add
stringlengths 0
2.05M
| context
stringlengths 4
228k
| meta
stringlengths 156
215
|
---|---|---|---|
generate = 1 | generate = True | def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, fromfile=None, findleaks=0, use_resources=None): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdir -- the directory in which to look for tests (optional) Users other than the Python test suite will certainly want to specify testdir; if it's omitted, the directory containing the Python test suite is searched for. If the tests argument is omitted, the tests listed on the command-line will be used. If that's empty, too, then all *.py files beginning with test_ will be used. The other default arguments (verbose, quiet, generate, exclude, single, randomize, findleaks, and use_resources) allow programmers calling main() directly to set the values that would normally be set by flags on the command line. """ test_support.record_original_stdout(sys.stdout) try: opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lu:t:', ['help', 'verbose', 'quiet', 'generate', 'exclude', 'single', 'random', 'fromfile', 'findleaks', 'use=', 'threshold=']) except getopt.error, msg: usage(2, msg) # Defaults if use_resources is None: use_resources = [] for o, a in opts: if o in ('-h', '--help'): usage(0) elif o in ('-v', '--verbose'): verbose += 1 elif o in ('-q', '--quiet'): quiet = 1; verbose = 0 elif o in ('-g', '--generate'): generate = 1 elif o in ('-x', '--exclude'): exclude = 1 elif o in ('-s', '--single'): single = 1 elif o in ('-r', '--randomize'): randomize = 1 elif o in ('-f', '--fromfile'): fromfile = a elif o in ('-l', '--findleaks'): findleaks = 1 elif o in ('-t', '--threshold'): import gc gc.set_threshold(int(a)) elif o in ('-u', '--use'): u = [x.lower() for x in a.split(',')] for r in u: if r == 'all': use_resources[:] = RESOURCE_NAMES continue remove = False if r[0] == '-': remove = True r = r[1:] if r not in RESOURCE_NAMES: usage(1, 'Invalid -u/--use option: ' + a) if remove: if r in use_resources: use_resources.remove(r) elif r not in use_resources: use_resources.append(r) if generate and verbose: usage(2, "-g and -v don't go together!") if single and fromfile: usage(2, "-s and -f don't go together!") good = [] bad = [] skipped = [] resource_denieds = [] if findleaks: try: import gc except ImportError: print 'No GC available, disabling findleaks.' findleaks = 0 else: # Uncomment the line below to report garbage that is not # freeable by reference counting alone. By default only # garbage that is not collectable by the GC is reported. #gc.set_debug(gc.DEBUG_SAVEALL) found_garbage = [] if single: from tempfile import gettempdir filename = os.path.join(gettempdir(), 'pynexttest') try: fp = open(filename, 'r') next = fp.read().strip() tests = [next] fp.close() except IOError: pass if fromfile: tests = [] fp = open(fromfile) for line in fp: guts = line.split() # assuming no test has whitespace in its name if guts and not guts[0].startswith('#'): tests.extend(guts) fp.close() # Strip .py extensions. if args: args = map(removepy, args) if tests: tests = map(removepy, tests) stdtests = STDTESTS[:] nottests = NOTTESTS[:] if exclude: for arg in args: if arg in stdtests: stdtests.remove(arg) nottests[:0] = args args = [] tests = tests or args or findtests(testdir, stdtests, nottests) if single: tests = tests[:1] if randomize: random.shuffle(tests) test_support.verbose = verbose # Tell tests to be moderately quiet test_support.use_resources = use_resources save_modules = sys.modules.keys() for test in tests: if not quiet: print test sys.stdout.flush() ok = runtest(test, generate, verbose, quiet, testdir) if ok > 0: good.append(test) elif ok == 0: bad.append(test) else: skipped.append(test) if ok == -2: resource_denieds.append(test) if findleaks: gc.collect() if gc.garbage: print "Warning: test created", len(gc.garbage), print "uncollectable object(s)." # move the uncollectable objects somewhere so we don't see # them again found_garbage.extend(gc.garbage) del gc.garbage[:] # Unload the newly imported modules (best effort finalization) for module in sys.modules.keys(): if module not in save_modules and module.startswith("test."): test_support.unload(module) # The lists won't be sorted if running with -r good.sort() bad.sort() skipped.sort() if good and not quiet: if not bad and not skipped and len(good) > 1: print "All", print count(len(good), "test"), "OK." if verbose: print "CAUTION: stdout isn't compared in verbose mode:" print "a test that passes in verbose mode may fail without it." if bad: print count(len(bad), "test"), "failed:" printlist(bad) if skipped and not quiet: print count(len(skipped), "test"), "skipped:" printlist(skipped) e = _ExpectedSkips() plat = sys.platform if e.isvalid(): surprise = set(skipped) - e.getexpected() - set(resource_denieds) if surprise: print count(len(surprise), "skip"), \ "unexpected on", plat + ":" printlist(surprise) else: print "Those skips are all expected on", plat + "." else: print "Ask someone to teach regrtest.py about which tests are" print "expected to get skipped on", plat + "." if single: alltests = findtests(testdir, stdtests, nottests) for i in range(len(alltests)): if tests[0] == alltests[i]: if i == len(alltests) - 1: os.unlink(filename) else: fp = open(filename, 'w') fp.write(alltests[i+1] + '\n') fp.close() break else: os.unlink(filename) sys.exit(len(bad) > 0) | 3b6d025d9bc6a0109e9a2ebd28a4864e8007193a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3b6d025d9bc6a0109e9a2ebd28a4864e8007193a/regrtest.py |
exclude = 1 | exclude = True | def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, fromfile=None, findleaks=0, use_resources=None): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdir -- the directory in which to look for tests (optional) Users other than the Python test suite will certainly want to specify testdir; if it's omitted, the directory containing the Python test suite is searched for. If the tests argument is omitted, the tests listed on the command-line will be used. If that's empty, too, then all *.py files beginning with test_ will be used. The other default arguments (verbose, quiet, generate, exclude, single, randomize, findleaks, and use_resources) allow programmers calling main() directly to set the values that would normally be set by flags on the command line. """ test_support.record_original_stdout(sys.stdout) try: opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lu:t:', ['help', 'verbose', 'quiet', 'generate', 'exclude', 'single', 'random', 'fromfile', 'findleaks', 'use=', 'threshold=']) except getopt.error, msg: usage(2, msg) # Defaults if use_resources is None: use_resources = [] for o, a in opts: if o in ('-h', '--help'): usage(0) elif o in ('-v', '--verbose'): verbose += 1 elif o in ('-q', '--quiet'): quiet = 1; verbose = 0 elif o in ('-g', '--generate'): generate = 1 elif o in ('-x', '--exclude'): exclude = 1 elif o in ('-s', '--single'): single = 1 elif o in ('-r', '--randomize'): randomize = 1 elif o in ('-f', '--fromfile'): fromfile = a elif o in ('-l', '--findleaks'): findleaks = 1 elif o in ('-t', '--threshold'): import gc gc.set_threshold(int(a)) elif o in ('-u', '--use'): u = [x.lower() for x in a.split(',')] for r in u: if r == 'all': use_resources[:] = RESOURCE_NAMES continue remove = False if r[0] == '-': remove = True r = r[1:] if r not in RESOURCE_NAMES: usage(1, 'Invalid -u/--use option: ' + a) if remove: if r in use_resources: use_resources.remove(r) elif r not in use_resources: use_resources.append(r) if generate and verbose: usage(2, "-g and -v don't go together!") if single and fromfile: usage(2, "-s and -f don't go together!") good = [] bad = [] skipped = [] resource_denieds = [] if findleaks: try: import gc except ImportError: print 'No GC available, disabling findleaks.' findleaks = 0 else: # Uncomment the line below to report garbage that is not # freeable by reference counting alone. By default only # garbage that is not collectable by the GC is reported. #gc.set_debug(gc.DEBUG_SAVEALL) found_garbage = [] if single: from tempfile import gettempdir filename = os.path.join(gettempdir(), 'pynexttest') try: fp = open(filename, 'r') next = fp.read().strip() tests = [next] fp.close() except IOError: pass if fromfile: tests = [] fp = open(fromfile) for line in fp: guts = line.split() # assuming no test has whitespace in its name if guts and not guts[0].startswith('#'): tests.extend(guts) fp.close() # Strip .py extensions. if args: args = map(removepy, args) if tests: tests = map(removepy, tests) stdtests = STDTESTS[:] nottests = NOTTESTS[:] if exclude: for arg in args: if arg in stdtests: stdtests.remove(arg) nottests[:0] = args args = [] tests = tests or args or findtests(testdir, stdtests, nottests) if single: tests = tests[:1] if randomize: random.shuffle(tests) test_support.verbose = verbose # Tell tests to be moderately quiet test_support.use_resources = use_resources save_modules = sys.modules.keys() for test in tests: if not quiet: print test sys.stdout.flush() ok = runtest(test, generate, verbose, quiet, testdir) if ok > 0: good.append(test) elif ok == 0: bad.append(test) else: skipped.append(test) if ok == -2: resource_denieds.append(test) if findleaks: gc.collect() if gc.garbage: print "Warning: test created", len(gc.garbage), print "uncollectable object(s)." # move the uncollectable objects somewhere so we don't see # them again found_garbage.extend(gc.garbage) del gc.garbage[:] # Unload the newly imported modules (best effort finalization) for module in sys.modules.keys(): if module not in save_modules and module.startswith("test."): test_support.unload(module) # The lists won't be sorted if running with -r good.sort() bad.sort() skipped.sort() if good and not quiet: if not bad and not skipped and len(good) > 1: print "All", print count(len(good), "test"), "OK." if verbose: print "CAUTION: stdout isn't compared in verbose mode:" print "a test that passes in verbose mode may fail without it." if bad: print count(len(bad), "test"), "failed:" printlist(bad) if skipped and not quiet: print count(len(skipped), "test"), "skipped:" printlist(skipped) e = _ExpectedSkips() plat = sys.platform if e.isvalid(): surprise = set(skipped) - e.getexpected() - set(resource_denieds) if surprise: print count(len(surprise), "skip"), \ "unexpected on", plat + ":" printlist(surprise) else: print "Those skips are all expected on", plat + "." else: print "Ask someone to teach regrtest.py about which tests are" print "expected to get skipped on", plat + "." if single: alltests = findtests(testdir, stdtests, nottests) for i in range(len(alltests)): if tests[0] == alltests[i]: if i == len(alltests) - 1: os.unlink(filename) else: fp = open(filename, 'w') fp.write(alltests[i+1] + '\n') fp.close() break else: os.unlink(filename) sys.exit(len(bad) > 0) | 3b6d025d9bc6a0109e9a2ebd28a4864e8007193a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3b6d025d9bc6a0109e9a2ebd28a4864e8007193a/regrtest.py |
single = 1 | single = True | def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, fromfile=None, findleaks=0, use_resources=None): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdir -- the directory in which to look for tests (optional) Users other than the Python test suite will certainly want to specify testdir; if it's omitted, the directory containing the Python test suite is searched for. If the tests argument is omitted, the tests listed on the command-line will be used. If that's empty, too, then all *.py files beginning with test_ will be used. The other default arguments (verbose, quiet, generate, exclude, single, randomize, findleaks, and use_resources) allow programmers calling main() directly to set the values that would normally be set by flags on the command line. """ test_support.record_original_stdout(sys.stdout) try: opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lu:t:', ['help', 'verbose', 'quiet', 'generate', 'exclude', 'single', 'random', 'fromfile', 'findleaks', 'use=', 'threshold=']) except getopt.error, msg: usage(2, msg) # Defaults if use_resources is None: use_resources = [] for o, a in opts: if o in ('-h', '--help'): usage(0) elif o in ('-v', '--verbose'): verbose += 1 elif o in ('-q', '--quiet'): quiet = 1; verbose = 0 elif o in ('-g', '--generate'): generate = 1 elif o in ('-x', '--exclude'): exclude = 1 elif o in ('-s', '--single'): single = 1 elif o in ('-r', '--randomize'): randomize = 1 elif o in ('-f', '--fromfile'): fromfile = a elif o in ('-l', '--findleaks'): findleaks = 1 elif o in ('-t', '--threshold'): import gc gc.set_threshold(int(a)) elif o in ('-u', '--use'): u = [x.lower() for x in a.split(',')] for r in u: if r == 'all': use_resources[:] = RESOURCE_NAMES continue remove = False if r[0] == '-': remove = True r = r[1:] if r not in RESOURCE_NAMES: usage(1, 'Invalid -u/--use option: ' + a) if remove: if r in use_resources: use_resources.remove(r) elif r not in use_resources: use_resources.append(r) if generate and verbose: usage(2, "-g and -v don't go together!") if single and fromfile: usage(2, "-s and -f don't go together!") good = [] bad = [] skipped = [] resource_denieds = [] if findleaks: try: import gc except ImportError: print 'No GC available, disabling findleaks.' findleaks = 0 else: # Uncomment the line below to report garbage that is not # freeable by reference counting alone. By default only # garbage that is not collectable by the GC is reported. #gc.set_debug(gc.DEBUG_SAVEALL) found_garbage = [] if single: from tempfile import gettempdir filename = os.path.join(gettempdir(), 'pynexttest') try: fp = open(filename, 'r') next = fp.read().strip() tests = [next] fp.close() except IOError: pass if fromfile: tests = [] fp = open(fromfile) for line in fp: guts = line.split() # assuming no test has whitespace in its name if guts and not guts[0].startswith('#'): tests.extend(guts) fp.close() # Strip .py extensions. if args: args = map(removepy, args) if tests: tests = map(removepy, tests) stdtests = STDTESTS[:] nottests = NOTTESTS[:] if exclude: for arg in args: if arg in stdtests: stdtests.remove(arg) nottests[:0] = args args = [] tests = tests or args or findtests(testdir, stdtests, nottests) if single: tests = tests[:1] if randomize: random.shuffle(tests) test_support.verbose = verbose # Tell tests to be moderately quiet test_support.use_resources = use_resources save_modules = sys.modules.keys() for test in tests: if not quiet: print test sys.stdout.flush() ok = runtest(test, generate, verbose, quiet, testdir) if ok > 0: good.append(test) elif ok == 0: bad.append(test) else: skipped.append(test) if ok == -2: resource_denieds.append(test) if findleaks: gc.collect() if gc.garbage: print "Warning: test created", len(gc.garbage), print "uncollectable object(s)." # move the uncollectable objects somewhere so we don't see # them again found_garbage.extend(gc.garbage) del gc.garbage[:] # Unload the newly imported modules (best effort finalization) for module in sys.modules.keys(): if module not in save_modules and module.startswith("test."): test_support.unload(module) # The lists won't be sorted if running with -r good.sort() bad.sort() skipped.sort() if good and not quiet: if not bad and not skipped and len(good) > 1: print "All", print count(len(good), "test"), "OK." if verbose: print "CAUTION: stdout isn't compared in verbose mode:" print "a test that passes in verbose mode may fail without it." if bad: print count(len(bad), "test"), "failed:" printlist(bad) if skipped and not quiet: print count(len(skipped), "test"), "skipped:" printlist(skipped) e = _ExpectedSkips() plat = sys.platform if e.isvalid(): surprise = set(skipped) - e.getexpected() - set(resource_denieds) if surprise: print count(len(surprise), "skip"), \ "unexpected on", plat + ":" printlist(surprise) else: print "Those skips are all expected on", plat + "." else: print "Ask someone to teach regrtest.py about which tests are" print "expected to get skipped on", plat + "." if single: alltests = findtests(testdir, stdtests, nottests) for i in range(len(alltests)): if tests[0] == alltests[i]: if i == len(alltests) - 1: os.unlink(filename) else: fp = open(filename, 'w') fp.write(alltests[i+1] + '\n') fp.close() break else: os.unlink(filename) sys.exit(len(bad) > 0) | 3b6d025d9bc6a0109e9a2ebd28a4864e8007193a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3b6d025d9bc6a0109e9a2ebd28a4864e8007193a/regrtest.py |
randomize = 1 | randomize = True | def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, fromfile=None, findleaks=0, use_resources=None): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdir -- the directory in which to look for tests (optional) Users other than the Python test suite will certainly want to specify testdir; if it's omitted, the directory containing the Python test suite is searched for. If the tests argument is omitted, the tests listed on the command-line will be used. If that's empty, too, then all *.py files beginning with test_ will be used. The other default arguments (verbose, quiet, generate, exclude, single, randomize, findleaks, and use_resources) allow programmers calling main() directly to set the values that would normally be set by flags on the command line. """ test_support.record_original_stdout(sys.stdout) try: opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lu:t:', ['help', 'verbose', 'quiet', 'generate', 'exclude', 'single', 'random', 'fromfile', 'findleaks', 'use=', 'threshold=']) except getopt.error, msg: usage(2, msg) # Defaults if use_resources is None: use_resources = [] for o, a in opts: if o in ('-h', '--help'): usage(0) elif o in ('-v', '--verbose'): verbose += 1 elif o in ('-q', '--quiet'): quiet = 1; verbose = 0 elif o in ('-g', '--generate'): generate = 1 elif o in ('-x', '--exclude'): exclude = 1 elif o in ('-s', '--single'): single = 1 elif o in ('-r', '--randomize'): randomize = 1 elif o in ('-f', '--fromfile'): fromfile = a elif o in ('-l', '--findleaks'): findleaks = 1 elif o in ('-t', '--threshold'): import gc gc.set_threshold(int(a)) elif o in ('-u', '--use'): u = [x.lower() for x in a.split(',')] for r in u: if r == 'all': use_resources[:] = RESOURCE_NAMES continue remove = False if r[0] == '-': remove = True r = r[1:] if r not in RESOURCE_NAMES: usage(1, 'Invalid -u/--use option: ' + a) if remove: if r in use_resources: use_resources.remove(r) elif r not in use_resources: use_resources.append(r) if generate and verbose: usage(2, "-g and -v don't go together!") if single and fromfile: usage(2, "-s and -f don't go together!") good = [] bad = [] skipped = [] resource_denieds = [] if findleaks: try: import gc except ImportError: print 'No GC available, disabling findleaks.' findleaks = 0 else: # Uncomment the line below to report garbage that is not # freeable by reference counting alone. By default only # garbage that is not collectable by the GC is reported. #gc.set_debug(gc.DEBUG_SAVEALL) found_garbage = [] if single: from tempfile import gettempdir filename = os.path.join(gettempdir(), 'pynexttest') try: fp = open(filename, 'r') next = fp.read().strip() tests = [next] fp.close() except IOError: pass if fromfile: tests = [] fp = open(fromfile) for line in fp: guts = line.split() # assuming no test has whitespace in its name if guts and not guts[0].startswith('#'): tests.extend(guts) fp.close() # Strip .py extensions. if args: args = map(removepy, args) if tests: tests = map(removepy, tests) stdtests = STDTESTS[:] nottests = NOTTESTS[:] if exclude: for arg in args: if arg in stdtests: stdtests.remove(arg) nottests[:0] = args args = [] tests = tests or args or findtests(testdir, stdtests, nottests) if single: tests = tests[:1] if randomize: random.shuffle(tests) test_support.verbose = verbose # Tell tests to be moderately quiet test_support.use_resources = use_resources save_modules = sys.modules.keys() for test in tests: if not quiet: print test sys.stdout.flush() ok = runtest(test, generate, verbose, quiet, testdir) if ok > 0: good.append(test) elif ok == 0: bad.append(test) else: skipped.append(test) if ok == -2: resource_denieds.append(test) if findleaks: gc.collect() if gc.garbage: print "Warning: test created", len(gc.garbage), print "uncollectable object(s)." # move the uncollectable objects somewhere so we don't see # them again found_garbage.extend(gc.garbage) del gc.garbage[:] # Unload the newly imported modules (best effort finalization) for module in sys.modules.keys(): if module not in save_modules and module.startswith("test."): test_support.unload(module) # The lists won't be sorted if running with -r good.sort() bad.sort() skipped.sort() if good and not quiet: if not bad and not skipped and len(good) > 1: print "All", print count(len(good), "test"), "OK." if verbose: print "CAUTION: stdout isn't compared in verbose mode:" print "a test that passes in verbose mode may fail without it." if bad: print count(len(bad), "test"), "failed:" printlist(bad) if skipped and not quiet: print count(len(skipped), "test"), "skipped:" printlist(skipped) e = _ExpectedSkips() plat = sys.platform if e.isvalid(): surprise = set(skipped) - e.getexpected() - set(resource_denieds) if surprise: print count(len(surprise), "skip"), \ "unexpected on", plat + ":" printlist(surprise) else: print "Those skips are all expected on", plat + "." else: print "Ask someone to teach regrtest.py about which tests are" print "expected to get skipped on", plat + "." if single: alltests = findtests(testdir, stdtests, nottests) for i in range(len(alltests)): if tests[0] == alltests[i]: if i == len(alltests) - 1: os.unlink(filename) else: fp = open(filename, 'w') fp.write(alltests[i+1] + '\n') fp.close() break else: os.unlink(filename) sys.exit(len(bad) > 0) | 3b6d025d9bc6a0109e9a2ebd28a4864e8007193a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3b6d025d9bc6a0109e9a2ebd28a4864e8007193a/regrtest.py |
findleaks = 1 | findleaks = True | def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, fromfile=None, findleaks=0, use_resources=None): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdir -- the directory in which to look for tests (optional) Users other than the Python test suite will certainly want to specify testdir; if it's omitted, the directory containing the Python test suite is searched for. If the tests argument is omitted, the tests listed on the command-line will be used. If that's empty, too, then all *.py files beginning with test_ will be used. The other default arguments (verbose, quiet, generate, exclude, single, randomize, findleaks, and use_resources) allow programmers calling main() directly to set the values that would normally be set by flags on the command line. """ test_support.record_original_stdout(sys.stdout) try: opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lu:t:', ['help', 'verbose', 'quiet', 'generate', 'exclude', 'single', 'random', 'fromfile', 'findleaks', 'use=', 'threshold=']) except getopt.error, msg: usage(2, msg) # Defaults if use_resources is None: use_resources = [] for o, a in opts: if o in ('-h', '--help'): usage(0) elif o in ('-v', '--verbose'): verbose += 1 elif o in ('-q', '--quiet'): quiet = 1; verbose = 0 elif o in ('-g', '--generate'): generate = 1 elif o in ('-x', '--exclude'): exclude = 1 elif o in ('-s', '--single'): single = 1 elif o in ('-r', '--randomize'): randomize = 1 elif o in ('-f', '--fromfile'): fromfile = a elif o in ('-l', '--findleaks'): findleaks = 1 elif o in ('-t', '--threshold'): import gc gc.set_threshold(int(a)) elif o in ('-u', '--use'): u = [x.lower() for x in a.split(',')] for r in u: if r == 'all': use_resources[:] = RESOURCE_NAMES continue remove = False if r[0] == '-': remove = True r = r[1:] if r not in RESOURCE_NAMES: usage(1, 'Invalid -u/--use option: ' + a) if remove: if r in use_resources: use_resources.remove(r) elif r not in use_resources: use_resources.append(r) if generate and verbose: usage(2, "-g and -v don't go together!") if single and fromfile: usage(2, "-s and -f don't go together!") good = [] bad = [] skipped = [] resource_denieds = [] if findleaks: try: import gc except ImportError: print 'No GC available, disabling findleaks.' findleaks = 0 else: # Uncomment the line below to report garbage that is not # freeable by reference counting alone. By default only # garbage that is not collectable by the GC is reported. #gc.set_debug(gc.DEBUG_SAVEALL) found_garbage = [] if single: from tempfile import gettempdir filename = os.path.join(gettempdir(), 'pynexttest') try: fp = open(filename, 'r') next = fp.read().strip() tests = [next] fp.close() except IOError: pass if fromfile: tests = [] fp = open(fromfile) for line in fp: guts = line.split() # assuming no test has whitespace in its name if guts and not guts[0].startswith('#'): tests.extend(guts) fp.close() # Strip .py extensions. if args: args = map(removepy, args) if tests: tests = map(removepy, tests) stdtests = STDTESTS[:] nottests = NOTTESTS[:] if exclude: for arg in args: if arg in stdtests: stdtests.remove(arg) nottests[:0] = args args = [] tests = tests or args or findtests(testdir, stdtests, nottests) if single: tests = tests[:1] if randomize: random.shuffle(tests) test_support.verbose = verbose # Tell tests to be moderately quiet test_support.use_resources = use_resources save_modules = sys.modules.keys() for test in tests: if not quiet: print test sys.stdout.flush() ok = runtest(test, generate, verbose, quiet, testdir) if ok > 0: good.append(test) elif ok == 0: bad.append(test) else: skipped.append(test) if ok == -2: resource_denieds.append(test) if findleaks: gc.collect() if gc.garbage: print "Warning: test created", len(gc.garbage), print "uncollectable object(s)." # move the uncollectable objects somewhere so we don't see # them again found_garbage.extend(gc.garbage) del gc.garbage[:] # Unload the newly imported modules (best effort finalization) for module in sys.modules.keys(): if module not in save_modules and module.startswith("test."): test_support.unload(module) # The lists won't be sorted if running with -r good.sort() bad.sort() skipped.sort() if good and not quiet: if not bad and not skipped and len(good) > 1: print "All", print count(len(good), "test"), "OK." if verbose: print "CAUTION: stdout isn't compared in verbose mode:" print "a test that passes in verbose mode may fail without it." if bad: print count(len(bad), "test"), "failed:" printlist(bad) if skipped and not quiet: print count(len(skipped), "test"), "skipped:" printlist(skipped) e = _ExpectedSkips() plat = sys.platform if e.isvalid(): surprise = set(skipped) - e.getexpected() - set(resource_denieds) if surprise: print count(len(surprise), "skip"), \ "unexpected on", plat + ":" printlist(surprise) else: print "Those skips are all expected on", plat + "." else: print "Ask someone to teach regrtest.py about which tests are" print "expected to get skipped on", plat + "." if single: alltests = findtests(testdir, stdtests, nottests) for i in range(len(alltests)): if tests[0] == alltests[i]: if i == len(alltests) - 1: os.unlink(filename) else: fp = open(filename, 'w') fp.write(alltests[i+1] + '\n') fp.close() break else: os.unlink(filename) sys.exit(len(bad) > 0) | 3b6d025d9bc6a0109e9a2ebd28a4864e8007193a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3b6d025d9bc6a0109e9a2ebd28a4864e8007193a/regrtest.py |
findleaks = 0 | findleaks = False | def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, fromfile=None, findleaks=0, use_resources=None): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdir -- the directory in which to look for tests (optional) Users other than the Python test suite will certainly want to specify testdir; if it's omitted, the directory containing the Python test suite is searched for. If the tests argument is omitted, the tests listed on the command-line will be used. If that's empty, too, then all *.py files beginning with test_ will be used. The other default arguments (verbose, quiet, generate, exclude, single, randomize, findleaks, and use_resources) allow programmers calling main() directly to set the values that would normally be set by flags on the command line. """ test_support.record_original_stdout(sys.stdout) try: opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lu:t:', ['help', 'verbose', 'quiet', 'generate', 'exclude', 'single', 'random', 'fromfile', 'findleaks', 'use=', 'threshold=']) except getopt.error, msg: usage(2, msg) # Defaults if use_resources is None: use_resources = [] for o, a in opts: if o in ('-h', '--help'): usage(0) elif o in ('-v', '--verbose'): verbose += 1 elif o in ('-q', '--quiet'): quiet = 1; verbose = 0 elif o in ('-g', '--generate'): generate = 1 elif o in ('-x', '--exclude'): exclude = 1 elif o in ('-s', '--single'): single = 1 elif o in ('-r', '--randomize'): randomize = 1 elif o in ('-f', '--fromfile'): fromfile = a elif o in ('-l', '--findleaks'): findleaks = 1 elif o in ('-t', '--threshold'): import gc gc.set_threshold(int(a)) elif o in ('-u', '--use'): u = [x.lower() for x in a.split(',')] for r in u: if r == 'all': use_resources[:] = RESOURCE_NAMES continue remove = False if r[0] == '-': remove = True r = r[1:] if r not in RESOURCE_NAMES: usage(1, 'Invalid -u/--use option: ' + a) if remove: if r in use_resources: use_resources.remove(r) elif r not in use_resources: use_resources.append(r) if generate and verbose: usage(2, "-g and -v don't go together!") if single and fromfile: usage(2, "-s and -f don't go together!") good = [] bad = [] skipped = [] resource_denieds = [] if findleaks: try: import gc except ImportError: print 'No GC available, disabling findleaks.' findleaks = 0 else: # Uncomment the line below to report garbage that is not # freeable by reference counting alone. By default only # garbage that is not collectable by the GC is reported. #gc.set_debug(gc.DEBUG_SAVEALL) found_garbage = [] if single: from tempfile import gettempdir filename = os.path.join(gettempdir(), 'pynexttest') try: fp = open(filename, 'r') next = fp.read().strip() tests = [next] fp.close() except IOError: pass if fromfile: tests = [] fp = open(fromfile) for line in fp: guts = line.split() # assuming no test has whitespace in its name if guts and not guts[0].startswith('#'): tests.extend(guts) fp.close() # Strip .py extensions. if args: args = map(removepy, args) if tests: tests = map(removepy, tests) stdtests = STDTESTS[:] nottests = NOTTESTS[:] if exclude: for arg in args: if arg in stdtests: stdtests.remove(arg) nottests[:0] = args args = [] tests = tests or args or findtests(testdir, stdtests, nottests) if single: tests = tests[:1] if randomize: random.shuffle(tests) test_support.verbose = verbose # Tell tests to be moderately quiet test_support.use_resources = use_resources save_modules = sys.modules.keys() for test in tests: if not quiet: print test sys.stdout.flush() ok = runtest(test, generate, verbose, quiet, testdir) if ok > 0: good.append(test) elif ok == 0: bad.append(test) else: skipped.append(test) if ok == -2: resource_denieds.append(test) if findleaks: gc.collect() if gc.garbage: print "Warning: test created", len(gc.garbage), print "uncollectable object(s)." # move the uncollectable objects somewhere so we don't see # them again found_garbage.extend(gc.garbage) del gc.garbage[:] # Unload the newly imported modules (best effort finalization) for module in sys.modules.keys(): if module not in save_modules and module.startswith("test."): test_support.unload(module) # The lists won't be sorted if running with -r good.sort() bad.sort() skipped.sort() if good and not quiet: if not bad and not skipped and len(good) > 1: print "All", print count(len(good), "test"), "OK." if verbose: print "CAUTION: stdout isn't compared in verbose mode:" print "a test that passes in verbose mode may fail without it." if bad: print count(len(bad), "test"), "failed:" printlist(bad) if skipped and not quiet: print count(len(skipped), "test"), "skipped:" printlist(skipped) e = _ExpectedSkips() plat = sys.platform if e.isvalid(): surprise = set(skipped) - e.getexpected() - set(resource_denieds) if surprise: print count(len(surprise), "skip"), \ "unexpected on", plat + ":" printlist(surprise) else: print "Those skips are all expected on", plat + "." else: print "Ask someone to teach regrtest.py about which tests are" print "expected to get skipped on", plat + "." if single: alltests = findtests(testdir, stdtests, nottests) for i in range(len(alltests)): if tests[0] == alltests[i]: if i == len(alltests) - 1: os.unlink(filename) else: fp = open(filename, 'w') fp.write(alltests[i+1] + '\n') fp.close() break else: os.unlink(filename) sys.exit(len(bad) > 0) | 3b6d025d9bc6a0109e9a2ebd28a4864e8007193a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3b6d025d9bc6a0109e9a2ebd28a4864e8007193a/regrtest.py |
ok = runtest(test, generate, verbose, quiet, testdir) if ok > 0: good.append(test) elif ok == 0: bad.append(test) | if trace: tracer.runctx('runtest(test, generate, verbose, quiet, testdir)', globals=globals(), locals=vars()) | def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, fromfile=None, findleaks=0, use_resources=None): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdir -- the directory in which to look for tests (optional) Users other than the Python test suite will certainly want to specify testdir; if it's omitted, the directory containing the Python test suite is searched for. If the tests argument is omitted, the tests listed on the command-line will be used. If that's empty, too, then all *.py files beginning with test_ will be used. The other default arguments (verbose, quiet, generate, exclude, single, randomize, findleaks, and use_resources) allow programmers calling main() directly to set the values that would normally be set by flags on the command line. """ test_support.record_original_stdout(sys.stdout) try: opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lu:t:', ['help', 'verbose', 'quiet', 'generate', 'exclude', 'single', 'random', 'fromfile', 'findleaks', 'use=', 'threshold=']) except getopt.error, msg: usage(2, msg) # Defaults if use_resources is None: use_resources = [] for o, a in opts: if o in ('-h', '--help'): usage(0) elif o in ('-v', '--verbose'): verbose += 1 elif o in ('-q', '--quiet'): quiet = 1; verbose = 0 elif o in ('-g', '--generate'): generate = 1 elif o in ('-x', '--exclude'): exclude = 1 elif o in ('-s', '--single'): single = 1 elif o in ('-r', '--randomize'): randomize = 1 elif o in ('-f', '--fromfile'): fromfile = a elif o in ('-l', '--findleaks'): findleaks = 1 elif o in ('-t', '--threshold'): import gc gc.set_threshold(int(a)) elif o in ('-u', '--use'): u = [x.lower() for x in a.split(',')] for r in u: if r == 'all': use_resources[:] = RESOURCE_NAMES continue remove = False if r[0] == '-': remove = True r = r[1:] if r not in RESOURCE_NAMES: usage(1, 'Invalid -u/--use option: ' + a) if remove: if r in use_resources: use_resources.remove(r) elif r not in use_resources: use_resources.append(r) if generate and verbose: usage(2, "-g and -v don't go together!") if single and fromfile: usage(2, "-s and -f don't go together!") good = [] bad = [] skipped = [] resource_denieds = [] if findleaks: try: import gc except ImportError: print 'No GC available, disabling findleaks.' findleaks = 0 else: # Uncomment the line below to report garbage that is not # freeable by reference counting alone. By default only # garbage that is not collectable by the GC is reported. #gc.set_debug(gc.DEBUG_SAVEALL) found_garbage = [] if single: from tempfile import gettempdir filename = os.path.join(gettempdir(), 'pynexttest') try: fp = open(filename, 'r') next = fp.read().strip() tests = [next] fp.close() except IOError: pass if fromfile: tests = [] fp = open(fromfile) for line in fp: guts = line.split() # assuming no test has whitespace in its name if guts and not guts[0].startswith('#'): tests.extend(guts) fp.close() # Strip .py extensions. if args: args = map(removepy, args) if tests: tests = map(removepy, tests) stdtests = STDTESTS[:] nottests = NOTTESTS[:] if exclude: for arg in args: if arg in stdtests: stdtests.remove(arg) nottests[:0] = args args = [] tests = tests or args or findtests(testdir, stdtests, nottests) if single: tests = tests[:1] if randomize: random.shuffle(tests) test_support.verbose = verbose # Tell tests to be moderately quiet test_support.use_resources = use_resources save_modules = sys.modules.keys() for test in tests: if not quiet: print test sys.stdout.flush() ok = runtest(test, generate, verbose, quiet, testdir) if ok > 0: good.append(test) elif ok == 0: bad.append(test) else: skipped.append(test) if ok == -2: resource_denieds.append(test) if findleaks: gc.collect() if gc.garbage: print "Warning: test created", len(gc.garbage), print "uncollectable object(s)." # move the uncollectable objects somewhere so we don't see # them again found_garbage.extend(gc.garbage) del gc.garbage[:] # Unload the newly imported modules (best effort finalization) for module in sys.modules.keys(): if module not in save_modules and module.startswith("test."): test_support.unload(module) # The lists won't be sorted if running with -r good.sort() bad.sort() skipped.sort() if good and not quiet: if not bad and not skipped and len(good) > 1: print "All", print count(len(good), "test"), "OK." if verbose: print "CAUTION: stdout isn't compared in verbose mode:" print "a test that passes in verbose mode may fail without it." if bad: print count(len(bad), "test"), "failed:" printlist(bad) if skipped and not quiet: print count(len(skipped), "test"), "skipped:" printlist(skipped) e = _ExpectedSkips() plat = sys.platform if e.isvalid(): surprise = set(skipped) - e.getexpected() - set(resource_denieds) if surprise: print count(len(surprise), "skip"), \ "unexpected on", plat + ":" printlist(surprise) else: print "Those skips are all expected on", plat + "." else: print "Ask someone to teach regrtest.py about which tests are" print "expected to get skipped on", plat + "." if single: alltests = findtests(testdir, stdtests, nottests) for i in range(len(alltests)): if tests[0] == alltests[i]: if i == len(alltests) - 1: os.unlink(filename) else: fp = open(filename, 'w') fp.write(alltests[i+1] + '\n') fp.close() break else: os.unlink(filename) sys.exit(len(bad) > 0) | 3b6d025d9bc6a0109e9a2ebd28a4864e8007193a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3b6d025d9bc6a0109e9a2ebd28a4864e8007193a/regrtest.py |
skipped.append(test) if ok == -2: resource_denieds.append(test) | ok = runtest(test, generate, verbose, quiet, testdir) if ok > 0: good.append(test) elif ok == 0: bad.append(test) else: skipped.append(test) if ok == -2: resource_denieds.append(test) | def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, fromfile=None, findleaks=0, use_resources=None): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdir -- the directory in which to look for tests (optional) Users other than the Python test suite will certainly want to specify testdir; if it's omitted, the directory containing the Python test suite is searched for. If the tests argument is omitted, the tests listed on the command-line will be used. If that's empty, too, then all *.py files beginning with test_ will be used. The other default arguments (verbose, quiet, generate, exclude, single, randomize, findleaks, and use_resources) allow programmers calling main() directly to set the values that would normally be set by flags on the command line. """ test_support.record_original_stdout(sys.stdout) try: opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lu:t:', ['help', 'verbose', 'quiet', 'generate', 'exclude', 'single', 'random', 'fromfile', 'findleaks', 'use=', 'threshold=']) except getopt.error, msg: usage(2, msg) # Defaults if use_resources is None: use_resources = [] for o, a in opts: if o in ('-h', '--help'): usage(0) elif o in ('-v', '--verbose'): verbose += 1 elif o in ('-q', '--quiet'): quiet = 1; verbose = 0 elif o in ('-g', '--generate'): generate = 1 elif o in ('-x', '--exclude'): exclude = 1 elif o in ('-s', '--single'): single = 1 elif o in ('-r', '--randomize'): randomize = 1 elif o in ('-f', '--fromfile'): fromfile = a elif o in ('-l', '--findleaks'): findleaks = 1 elif o in ('-t', '--threshold'): import gc gc.set_threshold(int(a)) elif o in ('-u', '--use'): u = [x.lower() for x in a.split(',')] for r in u: if r == 'all': use_resources[:] = RESOURCE_NAMES continue remove = False if r[0] == '-': remove = True r = r[1:] if r not in RESOURCE_NAMES: usage(1, 'Invalid -u/--use option: ' + a) if remove: if r in use_resources: use_resources.remove(r) elif r not in use_resources: use_resources.append(r) if generate and verbose: usage(2, "-g and -v don't go together!") if single and fromfile: usage(2, "-s and -f don't go together!") good = [] bad = [] skipped = [] resource_denieds = [] if findleaks: try: import gc except ImportError: print 'No GC available, disabling findleaks.' findleaks = 0 else: # Uncomment the line below to report garbage that is not # freeable by reference counting alone. By default only # garbage that is not collectable by the GC is reported. #gc.set_debug(gc.DEBUG_SAVEALL) found_garbage = [] if single: from tempfile import gettempdir filename = os.path.join(gettempdir(), 'pynexttest') try: fp = open(filename, 'r') next = fp.read().strip() tests = [next] fp.close() except IOError: pass if fromfile: tests = [] fp = open(fromfile) for line in fp: guts = line.split() # assuming no test has whitespace in its name if guts and not guts[0].startswith('#'): tests.extend(guts) fp.close() # Strip .py extensions. if args: args = map(removepy, args) if tests: tests = map(removepy, tests) stdtests = STDTESTS[:] nottests = NOTTESTS[:] if exclude: for arg in args: if arg in stdtests: stdtests.remove(arg) nottests[:0] = args args = [] tests = tests or args or findtests(testdir, stdtests, nottests) if single: tests = tests[:1] if randomize: random.shuffle(tests) test_support.verbose = verbose # Tell tests to be moderately quiet test_support.use_resources = use_resources save_modules = sys.modules.keys() for test in tests: if not quiet: print test sys.stdout.flush() ok = runtest(test, generate, verbose, quiet, testdir) if ok > 0: good.append(test) elif ok == 0: bad.append(test) else: skipped.append(test) if ok == -2: resource_denieds.append(test) if findleaks: gc.collect() if gc.garbage: print "Warning: test created", len(gc.garbage), print "uncollectable object(s)." # move the uncollectable objects somewhere so we don't see # them again found_garbage.extend(gc.garbage) del gc.garbage[:] # Unload the newly imported modules (best effort finalization) for module in sys.modules.keys(): if module not in save_modules and module.startswith("test."): test_support.unload(module) # The lists won't be sorted if running with -r good.sort() bad.sort() skipped.sort() if good and not quiet: if not bad and not skipped and len(good) > 1: print "All", print count(len(good), "test"), "OK." if verbose: print "CAUTION: stdout isn't compared in verbose mode:" print "a test that passes in verbose mode may fail without it." if bad: print count(len(bad), "test"), "failed:" printlist(bad) if skipped and not quiet: print count(len(skipped), "test"), "skipped:" printlist(skipped) e = _ExpectedSkips() plat = sys.platform if e.isvalid(): surprise = set(skipped) - e.getexpected() - set(resource_denieds) if surprise: print count(len(surprise), "skip"), \ "unexpected on", plat + ":" printlist(surprise) else: print "Those skips are all expected on", plat + "." else: print "Ask someone to teach regrtest.py about which tests are" print "expected to get skipped on", plat + "." if single: alltests = findtests(testdir, stdtests, nottests) for i in range(len(alltests)): if tests[0] == alltests[i]: if i == len(alltests) - 1: os.unlink(filename) else: fp = open(filename, 'w') fp.write(alltests[i+1] + '\n') fp.close() break else: os.unlink(filename) sys.exit(len(bad) > 0) | 3b6d025d9bc6a0109e9a2ebd28a4864e8007193a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3b6d025d9bc6a0109e9a2ebd28a4864e8007193a/regrtest.py |
def runtest(test, generate, verbose, quiet, testdir = None): | def runtest(test, generate, verbose, quiet, testdir=None): | def runtest(test, generate, verbose, quiet, testdir = None): """Run a single test. test -- the name of the test generate -- if true, generate output, instead of running the test and comparing it to a previously created output file verbose -- if true, print more messages quiet -- if true, don't print 'skipped' messages (probably redundant) testdir -- test directory """ test_support.unload(test) if not testdir: testdir = findtestdir() outputdir = os.path.join(testdir, "output") outputfile = os.path.join(outputdir, test) if verbose: cfp = None else: cfp = cStringIO.StringIO() try: save_stdout = sys.stdout try: if cfp: sys.stdout = cfp print test # Output file starts with test name if test.startswith('test.'): abstest = test else: # Always import it from the test package abstest = 'test.' + test the_package = __import__(abstest, globals(), locals(), []) the_module = getattr(the_package, test) # Most tests run to completion simply as a side-effect of # being imported. For the benefit of tests that can't run # that way (like test_threaded_import), explicitly invoke # their test_main() function (if it exists). indirect_test = getattr(the_module, "test_main", None) if indirect_test is not None: indirect_test() finally: sys.stdout = save_stdout except test_support.ResourceDenied, msg: if not quiet: print test, "skipped --", msg sys.stdout.flush() return -2 except (ImportError, test_support.TestSkipped), msg: if not quiet: print test, "skipped --", msg sys.stdout.flush() return -1 except KeyboardInterrupt: raise except test_support.TestFailed, msg: print "test", test, "failed --", msg sys.stdout.flush() return 0 except: type, value = sys.exc_info()[:2] print "test", test, "crashed --", str(type) + ":", value sys.stdout.flush() if verbose: traceback.print_exc(file=sys.stdout) sys.stdout.flush() return 0 else: if not cfp: return 1 output = cfp.getvalue() if generate: if output == test + "\n": if os.path.exists(outputfile): # Write it since it already exists (and the contents # may have changed), but let the user know it isn't # needed: print "output file", outputfile, \ "is no longer needed; consider removing it" else: # We don't need it, so don't create it. return 1 fp = open(outputfile, "w") fp.write(output) fp.close() return 1 if os.path.exists(outputfile): fp = open(outputfile, "r") expected = fp.read() fp.close() else: expected = test + "\n" if output == expected: return 1 print "test", test, "produced unexpected output:" sys.stdout.flush() reportdiff(expected, output) sys.stdout.flush() return 0 | 3b6d025d9bc6a0109e9a2ebd28a4864e8007193a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3b6d025d9bc6a0109e9a2ebd28a4864e8007193a/regrtest.py |
if not testdir: testdir = findtestdir() | if not testdir: testdir = findtestdir() | def runtest(test, generate, verbose, quiet, testdir = None): """Run a single test. test -- the name of the test generate -- if true, generate output, instead of running the test and comparing it to a previously created output file verbose -- if true, print more messages quiet -- if true, don't print 'skipped' messages (probably redundant) testdir -- test directory """ test_support.unload(test) if not testdir: testdir = findtestdir() outputdir = os.path.join(testdir, "output") outputfile = os.path.join(outputdir, test) if verbose: cfp = None else: cfp = cStringIO.StringIO() try: save_stdout = sys.stdout try: if cfp: sys.stdout = cfp print test # Output file starts with test name if test.startswith('test.'): abstest = test else: # Always import it from the test package abstest = 'test.' + test the_package = __import__(abstest, globals(), locals(), []) the_module = getattr(the_package, test) # Most tests run to completion simply as a side-effect of # being imported. For the benefit of tests that can't run # that way (like test_threaded_import), explicitly invoke # their test_main() function (if it exists). indirect_test = getattr(the_module, "test_main", None) if indirect_test is not None: indirect_test() finally: sys.stdout = save_stdout except test_support.ResourceDenied, msg: if not quiet: print test, "skipped --", msg sys.stdout.flush() return -2 except (ImportError, test_support.TestSkipped), msg: if not quiet: print test, "skipped --", msg sys.stdout.flush() return -1 except KeyboardInterrupt: raise except test_support.TestFailed, msg: print "test", test, "failed --", msg sys.stdout.flush() return 0 except: type, value = sys.exc_info()[:2] print "test", test, "crashed --", str(type) + ":", value sys.stdout.flush() if verbose: traceback.print_exc(file=sys.stdout) sys.stdout.flush() return 0 else: if not cfp: return 1 output = cfp.getvalue() if generate: if output == test + "\n": if os.path.exists(outputfile): # Write it since it already exists (and the contents # may have changed), but let the user know it isn't # needed: print "output file", outputfile, \ "is no longer needed; consider removing it" else: # We don't need it, so don't create it. return 1 fp = open(outputfile, "w") fp.write(output) fp.close() return 1 if os.path.exists(outputfile): fp = open(outputfile, "r") expected = fp.read() fp.close() else: expected = test + "\n" if output == expected: return 1 print "test", test, "produced unexpected output:" sys.stdout.flush() reportdiff(expected, output) sys.stdout.flush() return 0 | 3b6d025d9bc6a0109e9a2ebd28a4864e8007193a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3b6d025d9bc6a0109e9a2ebd28a4864e8007193a/regrtest.py |
startofline = tell() | try: startofline = tell() except IOError: startofline = tell = None self.seekable = 0 | def readheaders(self): """Read header lines. Read header lines up to the entirely blank line that terminates them. The (normally blank) line that ends the headers is skipped, but not included in the returned list. If a non-header line ends the headers, (which is an error), an attempt is made to backspace over it; it is never included in the returned list. The variable self.status is set to the empty string if all went well, otherwise it is an error message. The variable self.headers is a completely uninterpreted list of lines contained in the header (so printing them will reproduce the header exactly as it appears in the file). """ self.dict = {} self.unixfrom = '' self.headers = list = [] self.status = '' headerseen = "" firstline = 1 startofline = unread = tell = None if hasattr(self.fp, 'unread'): unread = self.fp.unread elif self.seekable: tell = self.fp.tell while 1: if tell: startofline = tell() line = self.fp.readline() if not line: self.status = 'EOF in headers' break # Skip unix From name time lines if firstline and line[:5] == 'From ': self.unixfrom = self.unixfrom + line continue firstline = 0 if headerseen and line[0] in ' \t': # It's a continuation line. list.append(line) x = (self.dict[headerseen] + "\n " + string.strip(line)) self.dict[headerseen] = string.strip(x) continue elif self.iscomment(line): # It's a comment. Ignore it. continue elif self.islast(line): # Note! No pushback here! The delimiter line gets eaten. break headerseen = self.isheader(line) if headerseen: # It's a legal header line, save it. list.append(line) self.dict[headerseen] = string.strip(line[len(headerseen)+1:]) continue else: # It's not a header line; throw it back and stop here. if not self.dict: self.status = 'No headers' else: self.status = 'Non-header line where header expected' # Try to undo the read. if unread: unread(line) elif tell: self.fp.seek(startofline) else: self.status = self.status + '; bad seek' break | a66eed62fd232bc276e9f8169f9d9025937f8899 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a66eed62fd232bc276e9f8169f9d9025937f8899/rfc822.py |
def pickle_complex(c): return complex, (c.real, c.imag) | try: complex except NameError: pass else: | def pickle_complex(c): return complex, (c.real, c.imag) | 502ba4630358423dc3da4da0f3f938d3cb56281f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/502ba4630358423dc3da4da0f3f938d3cb56281f/copy_reg.py |
pickle(type(1j), pickle_complex, complex) | def pickle_complex(c): return complex, (c.real, c.imag) pickle(complex, pickle_complex, complex) | def pickle_complex(c): return complex, (c.real, c.imag) | 502ba4630358423dc3da4da0f3f938d3cb56281f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/502ba4630358423dc3da4da0f3f938d3cb56281f/copy_reg.py |
raise TypeError, 'string payload expected' | raise TypeError, 'string payload expected: %s' % type(payload) | def _handle_text(self, msg): payload = msg.get_payload() if not isinstance(payload, StringType): raise TypeError, 'string payload expected' if self._mangle_from_: payload = fcre.sub('>From ', payload) self._fp.write(payload) | b384e01796fad1293256262e7ab022f176afce9a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b384e01796fad1293256262e7ab022f176afce9a/Generator.py |
g = self.__class__(s) | g = self.__class__(s, self._mangle_from_, self.__maxheaderlen) | def _handle_multipart(self, msg, isdigest=0): # The trick here is to write out each part separately, merge them all # together, and then make sure that the boundary we've chosen isn't # present in the payload. msgtexts = [] for part in msg.get_payload(): s = StringIO() g = self.__class__(s) g(part, unixfrom=0) msgtexts.append(s.getvalue()) # Now make sure the boundary we've selected doesn't appear in any of # the message texts. alltext = NL.join(msgtexts) # BAW: What about boundaries that are wrapped in double-quotes? boundary = msg.get_boundary(failobj=_make_boundary(alltext)) # If we had to calculate a new boundary because the body text # contained that string, set the new boundary. We don't do it # unconditionally because, while set_boundary() preserves order, it # doesn't preserve newlines/continuations in headers. This is no big # deal in practice, but turns out to be inconvenient for the unittest # suite. if msg.get_boundary() <> boundary: msg.set_boundary(boundary) # Write out any preamble if msg.preamble is not None: self._fp.write(msg.preamble) # First boundary is a bit different; it doesn't have a leading extra # newline. print >> self._fp, '--' + boundary if isdigest: print >> self._fp # Join and write the individual parts joiner = '\n--' + boundary + '\n' if isdigest: # multipart/digest types effectively add an extra newline between # the boundary and the body part. joiner += '\n' self._fp.write(joiner.join(msgtexts)) print >> self._fp, '\n--' + boundary + '--', # Write out any epilogue if msg.epilogue is not None: self._fp.write(msg.epilogue) | b384e01796fad1293256262e7ab022f176afce9a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b384e01796fad1293256262e7ab022f176afce9a/Generator.py |
def _handle_message_rfc822(self, msg): | def _handle_message_delivery_status(self, msg): blocks = [] for part in msg.get_payload(): s = StringIO() g = self.__class__(s, self._mangle_from_, self.__maxheaderlen) g(part, unixfrom=0) text = s.getvalue() lines = text.split('\n') if lines and lines[-1] == '': blocks.append(NL.join(lines[:-1])) else: blocks.append(text) self._fp.write(NL.join(blocks)) def _handle_message(self, msg): | def _handle_message_rfc822(self, msg): s = StringIO() g = self.__class__(s) # A message/rfc822 should contain a scalar payload which is another # Message object. Extract that object, stringify it, and write that # out. g(msg.get_payload(), unixfrom=0) self._fp.write(s.getvalue()) | b384e01796fad1293256262e7ab022f176afce9a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b384e01796fad1293256262e7ab022f176afce9a/Generator.py |
g = self.__class__(s) | g = self.__class__(s, self._mangle_from_, self.__maxheaderlen) | def _handle_message_rfc822(self, msg): s = StringIO() g = self.__class__(s) # A message/rfc822 should contain a scalar payload which is another # Message object. Extract that object, stringify it, and write that # out. g(msg.get_payload(), unixfrom=0) self._fp.write(s.getvalue()) | b384e01796fad1293256262e7ab022f176afce9a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b384e01796fad1293256262e7ab022f176afce9a/Generator.py |
if part.get_main_type('text') == 'text': | maintype = part.get_main_type('text') if maintype == 'text': | def _dispatch(self, msg): for part in msg.walk(): if part.get_main_type('text') == 'text': print >> self, part.get_payload(decode=1) else: print >> self, self._fmt % { 'type' : part.get_type('[no MIME type]'), 'maintype' : part.get_main_type('[no main MIME type]'), 'subtype' : part.get_subtype('[no sub-MIME type]'), 'filename' : part.get_filename('[no filename]'), 'description': part.get('Content-Description', '[no description]'), 'encoding' : part.get('Content-Transfer-Encoding', '[no encoding]'), } | b384e01796fad1293256262e7ab022f176afce9a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b384e01796fad1293256262e7ab022f176afce9a/Generator.py |
if terminator is None or terminator == '': | if not terminator: | def handle_read (self): | ca69f0248c94a08f2077f8e17cf6ad556a2d9d16 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ca69f0248c94a08f2077f8e17cf6ad556a2d9d16/asynchat.py |
elif isinstance(terminator, int): | elif isinstance(terminator, int) or isinstance(terminator, long): | def handle_read (self): | ca69f0248c94a08f2077f8e17cf6ad556a2d9d16 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ca69f0248c94a08f2077f8e17cf6ad556a2d9d16/asynchat.py |
>>> d._fancy_replace(['abcDefghiJkl\n'], 0, 1, ['abcdefGhijkl\n'], 0, 1) >>> print ''.join(d.results), | >>> results = d._fancy_replace(['abcDefghiJkl\n'], 0, 1, ... ['abcdefGhijkl\n'], 0, 1) >>> print ''.join(results), | def _fancy_replace(self, a, alo, ahi, b, blo, bhi): r""" When replacing one block of lines with another, search the blocks for *similar* lines; the best-matching pair (if any) is used as a synch point, and intraline difference marking is done on the similar pair. Lots of work, but often worth it. | 83325e9087e1072cd51fed09896dc92a524db781 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/83325e9087e1072cd51fed09896dc92a524db781/difflib.py |
>>> d._qformat('\tabcDefghiJkl\n', '\t\tabcdefGhijkl\n', ... ' ^ ^ ^ ', '+ ^ ^ ^ ') >>> for line in d.results: print repr(line) | >>> results = d._qformat('\tabcDefghiJkl\n', '\t\tabcdefGhijkl\n', ... ' ^ ^ ^ ', '+ ^ ^ ^ ') >>> for line in results: print repr(line) | def _qformat(self, aline, bline, atags, btags): r""" Format "?" output and deal with leading tabs. | 83325e9087e1072cd51fed09896dc92a524db781 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/83325e9087e1072cd51fed09896dc92a524db781/difflib.py |
def get_python_version (): | def get_python_version(): | def get_python_version (): """Return a string containing the major and minor Python version, leaving off the patchlevel. Sample return values could be '1.5' or '2.2'. """ return sys.version[:3] | df37c8c1ad51b6f8527e2cd398788e49cd686654 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/df37c8c1ad51b6f8527e2cd398788e49cd686654/sysconfig.py |
return os.path.join(prefix, "include", "python" + sys.version[:3]) | return os.path.join(prefix, "include", "python" + get_python_version()) | def get_python_inc(plat_specific=0, prefix=None): """Return the directory containing installed Python header files. If 'plat_specific' is false (the default), this is the path to the non-platform-specific header files, i.e. Python.h and so on; otherwise, this is the path to platform-specific header files (namely pyconfig.h). If 'prefix' is supplied, use it instead of sys.prefix or sys.exec_prefix -- i.e., ignore 'plat_specific'. """ if prefix is None: prefix = plat_specific and EXEC_PREFIX or PREFIX if os.name == "posix": if python_build: base = os.path.dirname(os.path.abspath(sys.executable)) if plat_specific: inc_dir = base else: inc_dir = os.path.join(base, "Include") if not os.path.exists(inc_dir): inc_dir = os.path.join(os.path.dirname(base), "Include") return inc_dir return os.path.join(prefix, "include", "python" + sys.version[:3]) elif os.name == "nt": return os.path.join(prefix, "include") elif os.name == "mac": if plat_specific: return os.path.join(prefix, "Mac", "Include") else: return os.path.join(prefix, "Include") elif os.name == "os2": return os.path.join(prefix, "Include") else: raise DistutilsPlatformError( "I don't know where Python installs its C header files " "on platform '%s'" % os.name) | df37c8c1ad51b6f8527e2cd398788e49cd686654 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/df37c8c1ad51b6f8527e2cd398788e49cd686654/sysconfig.py |
if sys.version < "2.2": | if get_python_version() < "2.2": | def get_python_lib(plat_specific=0, standard_lib=0, prefix=None): """Return the directory containing the Python library (standard or site additions). If 'plat_specific' is true, return the directory containing platform-specific modules, i.e. any module from a non-pure-Python module distribution; otherwise, return the platform-shared library directory. If 'standard_lib' is true, return the directory containing standard Python library modules; otherwise, return the directory for site-specific modules. If 'prefix' is supplied, use it instead of sys.prefix or sys.exec_prefix -- i.e., ignore 'plat_specific'. """ if prefix is None: prefix = plat_specific and EXEC_PREFIX or PREFIX if os.name == "posix": libpython = os.path.join(prefix, "lib", "python" + get_python_version()) if standard_lib: return libpython else: return os.path.join(libpython, "site-packages") elif os.name == "nt": if standard_lib: return os.path.join(prefix, "Lib") else: if sys.version < "2.2": return prefix else: return os.path.join(PREFIX, "Lib", "site-packages") elif os.name == "mac": if plat_specific: if standard_lib: return os.path.join(prefix, "Lib", "lib-dynload") else: return os.path.join(prefix, "Lib", "site-packages") else: if standard_lib: return os.path.join(prefix, "Lib") else: return os.path.join(prefix, "Lib", "site-packages") elif os.name == "os2": if standard_lib: return os.path.join(PREFIX, "Lib") else: return os.path.join(PREFIX, "Lib", "site-packages") else: raise DistutilsPlatformError( "I don't know where Python installs its library " "on platform '%s'" % os.name) | df37c8c1ad51b6f8527e2cd398788e49cd686654 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/df37c8c1ad51b6f8527e2cd398788e49cd686654/sysconfig.py |
if sys.version < '2.2': | if get_python_version() < '2.2': | def get_config_h_filename(): """Return full pathname of installed pyconfig.h file.""" if python_build: inc_dir = os.curdir else: inc_dir = get_python_inc(plat_specific=1) if sys.version < '2.2': config_h = 'config.h' else: # The name of the config.h file changed in 2.2 config_h = 'pyconfig.h' return os.path.join(inc_dir, config_h) | df37c8c1ad51b6f8527e2cd398788e49cd686654 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/df37c8c1ad51b6f8527e2cd398788e49cd686654/sysconfig.py |
elif sys.version < '2.1': | elif get_python_version() < '2.1': | def _init_posix(): """Initialize the module as appropriate for POSIX systems.""" g = {} # load the installed Makefile: try: filename = get_makefile_filename() parse_makefile(filename, g) except IOError, msg: my_msg = "invalid Python installation: unable to open %s" % filename if hasattr(msg, "strerror"): my_msg = my_msg + " (%s)" % msg.strerror raise DistutilsPlatformError(my_msg) # On MacOSX we need to check the setting of the environment variable # MACOSX_DEPLOYMENT_TARGET: configure bases some choices on it so # it needs to be compatible. # If it isn't set we set it to the configure-time value if sys.platform == 'darwin' and g.has_key('CONFIGURE_MACOSX_DEPLOYMENT_TARGET'): cfg_target = g['CONFIGURE_MACOSX_DEPLOYMENT_TARGET'] cur_target = os.getenv('MACOSX_DEPLOYMENT_TARGET', '') if cur_target == '': cur_target = cfg_target os.putenv('MACOSX_DEPLOYMENT_TARGET', cfg_target) if cfg_target != cur_target: my_msg = ('$MACOSX_DEPLOYMENT_TARGET mismatch: now "%s" but "%s" during configure' % (cur_target, cfg_target)) raise DistutilsPlatformError(my_msg) # On AIX, there are wrong paths to the linker scripts in the Makefile # -- these paths are relative to the Python source, but when installed # the scripts are in another directory. if python_build: g['LDSHARED'] = g['BLDSHARED'] elif sys.version < '2.1': # The following two branches are for 1.5.2 compatibility. if sys.platform == 'aix4': # what about AIX 3.x ? # Linker script is in the config directory, not in Modules as the # Makefile says. python_lib = get_python_lib(standard_lib=1) ld_so_aix = os.path.join(python_lib, 'config', 'ld_so_aix') python_exp = os.path.join(python_lib, 'config', 'python.exp') g['LDSHARED'] = "%s %s -bI:%s" % (ld_so_aix, g['CC'], python_exp) elif sys.platform == 'beos': # Linker script is in the config directory. In the Makefile it is # relative to the srcdir, which after installation no longer makes # sense. python_lib = get_python_lib(standard_lib=1) linkerscript_path = string.split(g['LDSHARED'])[0] linkerscript_name = os.path.basename(linkerscript_path) linkerscript = os.path.join(python_lib, 'config', linkerscript_name) # XXX this isn't the right place to do this: adding the Python # library to the link, if needed, should be in the "build_ext" # command. (It's also needed for non-MS compilers on Windows, and # it's taken care of for them by the 'build_ext.get_libraries()' # method.) g['LDSHARED'] = ("%s -L%s/lib -lpython%s" % (linkerscript, PREFIX, sys.version[0:3])) global _config_vars _config_vars = g | df37c8c1ad51b6f8527e2cd398788e49cd686654 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/df37c8c1ad51b6f8527e2cd398788e49cd686654/sysconfig.py |
(linkerscript, PREFIX, sys.version[0:3])) | (linkerscript, PREFIX, get_python_version())) | def _init_posix(): """Initialize the module as appropriate for POSIX systems.""" g = {} # load the installed Makefile: try: filename = get_makefile_filename() parse_makefile(filename, g) except IOError, msg: my_msg = "invalid Python installation: unable to open %s" % filename if hasattr(msg, "strerror"): my_msg = my_msg + " (%s)" % msg.strerror raise DistutilsPlatformError(my_msg) # On MacOSX we need to check the setting of the environment variable # MACOSX_DEPLOYMENT_TARGET: configure bases some choices on it so # it needs to be compatible. # If it isn't set we set it to the configure-time value if sys.platform == 'darwin' and g.has_key('CONFIGURE_MACOSX_DEPLOYMENT_TARGET'): cfg_target = g['CONFIGURE_MACOSX_DEPLOYMENT_TARGET'] cur_target = os.getenv('MACOSX_DEPLOYMENT_TARGET', '') if cur_target == '': cur_target = cfg_target os.putenv('MACOSX_DEPLOYMENT_TARGET', cfg_target) if cfg_target != cur_target: my_msg = ('$MACOSX_DEPLOYMENT_TARGET mismatch: now "%s" but "%s" during configure' % (cur_target, cfg_target)) raise DistutilsPlatformError(my_msg) # On AIX, there are wrong paths to the linker scripts in the Makefile # -- these paths are relative to the Python source, but when installed # the scripts are in another directory. if python_build: g['LDSHARED'] = g['BLDSHARED'] elif sys.version < '2.1': # The following two branches are for 1.5.2 compatibility. if sys.platform == 'aix4': # what about AIX 3.x ? # Linker script is in the config directory, not in Modules as the # Makefile says. python_lib = get_python_lib(standard_lib=1) ld_so_aix = os.path.join(python_lib, 'config', 'ld_so_aix') python_exp = os.path.join(python_lib, 'config', 'python.exp') g['LDSHARED'] = "%s %s -bI:%s" % (ld_so_aix, g['CC'], python_exp) elif sys.platform == 'beos': # Linker script is in the config directory. In the Makefile it is # relative to the srcdir, which after installation no longer makes # sense. python_lib = get_python_lib(standard_lib=1) linkerscript_path = string.split(g['LDSHARED'])[0] linkerscript_name = os.path.basename(linkerscript_path) linkerscript = os.path.join(python_lib, 'config', linkerscript_name) # XXX this isn't the right place to do this: adding the Python # library to the link, if needed, should be in the "build_ext" # command. (It's also needed for non-MS compilers on Windows, and # it's taken care of for them by the 'build_ext.get_libraries()' # method.) g['LDSHARED'] = ("%s -L%s/lib -lpython%s" % (linkerscript, PREFIX, sys.version[0:3])) global _config_vars _config_vars = g | df37c8c1ad51b6f8527e2cd398788e49cd686654 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/df37c8c1ad51b6f8527e2cd398788e49cd686654/sysconfig.py |
mbox = '/usr/mail/' + mbox | if os.path.isfile('/var/mail/' + mbox): mbox = '/var/mail/' + mbox else: mbox = '/usr/mail/' + mbox | def _test(): import sys args = sys.argv[1:] if not args: for key in 'MAILDIR', 'MAIL', 'LOGNAME', 'USER': if os.environ.has_key(key): mbox = os.environ[key] break else: print "$MAIL, $LOGNAME nor $USER set -- who are you?" return else: mbox = args[0] if mbox[:1] == '+': mbox = os.environ['HOME'] + '/Mail/' + mbox[1:] elif not '/' in mbox: mbox = '/usr/mail/' + mbox if os.path.isdir(mbox): if os.path.isdir(os.path.join(mbox, 'cur')): mb = Maildir(mbox) else: mb = MHMailbox(mbox) else: fp = open(mbox, 'r') mb = PortableUnixMailbox(fp) msgs = [] while 1: msg = mb.next() if msg is None: break msgs.append(msg) if len(args) <= 1: msg.fp = None if len(args) > 1: num = int(args[1]) print 'Message %d body:'%num msg = msgs[num-1] msg.rewindbody() sys.stdout.write(msg.fp.read()) else: print 'Mailbox',mbox,'has',len(msgs),'messages:' for msg in msgs: f = msg.getheader('from') or "" s = msg.getheader('subject') or "" d = msg.getheader('date') or "" print '-%20.20s %20.20s %-30.30s'%(f, d[5:], s) | 03f3ee6d891e86d3744793f5d66624e52c8261d5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/03f3ee6d891e86d3744793f5d66624e52c8261d5/mailbox.py |
menu.configure(postcommand=self.postwindowsmenu) | WindowList.register_callback(self.postwindowsmenu) | def __init__(self, flist=None, filename=None, key=None, root=None): self.flist = flist root = root or flist.root self.root = root if flist: self.vars = flist.vars self.menubar = Menu(root) self.top = top = self.Toplevel(root, menu=self.menubar) self.vbar = vbar = Scrollbar(top, name='vbar') self.text = text = Text(top, name='text', padx=5, background="white", wrap="none") | c4f752f803a20948826eff4601ea595d8b74bb96 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c4f752f803a20948826eff4601ea595d8b74bb96/EditorWindow.py |
import WindowList | def postwindowsmenu(self): # Only called when Windows menu exists # XXX Actually, this Just-In-Time updating interferes # XXX badly with the tear-off feature. It would be better # XXX to update all Windows menus whenever the list of windows # XXX changes. menu = self.menudict['windows'] end = menu.index("end") if end is None: end = -1 if end > self.wmenu_end: menu.delete(self.wmenu_end+1, end) import WindowList WindowList.add_windows_to_menu(menu) | c4f752f803a20948826eff4601ea595d8b74bb96 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c4f752f803a20948826eff4601ea595d8b74bb96/EditorWindow.py |
|
- excample: the Example object that failed | - example: the Example object that failed | def output_difference(self, example, got, optionflags): """ Return a string describing the differences between the expected output for a given example (`example`) and the actual output (`got`). `optionflags` is the set of option flags used to compare `want` and `got`. """ want = example.want # If <BLANKLINE>s are being used, then replace blank lines # with <BLANKLINE> in the actual output string. if not (optionflags & DONT_ACCEPT_BLANKLINE): got = re.sub('(?m)^[ ]*(?=\n)', BLANKLINE_MARKER, got) | d219e7f986a9b777c969614bf21967fd0c44df69 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d219e7f986a9b777c969614bf21967fd0c44df69/doctest.py |
- excample: the Example object that failed | - example: the Example object that failed | def __str__(self): return str(self.test) | d219e7f986a9b777c969614bf21967fd0c44df69 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d219e7f986a9b777c969614bf21967fd0c44df69/doctest.py |
f2 = self.tar.extractfile("S-SPARSE-WITH-NULLS") | f2 = self.tar.extractfile("/S-SPARSE-WITH-NULLS") | def test_sparse(self): """Test sparse member extraction. """ if self.sep != "|": f1 = self.tar.extractfile("S-SPARSE") f2 = self.tar.extractfile("S-SPARSE-WITH-NULLS") self.assert_(f1.read() == f2.read(), "_FileObject failed on sparse file member") | c7fcc2d772c6ccaa71002aaa2aace16ed8adf471 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c7fcc2d772c6ccaa71002aaa2aace16ed8adf471/test_tarfile.py |
filename = "0-REGTYPE-TEXT" | filename = "/0-REGTYPE-TEXT" | def test_readlines(self): """Test readlines() method of _FileObject. """ if self.sep != "|": filename = "0-REGTYPE-TEXT" self.tar.extract(filename, dirname()) lines1 = file(os.path.join(dirname(), filename), "r").readlines() lines2 = self.tar.extractfile(filename).readlines() self.assert_(lines1 == lines2, "_FileObject.readline() does not work correctly") | c7fcc2d772c6ccaa71002aaa2aace16ed8adf471 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c7fcc2d772c6ccaa71002aaa2aace16ed8adf471/test_tarfile.py |
lines1 = file(os.path.join(dirname(), filename), "r").readlines() | lines1 = file(os.path.join(dirname(), filename), "rU").readlines() | def test_readlines(self): """Test readlines() method of _FileObject. """ if self.sep != "|": filename = "0-REGTYPE-TEXT" self.tar.extract(filename, dirname()) lines1 = file(os.path.join(dirname(), filename), "r").readlines() lines2 = self.tar.extractfile(filename).readlines() self.assert_(lines1 == lines2, "_FileObject.readline() does not work correctly") | c7fcc2d772c6ccaa71002aaa2aace16ed8adf471 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c7fcc2d772c6ccaa71002aaa2aace16ed8adf471/test_tarfile.py |
filename = "0-REGTYPE" | filename = "/0-REGTYPE" | def test_seek(self): """Test seek() method of _FileObject, incl. random reading. """ if self.sep != "|": filename = "0-REGTYPE" self.tar.extract(filename, dirname()) data = file(os.path.join(dirname(), filename), "rb").read() | c7fcc2d772c6ccaa71002aaa2aace16ed8adf471 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c7fcc2d772c6ccaa71002aaa2aace16ed8adf471/test_tarfile.py |
def __getitem__(self, i): if i < 0 or i > 2: raise IndexError return i + 4 | 39a86c2188b22818c187e860fbf7d77a28a6a116 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/39a86c2188b22818c187e860fbf7d77a28a6a116/test_b2.py |
||
includes = ['-I' + incldir, '-I' + binlib] | includes = ['-I' + incldir, '-I' + config_h_dir] | def main(): # overridable context prefix = None # settable with -p option exec_prefix = None # settable with -P option extensions = [] exclude = [] # settable with -x option addn_link = [] # settable with -l, but only honored under Windows. path = sys.path[:] modargs = 0 debug = 1 odir = '' win = sys.platform[:3] == 'win' # default the exclude list for each platform | 590fc2c4fa9f831d5a1e5f7f3b59135f74f7e4ec /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/590fc2c4fa9f831d5a1e5f7f3b59135f74f7e4ec/freeze.py |
def testmod(m, name=None, globs=None, verbose=None, isprivate=None, | def testmod(m=None, name=None, globs=None, verbose=None, isprivate=None, | def testmod(m, name=None, globs=None, verbose=None, isprivate=None, report=1): """m, name=None, globs=None, verbose=None, isprivate=None, report=1 Test examples in docstrings in functions and classes reachable from module m, starting with m.__doc__. Private names are skipped. Also test examples reachable from dict m.__test__ if it exists and is not None. m.__dict__ maps names to functions, classes and strings; function and class docstrings are tested even if the name is private; strings are tested directly, as if they were docstrings. Return (#failures, #tests). See doctest.__doc__ for an overview. Optional keyword arg "name" gives the name of the module; by default use m.__name__. Optional keyword arg "globs" gives a dict to be used as the globals when executing examples; by default, use m.__dict__. A copy of this dict is actually used for each docstring, so that each docstring's examples start with a clean slate. Optional keyword arg "verbose" prints lots of stuff if true, prints only failures if false; by default, it's true iff "-v" is in sys.argv. Optional keyword arg "isprivate" specifies a function used to determine whether a name is private. The default function is doctest.is_private; see its docs for details. Optional keyword arg "report" prints a summary at the end when true, else prints nothing at the end. In verbose mode, the summary is detailed, else very brief (in fact, empty if all tests passed). Advanced tomfoolery: testmod runs methods of a local instance of class doctest.Tester, then merges the results into (or creates) global Tester instance doctest.master. Methods of doctest.master can be called directly too, if you want to do something unusual. Passing report=0 to testmod is especially useful then, to delay displaying a summary. Invoke doctest.master.summarize(verbose) when you're done fiddling. """ global master if not _ismodule(m): raise TypeError("testmod: module required; " + `m`) if name is None: name = m.__name__ tester = Tester(m, globs=globs, verbose=verbose, isprivate=isprivate) failures, tries = tester.rundoc(m, name) f, t = tester.rundict(m.__dict__, name, m) failures = failures + f tries = tries + t if hasattr(m, "__test__"): testdict = m.__test__ if testdict: if not hasattr(testdict, "items"): raise TypeError("testmod: module.__test__ must support " ".items(); " + `testdict`) f, t = tester.run__test__(testdict, name + ".__test__") failures = failures + f tries = tries + t if report: tester.summarize() if master is None: master = tester else: master.merge(tester) return failures, tries | 4581cfa326cf7d8b9d7888d4c0e96ee88950bcfa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4581cfa326cf7d8b9d7888d4c0e96ee88950bcfa/doctest.py |
"""m, name=None, globs=None, verbose=None, isprivate=None, report=1 Test examples in docstrings in functions and classes reachable from module m, starting with m.__doc__. Private names are skipped. | """m=None, name=None, globs=None, verbose=None, isprivate=None, report=1 Test examples in docstrings in functions and classes reachable from module m (or the current module if m is not supplied), starting with m.__doc__. Private names are skipped. | def testmod(m, name=None, globs=None, verbose=None, isprivate=None, report=1): """m, name=None, globs=None, verbose=None, isprivate=None, report=1 Test examples in docstrings in functions and classes reachable from module m, starting with m.__doc__. Private names are skipped. Also test examples reachable from dict m.__test__ if it exists and is not None. m.__dict__ maps names to functions, classes and strings; function and class docstrings are tested even if the name is private; strings are tested directly, as if they were docstrings. Return (#failures, #tests). See doctest.__doc__ for an overview. Optional keyword arg "name" gives the name of the module; by default use m.__name__. Optional keyword arg "globs" gives a dict to be used as the globals when executing examples; by default, use m.__dict__. A copy of this dict is actually used for each docstring, so that each docstring's examples start with a clean slate. Optional keyword arg "verbose" prints lots of stuff if true, prints only failures if false; by default, it's true iff "-v" is in sys.argv. Optional keyword arg "isprivate" specifies a function used to determine whether a name is private. The default function is doctest.is_private; see its docs for details. Optional keyword arg "report" prints a summary at the end when true, else prints nothing at the end. In verbose mode, the summary is detailed, else very brief (in fact, empty if all tests passed). Advanced tomfoolery: testmod runs methods of a local instance of class doctest.Tester, then merges the results into (or creates) global Tester instance doctest.master. Methods of doctest.master can be called directly too, if you want to do something unusual. Passing report=0 to testmod is especially useful then, to delay displaying a summary. Invoke doctest.master.summarize(verbose) when you're done fiddling. """ global master if not _ismodule(m): raise TypeError("testmod: module required; " + `m`) if name is None: name = m.__name__ tester = Tester(m, globs=globs, verbose=verbose, isprivate=isprivate) failures, tries = tester.rundoc(m, name) f, t = tester.rundict(m.__dict__, name, m) failures = failures + f tries = tries + t if hasattr(m, "__test__"): testdict = m.__test__ if testdict: if not hasattr(testdict, "items"): raise TypeError("testmod: module.__test__ must support " ".items(); " + `testdict`) f, t = tester.run__test__(testdict, name + ".__test__") failures = failures + f tries = tries + t if report: tester.summarize() if master is None: master = tester else: master.merge(tester) return failures, tries | 4581cfa326cf7d8b9d7888d4c0e96ee88950bcfa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4581cfa326cf7d8b9d7888d4c0e96ee88950bcfa/doctest.py |
class ResFunction(ResMixIn, OSErrFunctionGenerator): pass class ResMethod(ResMixIn, OSErrMethodGenerator): pass | class ResFunction(ResMixIn, OSErrWeakLinkFunctionGenerator): pass class ResMethod(ResMixIn, OSErrWeakLinkMethodGenerator): pass | def checkit(self): if self.returntype.__class__ != OSErrType: OutLbrace() Output("OSErr _err = ResError();") Output("if (_err != noErr) return PyMac_Error(_err);") OutRbrace() FunctionGenerator.checkit(self) # XXX | 150ed6113ce0e6558eafa27149e75e1463df20df /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/150ed6113ce0e6558eafa27149e75e1463df20df/ressupport.py |
if m[0] != '_' and m != 'config': | if m[0] != '_' and m != 'config' and m != 'configure': | def __init__(self, master=None, cnf={}, **kw): if kw: cnf = _cnfmerge((cnf, kw)) fcnf = {} for k in cnf.keys(): if type(k) == ClassType or k == 'name': fcnf[k] = cnf[k] del cnf[k] self.frame = apply(Frame, (master,), fcnf) self.vbar = Scrollbar(self.frame, name='vbar') self.vbar.pack(side=RIGHT, fill=Y) cnf['name'] = 'text' apply(Text.__init__, (self, self.frame), cnf) self.pack(side=LEFT, fill=BOTH, expand=1) self['yscrollcommand'] = self.vbar.set self.vbar['command'] = self.yview | 7f9732880ea24539e9c011e2c73bb9afb7ee316c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7f9732880ea24539e9c011e2c73bb9afb7ee316c/ScrolledText.py |
self.name = name | self.name = os.path.abspath(name) | def __init__(self, name=None, mode="r", fileobj=None): """Open an (uncompressed) tar archive `name'. `mode' is either 'r' to read from an existing archive, 'a' to append data to an existing file or 'w' to create a new file overwriting an existing one. `mode' defaults to 'r'. If `fileobj' is given, it is used for reading or writing data. If it can be determined, `mode' is overridden by `fileobj's mode. `fileobj' is not closed, when TarFile is closed. """ self.name = name | bc3b06087cf1907d1dfee6e21885a9ccfbf11af3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/bc3b06087cf1907d1dfee6e21885a9ccfbf11af3/tarfile.py |
self.name = fileobj.name | self.name = os.path.abspath(fileobj.name) | def __init__(self, name=None, mode="r", fileobj=None): """Open an (uncompressed) tar archive `name'. `mode' is either 'r' to read from an existing archive, 'a' to append data to an existing file or 'w' to create a new file overwriting an existing one. `mode' defaults to 'r'. If `fileobj' is given, it is used for reading or writing data. If it can be determined, `mode' is overridden by `fileobj's mode. `fileobj' is not closed, when TarFile is closed. """ self.name = name | bc3b06087cf1907d1dfee6e21885a9ccfbf11af3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/bc3b06087cf1907d1dfee6e21885a9ccfbf11af3/tarfile.py |
pre = os.path.basename(pre) | def gzopen(cls, name, mode="r", fileobj=None, compresslevel=9): """Open gzip compressed tar archive name for reading or writing. Appending is not allowed. """ if len(mode) > 1 or mode not in "rw": raise ValueError, "mode must be 'r' or 'w'" | bc3b06087cf1907d1dfee6e21885a9ccfbf11af3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/bc3b06087cf1907d1dfee6e21885a9ccfbf11af3/tarfile.py |
|
tarname = pre + ext | tarname = os.path.basename(pre + ext) | def gzopen(cls, name, mode="r", fileobj=None, compresslevel=9): """Open gzip compressed tar archive name for reading or writing. Appending is not allowed. """ if len(mode) > 1 or mode not in "rw": raise ValueError, "mode must be 'r' or 'w'" | bc3b06087cf1907d1dfee6e21885a9ccfbf11af3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/bc3b06087cf1907d1dfee6e21885a9ccfbf11af3/tarfile.py |
if mode != "r": name = tarname | def gzopen(cls, name, mode="r", fileobj=None, compresslevel=9): """Open gzip compressed tar archive name for reading or writing. Appending is not allowed. """ if len(mode) > 1 or mode not in "rw": raise ValueError, "mode must be 'r' or 'w'" | bc3b06087cf1907d1dfee6e21885a9ccfbf11af3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/bc3b06087cf1907d1dfee6e21885a9ccfbf11af3/tarfile.py |
|
t = cls.taropen(tarname, mode, gzip.GzipFile(name, mode, compresslevel, fileobj) | t = cls.taropen(name, mode, gzip.GzipFile(tarname, mode, compresslevel, fileobj) | def gzopen(cls, name, mode="r", fileobj=None, compresslevel=9): """Open gzip compressed tar archive name for reading or writing. Appending is not allowed. """ if len(mode) > 1 or mode not in "rw": raise ValueError, "mode must be 'r' or 'w'" | bc3b06087cf1907d1dfee6e21885a9ccfbf11af3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/bc3b06087cf1907d1dfee6e21885a9ccfbf11af3/tarfile.py |
pre, ext = os.path.splitext(name) pre = os.path.basename(pre) if ext == ".tbz2": ext = ".tar" if ext == ".bz2": ext = "" tarname = pre + ext | def bz2open(cls, name, mode="r", fileobj=None, compresslevel=9): """Open bzip2 compressed tar archive name for reading or writing. Appending is not allowed. """ if len(mode) > 1 or mode not in "rw": raise ValueError, "mode must be 'r' or 'w'." | bc3b06087cf1907d1dfee6e21885a9ccfbf11af3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/bc3b06087cf1907d1dfee6e21885a9ccfbf11af3/tarfile.py |
|
t = cls.taropen(tarname, mode, bz2.BZ2File(name, mode, compresslevel=compresslevel)) | t = cls.taropen(name, mode, bz2.BZ2File(name, mode, compresslevel=compresslevel)) | def bz2open(cls, name, mode="r", fileobj=None, compresslevel=9): """Open bzip2 compressed tar archive name for reading or writing. Appending is not allowed. """ if len(mode) > 1 or mode not in "rw": raise ValueError, "mode must be 'r' or 'w'." | bc3b06087cf1907d1dfee6e21885a9ccfbf11af3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/bc3b06087cf1907d1dfee6e21885a9ccfbf11af3/tarfile.py |
if self.name is not None \ and os.path.abspath(name) == os.path.abspath(self.name): | if self.name is not None and os.path.samefile(name, self.name): | def add(self, name, arcname=None, recursive=True): """Add the file `name' to the archive. `name' may be any type of file (directory, fifo, symbolic link, etc.). If given, `arcname' specifies an alternative name for the file in the archive. Directories are added recursively by default. This can be avoided by setting `recursive' to False. """ self._check("aw") | bc3b06087cf1907d1dfee6e21885a9ccfbf11af3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/bc3b06087cf1907d1dfee6e21885a9ccfbf11af3/tarfile.py |
def AS_TYPE_64BIT(as_): return \ | def AS_TYPE_64BIT(as): return \ | def AS_TYPE_64BIT(as_): return \ | 553a0296e93ee387ee04b27b3ba408f33e63dc8b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/553a0296e93ee387ee04b27b3ba408f33e63dc8b/STROPTS.py |
_tryorder = ["galeon", "mozilla", "netscape", "kfm", "grail", "links", "lynx", "w3m",] | _tryorder = ["links", "lynx", "w3m"] | def open_new(self, url): self.open(url) | 1456fde6a0d21cef0d78250c7d0f996772530502 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1456fde6a0d21cef0d78250c7d0f996772530502/webbrowser.py |
if y.hasattr('__setstate__'): | if hasattr(y, '__setstate__'): | def _copy_inst(x): if hasattr(x, '__copy__'): return x.__copy__() if hasattr(x, '__getinitargs__'): args = x.__getinitargs__() else: args = () y = apply(x.__class__, args) if hasattr(x, '__getstate__'): state = x.__getstate__() else: state = x.__dict__ if y.hasattr('__setstate__'): y.__setstate__(state) else: for key in state.keys(): setattr(y, key, state[key]) return y | fefbbe508582d6cd057e6e8e1be89607203076a9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fefbbe508582d6cd057e6e8e1be89607203076a9/copy.py |
if y.hasattr('__setstate__'): | if hasattr(y, '__setstate__'): | def _deepcopy_inst(x, memo): if hasattr(x, '__deepcopy__'): return x.__deepcopy__() if hasattr(x, '__getinitargs__'): args = x.__getinitargs__() args = deepcopy(args, memo) else: args = () y = apply(x.__class__, args) memo[id(x)] = y if hasattr(x, '__getstate__'): state = x.__getstate__() else: state = x.__dict__ state = deepcopy(state, memo) if y.hasattr('__setstate__'): y.__setstate__(state) else: for key in state.keys(): setattr(y, key, state[key]) return y | fefbbe508582d6cd057e6e8e1be89607203076a9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fefbbe508582d6cd057e6e8e1be89607203076a9/copy.py |
outfile.write(" ") | outfile.write(" ") | def write_results_file(self, path, lines, lnotab, lines_hit): """Return a coverage results file in path.""" | c171172614f77190a6b729cd834c27a58eb9aa41 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c171172614f77190a6b729cd834c27a58eb9aa41/trace.py |
raise UnimplementedError | raise NotImplementedError | def process_message(self, peer, mailfrom, rcpttos, data): """Override this abstract method to handle messages from the client. | b8b45eac7118cdfb8b9f87c31718023fe5ed29e1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b8b45eac7118cdfb8b9f87c31718023fe5ed29e1/smtpd.py |
self._tofill = [] | def reset(self): """ Clear the screen, re-center the pen, and set variables to the default values. | 06c68b800ca3e31d2551923083ce8294ab94cb24 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/06c68b800ca3e31d2551923083ce8294ab94cb24/turtle.py |
|
if self._tofill: for item in self._tofill: self._canvas.itemconfigure(item, fill=self._color) self._items.append(item) | def fill(self, flag): """ Call fill(1) before drawing the shape you want to fill, and fill(0) when done. | 06c68b800ca3e31d2551923083ce8294ab94cb24 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/06c68b800ca3e31d2551923083ce8294ab94cb24/turtle.py |
|
self._tofill = [] | def fill(self, flag): """ Call fill(1) before drawing the shape you want to fill, and fill(0) when done. | 06c68b800ca3e31d2551923083ce8294ab94cb24 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/06c68b800ca3e31d2551923083ce8294ab94cb24/turtle.py |
|
self.forward(0) | def fill(self, flag): """ Call fill(1) before drawing the shape you want to fill, and fill(0) when done. | 06c68b800ca3e31d2551923083ce8294ab94cb24 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/06c68b800ca3e31d2551923083ce8294ab94cb24/turtle.py |
|
self.fill(1) | self._path = [self._position] self._filling = 1 | def begin_fill(self): """ Called just before drawing a shape to be filled. | 06c68b800ca3e31d2551923083ce8294ab94cb24 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/06c68b800ca3e31d2551923083ce8294ab94cb24/turtle.py |
color("green") left(130) | left(120) | def demo2(): # exercises some new and improved features speed('fast') width(3) # draw a segmented half-circle setheading(towards(0,0)) x,y = position() r = (x**2+y**2)**.5/2.0 right(90) pendown = True for i in range(18): if pendown: up() pendown = False else: down() pendown = True circle(r,10) sleep(2) reset() left(90) # draw a series of triangles l = 10 color("green") width(3) left(180) sp = 5 for i in range(-2,16): if i > 0: color(1.0-0.05*i,0,0.05*i) fill(1) color("green") for j in range(3): forward(l) left(120) l += 10 left(15) if sp > 0: sp = sp-1 speed(speeds[sp]) color(0.25,0,0.75) fill(0) color("green") left(130) up() forward(90) color("red") speed('fastest') down(); # create a second turtle and make the original pursue and catch it turtle=Turtle() turtle.reset() turtle.left(90) turtle.speed('normal') turtle.up() turtle.goto(280,40) turtle.left(24) turtle.down() turtle.speed('fast') turtle.color("blue") turtle.width(2) speed('fastest') # turn default turtle towards new turtle object setheading(towards(turtle)) while ( abs(position()[0]-turtle.position()[0])>4 or abs(position()[1]-turtle.position()[1])>4): turtle.forward(3.5) turtle.left(0.6) # turn default turtle towards new turtle object setheading(towards(turtle)) forward(4) write("CAUGHT! ", move=True) | 06c68b800ca3e31d2551923083ce8294ab94cb24 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/06c68b800ca3e31d2551923083ce8294ab94cb24/turtle.py |
forward(90) | forward(70) right(30) down() | def demo2(): # exercises some new and improved features speed('fast') width(3) # draw a segmented half-circle setheading(towards(0,0)) x,y = position() r = (x**2+y**2)**.5/2.0 right(90) pendown = True for i in range(18): if pendown: up() pendown = False else: down() pendown = True circle(r,10) sleep(2) reset() left(90) # draw a series of triangles l = 10 color("green") width(3) left(180) sp = 5 for i in range(-2,16): if i > 0: color(1.0-0.05*i,0,0.05*i) fill(1) color("green") for j in range(3): forward(l) left(120) l += 10 left(15) if sp > 0: sp = sp-1 speed(speeds[sp]) color(0.25,0,0.75) fill(0) color("green") left(130) up() forward(90) color("red") speed('fastest') down(); # create a second turtle and make the original pursue and catch it turtle=Turtle() turtle.reset() turtle.left(90) turtle.speed('normal') turtle.up() turtle.goto(280,40) turtle.left(24) turtle.down() turtle.speed('fast') turtle.color("blue") turtle.width(2) speed('fastest') # turn default turtle towards new turtle object setheading(towards(turtle)) while ( abs(position()[0]-turtle.position()[0])>4 or abs(position()[1]-turtle.position()[1])>4): turtle.forward(3.5) turtle.left(0.6) # turn default turtle towards new turtle object setheading(towards(turtle)) forward(4) write("CAUGHT! ", move=True) | 06c68b800ca3e31d2551923083ce8294ab94cb24 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/06c68b800ca3e31d2551923083ce8294ab94cb24/turtle.py |
speed('fastest') | speed("fastest") fill(1) for i in range(4): circle(50,90) right(90) forward(30) right(90) color("yellow") fill(0) left(90) up() forward(30) | def demo2(): # exercises some new and improved features speed('fast') width(3) # draw a segmented half-circle setheading(towards(0,0)) x,y = position() r = (x**2+y**2)**.5/2.0 right(90) pendown = True for i in range(18): if pendown: up() pendown = False else: down() pendown = True circle(r,10) sleep(2) reset() left(90) # draw a series of triangles l = 10 color("green") width(3) left(180) sp = 5 for i in range(-2,16): if i > 0: color(1.0-0.05*i,0,0.05*i) fill(1) color("green") for j in range(3): forward(l) left(120) l += 10 left(15) if sp > 0: sp = sp-1 speed(speeds[sp]) color(0.25,0,0.75) fill(0) color("green") left(130) up() forward(90) color("red") speed('fastest') down(); # create a second turtle and make the original pursue and catch it turtle=Turtle() turtle.reset() turtle.left(90) turtle.speed('normal') turtle.up() turtle.goto(280,40) turtle.left(24) turtle.down() turtle.speed('fast') turtle.color("blue") turtle.width(2) speed('fastest') # turn default turtle towards new turtle object setheading(towards(turtle)) while ( abs(position()[0]-turtle.position()[0])>4 or abs(position()[1]-turtle.position()[1])>4): turtle.forward(3.5) turtle.left(0.6) # turn default turtle towards new turtle object setheading(towards(turtle)) forward(4) write("CAUGHT! ", move=True) | 06c68b800ca3e31d2551923083ce8294ab94cb24 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/06c68b800ca3e31d2551923083ce8294ab94cb24/turtle.py |
def __init__(self): | def __init__(self, verbose=0): self.verbose = verbose | def __init__(self): self.reset() | 3c0bfd0deeadccf10c8982d5b42dd39f63fb727e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3c0bfd0deeadccf10c8982d5b42dd39f63fb727e/sgmllib.py |
if j == n: break | if j == n or rawdata[i:i+2] == '<!': break | def goahead(self, end): rawdata = self.rawdata i = 0 n = len(rawdata) while i < n: if self.nomoretags: self.handle_data(rawdata[i:n]) i = n break j = incomplete.search(rawdata, i) if j < 0: j = n if i < j: self.handle_data(rawdata[i:j]) i = j if i == n: break if rawdata[i] == '<': if starttagopen.match(rawdata, i) >= 0: if self.literal: self.handle_data(rawdata[i]) i = i+1 continue k = self.parse_starttag(i) if k < 0: break i = i + k continue k = endtag.match(rawdata, i) if k >= 0: j = i+k self.parse_endtag(rawdata[i:j]) i = j self.literal = 0 continue if commentopen.match(rawdata, i) >= 0: if self.literal: self.handle_data(rawdata[i]) i = i+1 continue k = self.parse_comment(i) if k < 0: break i = i+k continue k = special.match(rawdata, i) if k >= 0: if self.literal: self.handle_data(rawdata[i]) i = i+1 continue i = i+k continue elif rawdata[i] == '&': k = charref.match(rawdata, i) if k >= 0: j = i+k self.handle_charref(rawdata[i+2:j-1]) i = j continue k = entityref.match(rawdata, i) if k >= 0: j = i+k self.handle_entityref(rawdata[i+1:j-1]) i = j continue else: raise RuntimeError, 'neither < nor & ??' # We get here only if incomplete matches but # nothing else k = incomplete.match(rawdata, i) if k < 0: raise RuntimeError, 'no incomplete match ??' j = i+k if j == n: break # Really incomplete self.handle_data(rawdata[i:j]) i = j # end while if end and i < n: self.handle_data(rawdata[i:n]) i = n self.rawdata = rawdata[i:] # XXX if end: check for empty stack | 3c0bfd0deeadccf10c8982d5b42dd39f63fb727e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3c0bfd0deeadccf10c8982d5b42dd39f63fb727e/sgmllib.py |
print '*** Unbalanced </' + tag + '>' print '*** Stack:', self.stack | if self.verbose: print '*** Unbalanced </' + tag + '>' print '*** Stack:', self.stack | def report_unbalanced(self, tag): print '*** Unbalanced </' + tag + '>' print '*** Stack:', self.stack | 3c0bfd0deeadccf10c8982d5b42dd39f63fb727e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3c0bfd0deeadccf10c8982d5b42dd39f63fb727e/sgmllib.py |
name = string.lower(name) | def handle_entityref(self, name): table = self.entitydefs name = string.lower(name) if table.has_key(name): self.handle_data(table[name]) else: self.unknown_entityref(name) return | 3c0bfd0deeadccf10c8982d5b42dd39f63fb727e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3c0bfd0deeadccf10c8982d5b42dd39f63fb727e/sgmllib.py |
|
@contextmanager | @contextfactory | def contextfactory(func): """@contextfactory decorator. Typical usage: @contextmanager def some_generator(<arguments>): <setup> try: yield <value> finally: <cleanup> This makes this: with some_generator(<arguments>) as <variable>: <body> equivalent to this: <setup> try: <variable> = <value> <body> finally: <cleanup> """ def helper(*args, **kwds): return GeneratorContext(func(*args, **kwds)) try: helper.__name__ = func.__name__ helper.__doc__ = func.__doc__ helper.__dict__ = func.__dict__ except: pass return helper | 1e0139753361f7fb820e63950b04203dc02e803c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1e0139753361f7fb820e63950b04203dc02e803c/contextlib.py |
if 0: not sys.platform.startswith('win'): | if 0: | def test_basic(): test_support.requires('network') import urllib socket.RAND_status() try: socket.RAND_egd(1) except TypeError: pass else: print "didn't raise TypeError" socket.RAND_add("this is a random string", 75.0) f = urllib.urlopen('https://sf.net') buf = f.read() f.close() | d8eaa49092f60dd6c5a6ea028e8b406e45594031 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d8eaa49092f60dd6c5a6ea028e8b406e45594031/test_socket_ssl.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' ) | cf393f3fd9759ffac71c816f97ea01780848512c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/cf393f3fd9759ffac71c816f97ea01780848512c/setup.py |
print " setting options:" for (option, (source, value)) in options.items(): print " %s = %s (from %s)" % (option, value, source) if not hasattr(cmd_obj, option): raise DistutilsOptionError, \ ("%s: command '%s' has no such option '%s'") % \ (source, command, option) setattr(cmd_obj, option, value) | self._set_command_options(cmd_obj, options) | def get_command_obj (self, command, create=1): """Return the command object for 'command'. Normally this object is cached on a previous call to 'get_command_obj()'; if no comand object for 'command' is in the cache, then we either create and return it (if 'create' is true) or return None. """ cmd_obj = self.command_obj.get(command) if not cmd_obj and create: print "Distribution.get_command_obj(): " \ "creating '%s' command object" % command | c32d9a69527af6d2823650ea7674e207c975f090 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c32d9a69527af6d2823650ea7674e207c975f090/dist.py |
def randrange(self, start, stop=None, step=1, int=int, default=None): """Choose a random item from range(start, stop[, step]). | 9146f27b7799dab231083f194a14c6157b57549f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9146f27b7799dab231083f194a14c6157b57549f/random.py |
||
if istart < istop: return istart + int(self.random() * (istop - istart)) | def randrange(self, start, stop=None, step=1, int=int, default=None): """Choose a random item from range(start, stop[, step]). | 9146f27b7799dab231083f194a14c6157b57549f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9146f27b7799dab231083f194a14c6157b57549f/random.py |
|
"Test MCRYPT type miscelaneous methods." | "Test BZ2File type miscellaneous methods." | def decompress(self, data): return bz2.decompress(data) | 33a5f2af59ddcf3f1b0447a8dbd0576fd78de303 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/33a5f2af59ddcf3f1b0447a8dbd0576fd78de303/test_bz2.py |
return "0L" | return "0" | def slow_format(self, x, base): if (x, base) == (0, 8): # this is an oddball! return "0L" digits = [] sign = 0 if x < 0: sign, x = 1, -x while x: x, r = divmod(x, base) digits.append(int(r)) digits.reverse() digits = digits or [0] return '-'[:sign] + \ {8: '0', 10: '', 16: '0x'}[base] + \ "".join(map(lambda i: "0123456789abcdef"[i], digits)) + "L" | d2dbecb4ae9177e2e87adcb047147c6bcbf28cc1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d2dbecb4ae9177e2e87adcb047147c6bcbf28cc1/test_long.py |
"".join(map(lambda i: "0123456789abcdef"[i], digits)) + "L" | "".join(map(lambda i: "0123456789abcdef"[i], digits)) | def slow_format(self, x, base): if (x, base) == (0, 8): # this is an oddball! return "0L" digits = [] sign = 0 if x < 0: sign, x = 1, -x while x: x, r = divmod(x, base) digits.append(int(r)) digits.reverse() digits = digits or [0] return '-'[:sign] + \ {8: '0', 10: '', 16: '0x'}[base] + \ "".join(map(lambda i: "0123456789abcdef"[i], digits)) + "L" | d2dbecb4ae9177e2e87adcb047147c6bcbf28cc1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d2dbecb4ae9177e2e87adcb047147c6bcbf28cc1/test_long.py |
expected = self.slow_format(x, 10)[:-1] | expected = self.slow_format(x, 10) | def check_format_1(self, x): for base, mapper in (8, oct), (10, repr), (16, hex): got = mapper(x) expected = self.slow_format(x, base) msg = Frm("%s returned %r but expected %r for %r", mapper.__name__, got, expected, x) self.assertEqual(got, expected, msg) self.assertEqual(long(got, 0), x, Frm('long("%s", 0) != %r', got, x)) # str() has to be checked a little differently since there's no # trailing "L" got = str(x) expected = self.slow_format(x, 10)[:-1] msg = Frm("%s returned %r but expected %r for %r", mapper.__name__, got, expected, x) self.assertEqual(got, expected, msg) | d2dbecb4ae9177e2e87adcb047147c6bcbf28cc1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d2dbecb4ae9177e2e87adcb047147c6bcbf28cc1/test_long.py |
print >>sys.stderr, "l1=%r, l2=%r, ignore=%r" % (l1, l2, ignore) | print >>sys.stderr, "l1=%r\nl2=%r\nignore=%r" % (l1, l2, ignore) | def assertListEq(self, l1, l2, ignore): ''' succeed iff {l1} - {ignore} == {l2} - {ignore} ''' try: for p1, p2 in (l1, l2), (l2, l1): for item in p1: ok = (item in p2) or (item in ignore) if not ok: self.fail("%r missing" % item) except: print >>sys.stderr, "l1=%r, l2=%r, ignore=%r" % (l1, l2, ignore) raise | 7f6a4390408e28e9c3cc3e1bb32f3908ba969091 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7f6a4390408e28e9c3cc3e1bb32f3908ba969091/test_pyclbr.py |
if type(getattr(py_item, m)) == MethodType: | if ismethod(getattr(py_item, m), m): | def checkModule(self, moduleName, module=None, ignore=()): ''' succeed iff pyclbr.readmodule_ex(modulename) corresponds to the actual module object, module. Any identifiers in ignore are ignored. If no module is provided, the appropriate module is loaded with __import__.''' | 7f6a4390408e28e9c3cc3e1bb32f3908ba969091 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7f6a4390408e28e9c3cc3e1bb32f3908ba969091/test_pyclbr.py |
self.assertListEq(foundMethods, actualMethods, ignore) self.assertEquals(py_item.__module__, value.module) | try: self.assertListEq(foundMethods, actualMethods, ignore) self.assertEquals(py_item.__module__, value.module) | def checkModule(self, moduleName, module=None, ignore=()): ''' succeed iff pyclbr.readmodule_ex(modulename) corresponds to the actual module object, module. Any identifiers in ignore are ignored. If no module is provided, the appropriate module is loaded with __import__.''' | 7f6a4390408e28e9c3cc3e1bb32f3908ba969091 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7f6a4390408e28e9c3cc3e1bb32f3908ba969091/test_pyclbr.py |
self.assertEquals(py_item.__name__, value.name, ignore) | self.assertEquals(py_item.__name__, value.name, ignore) except: print >>sys.stderr, "class=%s" % py_item raise | def checkModule(self, moduleName, module=None, ignore=()): ''' succeed iff pyclbr.readmodule_ex(modulename) corresponds to the actual module object, module. Any identifiers in ignore are ignored. If no module is provided, the appropriate module is loaded with __import__.''' | 7f6a4390408e28e9c3cc3e1bb32f3908ba969091 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7f6a4390408e28e9c3cc3e1bb32f3908ba969091/test_pyclbr.py |
self.checkModule('doctest', ignore=['_isclass', '_isfunction', '_ismodule', '_classify_class_attrs']) self.checkModule('rfc822', ignore=["get"]) | self.checkModule('doctest') self.checkModule('rfc822') | def test_easy(self): self.checkModule('pyclbr') self.checkModule('doctest', ignore=['_isclass', '_isfunction', '_ismodule', '_classify_class_attrs']) self.checkModule('rfc822', ignore=["get"]) self.checkModule('difflib') | 7f6a4390408e28e9c3cc3e1bb32f3908ba969091 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7f6a4390408e28e9c3cc3e1bb32f3908ba969091/test_pyclbr.py |
def test_others(self): cm = self.checkModule | 7f6a4390408e28e9c3cc3e1bb32f3908ba969091 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7f6a4390408e28e9c3cc3e1bb32f3908ba969091/test_pyclbr.py |
||
cm('cgi', ignore=('f', 'g', 'log')) cm('mhlib', ignore=('do', 'bisect')) cm('urllib', ignore=('getproxies_environment', 'getproxies_registry', 'open_https')) cm('pickle', ignore=('g',)) cm('aifc', ignore=('openfp',)) cm('Cookie', ignore=('__str__', 'Cookie')) cm('sre_parse', ignore=('literal', 'makedict', 'dump' )) | cm('cgi', ignore=('log',)) cm('mhlib') cm('urllib', ignore=('getproxies_registry', 'open_https')) cm('pickle', ignore=('g',)) cm('aifc', ignore=('openfp',)) cm('Cookie') cm('sre_parse', ignore=('dump',)) cm('pdb') cm('pydoc') | def test_others(self): cm = self.checkModule | 7f6a4390408e28e9c3cc3e1bb32f3908ba969091 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7f6a4390408e28e9c3cc3e1bb32f3908ba969091/test_pyclbr.py |
cm('test.test_pyclbr', ignore=('defined_in',)) | cm('test.test_pyclbr') | def test_others(self): cm = self.checkModule | 7f6a4390408e28e9c3cc3e1bb32f3908ba969091 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7f6a4390408e28e9c3cc3e1bb32f3908ba969091/test_pyclbr.py |
""" Check whether 'str' contains ANY of the chars in 'set' """ | """Check whether 'str' contains ANY of the chars in 'set'""" | def containsAny(str, set): """ Check whether 'str' contains ANY of the chars in 'set' """ return 1 in [c in str for c in set] | e04ee70a68045f8d229ab59ad9b0256d0278c745 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e04ee70a68045f8d229ab59ad9b0256d0278c745/pygettext.py |
""" Helper for getFilesForName(). """ | """Helper for getFilesForName().""" | def _visit_pyfiles(list, dirname, names): """ Helper for getFilesForName(). """ # get extension for python source files if not globals().has_key('_py_ext'): import imp global _py_ext _py_ext = [triple[0] for triple in imp.get_suffixes() if triple[2] == imp.PY_SOURCE][0] # don't recurse into CVS directories if 'CVS' in names: names.remove('CVS') # add all *.py files to list list.extend( [os.path.join(dirname, file) for file in names if os.path.splitext(file)[1] == _py_ext]) | e04ee70a68045f8d229ab59ad9b0256d0278c745 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e04ee70a68045f8d229ab59ad9b0256d0278c745/pygettext.py |
import imp | def _visit_pyfiles(list, dirname, names): """ Helper for getFilesForName(). """ # get extension for python source files if not globals().has_key('_py_ext'): import imp global _py_ext _py_ext = [triple[0] for triple in imp.get_suffixes() if triple[2] == imp.PY_SOURCE][0] # don't recurse into CVS directories if 'CVS' in names: names.remove('CVS') # add all *.py files to list list.extend( [os.path.join(dirname, file) for file in names if os.path.splitext(file)[1] == _py_ext]) | e04ee70a68045f8d229ab59ad9b0256d0278c745 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e04ee70a68045f8d229ab59ad9b0256d0278c745/pygettext.py |
|
_py_ext = [triple[0] for triple in imp.get_suffixes() if triple[2] == imp.PY_SOURCE][0] | _py_ext = [triple[0] for triple in imp.get_suffixes() if triple[2] == imp.PY_SOURCE][0] | def _visit_pyfiles(list, dirname, names): """ Helper for getFilesForName(). """ # get extension for python source files if not globals().has_key('_py_ext'): import imp global _py_ext _py_ext = [triple[0] for triple in imp.get_suffixes() if triple[2] == imp.PY_SOURCE][0] # don't recurse into CVS directories if 'CVS' in names: names.remove('CVS') # add all *.py files to list list.extend( [os.path.join(dirname, file) for file in names if os.path.splitext(file)[1] == _py_ext]) | e04ee70a68045f8d229ab59ad9b0256d0278c745 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e04ee70a68045f8d229ab59ad9b0256d0278c745/pygettext.py |
[os.path.join(dirname, file) for file in names if os.path.splitext(file)[1] == _py_ext]) | [os.path.join(dirname, file) for file in names if os.path.splitext(file)[1] == _py_ext] ) | def _visit_pyfiles(list, dirname, names): """ Helper for getFilesForName(). """ # get extension for python source files if not globals().has_key('_py_ext'): import imp global _py_ext _py_ext = [triple[0] for triple in imp.get_suffixes() if triple[2] == imp.PY_SOURCE][0] # don't recurse into CVS directories if 'CVS' in names: names.remove('CVS') # add all *.py files to list list.extend( [os.path.join(dirname, file) for file in names if os.path.splitext(file)[1] == _py_ext]) | e04ee70a68045f8d229ab59ad9b0256d0278c745 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e04ee70a68045f8d229ab59ad9b0256d0278c745/pygettext.py |
""" Get the filesystem path for a module or a package. Return the file system path to a file for a module, and to a directory for a package. Return None if the name is not found, or is a builtin or extension module. | """Get the filesystem path for a module or a package. Return the file system path to a file for a module, and to a directory for a package. Return None if the name is not found, or is a builtin or extension module. | def _get_modpkg_path(dotted_name, pathlist=None): """ Get the filesystem path for a module or a package. Return the file system path to a file for a module, and to a directory for a package. Return None if the name is not found, or is a builtin or extension module. """ import imp # split off top-most name parts = dotted_name.split('.', 1) if len(parts) > 1: # we have a dotted path, import top-level package try: file, pathname, description = imp.find_module(parts[0], pathlist) if file: file.close() except ImportError: return None # check if it's indeed a package if description[2] == imp.PKG_DIRECTORY: # recursively handle the remaining name parts pathname = _get_modpkg_path(parts[1], [pathname]) else: pathname = None else: # plain name try: file, pathname, description = imp.find_module(dotted_name, pathlist) if file: file.close() if description[2] not in [imp.PY_SOURCE, imp.PKG_DIRECTORY]: pathname = None except ImportError: pathname = None return pathname | e04ee70a68045f8d229ab59ad9b0256d0278c745 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e04ee70a68045f8d229ab59ad9b0256d0278c745/pygettext.py |
import imp | def _get_modpkg_path(dotted_name, pathlist=None): """ Get the filesystem path for a module or a package. Return the file system path to a file for a module, and to a directory for a package. Return None if the name is not found, or is a builtin or extension module. """ import imp # split off top-most name parts = dotted_name.split('.', 1) if len(parts) > 1: # we have a dotted path, import top-level package try: file, pathname, description = imp.find_module(parts[0], pathlist) if file: file.close() except ImportError: return None # check if it's indeed a package if description[2] == imp.PKG_DIRECTORY: # recursively handle the remaining name parts pathname = _get_modpkg_path(parts[1], [pathname]) else: pathname = None else: # plain name try: file, pathname, description = imp.find_module(dotted_name, pathlist) if file: file.close() if description[2] not in [imp.PY_SOURCE, imp.PKG_DIRECTORY]: pathname = None except ImportError: pathname = None return pathname | e04ee70a68045f8d229ab59ad9b0256d0278c745 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e04ee70a68045f8d229ab59ad9b0256d0278c745/pygettext.py |
|
file, pathname, description = imp.find_module(dotted_name, pathlist) if file: file.close() | file, pathname, description = imp.find_module( dotted_name, pathlist) if file: file.close() | def _get_modpkg_path(dotted_name, pathlist=None): """ Get the filesystem path for a module or a package. Return the file system path to a file for a module, and to a directory for a package. Return None if the name is not found, or is a builtin or extension module. """ import imp # split off top-most name parts = dotted_name.split('.', 1) if len(parts) > 1: # we have a dotted path, import top-level package try: file, pathname, description = imp.find_module(parts[0], pathlist) if file: file.close() except ImportError: return None # check if it's indeed a package if description[2] == imp.PKG_DIRECTORY: # recursively handle the remaining name parts pathname = _get_modpkg_path(parts[1], [pathname]) else: pathname = None else: # plain name try: file, pathname, description = imp.find_module(dotted_name, pathlist) if file: file.close() if description[2] not in [imp.PY_SOURCE, imp.PKG_DIRECTORY]: pathname = None except ImportError: pathname = None return pathname | e04ee70a68045f8d229ab59ad9b0256d0278c745 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e04ee70a68045f8d229ab59ad9b0256d0278c745/pygettext.py |
""" Get a list of module files for a filename, a module or package name, or a directory. | """Get a list of module files for a filename, a module or package name, or a directory. | def getFilesForName(name): """ Get a list of module files for a filename, a module or package name, or a directory. """ import imp if not os.path.exists(name): # check for glob chars if containsAny(name, "*?[]"): import glob files = glob.glob(name) list = [] for file in files: list.extend(getFilesForName(file)) return list # try to find module or package name = _get_modpkg_path(name) if not name: return [] if os.path.isdir(name): # find all python files in directory list = [] os.path.walk(name, _visit_pyfiles, list) return list elif os.path.exists(name): # a single file return [name] return [] | e04ee70a68045f8d229ab59ad9b0256d0278c745 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e04ee70a68045f8d229ab59ad9b0256d0278c745/pygettext.py |
import imp | def getFilesForName(name): """ Get a list of module files for a filename, a module or package name, or a directory. """ import imp if not os.path.exists(name): # check for glob chars if containsAny(name, "*?[]"): import glob files = glob.glob(name) list = [] for file in files: list.extend(getFilesForName(file)) return list # try to find module or package name = _get_modpkg_path(name) if not name: return [] if os.path.isdir(name): # find all python files in directory list = [] os.path.walk(name, _visit_pyfiles, list) return list elif os.path.exists(name): # a single file return [name] return [] | e04ee70a68045f8d229ab59ad9b0256d0278c745 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e04ee70a68045f8d229ab59ad9b0256d0278c745/pygettext.py |
|
import glob | def getFilesForName(name): """ Get a list of module files for a filename, a module or package name, or a directory. """ import imp if not os.path.exists(name): # check for glob chars if containsAny(name, "*?[]"): import glob files = glob.glob(name) list = [] for file in files: list.extend(getFilesForName(file)) return list # try to find module or package name = _get_modpkg_path(name) if not name: return [] if os.path.isdir(name): # find all python files in directory list = [] os.path.walk(name, _visit_pyfiles, list) return list elif os.path.exists(name): # a single file return [name] return [] | e04ee70a68045f8d229ab59ad9b0256d0278c745 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e04ee70a68045f8d229ab59ad9b0256d0278c745/pygettext.py |
|
def __openseen(self, ttype, tstring, lineno): if ttype == tokenize.OP and tstring == ')': # We've seen the last of the translatable strings. Record the # line number of the first line of the strings and update the list # of messages seen. Reset state for the next batch. If there # were no strings inside _(), then just ignore this entry. if self.__data: self.__addentry(EMPTYSTRING.join(self.__data)) self.__state = self.__waiting elif ttype == tokenize.STRING: self.__data.append(safe_eval(tstring)) elif ttype not in [tokenize.COMMENT, token.INDENT, token.DEDENT, token.NEWLINE, tokenize.NL]: # warn if we see anything else than STRING or whitespace print >>sys.stderr, _('*** %(file)s:%(lineno)s: Seen unexpected token "%(token)s"') % { 'token': tstring, 'file': self.__curfile, 'lineno': self.__lineno} self.__state = self.__waiting | e04ee70a68045f8d229ab59ad9b0256d0278c745 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e04ee70a68045f8d229ab59ad9b0256d0278c745/pygettext.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.