rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
self.fail("expected TypeError")
def test_intersection_update(self): try: self.set &= self.other self.fail("expected TypeError") except TypeError: pass
6cca754c2085e4eb203855b7d67df4a11ff0f534 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6cca754c2085e4eb203855b7d67df4a11ff0f534/test_sets.py
try: self.other & self.set self.fail("expected TypeError") except TypeError: pass try: self.set & self.other self.fail("expected TypeError") except TypeError: pass
self.assertRaises(TypeError, lambda: self.set & self.other) self.assertRaises(TypeError, lambda: self.other & self.set)
def test_intersection(self): try: self.other & self.set self.fail("expected TypeError") except TypeError: pass try: self.set & self.other self.fail("expected TypeError") except TypeError: pass
6cca754c2085e4eb203855b7d67df4a11ff0f534 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6cca754c2085e4eb203855b7d67df4a11ff0f534/test_sets.py
self.fail("expected TypeError")
def test_sym_difference_update(self): try: self.set ^= self.other self.fail("expected TypeError") except TypeError: pass
6cca754c2085e4eb203855b7d67df4a11ff0f534 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6cca754c2085e4eb203855b7d67df4a11ff0f534/test_sets.py
try: self.other ^ self.set self.fail("expected TypeError") except TypeError: pass try: self.set ^ self.other self.fail("expected TypeError") except TypeError: pass
self.assertRaises(TypeError, lambda: self.set ^ self.other) self.assertRaises(TypeError, lambda: self.other ^ self.set)
def test_sym_difference(self): try: self.other ^ self.set self.fail("expected TypeError") except TypeError: pass try: self.set ^ self.other self.fail("expected TypeError") except TypeError: pass
6cca754c2085e4eb203855b7d67df4a11ff0f534 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6cca754c2085e4eb203855b7d67df4a11ff0f534/test_sets.py
self.fail("expected TypeError")
def test_difference_update(self): try: self.set -= self.other self.fail("expected TypeError") except TypeError: pass
6cca754c2085e4eb203855b7d67df4a11ff0f534 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6cca754c2085e4eb203855b7d67df4a11ff0f534/test_sets.py
try: self.other - self.set self.fail("expected TypeError") except TypeError: pass try: self.set - self.other self.fail("expected TypeError") except TypeError: pass
self.assertRaises(TypeError, lambda: self.set - self.other) self.assertRaises(TypeError, lambda: self.other - self.set)
def test_difference(self): try: self.other - self.set self.fail("expected TypeError") except TypeError: pass try: self.set - self.other self.fail("expected TypeError") except TypeError: pass
6cca754c2085e4eb203855b7d67df4a11ff0f534 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6cca754c2085e4eb203855b7d67df4a11ff0f534/test_sets.py
makefile_in = os.path.join(exec_prefix, 'Modules', 'Makefile')
makefile_in = os.path.join(exec_prefix, 'Makefile')
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' replace_paths = [] # settable with -r option error_if_any_missing = 0 # default the exclude list for each platform if win: exclude = exclude + [ 'dos', 'dospath', 'mac', 'macpath', 'macfs', 'MACFS', 'posix', 'os2', 'ce', 'riscos', 'riscosenviron', 'riscospath', ] fail_import = exclude[:] # output files frozen_c = 'frozen.c' config_c = 'config.c' target = 'a.out' # normally derived from script name makefile = 'Makefile' subsystem = 'console' # parse command line by first replacing any "-i" options with the # file contents. pos = 1 while pos < len(sys.argv)-1: # last option can not be "-i", so this ensures "pos+1" is in range! if sys.argv[pos] == '-i': try: options = open(sys.argv[pos+1]).read().split() except IOError, why: usage("File name '%s' specified with the -i option " "can not be read - %s" % (sys.argv[pos+1], why) ) # Replace the '-i' and the filename with the read params. sys.argv[pos:pos+2] = options pos = pos + len(options) - 1 # Skip the name and the included args. pos = pos + 1 # Now parse the command line with the extras inserted. try: opts, args = getopt.getopt(sys.argv[1:], 'r:a:dEe:hmo:p:P:qs:wX:x:l:') except getopt.error, msg: usage('getopt error: ' + str(msg)) # proces option arguments for o, a in opts: if o == '-h': print __doc__ return if o == '-d': debug = debug + 1 if o == '-e': extensions.append(a) if o == '-m': modargs = 1 if o == '-o': odir = a if o == '-p': prefix = a if o == '-P': exec_prefix = a if o == '-q': debug = 0 if o == '-w': win = not win if o == '-s': if not win: usage("-s subsystem option only on Windows") subsystem = a if o == '-x': exclude.append(a) if o == '-X': exclude.append(a) fail_import.append(a) if o == '-E': error_if_any_missing = 1 if o == '-l': addn_link.append(a) if o == '-a': apply(modulefinder.AddPackagePath, tuple(a.split("=", 2))) if o == '-r': f,r = a.split("=", 2) replace_paths.append( (f,r) ) # modules that are imported by the Python runtime implicits = [] for module in ('site', 'warnings',): if module not in exclude: implicits.append(module) # default prefix and exec_prefix if not exec_prefix: if prefix: exec_prefix = prefix else: exec_prefix = sys.exec_prefix if not prefix: prefix = sys.prefix # determine whether -p points to the Python source tree ishome = os.path.exists(os.path.join(prefix, 'Python', 'ceval.c')) # locations derived from options version = sys.version[:3] if win: extensions_c = 'frozen_extensions.c' if ishome: print "(Using Python source directory)" binlib = exec_prefix incldir = os.path.join(prefix, 'Include') config_h_dir = exec_prefix config_c_in = os.path.join(prefix, 'Modules', 'config.c.in') frozenmain_c = os.path.join(prefix, 'Python', 'frozenmain.c') makefile_in = os.path.join(exec_prefix, 'Modules', 'Makefile') if win: frozendllmain_c = os.path.join(exec_prefix, 'Pc\\frozen_dllmain.c') else: binlib = os.path.join(exec_prefix, 'lib', 'python%s' % version, 'config') incldir = os.path.join(prefix, 'include', 'python%s' % version) config_h_dir = os.path.join(exec_prefix, 'include', 'python%s' % version) config_c_in = os.path.join(binlib, 'config.c.in') frozenmain_c = os.path.join(binlib, 'frozenmain.c') makefile_in = os.path.join(binlib, 'Makefile') frozendllmain_c = os.path.join(binlib, 'frozen_dllmain.c') supp_sources = [] defines = [] includes = ['-I' + incldir, '-I' + config_h_dir] # sanity check of directories and files check_dirs = [prefix, exec_prefix, binlib, incldir] if not win: # These are not directories on Windows. check_dirs = check_dirs + extensions for dir in check_dirs: if not os.path.exists(dir): usage('needed directory %s not found' % dir) if not os.path.isdir(dir): usage('%s: not a directory' % dir) if win: files = supp_sources + extensions # extensions are files on Windows. else: files = [config_c_in, makefile_in] + supp_sources for file in supp_sources: if not os.path.exists(file): usage('needed file %s not found' % file) if not os.path.isfile(file): usage('%s: not a plain file' % file) if not win: for dir in extensions: setup = os.path.join(dir, 'Setup') if not os.path.exists(setup): usage('needed file %s not found' % setup) if not os.path.isfile(setup): usage('%s: not a plain file' % setup) # check that enough arguments are passed if not args: usage('at least one filename argument required') # check that file arguments exist for arg in args: if arg == '-m': break # if user specified -m on the command line before _any_ # file names, then nothing should be checked (as the # very first file should be a module name) if modargs: break if not os.path.exists(arg): usage('argument %s not found' % arg) if not os.path.isfile(arg): usage('%s: not a plain file' % arg) # process non-option arguments scriptfile = args[0] modules = args[1:] # derive target name from script name base = os.path.basename(scriptfile) base, ext = os.path.splitext(base) if base: if base != scriptfile: target = base else: target = base + '.bin' # handle -o option base_frozen_c = frozen_c base_config_c = config_c base_target = target if odir and not os.path.isdir(odir): try: os.mkdir(odir) print "Created output directory", odir except os.error, msg: usage('%s: mkdir failed (%s)' % (odir, str(msg))) base = '' if odir: base = os.path.join(odir, '') frozen_c = os.path.join(odir, frozen_c) config_c = os.path.join(odir, config_c) target = os.path.join(odir, target) makefile = os.path.join(odir, makefile) if win: extensions_c = os.path.join(odir, extensions_c) # Handle special entry point requirements # (on Windows, some frozen programs do not use __main__, but # import the module directly. Eg, DLLs, Services, etc custom_entry_point = None # Currently only used on Windows python_entry_is_main = 1 # Is the entry point called __main__? # handle -s option on Windows if win: import winmakemakefile try: custom_entry_point, python_entry_is_main = \ winmakemakefile.get_custom_entry_point(subsystem) except ValueError, why: usage(why) # Actual work starts here... # collect all modules of the program dir = os.path.dirname(scriptfile) path[0] = dir mf = modulefinder.ModuleFinder(path, debug, exclude, replace_paths) if win and subsystem=='service': # If a Windows service, then add the "built-in" module. mod = mf.add_module("servicemanager") mod.__file__="dummy.pyd" # really built-in to the resulting EXE for mod in implicits: mf.import_hook(mod) for mod in modules: if mod == '-m': modargs = 1 continue if modargs: if mod[-2:] == '.*': mf.import_hook(mod[:-2], None, ["*"]) else: mf.import_hook(mod) else: mf.load_file(mod) # Add the main script as either __main__, or the actual module name. if python_entry_is_main: mf.run_script(scriptfile) else: mf.load_file(scriptfile) if debug > 0: mf.report() print dict = mf.modules if error_if_any_missing: missing = mf.any_missing() if missing: sys.exit("There are some missing modules: %r" % missing) # generate output for frozen modules files = makefreeze.makefreeze(base, dict, debug, custom_entry_point, fail_import) # look for unfrozen modules (builtin and of unknown origin) builtins = [] unknown = [] mods = dict.keys() mods.sort() for mod in mods: if dict[mod].__code__: continue if not dict[mod].__file__: builtins.append(mod) else: unknown.append(mod) # search for unknown modules in extensions directories (not on Windows) addfiles = [] frozen_extensions = [] # Windows list of modules. if unknown or (not win and builtins): if not win: addfiles, addmods = \ checkextensions.checkextensions(unknown+builtins, extensions) for mod in addmods: if mod in unknown: unknown.remove(mod) builtins.append(mod) else: # Do the windows thang... import checkextensions_win32 # Get a list of CExtension instances, each describing a module # (including its source files) frozen_extensions = checkextensions_win32.checkextensions( unknown, extensions, prefix) for mod in frozen_extensions: unknown.remove(mod.name) # report unknown modules if unknown: sys.stderr.write('Warning: unknown modules remain: %s\n' % ' '.join(unknown)) # windows gets different treatment if win: # Taking a shortcut here... import winmakemakefile, checkextensions_win32 checkextensions_win32.write_extension_table(extensions_c, frozen_extensions) # Create a module definition for the bootstrap C code. xtras = [frozenmain_c, os.path.basename(frozen_c), frozendllmain_c, os.path.basename(extensions_c)] + files maindefn = checkextensions_win32.CExtension( '__main__', xtras ) frozen_extensions.append( maindefn ) outfp = open(makefile, 'w') try: winmakemakefile.makemakefile(outfp, locals(), frozen_extensions, os.path.basename(target)) finally: outfp.close() return # generate config.c and Makefile builtins.sort() infp = open(config_c_in) outfp = bkfile.open(config_c, 'w') try: makeconfig.makeconfig(infp, outfp, builtins) finally: outfp.close() infp.close() cflags = ['$(OPT)'] cppflags = defines + includes libs = [os.path.join(binlib, 'libpython$(VERSION).a')] somevars = {} if os.path.exists(makefile_in): makevars = parsesetup.getmakevars(makefile_in) for key in makevars.keys(): somevars[key] = makevars[key] somevars['CFLAGS'] = ' '.join(cflags) # override somevars['CPPFLAGS'] = ' '.join(cppflags) # override files = [base_config_c, base_frozen_c] + \ files + supp_sources + addfiles + libs + \ ['$(MODLIBS)', '$(LIBS)', '$(SYSLIBS)'] outfp = bkfile.open(makefile, 'w') try: makemakefile.makemakefile(outfp, somevars, files, base_target) finally: outfp.close() # Done! if odir: print 'Now run "make" in', odir, print 'to build the target:', base_target else: print 'Now run "make" to build the target:', base_target
ffa5a5015a359045d7efb2c4cd0b5738c97b86ce /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ffa5a5015a359045d7efb2c4cd0b5738c97b86ce/freeze.py
for key in makevars.keys(): somevars[key] = makevars[key]
for key in makevars.keys(): somevars[key] = makevars[key]
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' replace_paths = [] # settable with -r option error_if_any_missing = 0 # default the exclude list for each platform if win: exclude = exclude + [ 'dos', 'dospath', 'mac', 'macpath', 'macfs', 'MACFS', 'posix', 'os2', 'ce', 'riscos', 'riscosenviron', 'riscospath', ] fail_import = exclude[:] # output files frozen_c = 'frozen.c' config_c = 'config.c' target = 'a.out' # normally derived from script name makefile = 'Makefile' subsystem = 'console' # parse command line by first replacing any "-i" options with the # file contents. pos = 1 while pos < len(sys.argv)-1: # last option can not be "-i", so this ensures "pos+1" is in range! if sys.argv[pos] == '-i': try: options = open(sys.argv[pos+1]).read().split() except IOError, why: usage("File name '%s' specified with the -i option " "can not be read - %s" % (sys.argv[pos+1], why) ) # Replace the '-i' and the filename with the read params. sys.argv[pos:pos+2] = options pos = pos + len(options) - 1 # Skip the name and the included args. pos = pos + 1 # Now parse the command line with the extras inserted. try: opts, args = getopt.getopt(sys.argv[1:], 'r:a:dEe:hmo:p:P:qs:wX:x:l:') except getopt.error, msg: usage('getopt error: ' + str(msg)) # proces option arguments for o, a in opts: if o == '-h': print __doc__ return if o == '-d': debug = debug + 1 if o == '-e': extensions.append(a) if o == '-m': modargs = 1 if o == '-o': odir = a if o == '-p': prefix = a if o == '-P': exec_prefix = a if o == '-q': debug = 0 if o == '-w': win = not win if o == '-s': if not win: usage("-s subsystem option only on Windows") subsystem = a if o == '-x': exclude.append(a) if o == '-X': exclude.append(a) fail_import.append(a) if o == '-E': error_if_any_missing = 1 if o == '-l': addn_link.append(a) if o == '-a': apply(modulefinder.AddPackagePath, tuple(a.split("=", 2))) if o == '-r': f,r = a.split("=", 2) replace_paths.append( (f,r) ) # modules that are imported by the Python runtime implicits = [] for module in ('site', 'warnings',): if module not in exclude: implicits.append(module) # default prefix and exec_prefix if not exec_prefix: if prefix: exec_prefix = prefix else: exec_prefix = sys.exec_prefix if not prefix: prefix = sys.prefix # determine whether -p points to the Python source tree ishome = os.path.exists(os.path.join(prefix, 'Python', 'ceval.c')) # locations derived from options version = sys.version[:3] if win: extensions_c = 'frozen_extensions.c' if ishome: print "(Using Python source directory)" binlib = exec_prefix incldir = os.path.join(prefix, 'Include') config_h_dir = exec_prefix config_c_in = os.path.join(prefix, 'Modules', 'config.c.in') frozenmain_c = os.path.join(prefix, 'Python', 'frozenmain.c') makefile_in = os.path.join(exec_prefix, 'Modules', 'Makefile') if win: frozendllmain_c = os.path.join(exec_prefix, 'Pc\\frozen_dllmain.c') else: binlib = os.path.join(exec_prefix, 'lib', 'python%s' % version, 'config') incldir = os.path.join(prefix, 'include', 'python%s' % version) config_h_dir = os.path.join(exec_prefix, 'include', 'python%s' % version) config_c_in = os.path.join(binlib, 'config.c.in') frozenmain_c = os.path.join(binlib, 'frozenmain.c') makefile_in = os.path.join(binlib, 'Makefile') frozendllmain_c = os.path.join(binlib, 'frozen_dllmain.c') supp_sources = [] defines = [] includes = ['-I' + incldir, '-I' + config_h_dir] # sanity check of directories and files check_dirs = [prefix, exec_prefix, binlib, incldir] if not win: # These are not directories on Windows. check_dirs = check_dirs + extensions for dir in check_dirs: if not os.path.exists(dir): usage('needed directory %s not found' % dir) if not os.path.isdir(dir): usage('%s: not a directory' % dir) if win: files = supp_sources + extensions # extensions are files on Windows. else: files = [config_c_in, makefile_in] + supp_sources for file in supp_sources: if not os.path.exists(file): usage('needed file %s not found' % file) if not os.path.isfile(file): usage('%s: not a plain file' % file) if not win: for dir in extensions: setup = os.path.join(dir, 'Setup') if not os.path.exists(setup): usage('needed file %s not found' % setup) if not os.path.isfile(setup): usage('%s: not a plain file' % setup) # check that enough arguments are passed if not args: usage('at least one filename argument required') # check that file arguments exist for arg in args: if arg == '-m': break # if user specified -m on the command line before _any_ # file names, then nothing should be checked (as the # very first file should be a module name) if modargs: break if not os.path.exists(arg): usage('argument %s not found' % arg) if not os.path.isfile(arg): usage('%s: not a plain file' % arg) # process non-option arguments scriptfile = args[0] modules = args[1:] # derive target name from script name base = os.path.basename(scriptfile) base, ext = os.path.splitext(base) if base: if base != scriptfile: target = base else: target = base + '.bin' # handle -o option base_frozen_c = frozen_c base_config_c = config_c base_target = target if odir and not os.path.isdir(odir): try: os.mkdir(odir) print "Created output directory", odir except os.error, msg: usage('%s: mkdir failed (%s)' % (odir, str(msg))) base = '' if odir: base = os.path.join(odir, '') frozen_c = os.path.join(odir, frozen_c) config_c = os.path.join(odir, config_c) target = os.path.join(odir, target) makefile = os.path.join(odir, makefile) if win: extensions_c = os.path.join(odir, extensions_c) # Handle special entry point requirements # (on Windows, some frozen programs do not use __main__, but # import the module directly. Eg, DLLs, Services, etc custom_entry_point = None # Currently only used on Windows python_entry_is_main = 1 # Is the entry point called __main__? # handle -s option on Windows if win: import winmakemakefile try: custom_entry_point, python_entry_is_main = \ winmakemakefile.get_custom_entry_point(subsystem) except ValueError, why: usage(why) # Actual work starts here... # collect all modules of the program dir = os.path.dirname(scriptfile) path[0] = dir mf = modulefinder.ModuleFinder(path, debug, exclude, replace_paths) if win and subsystem=='service': # If a Windows service, then add the "built-in" module. mod = mf.add_module("servicemanager") mod.__file__="dummy.pyd" # really built-in to the resulting EXE for mod in implicits: mf.import_hook(mod) for mod in modules: if mod == '-m': modargs = 1 continue if modargs: if mod[-2:] == '.*': mf.import_hook(mod[:-2], None, ["*"]) else: mf.import_hook(mod) else: mf.load_file(mod) # Add the main script as either __main__, or the actual module name. if python_entry_is_main: mf.run_script(scriptfile) else: mf.load_file(scriptfile) if debug > 0: mf.report() print dict = mf.modules if error_if_any_missing: missing = mf.any_missing() if missing: sys.exit("There are some missing modules: %r" % missing) # generate output for frozen modules files = makefreeze.makefreeze(base, dict, debug, custom_entry_point, fail_import) # look for unfrozen modules (builtin and of unknown origin) builtins = [] unknown = [] mods = dict.keys() mods.sort() for mod in mods: if dict[mod].__code__: continue if not dict[mod].__file__: builtins.append(mod) else: unknown.append(mod) # search for unknown modules in extensions directories (not on Windows) addfiles = [] frozen_extensions = [] # Windows list of modules. if unknown or (not win and builtins): if not win: addfiles, addmods = \ checkextensions.checkextensions(unknown+builtins, extensions) for mod in addmods: if mod in unknown: unknown.remove(mod) builtins.append(mod) else: # Do the windows thang... import checkextensions_win32 # Get a list of CExtension instances, each describing a module # (including its source files) frozen_extensions = checkextensions_win32.checkextensions( unknown, extensions, prefix) for mod in frozen_extensions: unknown.remove(mod.name) # report unknown modules if unknown: sys.stderr.write('Warning: unknown modules remain: %s\n' % ' '.join(unknown)) # windows gets different treatment if win: # Taking a shortcut here... import winmakemakefile, checkextensions_win32 checkextensions_win32.write_extension_table(extensions_c, frozen_extensions) # Create a module definition for the bootstrap C code. xtras = [frozenmain_c, os.path.basename(frozen_c), frozendllmain_c, os.path.basename(extensions_c)] + files maindefn = checkextensions_win32.CExtension( '__main__', xtras ) frozen_extensions.append( maindefn ) outfp = open(makefile, 'w') try: winmakemakefile.makemakefile(outfp, locals(), frozen_extensions, os.path.basename(target)) finally: outfp.close() return # generate config.c and Makefile builtins.sort() infp = open(config_c_in) outfp = bkfile.open(config_c, 'w') try: makeconfig.makeconfig(infp, outfp, builtins) finally: outfp.close() infp.close() cflags = ['$(OPT)'] cppflags = defines + includes libs = [os.path.join(binlib, 'libpython$(VERSION).a')] somevars = {} if os.path.exists(makefile_in): makevars = parsesetup.getmakevars(makefile_in) for key in makevars.keys(): somevars[key] = makevars[key] somevars['CFLAGS'] = ' '.join(cflags) # override somevars['CPPFLAGS'] = ' '.join(cppflags) # override files = [base_config_c, base_frozen_c] + \ files + supp_sources + addfiles + libs + \ ['$(MODLIBS)', '$(LIBS)', '$(SYSLIBS)'] outfp = bkfile.open(makefile, 'w') try: makemakefile.makemakefile(outfp, somevars, files, base_target) finally: outfp.close() # Done! if odir: print 'Now run "make" in', odir, print 'to build the target:', base_target else: print 'Now run "make" to build the target:', base_target
ffa5a5015a359045d7efb2c4cd0b5738c97b86ce /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ffa5a5015a359045d7efb2c4cd0b5738c97b86ce/freeze.py
testclasses = (WichmannHill_TestBasicOps,
testclasses = [WichmannHill_TestBasicOps,
def test_main(verbose=None): testclasses = (WichmannHill_TestBasicOps, MersenneTwister_TestBasicOps, HardwareRandom_TestBasicOps, TestDistributions, TestModule) test_support.run_unittest(*testclasses) # verify reference counting import sys if verbose and hasattr(sys, "gettotalrefcount"): counts = [None] * 5 for i in xrange(len(counts)): test_support.run_unittest(*testclasses) counts[i] = sys.gettotalrefcount() print counts
b8717631561fec74cb1ab1963d918e53ead29a97 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b8717631561fec74cb1ab1963d918e53ead29a97/test_random.py
HardwareRandom_TestBasicOps,
def test_main(verbose=None): testclasses = (WichmannHill_TestBasicOps, MersenneTwister_TestBasicOps, HardwareRandom_TestBasicOps, TestDistributions, TestModule) test_support.run_unittest(*testclasses) # verify reference counting import sys if verbose and hasattr(sys, "gettotalrefcount"): counts = [None] * 5 for i in xrange(len(counts)): test_support.run_unittest(*testclasses) counts[i] = sys.gettotalrefcount() print counts
b8717631561fec74cb1ab1963d918e53ead29a97 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b8717631561fec74cb1ab1963d918e53ead29a97/test_random.py
TestModule)
TestModule] if random._urandom is not None: testclasses.append(HardwareRandom_TestBasicOps)
def test_main(verbose=None): testclasses = (WichmannHill_TestBasicOps, MersenneTwister_TestBasicOps, HardwareRandom_TestBasicOps, TestDistributions, TestModule) test_support.run_unittest(*testclasses) # verify reference counting import sys if verbose and hasattr(sys, "gettotalrefcount"): counts = [None] * 5 for i in xrange(len(counts)): test_support.run_unittest(*testclasses) counts[i] = sys.gettotalrefcount() print counts
b8717631561fec74cb1ab1963d918e53ead29a97 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b8717631561fec74cb1ab1963d918e53ead29a97/test_random.py
preprocessor=cc + " -E",
preprocessor=cpp,
def customize_compiler(compiler): """Do any platform-specific customization of a CCompiler instance. Mainly needed on Unix, so we can plug in the information that varies across Unices and is stored in Python's Makefile. """ if compiler.compiler_type == "unix": (cc, opt, ccshared, ldshared, so_ext) = \ get_config_vars('CC', 'OPT', 'CCSHARED', 'LDSHARED', 'SO') cc_cmd = cc + ' ' + opt compiler.set_executables( preprocessor=cc + " -E", # not always! compiler=cc_cmd, compiler_so=cc_cmd + ' ' + ccshared, linker_so=ldshared, linker_exe=cc) compiler.shared_lib_extension = so_ext
29c8623e5cdec2855ddbdec2c9c6305a8daa8fbd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/29c8623e5cdec2855ddbdec2c9c6305a8daa8fbd/sysconfig.py
def visitLambda(self, node, parent):
def visitLambda(self, node, parent, assign=0): assert not assign
def visitLambda(self, node, parent): for n in node.defaults: self.visit(n, parent) scope = LambdaScope(self.module, self.klass) if parent.nested or isinstance(parent, FunctionScope): scope.nested = 1 self.scopes[node] = scope self._do_args(scope, node.argnames) self.visit(node.code, scope) self.handle_free_vars(scope, parent)
ead21f596ce9c3f3ed3349bdf872182a1e930ca0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ead21f596ce9c3f3ed3349bdf872182a1e930ca0/symbols.py
s = marshal.dumps(f)
s = marshal.dumps(f, 2)
def test_floats(self): # Test a few floats small = 1e-25 n = sys.maxint * 3.7e250 while n > small: for expected in (-n, n): f = float(expected) s = marshal.dumps(f) got = marshal.loads(s) self.assertEqual(f, got) marshal.dump(f, file(test_support.TESTFN, "wb")) got = marshal.load(file(test_support.TESTFN, "rb")) self.assertEqual(f, got) n /= 123.4567
df88846ebca9186514e86bc2067242233ade4608 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/df88846ebca9186514e86bc2067242233ade4608/test_marshal.py
self.compile = None self.no_compile = None
self.compile = 0
def initialize_options (self):
3f1822b468efed725bf1d16d6d6d5b324573f0dd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3f1822b468efed725bf1d16d6d6d5b324573f0dd/install.py
filename = compiler.library_filename(libname, lib_type='shared') result = find_file(filename, std_dirs, paths) if result is not None: return result filename = compiler.library_filename(libname, lib_type='static') result = find_file(filename, std_dirs, paths) return result
result = compiler.find_library_file(std_dirs + paths, libname) if result is None: return None dirname = os.path.dirname(result) for p in std_dirs: if p.endswith(os.sep): p = p.strip(os.sep) if p == dirname: return [ ] for p in paths: if p.endswith(os.sep): p = p.strip(os.sep) if p == dirname: return [p] else: assert False, "Internal error: Path not found in std_dirs or paths"
def find_library_file(compiler, libname, std_dirs, paths): filename = compiler.library_filename(libname, lib_type='shared') result = find_file(filename, std_dirs, paths) if result is not None: return result filename = compiler.library_filename(libname, lib_type='static') result = find_file(filename, std_dirs, paths) return result
a246d9fefd729294e84a190f2e92cf4e4ff08f20 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a246d9fefd729294e84a190f2e92cf4e4ff08f20/setup.py
access *: private
if 0: access *: private
def close(self): self._ensure_header_written() if self._nframeswritten != self._nframes or \ self._datalength != self._datawritten: self._patchheader() self._file.flush() self._file = None
f33a69f2739a2ad7968c0cada7577cbe130602b4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f33a69f2739a2ad7968c0cada7577cbe130602b4/sunau.py
def urlparse(url, scheme = '', allow_fragments = 1):
def urlparse(url, scheme='', allow_fragments=1):
def urlparse(url, scheme = '', allow_fragments = 1): """Parse a URL into 6 components: <scheme>://<netloc>/<path>;<params>?<query>#<fragment> Return a 6-tuple: (scheme, netloc, path, params, query, fragment). Note that we don't break the components up in smaller bits (e.g. netloc is a single string) and we don't expand % escapes.""" key = url, scheme, allow_fragments cached = _parse_cache.get(key, None) if cached: return cached if len(_parse_cache) >= MAX_CACHE_SIZE: # avoid runaway growth clear_cache() netloc = params = query = fragment = '' i = url.find(':') if i > 0: if url[:i] == 'http': # optimize the common case scheme = url[:i].lower() url = url[i+1:] if url[:2] == '//': i = url.find('/', 2) if i < 0: i = len(url) netloc = url[2:i] url = url[i:] if allow_fragments: i = url.rfind('#') if i >= 0: fragment = url[i+1:] url = url[:i] i = url.find('?') if i >= 0: query = url[i+1:] url = url[:i] i = url.find(';') if i >= 0: params = url[i+1:] url = url[:i] tuple = scheme, netloc, url, params, query, fragment _parse_cache[key] = tuple return tuple for c in url[:i]: if c not in scheme_chars: break else: scheme, url = url[:i].lower(), url[i+1:] if scheme in uses_netloc: if url[:2] == '//': i = url.find('/', 2) if i < 0: i = len(url) netloc, url = url[2:i], url[i:] if allow_fragments and scheme in uses_fragment: i = url.rfind('#') if i >= 0: url, fragment = url[:i], url[i+1:] if scheme in uses_query: i = url.find('?') if i >= 0: url, query = url[:i], url[i+1:] if scheme in uses_params: i = url.find(';') if i >= 0: url, params = url[:i], url[i+1:] tuple = scheme, netloc, url, params, query, fragment _parse_cache[key] = tuple return tuple
5751a22ede6a1c40f3926439e6c8368889f9b8d2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5751a22ede6a1c40f3926439e6c8368889f9b8d2/urlparse.py
netloc = params = query = fragment = ''
netloc = query = fragment = ''
def urlparse(url, scheme = '', allow_fragments = 1): """Parse a URL into 6 components: <scheme>://<netloc>/<path>;<params>?<query>#<fragment> Return a 6-tuple: (scheme, netloc, path, params, query, fragment). Note that we don't break the components up in smaller bits (e.g. netloc is a single string) and we don't expand % escapes.""" key = url, scheme, allow_fragments cached = _parse_cache.get(key, None) if cached: return cached if len(_parse_cache) >= MAX_CACHE_SIZE: # avoid runaway growth clear_cache() netloc = params = query = fragment = '' i = url.find(':') if i > 0: if url[:i] == 'http': # optimize the common case scheme = url[:i].lower() url = url[i+1:] if url[:2] == '//': i = url.find('/', 2) if i < 0: i = len(url) netloc = url[2:i] url = url[i:] if allow_fragments: i = url.rfind('#') if i >= 0: fragment = url[i+1:] url = url[:i] i = url.find('?') if i >= 0: query = url[i+1:] url = url[:i] i = url.find(';') if i >= 0: params = url[i+1:] url = url[:i] tuple = scheme, netloc, url, params, query, fragment _parse_cache[key] = tuple return tuple for c in url[:i]: if c not in scheme_chars: break else: scheme, url = url[:i].lower(), url[i+1:] if scheme in uses_netloc: if url[:2] == '//': i = url.find('/', 2) if i < 0: i = len(url) netloc, url = url[2:i], url[i:] if allow_fragments and scheme in uses_fragment: i = url.rfind('#') if i >= 0: url, fragment = url[:i], url[i+1:] if scheme in uses_query: i = url.find('?') if i >= 0: url, query = url[:i], url[i+1:] if scheme in uses_params: i = url.find(';') if i >= 0: url, params = url[:i], url[i+1:] tuple = scheme, netloc, url, params, query, fragment _parse_cache[key] = tuple return tuple
5751a22ede6a1c40f3926439e6c8368889f9b8d2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5751a22ede6a1c40f3926439e6c8368889f9b8d2/urlparse.py
if allow_fragments: i = url.rfind(' if i >= 0: fragment = url[i+1:] url = url[:i] i = url.find('?') if i >= 0: query = url[i+1:] url = url[:i] i = url.find(';') if i >= 0: params = url[i+1:] url = url[:i] tuple = scheme, netloc, url, params, query, fragment
if allow_fragments and ' url, fragment = url.split(' if '?' in url: url, query = url.split('?', 1) tuple = scheme, netloc, url, query, fragment
def urlparse(url, scheme = '', allow_fragments = 1): """Parse a URL into 6 components: <scheme>://<netloc>/<path>;<params>?<query>#<fragment> Return a 6-tuple: (scheme, netloc, path, params, query, fragment). Note that we don't break the components up in smaller bits (e.g. netloc is a single string) and we don't expand % escapes.""" key = url, scheme, allow_fragments cached = _parse_cache.get(key, None) if cached: return cached if len(_parse_cache) >= MAX_CACHE_SIZE: # avoid runaway growth clear_cache() netloc = params = query = fragment = '' i = url.find(':') if i > 0: if url[:i] == 'http': # optimize the common case scheme = url[:i].lower() url = url[i+1:] if url[:2] == '//': i = url.find('/', 2) if i < 0: i = len(url) netloc = url[2:i] url = url[i:] if allow_fragments: i = url.rfind('#') if i >= 0: fragment = url[i+1:] url = url[:i] i = url.find('?') if i >= 0: query = url[i+1:] url = url[:i] i = url.find(';') if i >= 0: params = url[i+1:] url = url[:i] tuple = scheme, netloc, url, params, query, fragment _parse_cache[key] = tuple return tuple for c in url[:i]: if c not in scheme_chars: break else: scheme, url = url[:i].lower(), url[i+1:] if scheme in uses_netloc: if url[:2] == '//': i = url.find('/', 2) if i < 0: i = len(url) netloc, url = url[2:i], url[i:] if allow_fragments and scheme in uses_fragment: i = url.rfind('#') if i >= 0: url, fragment = url[:i], url[i+1:] if scheme in uses_query: i = url.find('?') if i >= 0: url, query = url[:i], url[i+1:] if scheme in uses_params: i = url.find(';') if i >= 0: url, params = url[:i], url[i+1:] tuple = scheme, netloc, url, params, query, fragment _parse_cache[key] = tuple return tuple
5751a22ede6a1c40f3926439e6c8368889f9b8d2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5751a22ede6a1c40f3926439e6c8368889f9b8d2/urlparse.py
if allow_fragments and scheme in uses_fragment: i = url.rfind(' if i >= 0: url, fragment = url[:i], url[i+1:] if scheme in uses_query: i = url.find('?') if i >= 0: url, query = url[:i], url[i+1:] if scheme in uses_params: i = url.find(';') if i >= 0: url, params = url[:i], url[i+1:] tuple = scheme, netloc, url, params, query, fragment
if allow_fragments and scheme in uses_fragment and ' url, fragment = url.split(' if scheme in uses_query and '?' in url: url, query = url.split('?', 1) tuple = scheme, netloc, url, query, fragment
def urlparse(url, scheme = '', allow_fragments = 1): """Parse a URL into 6 components: <scheme>://<netloc>/<path>;<params>?<query>#<fragment> Return a 6-tuple: (scheme, netloc, path, params, query, fragment). Note that we don't break the components up in smaller bits (e.g. netloc is a single string) and we don't expand % escapes.""" key = url, scheme, allow_fragments cached = _parse_cache.get(key, None) if cached: return cached if len(_parse_cache) >= MAX_CACHE_SIZE: # avoid runaway growth clear_cache() netloc = params = query = fragment = '' i = url.find(':') if i > 0: if url[:i] == 'http': # optimize the common case scheme = url[:i].lower() url = url[i+1:] if url[:2] == '//': i = url.find('/', 2) if i < 0: i = len(url) netloc = url[2:i] url = url[i:] if allow_fragments: i = url.rfind('#') if i >= 0: fragment = url[i+1:] url = url[:i] i = url.find('?') if i >= 0: query = url[i+1:] url = url[:i] i = url.find(';') if i >= 0: params = url[i+1:] url = url[:i] tuple = scheme, netloc, url, params, query, fragment _parse_cache[key] = tuple return tuple for c in url[:i]: if c not in scheme_chars: break else: scheme, url = url[:i].lower(), url[i+1:] if scheme in uses_netloc: if url[:2] == '//': i = url.find('/', 2) if i < 0: i = len(url) netloc, url = url[2:i], url[i:] if allow_fragments and scheme in uses_fragment: i = url.rfind('#') if i >= 0: url, fragment = url[:i], url[i+1:] if scheme in uses_query: i = url.find('?') if i >= 0: url, query = url[:i], url[i+1:] if scheme in uses_params: i = url.find(';') if i >= 0: url, params = url[:i], url[i+1:] tuple = scheme, netloc, url, params, query, fragment _parse_cache[key] = tuple return tuple
5751a22ede6a1c40f3926439e6c8368889f9b8d2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5751a22ede6a1c40f3926439e6c8368889f9b8d2/urlparse.py
if params: url = url + ';' + params
def urlunparse((scheme, netloc, url, params, query, fragment)): """Put a parsed URL back together again. This may result in a slightly different, but equivalent URL, if the URL that was parsed originally had redundant delimiters, e.g. a ? with an empty query (the draft states that these are equivalent).""" if netloc or (scheme in uses_netloc and url[:2] == '//'): if url and url[:1] != '/': url = '/' + url url = '//' + (netloc or '') + url if scheme: url = scheme + ':' + url if params: url = url + ';' + params if query: url = url + '?' + query if fragment: url = url + '#' + fragment return url
5751a22ede6a1c40f3926439e6c8368889f9b8d2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5751a22ede6a1c40f3926439e6c8368889f9b8d2/urlparse.py
s, n, p, a, q, frag = urlparse(url) defrag = urlunparse((s, n, p, a, q, '')) return defrag, frag
if ' s, n, p, a, q, frag = urlparse(url) defrag = urlunparse((s, n, p, a, q, '')) return defrag, frag else: return url, ''
def urldefrag(url): """Removes any existing fragment from URL. Returns a tuple of the defragmented URL and the fragment. If the URL contained no fragments, the second element is the empty string. """ s, n, p, a, q, frag = urlparse(url) defrag = urlunparse((s, n, p, a, q, '')) return defrag, frag
5751a22ede6a1c40f3926439e6c8368889f9b8d2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5751a22ede6a1c40f3926439e6c8368889f9b8d2/urlparse.py
assert re.sub('(?P<a>x)', '\g<a>\g<a>', 'xx') == 'xxxx'
assert re.sub('(?P<unk>x)', '\g<unk>\g<unk>', 'xx') == 'xxxx'
def bump_num(matchobj):
9ec2ed466b5c1430f4980fcf0af1fe5e46adb25c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9ec2ed466b5c1430f4980fcf0af1fe5e46adb25c/test_re.py
self._out.write('<?xml version="1.0" encoding="%s"?>\n' %
self._write('<?xml version="1.0" encoding="%s"?>\n' %
def startDocument(self): self._out.write('<?xml version="1.0" encoding="%s"?>\n' % self._encoding)
ae20722d9619f0e2128d5e23f68c3d64db961bfd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ae20722d9619f0e2128d5e23f68c3d64db961bfd/saxutils.py
self._out.write('<' + name)
self._write('<' + name)
def startElement(self, name, attrs): self._out.write('<' + name) for (name, value) in attrs.items(): self._out.write(' %s=%s' % (name, quoteattr(value))) self._out.write('>')
ae20722d9619f0e2128d5e23f68c3d64db961bfd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ae20722d9619f0e2128d5e23f68c3d64db961bfd/saxutils.py
self._out.write(' %s=%s' % (name, quoteattr(value))) self._out.write('>')
self._write(' %s=%s' % (name, quoteattr(value))) self._write('>')
def startElement(self, name, attrs): self._out.write('<' + name) for (name, value) in attrs.items(): self._out.write(' %s=%s' % (name, quoteattr(value))) self._out.write('>')
ae20722d9619f0e2128d5e23f68c3d64db961bfd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ae20722d9619f0e2128d5e23f68c3d64db961bfd/saxutils.py
self._out.write('</%s>' % name)
self._write('</%s>' % name)
def endElement(self, name): self._out.write('</%s>' % name)
ae20722d9619f0e2128d5e23f68c3d64db961bfd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ae20722d9619f0e2128d5e23f68c3d64db961bfd/saxutils.py
self._out.write('<' + name)
self._write('<' + name)
def startElementNS(self, name, qname, attrs): if name[0] is None: # if the name was not namespace-scoped, use the unqualified part name = name[1] else: # else try to restore the original prefix from the namespace name = self._current_context[name[0]] + ":" + name[1] self._out.write('<' + name)
ae20722d9619f0e2128d5e23f68c3d64db961bfd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ae20722d9619f0e2128d5e23f68c3d64db961bfd/saxutils.py
self._out.write(' xmlns:%s="%s"' % pair)
self._write(' xmlns:%s="%s"' % pair)
def startElementNS(self, name, qname, attrs): if name[0] is None: # if the name was not namespace-scoped, use the unqualified part name = name[1] else: # else try to restore the original prefix from the namespace name = self._current_context[name[0]] + ":" + name[1] self._out.write('<' + name)
ae20722d9619f0e2128d5e23f68c3d64db961bfd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ae20722d9619f0e2128d5e23f68c3d64db961bfd/saxutils.py
self._out.write(' %s=%s' % (name, quoteattr(value))) self._out.write('>')
self._write(' %s=%s' % (name, quoteattr(value))) self._write('>')
def startElementNS(self, name, qname, attrs): if name[0] is None: # if the name was not namespace-scoped, use the unqualified part name = name[1] else: # else try to restore the original prefix from the namespace name = self._current_context[name[0]] + ":" + name[1] self._out.write('<' + name)
ae20722d9619f0e2128d5e23f68c3d64db961bfd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ae20722d9619f0e2128d5e23f68c3d64db961bfd/saxutils.py
self._out.write('</%s>' % name)
self._write('</%s>' % name)
def endElementNS(self, name, qname): if name[0] is None: name = name[1] else: name = self._current_context[name[0]] + ":" + name[1] self._out.write('</%s>' % name)
ae20722d9619f0e2128d5e23f68c3d64db961bfd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ae20722d9619f0e2128d5e23f68c3d64db961bfd/saxutils.py
self._out.write(escape(content))
self._write(escape(content))
def characters(self, content): self._out.write(escape(content))
ae20722d9619f0e2128d5e23f68c3d64db961bfd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ae20722d9619f0e2128d5e23f68c3d64db961bfd/saxutils.py
self._out.write(content)
self._write(content)
def ignorableWhitespace(self, content): self._out.write(content)
ae20722d9619f0e2128d5e23f68c3d64db961bfd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ae20722d9619f0e2128d5e23f68c3d64db961bfd/saxutils.py
self._out.write('<?%s %s?>' % (target, data))
self._write('<?%s %s?>' % (target, data))
def processingInstruction(self, target, data): self._out.write('<?%s %s?>' % (target, data))
ae20722d9619f0e2128d5e23f68c3d64db961bfd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ae20722d9619f0e2128d5e23f68c3d64db961bfd/saxutils.py
def TemporaryFile(mode='w+b', bufsize=-1, suffix=""): """Create and return a temporary file (opened read-write by default).""" name = mktemp(suffix) if os.name == 'posix': # Unix -- be very careful fd = os.open(name, os.O_RDWR|os.O_CREAT|os.O_EXCL, 0700) try: os.unlink(name) return os.fdopen(fd, mode, bufsize) except: os.close(fd) raise else: # Non-unix -- can't unlink file that's still open, use wrapper file = open(name, mode, bufsize) return TemporaryFileWrapper(file, name)
c7349ee2c6863263eef4d48ee19f741e6d2244be /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c7349ee2c6863263eef4d48ee19f741e6d2244be/tempfile.py
if DEBUG: sys.stderr.write("%s<%s> at %s\n" % (" "*depth, name, point))
dbgmsg("%s<%s> at %s" % (" "*depth, name, point))
def pushing(name, point, depth): if DEBUG: sys.stderr.write("%s<%s> at %s\n" % (" "*depth, name, point))
f79acbdaa1798eceb5e00ad32bbbfbf191333817 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f79acbdaa1798eceb5e00ad32bbbfbf191333817/latex2esis.py
if DEBUG: sys.stderr.write("%s</%s> at %s\n" % (" "*depth, name, point))
dbgmsg("%s</%s> at %s" % (" "*depth, name, point))
def popping(name, point, depth): if DEBUG: sys.stderr.write("%s</%s> at %s\n" % (" "*depth, name, point))
f79acbdaa1798eceb5e00ad32bbbfbf191333817 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f79acbdaa1798eceb5e00ad32bbbfbf191333817/latex2esis.py
stack = [] line = self.line
def subconvert(self, endchar=None, depth=0): if DEBUG and endchar: self.err_write( "subconvert(%s)\n line = %s\n" % (`endchar`, `line[:20]`)) stack = [] line = self.line while line: if line[0] == endchar and not stack: if DEBUG: self.err_write("subconvert() --> %s\n" % `line[1:21]`) self.line = line return line m = _comment_rx.match(line) if m: text = m.group(1) if text: self.write("(COMMENT\n- %s \n)COMMENT\n-\\n\n" % encode(text)) line = line[m.end():] continue m = _begin_env_rx.match(line) if m: # re-write to use the macro handler line = r"\%s %s" % (m.group(1), line[m.end():]) continue m = _end_env_rx.match(line) if m: # end of environment envname = m.group(1) if envname == "document": # special magic for n in stack[1:]: if n not in self.autoclosing: raise LaTeXFormatError( "open element on stack: " + `n`) # should be more careful, but this is easier to code: stack = [] self.write(")document\n") elif envname == stack[-1]: self.write(")%s\n" % envname) del stack[-1] popping(envname, "a", len(stack) + depth) else: self.err_write("stack: %s\n" % `stack`) raise LaTeXFormatError( "environment close for %s doesn't match" % envname) line = line[m.end():] continue m = _begin_macro_rx.match(line) if m: # start of macro macroname = m.group(1) if macroname == "verbatim": # really magic case! pos = string.find(line, "\\end{verbatim}") text = line[m.end(1):pos] self.write("(verbatim\n") self.write("-%s\n" % encode(text)) self.write(")verbatim\n") line = line[pos + len("\\end{verbatim}"):] continue numbered = 1 opened = 0 if macroname[-1] == "*": macroname = macroname[:-1] numbered = 0 if macroname in self.autoclosing and macroname in stack: while stack[-1] != macroname: top = stack.pop() if top and top not in self.discards: self.write(")%s\n-\\n\n" % top) popping(top, "b", len(stack) + depth) if macroname not in self.discards: self.write("-\\n\n)%s\n-\\n\n" % macroname) popping(macroname, "c", len(stack) + depth - 1) del stack[-1] # if macroname in self.discards: self.push_output(StringIO.StringIO()) else: self.push_output(self.ofp) # params, optional, empty, environ = self.start_macro(macroname) if not numbered: self.write("Anumbered TOKEN no\n") # rip off the macroname if params: if optional and len(params) == 1: line = line[m.end():] else: line = line[m.end(1):] elif empty: line = line[m.end(1):] else: line = line[m.end():] # # Very ugly special case to deal with \item[]. The catch # is that this needs to occur outside the for loop that # handles attribute parsing so we can 'continue' the outer # loop. # if optional and type(params[0]) is type(()): # the attribute name isn't used in this special case pushing(macroname, "a", depth + len(stack)) stack.append(macroname) self.write("(%s\n" % macroname) m = _start_optional_rx.match(line) if m: self.line = line[m.end():] line = self.subconvert("]", depth + len(stack)) line = "}" + line continue # handle attribute mappings here: for attrname in params: if optional: optional = 0 if type(attrname) is type(""): m = _optional_rx.match(line) if m: line = line[m.end():] self.write("A%s TOKEN %s\n" % (attrname, encode(m.group(1)))) elif type(attrname) is type(()): # This is a sub-element; but don't place the # element we found on the stack (\section-like) pushing(macroname, "b", len(stack) + depth) stack.append(macroname) self.write("(%s\n" % macroname) macroname = attrname[0] m = _start_group_rx.match(line) if m: line = line[m.end():] elif type(attrname) is type([]): # A normal subelement. attrname = attrname[0] if not opened: opened = 1 self.write("(%s\n" % macroname) pushing(macroname, "c", len(stack) + depth) self.write("(%s\n" % attrname) pushing(attrname, "sub-elem", len(stack) + depth + 1) self.line = skip_white(line)[1:] line = subconvert("}", depth + len(stack) + 2) popping(attrname, "sub-elem", len(stack) + depth + 1) self.write(")%s\n" % attrname) else: m = _parameter_rx.match(line) if not m: raise LaTeXFormatError( "could not extract parameter %s for %s: %s" % (attrname, macroname, `line[:100]`)) value = m.group(1) if _token_rx.match(value): dtype = "TOKEN" else: dtype = "CDATA" self.write("A%s %s %s\n" % (attrname, dtype, encode(value))) line = line[m.end():] if params and type(params[-1]) is type('') \ and (not empty) and not environ: # attempt to strip off next '{' m = _start_group_rx.match(line) if not m: raise LaTeXFormatError( "non-empty element '%s' has no content: %s" % (macroname, line[:12])) line = line[m.end():] if not opened: self.write("(%s\n" % macroname) pushing(macroname, "d", len(stack) + depth) if empty: line = "}" + line stack.append(macroname) self.pop_output() continue if line[0] == endchar and not stack: if DEBUG: self.err_write("subconvert() --> %s\n" % `line[1:21]`) self.line = line[1:] return self.line if line[0] == "}": # end of macro or group macroname = stack[-1] conversion = self.table.get(macroname) if macroname \ and macroname not in self.discards \ and type(conversion) is not type(""): # otherwise, it was just a bare group self.write(")%s\n" % stack[-1]) popping(macroname, "d", len(stack) + depth - 1) del stack[-1] line = line[1:] continue if line[0] == "{": pushing("", "e", len(stack) + depth) stack.append("") line = line[1:] continue if line[0] == "\\" and line[1] in ESCAPED_CHARS: self.write("-%s\n" % encode(line[1])) line = line[2:] continue if line[:2] == r"\\": self.write("(BREAK\n)BREAK\n") line = line[2:] continue m = _text_rx.match(line) if m: text = encode(m.group()) self.write("-%s\n" % text) line = line[m.end():] continue # special case because of \item[] if line[0] == "]": self.write("-]\n") line = line[1:] continue # avoid infinite loops extra = "" if len(line) > 100: extra = "..." raise LaTeXFormatError("could not identify markup: %s%s" % (`line[:100]`, extra)) while stack and stack[-1] in self.autoclosing: self.write("-\\n\n") self.write(")%s\n" % stack[-1]) popping(stack.pop(), "e", len(stack) + depth - 1) if stack: raise LaTeXFormatError("elements remain on stack: " + string.join(stack, ", ")) # otherwise we just ran out of input here...
f79acbdaa1798eceb5e00ad32bbbfbf191333817 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f79acbdaa1798eceb5e00ad32bbbfbf191333817/latex2esis.py
elif envname == stack[-1]:
elif stack and envname == stack[-1]:
def subconvert(self, endchar=None, depth=0): if DEBUG and endchar: self.err_write( "subconvert(%s)\n line = %s\n" % (`endchar`, `line[:20]`)) stack = [] line = self.line while line: if line[0] == endchar and not stack: if DEBUG: self.err_write("subconvert() --> %s\n" % `line[1:21]`) self.line = line return line m = _comment_rx.match(line) if m: text = m.group(1) if text: self.write("(COMMENT\n- %s \n)COMMENT\n-\\n\n" % encode(text)) line = line[m.end():] continue m = _begin_env_rx.match(line) if m: # re-write to use the macro handler line = r"\%s %s" % (m.group(1), line[m.end():]) continue m = _end_env_rx.match(line) if m: # end of environment envname = m.group(1) if envname == "document": # special magic for n in stack[1:]: if n not in self.autoclosing: raise LaTeXFormatError( "open element on stack: " + `n`) # should be more careful, but this is easier to code: stack = [] self.write(")document\n") elif envname == stack[-1]: self.write(")%s\n" % envname) del stack[-1] popping(envname, "a", len(stack) + depth) else: self.err_write("stack: %s\n" % `stack`) raise LaTeXFormatError( "environment close for %s doesn't match" % envname) line = line[m.end():] continue m = _begin_macro_rx.match(line) if m: # start of macro macroname = m.group(1) if macroname == "verbatim": # really magic case! pos = string.find(line, "\\end{verbatim}") text = line[m.end(1):pos] self.write("(verbatim\n") self.write("-%s\n" % encode(text)) self.write(")verbatim\n") line = line[pos + len("\\end{verbatim}"):] continue numbered = 1 opened = 0 if macroname[-1] == "*": macroname = macroname[:-1] numbered = 0 if macroname in self.autoclosing and macroname in stack: while stack[-1] != macroname: top = stack.pop() if top and top not in self.discards: self.write(")%s\n-\\n\n" % top) popping(top, "b", len(stack) + depth) if macroname not in self.discards: self.write("-\\n\n)%s\n-\\n\n" % macroname) popping(macroname, "c", len(stack) + depth - 1) del stack[-1] # if macroname in self.discards: self.push_output(StringIO.StringIO()) else: self.push_output(self.ofp) # params, optional, empty, environ = self.start_macro(macroname) if not numbered: self.write("Anumbered TOKEN no\n") # rip off the macroname if params: if optional and len(params) == 1: line = line[m.end():] else: line = line[m.end(1):] elif empty: line = line[m.end(1):] else: line = line[m.end():] # # Very ugly special case to deal with \item[]. The catch # is that this needs to occur outside the for loop that # handles attribute parsing so we can 'continue' the outer # loop. # if optional and type(params[0]) is type(()): # the attribute name isn't used in this special case pushing(macroname, "a", depth + len(stack)) stack.append(macroname) self.write("(%s\n" % macroname) m = _start_optional_rx.match(line) if m: self.line = line[m.end():] line = self.subconvert("]", depth + len(stack)) line = "}" + line continue # handle attribute mappings here: for attrname in params: if optional: optional = 0 if type(attrname) is type(""): m = _optional_rx.match(line) if m: line = line[m.end():] self.write("A%s TOKEN %s\n" % (attrname, encode(m.group(1)))) elif type(attrname) is type(()): # This is a sub-element; but don't place the # element we found on the stack (\section-like) pushing(macroname, "b", len(stack) + depth) stack.append(macroname) self.write("(%s\n" % macroname) macroname = attrname[0] m = _start_group_rx.match(line) if m: line = line[m.end():] elif type(attrname) is type([]): # A normal subelement. attrname = attrname[0] if not opened: opened = 1 self.write("(%s\n" % macroname) pushing(macroname, "c", len(stack) + depth) self.write("(%s\n" % attrname) pushing(attrname, "sub-elem", len(stack) + depth + 1) self.line = skip_white(line)[1:] line = subconvert("}", depth + len(stack) + 2) popping(attrname, "sub-elem", len(stack) + depth + 1) self.write(")%s\n" % attrname) else: m = _parameter_rx.match(line) if not m: raise LaTeXFormatError( "could not extract parameter %s for %s: %s" % (attrname, macroname, `line[:100]`)) value = m.group(1) if _token_rx.match(value): dtype = "TOKEN" else: dtype = "CDATA" self.write("A%s %s %s\n" % (attrname, dtype, encode(value))) line = line[m.end():] if params and type(params[-1]) is type('') \ and (not empty) and not environ: # attempt to strip off next '{' m = _start_group_rx.match(line) if not m: raise LaTeXFormatError( "non-empty element '%s' has no content: %s" % (macroname, line[:12])) line = line[m.end():] if not opened: self.write("(%s\n" % macroname) pushing(macroname, "d", len(stack) + depth) if empty: line = "}" + line stack.append(macroname) self.pop_output() continue if line[0] == endchar and not stack: if DEBUG: self.err_write("subconvert() --> %s\n" % `line[1:21]`) self.line = line[1:] return self.line if line[0] == "}": # end of macro or group macroname = stack[-1] conversion = self.table.get(macroname) if macroname \ and macroname not in self.discards \ and type(conversion) is not type(""): # otherwise, it was just a bare group self.write(")%s\n" % stack[-1]) popping(macroname, "d", len(stack) + depth - 1) del stack[-1] line = line[1:] continue if line[0] == "{": pushing("", "e", len(stack) + depth) stack.append("") line = line[1:] continue if line[0] == "\\" and line[1] in ESCAPED_CHARS: self.write("-%s\n" % encode(line[1])) line = line[2:] continue if line[:2] == r"\\": self.write("(BREAK\n)BREAK\n") line = line[2:] continue m = _text_rx.match(line) if m: text = encode(m.group()) self.write("-%s\n" % text) line = line[m.end():] continue # special case because of \item[] if line[0] == "]": self.write("-]\n") line = line[1:] continue # avoid infinite loops extra = "" if len(line) > 100: extra = "..." raise LaTeXFormatError("could not identify markup: %s%s" % (`line[:100]`, extra)) while stack and stack[-1] in self.autoclosing: self.write("-\\n\n") self.write(")%s\n" % stack[-1]) popping(stack.pop(), "e", len(stack) + depth - 1) if stack: raise LaTeXFormatError("elements remain on stack: " + string.join(stack, ", ")) # otherwise we just ran out of input here...
f79acbdaa1798eceb5e00ad32bbbfbf191333817 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f79acbdaa1798eceb5e00ad32bbbfbf191333817/latex2esis.py
def subconvert(self, endchar=None, depth=0): if DEBUG and endchar: self.err_write( "subconvert(%s)\n line = %s\n" % (`endchar`, `line[:20]`)) stack = [] line = self.line while line: if line[0] == endchar and not stack: if DEBUG: self.err_write("subconvert() --> %s\n" % `line[1:21]`) self.line = line return line m = _comment_rx.match(line) if m: text = m.group(1) if text: self.write("(COMMENT\n- %s \n)COMMENT\n-\\n\n" % encode(text)) line = line[m.end():] continue m = _begin_env_rx.match(line) if m: # re-write to use the macro handler line = r"\%s %s" % (m.group(1), line[m.end():]) continue m = _end_env_rx.match(line) if m: # end of environment envname = m.group(1) if envname == "document": # special magic for n in stack[1:]: if n not in self.autoclosing: raise LaTeXFormatError( "open element on stack: " + `n`) # should be more careful, but this is easier to code: stack = [] self.write(")document\n") elif envname == stack[-1]: self.write(")%s\n" % envname) del stack[-1] popping(envname, "a", len(stack) + depth) else: self.err_write("stack: %s\n" % `stack`) raise LaTeXFormatError( "environment close for %s doesn't match" % envname) line = line[m.end():] continue m = _begin_macro_rx.match(line) if m: # start of macro macroname = m.group(1) if macroname == "verbatim": # really magic case! pos = string.find(line, "\\end{verbatim}") text = line[m.end(1):pos] self.write("(verbatim\n") self.write("-%s\n" % encode(text)) self.write(")verbatim\n") line = line[pos + len("\\end{verbatim}"):] continue numbered = 1 opened = 0 if macroname[-1] == "*": macroname = macroname[:-1] numbered = 0 if macroname in self.autoclosing and macroname in stack: while stack[-1] != macroname: top = stack.pop() if top and top not in self.discards: self.write(")%s\n-\\n\n" % top) popping(top, "b", len(stack) + depth) if macroname not in self.discards: self.write("-\\n\n)%s\n-\\n\n" % macroname) popping(macroname, "c", len(stack) + depth - 1) del stack[-1] # if macroname in self.discards: self.push_output(StringIO.StringIO()) else: self.push_output(self.ofp) # params, optional, empty, environ = self.start_macro(macroname) if not numbered: self.write("Anumbered TOKEN no\n") # rip off the macroname if params: if optional and len(params) == 1: line = line[m.end():] else: line = line[m.end(1):] elif empty: line = line[m.end(1):] else: line = line[m.end():] # # Very ugly special case to deal with \item[]. The catch # is that this needs to occur outside the for loop that # handles attribute parsing so we can 'continue' the outer # loop. # if optional and type(params[0]) is type(()): # the attribute name isn't used in this special case pushing(macroname, "a", depth + len(stack)) stack.append(macroname) self.write("(%s\n" % macroname) m = _start_optional_rx.match(line) if m: self.line = line[m.end():] line = self.subconvert("]", depth + len(stack)) line = "}" + line continue # handle attribute mappings here: for attrname in params: if optional: optional = 0 if type(attrname) is type(""): m = _optional_rx.match(line) if m: line = line[m.end():] self.write("A%s TOKEN %s\n" % (attrname, encode(m.group(1)))) elif type(attrname) is type(()): # This is a sub-element; but don't place the # element we found on the stack (\section-like) pushing(macroname, "b", len(stack) + depth) stack.append(macroname) self.write("(%s\n" % macroname) macroname = attrname[0] m = _start_group_rx.match(line) if m: line = line[m.end():] elif type(attrname) is type([]): # A normal subelement. attrname = attrname[0] if not opened: opened = 1 self.write("(%s\n" % macroname) pushing(macroname, "c", len(stack) + depth) self.write("(%s\n" % attrname) pushing(attrname, "sub-elem", len(stack) + depth + 1) self.line = skip_white(line)[1:] line = subconvert("}", depth + len(stack) + 2) popping(attrname, "sub-elem", len(stack) + depth + 1) self.write(")%s\n" % attrname) else: m = _parameter_rx.match(line) if not m: raise LaTeXFormatError( "could not extract parameter %s for %s: %s" % (attrname, macroname, `line[:100]`)) value = m.group(1) if _token_rx.match(value): dtype = "TOKEN" else: dtype = "CDATA" self.write("A%s %s %s\n" % (attrname, dtype, encode(value))) line = line[m.end():] if params and type(params[-1]) is type('') \ and (not empty) and not environ: # attempt to strip off next '{' m = _start_group_rx.match(line) if not m: raise LaTeXFormatError( "non-empty element '%s' has no content: %s" % (macroname, line[:12])) line = line[m.end():] if not opened: self.write("(%s\n" % macroname) pushing(macroname, "d", len(stack) + depth) if empty: line = "}" + line stack.append(macroname) self.pop_output() continue if line[0] == endchar and not stack: if DEBUG: self.err_write("subconvert() --> %s\n" % `line[1:21]`) self.line = line[1:] return self.line if line[0] == "}": # end of macro or group macroname = stack[-1] conversion = self.table.get(macroname) if macroname \ and macroname not in self.discards \ and type(conversion) is not type(""): # otherwise, it was just a bare group self.write(")%s\n" % stack[-1]) popping(macroname, "d", len(stack) + depth - 1) del stack[-1] line = line[1:] continue if line[0] == "{": pushing("", "e", len(stack) + depth) stack.append("") line = line[1:] continue if line[0] == "\\" and line[1] in ESCAPED_CHARS: self.write("-%s\n" % encode(line[1])) line = line[2:] continue if line[:2] == r"\\": self.write("(BREAK\n)BREAK\n") line = line[2:] continue m = _text_rx.match(line) if m: text = encode(m.group()) self.write("-%s\n" % text) line = line[m.end():] continue # special case because of \item[] if line[0] == "]": self.write("-]\n") line = line[1:] continue # avoid infinite loops extra = "" if len(line) > 100: extra = "..." raise LaTeXFormatError("could not identify markup: %s%s" % (`line[:100]`, extra)) while stack and stack[-1] in self.autoclosing: self.write("-\\n\n") self.write(")%s\n" % stack[-1]) popping(stack.pop(), "e", len(stack) + depth - 1) if stack: raise LaTeXFormatError("elements remain on stack: " + string.join(stack, ", ")) # otherwise we just ran out of input here...
f79acbdaa1798eceb5e00ad32bbbfbf191333817 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f79acbdaa1798eceb5e00ad32bbbfbf191333817/latex2esis.py
line = subconvert("}", depth + len(stack) + 2)
line = self.subconvert("}", len(stack) + depth + 1)[1:] dbgmsg("subconvert() ==> " + `line[:20]`)
def subconvert(self, endchar=None, depth=0): if DEBUG and endchar: self.err_write( "subconvert(%s)\n line = %s\n" % (`endchar`, `line[:20]`)) stack = [] line = self.line while line: if line[0] == endchar and not stack: if DEBUG: self.err_write("subconvert() --> %s\n" % `line[1:21]`) self.line = line return line m = _comment_rx.match(line) if m: text = m.group(1) if text: self.write("(COMMENT\n- %s \n)COMMENT\n-\\n\n" % encode(text)) line = line[m.end():] continue m = _begin_env_rx.match(line) if m: # re-write to use the macro handler line = r"\%s %s" % (m.group(1), line[m.end():]) continue m = _end_env_rx.match(line) if m: # end of environment envname = m.group(1) if envname == "document": # special magic for n in stack[1:]: if n not in self.autoclosing: raise LaTeXFormatError( "open element on stack: " + `n`) # should be more careful, but this is easier to code: stack = [] self.write(")document\n") elif envname == stack[-1]: self.write(")%s\n" % envname) del stack[-1] popping(envname, "a", len(stack) + depth) else: self.err_write("stack: %s\n" % `stack`) raise LaTeXFormatError( "environment close for %s doesn't match" % envname) line = line[m.end():] continue m = _begin_macro_rx.match(line) if m: # start of macro macroname = m.group(1) if macroname == "verbatim": # really magic case! pos = string.find(line, "\\end{verbatim}") text = line[m.end(1):pos] self.write("(verbatim\n") self.write("-%s\n" % encode(text)) self.write(")verbatim\n") line = line[pos + len("\\end{verbatim}"):] continue numbered = 1 opened = 0 if macroname[-1] == "*": macroname = macroname[:-1] numbered = 0 if macroname in self.autoclosing and macroname in stack: while stack[-1] != macroname: top = stack.pop() if top and top not in self.discards: self.write(")%s\n-\\n\n" % top) popping(top, "b", len(stack) + depth) if macroname not in self.discards: self.write("-\\n\n)%s\n-\\n\n" % macroname) popping(macroname, "c", len(stack) + depth - 1) del stack[-1] # if macroname in self.discards: self.push_output(StringIO.StringIO()) else: self.push_output(self.ofp) # params, optional, empty, environ = self.start_macro(macroname) if not numbered: self.write("Anumbered TOKEN no\n") # rip off the macroname if params: if optional and len(params) == 1: line = line[m.end():] else: line = line[m.end(1):] elif empty: line = line[m.end(1):] else: line = line[m.end():] # # Very ugly special case to deal with \item[]. The catch # is that this needs to occur outside the for loop that # handles attribute parsing so we can 'continue' the outer # loop. # if optional and type(params[0]) is type(()): # the attribute name isn't used in this special case pushing(macroname, "a", depth + len(stack)) stack.append(macroname) self.write("(%s\n" % macroname) m = _start_optional_rx.match(line) if m: self.line = line[m.end():] line = self.subconvert("]", depth + len(stack)) line = "}" + line continue # handle attribute mappings here: for attrname in params: if optional: optional = 0 if type(attrname) is type(""): m = _optional_rx.match(line) if m: line = line[m.end():] self.write("A%s TOKEN %s\n" % (attrname, encode(m.group(1)))) elif type(attrname) is type(()): # This is a sub-element; but don't place the # element we found on the stack (\section-like) pushing(macroname, "b", len(stack) + depth) stack.append(macroname) self.write("(%s\n" % macroname) macroname = attrname[0] m = _start_group_rx.match(line) if m: line = line[m.end():] elif type(attrname) is type([]): # A normal subelement. attrname = attrname[0] if not opened: opened = 1 self.write("(%s\n" % macroname) pushing(macroname, "c", len(stack) + depth) self.write("(%s\n" % attrname) pushing(attrname, "sub-elem", len(stack) + depth + 1) self.line = skip_white(line)[1:] line = subconvert("}", depth + len(stack) + 2) popping(attrname, "sub-elem", len(stack) + depth + 1) self.write(")%s\n" % attrname) else: m = _parameter_rx.match(line) if not m: raise LaTeXFormatError( "could not extract parameter %s for %s: %s" % (attrname, macroname, `line[:100]`)) value = m.group(1) if _token_rx.match(value): dtype = "TOKEN" else: dtype = "CDATA" self.write("A%s %s %s\n" % (attrname, dtype, encode(value))) line = line[m.end():] if params and type(params[-1]) is type('') \ and (not empty) and not environ: # attempt to strip off next '{' m = _start_group_rx.match(line) if not m: raise LaTeXFormatError( "non-empty element '%s' has no content: %s" % (macroname, line[:12])) line = line[m.end():] if not opened: self.write("(%s\n" % macroname) pushing(macroname, "d", len(stack) + depth) if empty: line = "}" + line stack.append(macroname) self.pop_output() continue if line[0] == endchar and not stack: if DEBUG: self.err_write("subconvert() --> %s\n" % `line[1:21]`) self.line = line[1:] return self.line if line[0] == "}": # end of macro or group macroname = stack[-1] conversion = self.table.get(macroname) if macroname \ and macroname not in self.discards \ and type(conversion) is not type(""): # otherwise, it was just a bare group self.write(")%s\n" % stack[-1]) popping(macroname, "d", len(stack) + depth - 1) del stack[-1] line = line[1:] continue if line[0] == "{": pushing("", "e", len(stack) + depth) stack.append("") line = line[1:] continue if line[0] == "\\" and line[1] in ESCAPED_CHARS: self.write("-%s\n" % encode(line[1])) line = line[2:] continue if line[:2] == r"\\": self.write("(BREAK\n)BREAK\n") line = line[2:] continue m = _text_rx.match(line) if m: text = encode(m.group()) self.write("-%s\n" % text) line = line[m.end():] continue # special case because of \item[] if line[0] == "]": self.write("-]\n") line = line[1:] continue # avoid infinite loops extra = "" if len(line) > 100: extra = "..." raise LaTeXFormatError("could not identify markup: %s%s" % (`line[:100]`, extra)) while stack and stack[-1] in self.autoclosing: self.write("-\\n\n") self.write(")%s\n" % stack[-1]) popping(stack.pop(), "e", len(stack) + depth - 1) if stack: raise LaTeXFormatError("elements remain on stack: " + string.join(stack, ", ")) # otherwise we just ran out of input here...
f79acbdaa1798eceb5e00ad32bbbfbf191333817 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f79acbdaa1798eceb5e00ad32bbbfbf191333817/latex2esis.py
explicitely. DEFAULT can be the relative path to a .ico file
explicitly. DEFAULT can be the relative path to a .ico file
def wm_iconbitmap(self, bitmap=None, default=None): """Set bitmap for the iconified widget to BITMAP. Return the bitmap if None is given.
210262c0ec0356dfa7e8f0778783e678e8075a04 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/210262c0ec0356dfa7e8f0778783e678e8075a04/Tkinter.py
if h[0] == 'P' and h[1] in '123456' and h[2] in ' \t\n\r':
if len(h) >= 3 and \ h[0] == 'P' and h[1] in '123456' and h[2] in ' \t\n\r':
def test_pnm(h, f): # PBM, PGM, PPM (portable {bit,gray,pix}map; together portable anymap) if h[0] == 'P' and h[1] in '123456' and h[2] in ' \t\n\r': return 'pnm'
05b55e76f07805af719f53d9c832871774a855aa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/05b55e76f07805af719f53d9c832871774a855aa/imghdr.py
ic.launcurl(url)
ic.launchurl(url)
def open(self, url, new=0): ic.launcurl(url)
2595a837b5b536bd850660e8337a96116eccf80a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2595a837b5b536bd850660e8337a96116eccf80a/webbrowser.py
return self.parser.names
if self.parser: return self.parser.names else: return []
def getnames(self): return self.parser.names
84306246f1d9a70b887881e029a082aab8db9211 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/84306246f1d9a70b887881e029a082aab8db9211/webchecker.py
def synopsis(filename, cache={}): """Get the one-line summary out of a module file.""" mtime = os.stat(filename)[stat.ST_MTIME] lastupdate, result = cache.get(filename, (0, None)) # XXX what if ext is 'rb' type in imp_getsuffixes? if lastupdate < mtime: file = open(filename) line = file.readline() while line[:1] == '#' or strip(line) == '': line = file.readline() if not line: break if line[-2:] == '\\\n': line = line[:-2] + file.readline() line = strip(line) if line[:3] == '"""': line = line[3:] while strip(line) == '': line = file.readline() if not line: break result = strip(split(line, '"""')[0]) else: result = None file.close() cache[filename] = (mtime, result) return result
5a804edd3cacf2a790ff3c872adad22f95e7a604 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5a804edd3cacf2a790ff3c872adad22f95e7a604/pydoc.py
line = file.readline() while line[:1] == '
if info and 'b' in info[2]: try: module = imp.load_module(info[0], file, filename, info[1:]) except: return None result = split(module.__doc__ or '', '\n')[0] else:
def synopsis(filename, cache={}): """Get the one-line summary out of a module file.""" mtime = os.stat(filename)[stat.ST_MTIME] lastupdate, result = cache.get(filename, (0, None)) # XXX what if ext is 'rb' type in imp_getsuffixes? if lastupdate < mtime: file = open(filename) line = file.readline() while line[:1] == '#' or strip(line) == '': line = file.readline() if not line: break if line[-2:] == '\\\n': line = line[:-2] + file.readline() line = strip(line) if line[:3] == '"""': line = line[3:] while strip(line) == '': line = file.readline() if not line: break result = strip(split(line, '"""')[0]) else: result = None file.close() cache[filename] = (mtime, result) return result
5a804edd3cacf2a790ff3c872adad22f95e7a604 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5a804edd3cacf2a790ff3c872adad22f95e7a604/pydoc.py
if not line: break if line[-2:] == '\\\n': line = line[:-2] + file.readline() line = strip(line) if line[:3] == '"""': line = line[3:] while strip(line) == '':
while line[:1] == '
def synopsis(filename, cache={}): """Get the one-line summary out of a module file.""" mtime = os.stat(filename)[stat.ST_MTIME] lastupdate, result = cache.get(filename, (0, None)) # XXX what if ext is 'rb' type in imp_getsuffixes? if lastupdate < mtime: file = open(filename) line = file.readline() while line[:1] == '#' or strip(line) == '': line = file.readline() if not line: break if line[-2:] == '\\\n': line = line[:-2] + file.readline() line = strip(line) if line[:3] == '"""': line = line[3:] while strip(line) == '': line = file.readline() if not line: break result = strip(split(line, '"""')[0]) else: result = None file.close() cache[filename] = (mtime, result) return result
5a804edd3cacf2a790ff3c872adad22f95e7a604 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5a804edd3cacf2a790ff3c872adad22f95e7a604/pydoc.py
result = strip(split(line, '"""')[0]) else: result = None
line = strip(line) if line[:4] == 'r"""': line = line[1:] if line[:3] == '"""': line = line[3:] if line[-1:] == '\\': line = line[:-1] while not strip(line): line = file.readline() if not line: break result = strip(split(line, '"""')[0]) else: result = None
def synopsis(filename, cache={}): """Get the one-line summary out of a module file.""" mtime = os.stat(filename)[stat.ST_MTIME] lastupdate, result = cache.get(filename, (0, None)) # XXX what if ext is 'rb' type in imp_getsuffixes? if lastupdate < mtime: file = open(filename) line = file.readline() while line[:1] == '#' or strip(line) == '': line = file.readline() if not line: break if line[-2:] == '\\\n': line = line[:-2] + file.readline() line = strip(line) if line[:3] == '"""': line = line[3:] while strip(line) == '': line = file.readline() if not line: break result = strip(split(line, '"""')[0]) else: result = None file.close() cache[filename] = (mtime, result) return result
5a804edd3cacf2a790ff3c872adad22f95e7a604 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5a804edd3cacf2a790ff3c872adad22f95e7a604/pydoc.py
def stripid(text): """Remove the hexadecimal id from a Python object representation.""" # The behaviour of %p is implementation-dependent, so we need an example. for pattern in [' at 0x[0-9a-f]{6,}>$', ' at [0-9A-F]{8,}>$']: if re.search(pattern, repr(Exception)): return re.sub(pattern, '>', text) return text
5a804edd3cacf2a790ff3c872adad22f95e7a604 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5a804edd3cacf2a790ff3c872adad22f95e7a604/pydoc.py
def modulename(path): """Return the Python module name for a given path, or None.""" filename = os.path.basename(path) suffixes = map(lambda (suffix, mode, kind): (len(suffix), suffix), imp.get_suffixes()) suffixes.sort() suffixes.reverse() for length, suffix in suffixes: if len(filename) > length and filename[-length:] == suffix: return filename[:-length]
def stripid(text): """Remove the hexadecimal id from a Python object representation.""" # The behaviour of %p is implementation-dependent, so we need an example. for pattern in [' at 0x[0-9a-f]{6,}>$', ' at [0-9A-F]{8,}>$']: if re.search(pattern, repr(Exception)): return re.sub(pattern, '>', text) return text
5a804edd3cacf2a790ff3c872adad22f95e7a604 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5a804edd3cacf2a790ff3c872adad22f95e7a604/pydoc.py
return re.sub(r'((\\[\\abfnrtv\'"]|\\x..|\\u....)+)',
return re.sub(r'((\\[\\abfnrtv\'"]|\\[0-9]..|\\x..|\\u....)+)',
def repr_string(self, x, level): test = cram(x, self.maxstring) testrepr = repr(test) if '\\' in test and '\\' not in replace(testrepr, (r'\\', '')): # Backslashes are only literal in the string and are never # needed to make any special characters, so show a raw string. return 'r' + testrepr[0] + self.escape(test) + testrepr[0] return re.sub(r'((\\[\\abfnrtv\'"]|\\x..|\\u....)+)', r'<font color="#c040c0">\1</font>', self.escape(testrepr))
5a804edd3cacf2a790ff3c872adad22f95e7a604 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5a804edd3cacf2a790ff3c872adad22f95e7a604/pydoc.py
def section(self, title, fgcol, bgcol, contents, width=20,
def section(self, title, fgcol, bgcol, contents, width=10,
def section(self, title, fgcol, bgcol, contents, width=20, prelude='', marginalia=None, gap='&nbsp;&nbsp;'): """Format a section with a heading.""" if marginalia is None: marginalia = '&nbsp;' * width result = '''
5a804edd3cacf2a790ff3c872adad22f95e7a604 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5a804edd3cacf2a790ff3c872adad22f95e7a604/pydoc.py
marginalia = '&nbsp;' * width
marginalia = '<tt>' + '&nbsp;' * width + '</tt>'
def section(self, title, fgcol, bgcol, contents, width=20, prelude='', marginalia=None, gap='&nbsp;&nbsp;'): """Format a section with a heading.""" if marginalia is None: marginalia = '&nbsp;' * width result = '''
5a804edd3cacf2a790ff3c872adad22f95e7a604 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5a804edd3cacf2a790ff3c872adad22f95e7a604/pydoc.py
return result + '<td width="100%%">%s</td></tr></table>' % contents
return result + '\n<td width="100%%">%s</td></tr></table>' % contents
def section(self, title, fgcol, bgcol, contents, width=20, prelude='', marginalia=None, gap='&nbsp;&nbsp;'): """Format a section with a heading.""" if marginalia is None: marginalia = '&nbsp;' * width result = '''
5a804edd3cacf2a790ff3c872adad22f95e7a604 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5a804edd3cacf2a790ff3c872adad22f95e7a604/pydoc.py
if 0 and hasattr(object, '__all__'): visible = lambda key, all=object.__all__: key in all else: visible = lambda key: key[:1] != '_'
def docmodule(self, object, name=None): """Produce HTML documentation for a module object.""" name = object.__name__ # ignore the passed-in name parts = split(name, '.') links = [] for i in range(len(parts)-1): links.append( '<a href="%s.html"><font color="#ffffff">%s</font></a>' % (join(parts[:i+1], '.'), parts[i])) linkedname = join(links + parts[-1:], '.') head = '<big><big><strong>%s</strong></big></big>' % linkedname try: path = inspect.getabsfile(object) filelink = '<a href="file:%s">%s</a>' % (path, path) except TypeError: filelink = '(built-in)' info = [] if hasattr(object, '__version__'): version = str(object.__version__) if version[:11] == '$' + 'Revision: ' and version[-1:] == '$': version = strip(version[11:-1]) info.append('version %s' % self.escape(version)) if hasattr(object, '__date__'): info.append(self.escape(str(object.__date__))) if info: head = head + ' (%s)' % join(info, ', ') result = self.heading( head, '#ffffff', '#7799ee', '<a href=".">index</a><br>' + filelink)
5a804edd3cacf2a790ff3c872adad22f95e7a604 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5a804edd3cacf2a790ff3c872adad22f95e7a604/pydoc.py
if visible(key) and ( inspect.getmodule(value) or object) is object:
if (inspect.getmodule(value) or object) is object:
def docmodule(self, object, name=None): """Produce HTML documentation for a module object.""" name = object.__name__ # ignore the passed-in name parts = split(name, '.') links = [] for i in range(len(parts)-1): links.append( '<a href="%s.html"><font color="#ffffff">%s</font></a>' % (join(parts[:i+1], '.'), parts[i])) linkedname = join(links + parts[-1:], '.') head = '<big><big><strong>%s</strong></big></big>' % linkedname try: path = inspect.getabsfile(object) filelink = '<a href="file:%s">%s</a>' % (path, path) except TypeError: filelink = '(built-in)' info = [] if hasattr(object, '__version__'): version = str(object.__version__) if version[:11] == '$' + 'Revision: ' and version[-1:] == '$': version = strip(version[11:-1]) info.append('version %s' % self.escape(version)) if hasattr(object, '__date__'): info.append(self.escape(str(object.__date__))) if info: head = head + ' (%s)' % join(info, ', ') result = self.heading( head, '#ffffff', '#7799ee', '<a href=".">index</a><br>' + filelink)
5a804edd3cacf2a790ff3c872adad22f95e7a604 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5a804edd3cacf2a790ff3c872adad22f95e7a604/pydoc.py
if visible(key) and (inspect.isbuiltin(value) or inspect.getmodule(value) is object):
if inspect.isbuiltin(value) or inspect.getmodule(value) is object:
def docmodule(self, object, name=None): """Produce HTML documentation for a module object.""" name = object.__name__ # ignore the passed-in name parts = split(name, '.') links = [] for i in range(len(parts)-1): links.append( '<a href="%s.html"><font color="#ffffff">%s</font></a>' % (join(parts[:i+1], '.'), parts[i])) linkedname = join(links + parts[-1:], '.') head = '<big><big><strong>%s</strong></big></big>' % linkedname try: path = inspect.getabsfile(object) filelink = '<a href="file:%s">%s</a>' % (path, path) except TypeError: filelink = '(built-in)' info = [] if hasattr(object, '__version__'): version = str(object.__version__) if version[:11] == '$' + 'Revision: ' and version[-1:] == '$': version = strip(version[11:-1]) info.append('version %s' % self.escape(version)) if hasattr(object, '__date__'): info.append(self.escape(str(object.__date__))) if info: head = head + ' (%s)' % join(info, ', ') result = self.heading( head, '#ffffff', '#7799ee', '<a href=".">index</a><br>' + filelink)
5a804edd3cacf2a790ff3c872adad22f95e7a604 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5a804edd3cacf2a790ff3c872adad22f95e7a604/pydoc.py
if visible(key): constants.append((key, value))
constants.append((key, value))
def docmodule(self, object, name=None): """Produce HTML documentation for a module object.""" name = object.__name__ # ignore the passed-in name parts = split(name, '.') links = [] for i in range(len(parts)-1): links.append( '<a href="%s.html"><font color="#ffffff">%s</font></a>' % (join(parts[:i+1], '.'), parts[i])) linkedname = join(links + parts[-1:], '.') head = '<big><big><strong>%s</strong></big></big>' % linkedname try: path = inspect.getabsfile(object) filelink = '<a href="file:%s">%s</a>' % (path, path) except TypeError: filelink = '(built-in)' info = [] if hasattr(object, '__version__'): version = str(object.__version__) if version[:11] == '$' + 'Revision: ' and version[-1:] == '$': version = strip(version[11:-1]) info.append('version %s' % self.escape(version)) if hasattr(object, '__date__'): info.append(self.escape(str(object.__date__))) if info: head = head + ' (%s)' % join(info, ', ') result = self.heading( head, '#ffffff', '#7799ee', '<a href=".">index</a><br>' + filelink)
5a804edd3cacf2a790ff3c872adad22f95e7a604 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5a804edd3cacf2a790ff3c872adad22f95e7a604/pydoc.py
if file[:1] != '_': path = os.path.join(object.__path__[0], file) modname = modulename(file) if modname and modname not in modnames: modpkgs.append((modname, name, 0, 0)) modnames.append(modname) elif ispackage(path): modpkgs.append((file, name, 1, 0))
path = os.path.join(object.__path__[0], file) modname = inspect.getmodulename(file) if modname and modname not in modnames: modpkgs.append((modname, name, 0, 0)) modnames.append(modname) elif ispackage(path): modpkgs.append((file, name, 1, 0))
def docmodule(self, object, name=None): """Produce HTML documentation for a module object.""" name = object.__name__ # ignore the passed-in name parts = split(name, '.') links = [] for i in range(len(parts)-1): links.append( '<a href="%s.html"><font color="#ffffff">%s</font></a>' % (join(parts[:i+1], '.'), parts[i])) linkedname = join(links + parts[-1:], '.') head = '<big><big><strong>%s</strong></big></big>' % linkedname try: path = inspect.getabsfile(object) filelink = '<a href="file:%s">%s</a>' % (path, path) except TypeError: filelink = '(built-in)' info = [] if hasattr(object, '__version__'): version = str(object.__version__) if version[:11] == '$' + 'Revision: ' and version[-1:] == '$': version = strip(version[11:-1]) info.append('version %s' % self.escape(version)) if hasattr(object, '__date__'): info.append(self.escape(str(object.__date__))) if info: head = head + ' (%s)' % join(info, ', ') result = self.heading( head, '#ffffff', '#7799ee', '<a href=".">index</a><br>' + filelink)
5a804edd3cacf2a790ff3c872adad22f95e7a604 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5a804edd3cacf2a790ff3c872adad22f95e7a604/pydoc.py
doc = self.small(doc and '<tt>%s<br>&nbsp;</tt>' % doc or '<tt>&nbsp;</tt>') return self.section(title, '
doc = self.small(doc and '<tt>%s<br>&nbsp;</tt>' % doc or self.small('&nbsp;')) return self.section(title, '
def docclass(self, object, name=None, funcs={}, classes={}): """Produce HTML documentation for a class object.""" realname = object.__name__ name = name or realname bases = object.__bases__ contents = ''
5a804edd3cacf2a790ff3c872adad22f95e7a604 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5a804edd3cacf2a790ff3c872adad22f95e7a604/pydoc.py
doc = doc and '<tt>%s</tt>' % doc return '<dl><dt>%s<dd>%s</dl>\n' % (decl, self.small(doc))
doc = doc and '<dd>' + self.small('<tt>%s</tt>' % doc) return '<dl><dt>%s%s</dl>\n' % (decl, doc)
def docroutine(self, object, name=None, funcs={}, classes={}, methods={}, cl=None): """Produce HTML documentation for a function or method object.""" realname = object.__name__ name = name or realname anchor = (cl and cl.__name__ or '') + '-' + name note = '' skipdocs = 0 if inspect.ismethod(object): if cl: if object.im_class is not cl: base = object.im_class url = '#%s-%s' % (base.__name__, name) basename = base.__name__ if base.__module__ != cl.__module__: url = base.__module__ + '.html' + url basename = base.__module__ + '.' + basename note = ' from <a href="%s">%s</a>' % (url, basename) skipdocs = 1 else: note = (object.im_self and ' method of ' + self.repr(object.im_self) or ' unbound %s method' % object.im_class.__name__) object = object.im_func
5a804edd3cacf2a790ff3c872adad22f95e7a604 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5a804edd3cacf2a790ff3c872adad22f95e7a604/pydoc.py
if file[:1] != '_' and os.path.isfile(path): modname = modulename(file)
if os.path.isfile(path): modname = inspect.getmodulename(file)
def found(name, ispackage, modpkgs=modpkgs, shadowed=shadowed, seen=seen): if not seen.has_key(name): modpkgs.append((name, '', ispackage, shadowed.has_key(name))) seen[name] = 1 shadowed[name] = 1
5a804edd3cacf2a790ff3c872adad22f95e7a604 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5a804edd3cacf2a790ff3c872adad22f95e7a604/pydoc.py
namesec = name lines = split(strip(getdoc(object)), '\n') if len(lines) == 1: if lines[0]: namesec = namesec + ' - ' + lines[0] lines = [] elif len(lines) >= 2 and not rstrip(lines[1]): if lines[0]: namesec = namesec + ' - ' + lines[0] lines = lines[2:] result = self.section('NAME', namesec)
synop, desc = splitdoc(getdoc(object)) result = self.section('NAME', name + (synop and ' - ' + synop))
def docmodule(self, object, name=None): """Produce text documentation for a given module object.""" name = object.__name__ # ignore the passed-in name namesec = name lines = split(strip(getdoc(object)), '\n') if len(lines) == 1: if lines[0]: namesec = namesec + ' - ' + lines[0] lines = [] elif len(lines) >= 2 and not rstrip(lines[1]): if lines[0]: namesec = namesec + ' - ' + lines[0] lines = lines[2:] result = self.section('NAME', namesec)
5a804edd3cacf2a790ff3c872adad22f95e7a604 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5a804edd3cacf2a790ff3c872adad22f95e7a604/pydoc.py
if lines: result = result + self.section('DESCRIPTION', join(lines, '\n'))
if desc: result = result + self.section('DESCRIPTION', desc)
def docmodule(self, object, name=None): """Produce text documentation for a given module object.""" name = object.__name__ # ignore the passed-in name namesec = name lines = split(strip(getdoc(object)), '\n') if len(lines) == 1: if lines[0]: namesec = namesec + ' - ' + lines[0] lines = [] elif len(lines) >= 2 and not rstrip(lines[1]): if lines[0]: namesec = namesec + ' - ' + lines[0] lines = lines[2:] result = self.section('NAME', namesec)
5a804edd3cacf2a790ff3c872adad22f95e7a604 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5a804edd3cacf2a790ff3c872adad22f95e7a604/pydoc.py
if key[:1] != '_': constants.append((key, value))
constants.append((key, value))
def docmodule(self, object, name=None): """Produce text documentation for a given module object.""" name = object.__name__ # ignore the passed-in name namesec = name lines = split(strip(getdoc(object)), '\n') if len(lines) == 1: if lines[0]: namesec = namesec + ' - ' + lines[0] lines = [] elif len(lines) >= 2 and not rstrip(lines[1]): if lines[0]: namesec = namesec + ' - ' + lines[0] lines = lines[2:] result = self.section('NAME', namesec)
5a804edd3cacf2a790ff3c872adad22f95e7a604 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5a804edd3cacf2a790ff3c872adad22f95e7a604/pydoc.py
if file[:1] != '_': path = os.path.join(object.__path__[0], file) modname = modulename(file) if modname and modname not in modpkgs: modpkgs.append(modname) elif ispackage(path): modpkgs.append(file + ' (package)')
path = os.path.join(object.__path__[0], file) modname = inspect.getmodulename(file) if modname and modname not in modpkgs: modpkgs.append(modname) elif ispackage(path): modpkgs.append(file + ' (package)')
def docmodule(self, object, name=None): """Produce text documentation for a given module object.""" name = object.__name__ # ignore the passed-in name namesec = name lines = split(strip(getdoc(object)), '\n') if len(lines) == 1: if lines[0]: namesec = namesec + ' - ' + lines[0] lines = [] elif len(lines) >= 2 and not rstrip(lines[1]): if lines[0]: namesec = namesec + ' - ' + lines[0] lines = lines[2:] result = self.section('NAME', namesec)
5a804edd3cacf2a790ff3c872adad22f95e7a604 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5a804edd3cacf2a790ff3c872adad22f95e7a604/pydoc.py
return lambda a: pipepager(a, os.environ['PAGER'])
if sys.platform == 'win32': return lambda a: tempfilepager(a, os.environ['PAGER']) else: return lambda a: pipepager(a, os.environ['PAGER'])
def getpager(): """Decide what method to use for paging through text.""" if type(sys.stdout) is not types.FileType: return plainpager if not sys.stdin.isatty() or not sys.stdout.isatty(): return plainpager if os.environ.has_key('PAGER'): return lambda a: pipepager(a, os.environ['PAGER']) if sys.platform == 'win32': return lambda a: tempfilepager(a, 'more <') if hasattr(os, 'system') and os.system('less 2>/dev/null') == 0: return lambda a: pipepager(a, 'less') import tempfile filename = tempfile.mktemp() open(filename, 'w').close() try: if hasattr(os, 'system') and os.system('more %s' % filename) == 0: return lambda text: pipepager(text, 'more') else: return ttypager finally: os.unlink(filename)
5a804edd3cacf2a790ff3c872adad22f95e7a604 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5a804edd3cacf2a790ff3c872adad22f95e7a604/pydoc.py
raise DocImportError(filename, sys.exc_info())
raise ErrorDuringImport(filename, sys.exc_info())
def locate(path): """Locate an object by name (or dotted path), importing as necessary.""" if not path: # special case: imp.find_module('') strangely succeeds return None if type(path) is not types.StringType: return path parts = split(path, '.') n = len(parts) while n > 0: path = join(parts[:n], '.') try: module = freshimport(path) except: # Did the error occur before or after the module was found? (exc, value, tb) = info = sys.exc_info() if sys.modules.has_key(path): # An error occured while executing the imported module. raise ErrorDuringImport(sys.modules[path].__file__, info) elif exc is SyntaxError: # A SyntaxError occurred before we could execute the module. raise ErrorDuringImport(value.filename, info) elif exc is ImportError and \ split(lower(str(value)))[:2] == ['no', 'module']: # The module was not found. n = n - 1 continue else: # Some other error occurred before executing the module. raise DocImportError(filename, sys.exc_info()) try: x = module for p in parts[n:]: x = getattr(x, p) return x except AttributeError: n = n - 1 continue if hasattr(__builtins__, path): return getattr(__builtins__, path) return None
5a804edd3cacf2a790ff3c872adad22f95e7a604 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5a804edd3cacf2a790ff3c872adad22f95e7a604/pydoc.py
page = html.page('Python: ' + describe(object),
page = html.page(describe(object),
def writedoc(key): """Write HTML documentation to a file in the current directory.""" try: object = locate(key) except ErrorDuringImport, value: print value else: if object: page = html.page('Python: ' + describe(object), html.document(object, object.__name__)) file = open(key + '.html', 'w') file.write(page) file.close() print 'wrote', key + '.html' else: print 'no Python documentation found for %s' % repr(key)
5a804edd3cacf2a790ff3c872adad22f95e7a604 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5a804edd3cacf2a790ff3c872adad22f95e7a604/pydoc.py
modname = modulename(path)
modname = inspect.getmodulename(path)
def writedocs(dir, pkgpath='', done={}): """Write out HTML documentation for all modules in a directory tree.""" for file in os.listdir(dir): path = os.path.join(dir, file) if ispackage(path): writedocs(path, pkgpath + file + '.') elif os.path.isfile(path): modname = modulename(path) if modname: modname = pkgpath + modname if not done.has_key(modname): done[modname] = 1 writedoc(modname)
5a804edd3cacf2a790ff3c872adad22f95e7a604 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5a804edd3cacf2a790ff3c872adad22f95e7a604/pydoc.py
modname = modulename(path)
modname = inspect.getmodulename(path)
def run(self, key, callback, completer=None): self.quit = 0 seen = {}
5a804edd3cacf2a790ff3c872adad22f95e7a604 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5a804edd3cacf2a790ff3c872adad22f95e7a604/pydoc.py
print modname, '-', desc or '(no description)'
print modname, desc and '- ' + desc try: import warnings except ImportError: pass else: warnings.filterwarnings('ignore')
def callback(path, modname, desc): if modname[-9:] == '.__init__': modname = modname[:-9] + ' (package)' print modname, '-', desc or '(no description)'
5a804edd3cacf2a790ff3c872adad22f95e7a604 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5a804edd3cacf2a790ff3c872adad22f95e7a604/pydoc.py
try: import ic ic.launchurl(url)
try: import ic
def open(self, event=None, url=None): url = url or self.server.url try: import webbrowser webbrowser.open(url) except ImportError: # pre-webbrowser.py compatibility if sys.platform == 'win32': os.system('start "%s"' % url) elif sys.platform == 'mac': try: import ic ic.launchurl(url) except ImportError: pass else: rc = os.system('netscape -remote "openURL(%s)" &' % url) if rc: os.system('netscape "%s" &' % url)
5a804edd3cacf2a790ff3c872adad22f95e7a604 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5a804edd3cacf2a790ff3c872adad22f95e7a604/pydoc.py
Pop up a graphical interface for serving and finding documentation.
Pop up a graphical interface for finding and serving documentation.
def ready(server): print 'server ready at %s' % server.url
5a804edd3cacf2a790ff3c872adad22f95e7a604 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5a804edd3cacf2a790ff3c872adad22f95e7a604/pydoc.py
directory. If <name> contains a '%s', it is treated as a filename.
directory. If <name> contains a '%s', it is treated as a filename; if it names a directory, documentation is written for all the contents.
def ready(server): print 'server ready at %s' % server.url
5a804edd3cacf2a790ff3c872adad22f95e7a604 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5a804edd3cacf2a790ff3c872adad22f95e7a604/pydoc.py
if _os.name != 'posix':
if _os.name != 'posix' or _os.sys.platform == 'cygwin':
def NamedTemporaryFile(mode='w+b', bufsize=-1, suffix="", prefix=template, dir=gettempdir()): """Create and return a temporary file. Arguments: 'prefix', 'suffix', 'dir' -- as for mkstemp. 'mode' -- the mode argument to os.fdopen (default "w+b"). 'bufsize' -- the buffer size argument to os.fdopen (default -1). The file is created as mkstemp() would do it. Returns a file object; the name of the file is accessible as file.name. The file will be automatically deleted when it is closed. """ if 'b' in mode: flags = _bin_openflags else: flags = _text_openflags # Setting O_TEMPORARY in the flags causes the OS to delete # the file when it is closed. This is only supported by Windows. if _os.name == 'nt': flags |= _os.O_TEMPORARY (fd, name) = _mkstemp_inner(dir, prefix, suffix, flags) file = _os.fdopen(fd, mode, bufsize) return _TemporaryFileWrapper(file, name)
80c02af345d0f85be06422915394bbacfbd87bdb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/80c02af345d0f85be06422915394bbacfbd87bdb/tempfile.py
def open_https(self, url):
def open_https(self, url, data=None):
def open_https(self, url): """Use HTTPS protocol.""" import httplib if type(url) is type(""): host, selector = splithost(url) user_passwd, host = splituser(host) else: host, selector = url urltype, rest = splittype(selector) if string.lower(urltype) == 'https': realhost, rest = splithost(rest) user_passwd, realhost = splituser(realhost) if user_passwd: selector = "%s://%s%s" % (urltype, realhost, rest) print "proxy via https:", host, selector if not host: raise IOError, ('https error', 'no host given') if user_passwd: import base64 auth = string.strip(base64.encodestring(user_passwd)) else: auth = None h = httplib.HTTPS(host, 0, key_file=self.key_file, cert_file=self.cert_file) h.putrequest('GET', selector) if auth: h.putheader('Authorization: Basic %s' % auth) for args in self.addheaders: apply(h.putheader, args) h.endheaders() errcode, errmsg, headers = h.getreply() fp = h.getfile() if errcode == 200: return addinfourl(fp, headers, url) else: return self.http_error(url, fp, errcode, errmsg, headers)
141e9894b7818daa06773d50705d7c64d298f9d8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/141e9894b7818daa06773d50705d7c64d298f9d8/urllib.py
h.putrequest('GET', selector)
if data is not None: h.putrequest('POST', selector) h.putheader('Content-type', 'application/x-www-form-urlencoded') h.putheader('Content-length', '%d' % len(data)) else: h.putrequest('GET', selector)
def open_https(self, url): """Use HTTPS protocol.""" import httplib if type(url) is type(""): host, selector = splithost(url) user_passwd, host = splituser(host) else: host, selector = url urltype, rest = splittype(selector) if string.lower(urltype) == 'https': realhost, rest = splithost(rest) user_passwd, realhost = splituser(realhost) if user_passwd: selector = "%s://%s%s" % (urltype, realhost, rest) print "proxy via https:", host, selector if not host: raise IOError, ('https error', 'no host given') if user_passwd: import base64 auth = string.strip(base64.encodestring(user_passwd)) else: auth = None h = httplib.HTTPS(host, 0, key_file=self.key_file, cert_file=self.cert_file) h.putrequest('GET', selector) if auth: h.putheader('Authorization: Basic %s' % auth) for args in self.addheaders: apply(h.putheader, args) h.endheaders() errcode, errmsg, headers = h.getreply() fp = h.getfile() if errcode == 200: return addinfourl(fp, headers, url) else: return self.http_error(url, fp, errcode, errmsg, headers)
141e9894b7818daa06773d50705d7c64d298f9d8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/141e9894b7818daa06773d50705d7c64d298f9d8/urllib.py
ld_args.extend (extra_postargs)
ld_args.extend(extra_postargs)
def link_shared_object (self, objects, output_filename, output_dir=None, libraries=None, library_dirs=None, runtime_library_dirs=None, export_symbols=None, debug=0, extra_preargs=None, extra_postargs=None, build_temp=None):
159eb92239c20198e9318acbe142ab3e168aae4b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/159eb92239c20198e9318acbe142ab3e168aae4b/msvccompiler.py
msgbuf = ""
msgbuf = []
def makefile(self, mode, bufsize=None): """Return a readable file-like object with data from socket.
42dd01add5cc53dc5a5eab46b04b44c8ef6c969f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/42dd01add5cc53dc5a5eab46b04b44c8ef6c969f/httplib.py
msgbuf = msgbuf + self.__ssl.read()
buf = self.__ssl.read()
def makefile(self, mode, bufsize=None): """Return a readable file-like object with data from socket.
42dd01add5cc53dc5a5eab46b04b44c8ef6c969f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/42dd01add5cc53dc5a5eab46b04b44c8ef6c969f/httplib.py
return StringIO(msgbuf)
if buf == '': break msgbuf.append(buf) return StringIO("".join(msgbuf))
def makefile(self, mode, bufsize=None): """Return a readable file-like object with data from socket.
42dd01add5cc53dc5a5eab46b04b44c8ef6c969f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/42dd01add5cc53dc5a5eab46b04b44c8ef6c969f/httplib.py
if inst.poll(_deadstate=sys.maxint) >= 0:
res = inst.poll(_deadstate=sys.maxint) if res is not None and res >= 0:
def _cleanup(): for inst in _active[:]: if inst.poll(_deadstate=sys.maxint) >= 0: try: _active.remove(inst) except ValueError: # This can happen if two threads create a new Popen instance. # It's harmless that it was already removed, so ignore. pass
b5d47efe92fd12cde1de6a473108ef48238a43cc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b5d47efe92fd12cde1de6a473108ef48238a43cc/subprocess.py
"""execv(file, args, env)
"""execvpe(file, args, env)
def execvpe(file, args, env): """execv(file, args, env) Execute the executable file (which is searched for along $PATH) with argument list args and environment env , replacing the current process. args may be a list or tuple of strings. """ _execvpe(file, args, env)
683c0fe41430d66e329279e164912cea62170f0a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/683c0fe41430d66e329279e164912cea62170f0a/os.py
except error, (errno, msg): if errno != ENOENT and errno != ENOTDIR: raise raise error, (errno, msg)
except error, e: tb = sys.exc_info()[2] if (e.errno != ENOENT and e.errno != ENOTDIR and saved_exc is None): saved_exc = e saved_tb = tb if saved_exc: raise error, saved_exc, saved_tb raise error, e, tb
def _execvpe(file, args, env=None): from errno import ENOENT, ENOTDIR if env is not None: func = execve argrest = (args, env) else: func = execv argrest = (args,) env = environ head, tail = path.split(file) if head: apply(func, (file,) + argrest) return if 'PATH' in env: envpath = env['PATH'] else: envpath = defpath PATH = envpath.split(pathsep) for dir in PATH: fullname = path.join(dir, file) try: apply(func, (fullname,) + argrest) except error, (errno, msg): if errno != ENOENT and errno != ENOTDIR: raise raise error, (errno, msg)
683c0fe41430d66e329279e164912cea62170f0a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/683c0fe41430d66e329279e164912cea62170f0a/os.py
def _test():
def test_main():
def _test(): threads = [] print "Creating" for i in range(NUM_THREADS): t = TempFileGreedy() threads.append(t) t.start() print "Starting" startEvent.set() print "Reaping" ok = errors = 0 for t in threads: t.join() ok += t.ok_count errors += t.error_count if t.error_count: print '%s errors:\n%s' % (t.getName(), t.errors.getvalue()) msg = "Done: errors %d ok %d" % (errors, ok) print msg if errors: raise TestFailed(msg)
d8a9d2a0e964d1018f1ba4fa3857a3f061a24137 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d8a9d2a0e964d1018f1ba4fa3857a3f061a24137/test_threadedtempfile.py
_test()
test_main()
def _test(): threads = [] print "Creating" for i in range(NUM_THREADS): t = TempFileGreedy() threads.append(t) t.start() print "Starting" startEvent.set() print "Reaping" ok = errors = 0 for t in threads: t.join() ok += t.ok_count errors += t.error_count if t.error_count: print '%s errors:\n%s' % (t.getName(), t.errors.getvalue()) msg = "Done: errors %d ok %d" % (errors, ok) print msg if errors: raise TestFailed(msg)
d8a9d2a0e964d1018f1ba4fa3857a3f061a24137 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d8a9d2a0e964d1018f1ba4fa3857a3f061a24137/test_threadedtempfile.py
print_lines is the default callback.'''
print_line() is the default callback.'''
def retrlines(self, cmd, callback = None): '''Retrieve data in line mode. The argument is a RETR or LIST command. The callback function (2nd argument) is called for each line, with trailing CRLF stripped. This creates a new port for you. print_lines is the default callback.''' if not callback: callback = print_line resp = self.sendcmd('TYPE A') conn = self.transfercmd(cmd) fp = conn.makefile('rb') while 1: line = fp.readline() if self.debugging > 2: print '*retr*', `line` if not line: break if line[-2:] == CRLF: line = line[:-2] elif line[-1:] == '\n': line = line[:-1] callback(line) fp.close() conn.close() return self.voidresp()
d5f173bf1f215ce156805545ff20e0d764162e89 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d5f173bf1f215ce156805545ff20e0d764162e89/ftplib.py
self.botframe = frame
self.botframe = frame.f_back
def dispatch_call(self, frame, arg): # XXX 'arg' is no longer used if self.botframe is None: # First call of dispatch since reset() self.botframe = frame return self.trace_dispatch if not (self.stop_here(frame) or self.break_anywhere(frame)): # No need to trace this function return # None self.user_call(frame, arg) if self.quitting: raise BdbQuit return self.trace_dispatch
313a7513b0c5771042d850d70782a2448d1cdcb7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/313a7513b0c5771042d850d70782a2448d1cdcb7/bdb.py
if self.stopframe is None: return True
def stop_here(self, frame): if self.stopframe is None: return True if frame is self.stopframe: return True while frame is not None and frame is not self.stopframe: if frame is self.botframe: return True frame = frame.f_back return False
313a7513b0c5771042d850d70782a2448d1cdcb7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/313a7513b0c5771042d850d70782a2448d1cdcb7/bdb.py
try: raise Exception except: frame = sys.exc_info()[2].tb_frame.f_back
frame = sys._getframe().f_back
def set_trace(self): """Start debugging from here.""" try: raise Exception except: frame = sys.exc_info()[2].tb_frame.f_back self.reset() while frame: frame.f_trace = self.trace_dispatch self.botframe = frame frame = frame.f_back self.set_step() sys.settrace(self.trace_dispatch)
313a7513b0c5771042d850d70782a2448d1cdcb7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/313a7513b0c5771042d850d70782a2448d1cdcb7/bdb.py
try: raise Exception except: frame = sys.exc_info()[2].tb_frame.f_back
frame = sys._getframe().f_back
def set_continue(self): # Don't stop except at breakpoints or when finished self.stopframe = self.botframe self.returnframe = None self.quitting = 0 if not self.breaks: # no breakpoints; run without debugger overhead sys.settrace(None) try: raise Exception except: frame = sys.exc_info()[2].tb_frame.f_back while frame and frame is not self.botframe: del frame.f_trace frame = frame.f_back
313a7513b0c5771042d850d70782a2448d1cdcb7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/313a7513b0c5771042d850d70782a2448d1cdcb7/bdb.py
if platform in ['cygwin', 'aix4']:
data = open('pyconfig.h').read() m = re.search(r" if m is not None:
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
19d173486b2263a269260343d65ac3929c89297e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/19d173486b2263a269260343d65ac3929c89297e/setup.py
def __init__(self, counts=None, calledfuncs=None, infile=None, outfile=None): self.counts = counts if self.counts is None: self.counts = {} self.counter = self.counts.copy() # map (filename, lineno) to count self.calledfuncs = calledfuncs if self.calledfuncs is None: self.calledfuncs = {} self.calledfuncs = self.calledfuncs.copy() self.infile = infile self.outfile = outfile if self.infile: # Try and merge existing counts file. # This code understand a couple of old trace.py formats. try: thingie = pickle.load(open(self.infile, 'r')) if isinstance(thingie, dict): self.update(self.__class__(thingie)) elif isinstance(thingie, tuple) and len(thingie) == 2: counts, calledfuncs = thingie self.update(self.__class__(counts, calledfuncs)) except (IOError, EOFError), err: print >> sys.stderr, ("Skipping counts file %r: %s" % (self.infile, err)) except pickle.UnpicklingError: self.update(self.__class__(marshal.load(open(self.infile))))
d7ce86dcab78d3fef32bb8fff23e84cf9df628db /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d7ce86dcab78d3fef32bb8fff23e84cf9df628db/trace.py
thingie = pickle.load(open(self.infile, 'r')) if isinstance(thingie, dict): self.update(self.__class__(thingie)) elif isinstance(thingie, tuple) and len(thingie) == 2: counts, calledfuncs = thingie self.update(self.__class__(counts, calledfuncs)) except (IOError, EOFError), err:
counts, calledfuncs = pickle.load(open(self.infile, 'r')) self.update(self.__class__(counts, calledfuncs)) except (IOError, EOFError, ValueError), err:
def __init__(self, counts=None, calledfuncs=None, infile=None, outfile=None): self.counts = counts if self.counts is None: self.counts = {} self.counter = self.counts.copy() # map (filename, lineno) to count self.calledfuncs = calledfuncs if self.calledfuncs is None: self.calledfuncs = {} self.calledfuncs = self.calledfuncs.copy() self.infile = infile self.outfile = outfile if self.infile: # Try and merge existing counts file. # This code understand a couple of old trace.py formats. try: thingie = pickle.load(open(self.infile, 'r')) if isinstance(thingie, dict): self.update(self.__class__(thingie)) elif isinstance(thingie, tuple) and len(thingie) == 2: counts, calledfuncs = thingie self.update(self.__class__(counts, calledfuncs)) except (IOError, EOFError), err: print >> sys.stderr, ("Skipping counts file %r: %s" % (self.infile, err)) except pickle.UnpicklingError: self.update(self.__class__(marshal.load(open(self.infile))))
d7ce86dcab78d3fef32bb8fff23e84cf9df628db /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d7ce86dcab78d3fef32bb8fff23e84cf9df628db/trace.py
if not host: return addinfourl(open(url2pathname(file), 'r'), noheaders(), self.openedurl)
if not host: return addinfourl(open(url2pathname(file), 'r'), noheaders(), 'file:'+file)
def open_local_file(self, url): host, file = splithost(url) if not host: return addinfourl(open(url2pathname(file), 'r'), noheaders(), self.openedurl) host, port = splitport(host) if not port and socket.gethostbyname(host) in ( localhost(), thishost()): file = unquote(file) return addinfourl(open(url2pathname(file), 'r'), noheaders(), self.openedurl) raise IOError, ('local file error', 'not on local host')
b030bc026eb57861568fdc9310512185c95a6f11 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b030bc026eb57861568fdc9310512185c95a6f11/urllib.py
return addinfourl(open(url2pathname(file), 'r'), noheaders(), self.openedurl)
return addinfourl(open(url2pathname(file), 'r'), noheaders(), 'file:'+file)
def open_local_file(self, url): host, file = splithost(url) if not host: return addinfourl(open(url2pathname(file), 'r'), noheaders(), self.openedurl) host, port = splitport(host) if not port and socket.gethostbyname(host) in ( localhost(), thishost()): file = unquote(file) return addinfourl(open(url2pathname(file), 'r'), noheaders(), self.openedurl) raise IOError, ('local file error', 'not on local host')
b030bc026eb57861568fdc9310512185c95a6f11 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b030bc026eb57861568fdc9310512185c95a6f11/urllib.py
self.assertRaises(TypeError, setattr, X.x, "offset", 92) self.assertRaises(TypeError, setattr, X.x, "size", 92)
self.assertRaises(AttributeError, setattr, X.x, "offset", 92) self.assertRaises(AttributeError, setattr, X.x, "size", 92)
def test_fields(self): # test the offset and size attributes of Structure/Unoin fields. class X(Structure): _fields_ = [("x", c_int), ("y", c_char)]
ecc3e67b986a1eed404b528ccbc099049c149edb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ecc3e67b986a1eed404b528ccbc099049c149edb/test_structures.py