rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
try: self.__buf = self.__buf + struct.pack('>f', x)
try: self.__buf.write(struct.pack('>f', x))
def pack_float(self, x): try: self.__buf = self.__buf + struct.pack('>f', x) except struct.error, msg: raise ConversionError, msg
c47016ee74fdd765bdad0f890c810518501de22a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c47016ee74fdd765bdad0f890c810518501de22a/xdrlib.py
try: self.__buf = self.__buf + struct.pack('>d', x)
try: self.__buf.write(struct.pack('>d', x))
def pack_double(self, x): try: self.__buf = self.__buf + struct.pack('>d', x) except struct.error, msg: raise ConversionError, msg
c47016ee74fdd765bdad0f890c810518501de22a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c47016ee74fdd765bdad0f890c810518501de22a/xdrlib.py
self.__buf = self.__buf + data
self.__buf.write(data)
def pack_fstring(self, n, s): if n < 0: raise ValueError, 'fstring size must be nonnegative' n = ((n+3)/4)*4 data = s[:n] data = data + (n - len(data)) * '\0' self.__buf = self.__buf + data
c47016ee74fdd765bdad0f890c810518501de22a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c47016ee74fdd765bdad0f890c810518501de22a/xdrlib.py
self.hashcode = random.randrange(1000000000) def __hash__(self): return self.hashcode
def __hash__(self): return 42
def __init__(self, i): # Comparison outcomes are determined by the value of i. self.i = i
dc5f6b232be9f669f78d627cdcacc07d2ba167af /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/dc5f6b232be9f669f78d627cdcacc07d2ba167af/test_mutants.py
XXX
def test_one(n): global mutate, dict1, dict2, dict1keys, dict2keys # Fill the dicts without mutating them. mutate = 0 dict1keys = fill_dict(dict1, range(n), n) dict2keys = fill_dict(dict2, range(n), n) # Enable mutation, then compare the dicts so long as they have the # same size. mutate = 1 if verbose: print "trying w/ lengths", len(dict1), len(dict2), while dict1 and len(dict1) == len(dict2): if verbose: print ".", c = dict1 == dict2 XXX # Can't figure out how to make this work if verbose: print
dc5f6b232be9f669f78d627cdcacc07d2ba167af /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/dc5f6b232be9f669f78d627cdcacc07d2ba167af/test_mutants.py
parts = parts[1:]
parts = parts[1:]
def loadTestsFromName(self, name, module=None): """Return a suite of all tests cases given a string specifier.
1b3c04b510c875fd3e31d13b73e76d3702bf99a0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1b3c04b510c875fd3e31d13b73e76d3702bf99a0/unittest.py
for key, val in dict.items():
for key in dict.keys():
def __fixdict(self, dict): for key, val in dict.items(): if key[:6] == 'start_': key = key[6:] start, end = self.elements.get(key, (None, None)) if start is None: self.elements[key] = val, end elif key[:4] == 'end_': key = key[4:] start, end = self.elements.get(key, (None, None)) if end is None: self.elements[key] = start, val
2e3f7bece07f3c40f0fe1785b83dd90aea59cb34 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2e3f7bece07f3c40f0fe1785b83dd90aea59cb34/xmllib.py
key = key[6:] start, end = self.elements.get(key, (None, None))
tag = key[6:] start, end = self.elements.get(tag, (None, None))
def __fixdict(self, dict): for key, val in dict.items(): if key[:6] == 'start_': key = key[6:] start, end = self.elements.get(key, (None, None)) if start is None: self.elements[key] = val, end elif key[:4] == 'end_': key = key[4:] start, end = self.elements.get(key, (None, None)) if end is None: self.elements[key] = start, val
2e3f7bece07f3c40f0fe1785b83dd90aea59cb34 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2e3f7bece07f3c40f0fe1785b83dd90aea59cb34/xmllib.py
self.elements[key] = val, end
self.elements[tag] = getattr(self, key), end
def __fixdict(self, dict): for key, val in dict.items(): if key[:6] == 'start_': key = key[6:] start, end = self.elements.get(key, (None, None)) if start is None: self.elements[key] = val, end elif key[:4] == 'end_': key = key[4:] start, end = self.elements.get(key, (None, None)) if end is None: self.elements[key] = start, val
2e3f7bece07f3c40f0fe1785b83dd90aea59cb34 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2e3f7bece07f3c40f0fe1785b83dd90aea59cb34/xmllib.py
key = key[4:] start, end = self.elements.get(key, (None, None))
tag = key[4:] start, end = self.elements.get(tag, (None, None))
def __fixdict(self, dict): for key, val in dict.items(): if key[:6] == 'start_': key = key[6:] start, end = self.elements.get(key, (None, None)) if start is None: self.elements[key] = val, end elif key[:4] == 'end_': key = key[4:] start, end = self.elements.get(key, (None, None)) if end is None: self.elements[key] = start, val
2e3f7bece07f3c40f0fe1785b83dd90aea59cb34 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2e3f7bece07f3c40f0fe1785b83dd90aea59cb34/xmllib.py
self.elements[key] = start, val
self.elements[tag] = start, getattr(self, key)
def __fixdict(self, dict): for key, val in dict.items(): if key[:6] == 'start_': key = key[6:] start, end = self.elements.get(key, (None, None)) if start is None: self.elements[key] = val, end elif key[:4] == 'end_': key = key[4:] start, end = self.elements.get(key, (None, None)) if end is None: self.elements[key] = start, val
2e3f7bece07f3c40f0fe1785b83dd90aea59cb34 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2e3f7bece07f3c40f0fe1785b83dd90aea59cb34/xmllib.py
try: f = eval('self.repr_' + typename) except AttributeError:
if hasattr(self, 'repr_' + typename): return getattr(self, 'repr_' + typename)(x, level) else:
def repr1(self, x, level): typename = `type(x)`[7:-2] # "<type '......'>" if ' ' in typename: parts = string.split(typename) typename = string.joinfields(parts, '_') try: f = eval('self.repr_' + typename) except AttributeError: s = `x` if len(s) > self.maxother: i = max(0, (self.maxother-3)/2) j = max(0, self.maxother-3-i) s = s[:i] + '...' + s[len(s)-j:] return s return f(x, level)
8d2080d043629702a5a79b968e778bcf991dfd73 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8d2080d043629702a5a79b968e778bcf991dfd73/repr.py
return f(x, level)
def repr1(self, x, level): typename = `type(x)`[7:-2] # "<type '......'>" if ' ' in typename: parts = string.split(typename) typename = string.joinfields(parts, '_') try: f = eval('self.repr_' + typename) except AttributeError: s = `x` if len(s) > self.maxother: i = max(0, (self.maxother-3)/2) j = max(0, self.maxother-3-i) s = s[:i] + '...' + s[len(s)-j:] return s return f(x, level)
8d2080d043629702a5a79b968e778bcf991dfd73 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8d2080d043629702a5a79b968e778bcf991dfd73/repr.py
if inspect.isroutine(object): returnself.docroutine(*args)
if inspect.isroutine(object): return self.docroutine(*args)
def document(self, object, name=None, *args): """Generate documentation for an object.""" args = (object, name) + args if inspect.ismodule(object): return self.docmodule(*args) if inspect.isclass(object): return self.docclass(*args) if inspect.isroutine(object): returnself.docroutine(*args) return self.docother(*args)
4f959d2c73463bdce97a0f2047c9964f2ca0d32d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4f959d2c73463bdce97a0f2047c9964f2ca0d32d/pydoc.py
def test_lc_numeric_basic(self): # Test nl_langinfo against localeconv for loc in candidate_locales: try: setlocale(LC_NUMERIC, loc) except Error: continue for li, lc in ((RADIXCHAR, "decimal_point"), (THOUSEP, "thousands_sep")): nl_radixchar = nl_langinfo(li) li_radixchar = localeconv()[lc] try: set_locale = setlocale(LC_NUMERIC) except Error: set_locale = "<not able to determine>" self.assertEquals(nl_radixchar, li_radixchar, "%s (nl_langinfo) != %s (localeconv) " "(set to %s, using %s)" % ( nl_radixchar, li_radixchar, loc, set_locale))
bb459734550094e9ea85d327afe87dc179b59986 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/bb459734550094e9ea85d327afe87dc179b59986/test__locale.py
def test_float_parsing(self): # Bug #1391872: Test whether float parsing is okay on European # locales. for loc in candidate_locales: try: setlocale(LC_NUMERIC, loc) except Error: continue self.assertEquals(int(eval('3.14') * 100), 314, "using eval('3.14') failed for %s" % loc) self.assertEquals(int(float('3.14') * 100), 314, "using float('3.14') failed for %s" % loc)
bb459734550094e9ea85d327afe87dc179b59986 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/bb459734550094e9ea85d327afe87dc179b59986/test__locale.py
map = socket_map
map = self._map
def add_channel(self, map=None): #self.log_info('adding channel %s' % self) if map is None: map = socket_map map[self._fileno] = self
f9ca40929241fa83c4fc7a8f2ba6c334286e5e16 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f9ca40929241fa83c4fc7a8f2ba6c334286e5e16/asyncore.py
map = socket_map
map = self._map
def del_channel(self, map=None): fd = self._fileno if map is None: map = socket_map if map.has_key(fd): #self.log_info('closing channel %d:%s' % (fd, self)) del map[fd]
f9ca40929241fa83c4fc7a8f2ba6c334286e5e16 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f9ca40929241fa83c4fc7a8f2ba6c334286e5e16/asyncore.py
def make_release_tree (self, base_dir, files):
1b3a9af5cf4827ff8248a69ef01468044ae67f25 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1b3a9af5cf4827ff8248a69ef01468044ae67f25/dist.py
self.announce ("making hard links in %s..." % base_dir)
try: link = os.link msg = "making hard links in %s..." % base_dir except AttributeError: link = 0 msg = "copying files to %s..." % base_dir self.announce (msg)
def make_release_tree (self, base_dir, files):
1b3a9af5cf4827ff8248a69ef01468044ae67f25 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1b3a9af5cf4827ff8248a69ef01468044ae67f25/dist.py
if not os.path.exists (dest): self.execute (os.link, (file, dest), "linking %s -> %s" % (file, dest))
if link: if not os.path.exists (dest): self.execute (os.link, (file, dest), "linking %s -> %s" % (file, dest)) else: self.copy_file (file, dest)
def make_release_tree (self, base_dir, files):
1b3a9af5cf4827ff8248a69ef01468044ae67f25 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1b3a9af5cf4827ff8248a69ef01468044ae67f25/dist.py
("unable to create zip file '%s.zip':" +
("unable to create zip file '%s.zip': " +
def make_zipfile (self, base_dir):
1b3a9af5cf4827ff8248a69ef01468044ae67f25 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1b3a9af5cf4827ff8248a69ef01468044ae67f25/dist.py
elif os.name == 'windows': if verbose: print string.join (cmd, ' ') if not dry_run: os.spawnv (os.P_WAIT, cmd[0], cmd[1:])
elif os.name in ( 'nt', 'windows' ): _spawn_nt (cmd, search_path, verbose, dry_run)
def spawn (cmd, search_path=1, verbose=0, dry_run=0): """Run another program, specified as a command list 'cmd', in a new process. 'cmd' is just the argument list for the new process, ie. cmd[0] is the program to run and cmd[1:] are the rest of its arguments. There is no way to run a program with a name different from that of its executable. If 'search_path' is true (the default), the system's executable search path will be used to find the program; otherwise, cmd[0] must be the exact path to the executable. If 'verbose' is true, a one-line summary of the command will be printed before it is run. If 'dry_run' is true, the command will not actually be run. Raise DistutilsExecError if running the program fails in any way; just return on success.""" if os.name == 'posix': _spawn_posix (cmd, search_path, verbose, dry_run) elif os.name == 'windows': # ??? # XXX should 'args' be cmd[1:] or cmd? # XXX how do we detect failure? # XXX how to do this in pre-1.5.2? # XXX is P_WAIT the correct mode? # XXX how to make Windows search the path? if verbose: print string.join (cmd, ' ') if not dry_run: os.spawnv (os.P_WAIT, cmd[0], cmd[1:]) else: raise DistutilsPlatformError, \ "don't know how to spawn programs on platform '%s'" % os.name
69628b0ad10f89a65902f5b911d1040ed9ae1ca2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/69628b0ad10f89a65902f5b911d1040ed9ae1ca2/spawn.py
self.copy_file(name, outfile, preserve_mode = 0)
self.copy_file(os.path.join(package_dir, name), outfile, preserve_mode = 0)
def run(self): # Copies all .py files, then also copies the txt and gif files build_py.run(self) assert self.packages == [idlelib] for name in txt_files: outfile = self.get_plain_outfile(self.build_lib, [idlelib], name) dir = os.path.dirname(outfile) self.mkpath(dir) self.copy_file(name, outfile, preserve_mode = 0) for name in Icons: outfile = self.get_plain_outfile(self.build_lib, [idlelib,"Icons"], name) dir = os.path.dirname(outfile) self.mkpath(dir) self.copy_file(os.path.join("Icons",name), outfile, preserve_mode = 0)
dc46175dc35d47df87e2955fec899cf471d3135f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/dc46175dc35d47df87e2955fec899cf471d3135f/setup.py
icons = [os.path.join("Icons",name) for name in Icons]
icons = [os.path.join(package_dir, "Icons",name) for name in Icons] txts = [os.path.join(package_dir, name) for name in txt_files]
def get_source_files(self): # returns the .py files, the .txt files, and the icons icons = [os.path.join("Icons",name) for name in Icons] return build_py.get_source_files(self)+txt_files+icons
dc46175dc35d47df87e2955fec899cf471d3135f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/dc46175dc35d47df87e2955fec899cf471d3135f/setup.py
package_dir = {idlelib:'.'},
package_dir = {idlelib: package_dir},
def _bytecode_filenames(self, files): files = [n for n in files if n.endswith('.py')] return install_lib._bytecode_filenames(self,files)
dc46175dc35d47df87e2955fec899cf471d3135f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/dc46175dc35d47df87e2955fec899cf471d3135f/setup.py
scripts = ['idle']
scripts = [os.path.join(package_dir, 'idle')]
def _bytecode_filenames(self, files): files = [n for n in files if n.endswith('.py')] return install_lib._bytecode_filenames(self,files)
dc46175dc35d47df87e2955fec899cf471d3135f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/dc46175dc35d47df87e2955fec899cf471d3135f/setup.py
import sys
if debug_stderr: sys.stderr = debug_stderr
def __init__(self): self.preffilepath = ":Python:PythonIDE preferences" Wapplication.Application.__init__(self, 'Pide') from Carbon import AE from Carbon import AppleEvents AE.AEInstallEventHandler(AppleEvents.kCoreEventClass, AppleEvents.kAEOpenApplication, self.ignoreevent) AE.AEInstallEventHandler(AppleEvents.kCoreEventClass, AppleEvents.kAEReopenApplication, self.ignoreevent) AE.AEInstallEventHandler(AppleEvents.kCoreEventClass, AppleEvents.kAEPrintDocuments, self.ignoreevent) AE.AEInstallEventHandler(AppleEvents.kCoreEventClass, AppleEvents.kAEOpenDocuments, self.opendocsevent) AE.AEInstallEventHandler(AppleEvents.kCoreEventClass, AppleEvents.kAEQuitApplication, self.quitevent) import PyConsole, PyEdit Splash.wait() PyConsole.installoutput() PyConsole.installconsole() import sys for path in sys.argv[1:]: self.opendoc(path) try: import Wthreading except ImportError: self.mainloop() else: if Wthreading.haveThreading: self.mainthread = Wthreading.Thread("IDE event loop", self.mainloop) self.mainthread.start() #self.mainthread.setResistant(1) Wthreading.run() else: self.mainloop()
e0ba087d4476c43dd91cdf7779f3eea27c70bc12 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e0ba087d4476c43dd91cdf7779f3eea27c70bc12/PythonIDEMain.py
if not ':' in head:
if os.sep == ':' and not ':' in head:
def mkdirs(dst): """Make directories leading to 'dst' if they don't exist yet""" if dst == '' or os.path.exists(dst): return head, tail = os.path.split(dst) if not ':' in head: head = head + ':' mkdirs(head) os.mkdir(dst, 0777)
d64845dbbec63c44a0a23b558b3cfe12dbc495fc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d64845dbbec63c44a0a23b558b3cfe12dbc495fc/macostools.py
expected = compile(str, "<input>", symbol, PyCF_DONT_IMPLY_DEDENT) self.assertEquals( compile_command(str, "<input>", symbol), expected)
if is_jython: code = compile_command(str, "<input>", symbol) self.assert_(code) if symbol == "single": d,r = {},{} sys.stdout = cStringIO.StringIO() try: exec code in d exec compile(str,"<input>","single") in r finally: sys.stdout = sys.__stdout__ elif symbol == 'eval': ctx = {'a': 2} d = { 'value': eval(code,ctx) } r = { 'value': eval(str,ctx) } self.assertEquals(unify_callables(r),unify_callables(d)) else: expected = compile(str, "<input>", symbol, PyCF_DONT_IMPLY_DEDENT) self.assertEquals( compile_command(str, "<input>", symbol), expected)
def assertValid(self, str, symbol='single'): '''succeed iff str is a valid piece of code''' expected = compile(str, "<input>", symbol, PyCF_DONT_IMPLY_DEDENT) self.assertEquals( compile_command(str, "<input>", symbol), expected)
de9a0d3158df0278d83754740f33276f780cef90 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/de9a0d3158df0278d83754740f33276f780cef90/test_codeop.py
self.assertEquals(compile_command(""), compile("pass", "<input>", 'single', PyCF_DONT_IMPLY_DEDENT))
av("a = 9+ \\\n3")
av("def x():\n pass\n")
de9a0d3158df0278d83754740f33276f780cef90 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/de9a0d3158df0278d83754740f33276f780cef90/test_codeop.py
ai("def x():\n")
ai("def x():\n")
de9a0d3158df0278d83754740f33276f780cef90 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/de9a0d3158df0278d83754740f33276f780cef90/test_codeop.py
ai("a = (")
ai("if 1:") ai("if 1:\n") ai("if 1:\n pass\n if 1:\n pass\n else:") ai("if 1:\n pass\n if 1:\n pass\n else:\n") ai("if 1:\n pass\n if 1:\n pass\n else:\n pass") ai("def x():") ai("def x():\n") ai("def x():\n\n") ai("def x():\n pass") ai("def x():\n pass\n ") ai("def x():\n pass\n ") ai("\n\ndef x():\n pass")
ai("def x():\n")
de9a0d3158df0278d83754740f33276f780cef90 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/de9a0d3158df0278d83754740f33276f780cef90/test_codeop.py
r = (24 - currentHour) * 60 * 60 r = r + (59 - currentMinute) * 60 r = r + (59 - currentSecond)
if (currentMinute == 0) and (currentSecond == 0): r = (24 - currentHour) * 60 * 60 else: r = (23 - currentHour) * 60 * 60 r = r + (59 - currentMinute) * 60 r = r + (60 - currentSecond)
def __init__(self, filename, when='h', interval=1, backupCount=0, encoding=None): BaseRotatingHandler.__init__(self, filename, 'a', encoding) self.when = string.upper(when) self.backupCount = backupCount # Calculate the real rollover interval, which is just the number of # seconds between rollovers. Also set the filename suffix used when # a rollover occurs. Current 'when' events supported: # S - Seconds # M - Minutes # H - Hours # D - Days # midnight - roll over at midnight # W{0-6} - roll over on a certain day; 0 - Monday # # Case of the 'when' specifier is not important; lower or upper case # will work. currentTime = int(time.time()) if self.when == 'S': self.interval = 1 # one second self.suffix = "%Y-%m-%d_%H-%M-%S" elif self.when == 'M': self.interval = 60 # one minute self.suffix = "%Y-%m-%d_%H-%M" elif self.when == 'H': self.interval = 60 * 60 # one hour self.suffix = "%Y-%m-%d_%H" elif self.when == 'D' or self.when == 'MIDNIGHT': self.interval = 60 * 60 * 24 # one day self.suffix = "%Y-%m-%d" elif self.when.startswith('W'): self.interval = 60 * 60 * 24 * 7 # one week if len(self.when) != 2: raise ValueError("You must specify a day for weekly rollover from 0 to 6 (0 is Monday): %s" % self.when) if self.when[1] < '0' or self.when[1] > '6': raise ValueError("Invalid day specified for weekly rollover: %s" % self.when) self.dayOfWeek = int(self.when[1]) self.suffix = "%Y-%m-%d" else: raise ValueError("Invalid rollover interval specified: %s" % self.when)
74a83e9ffbee00288bbc1ddd0e5a40e84a03b4af /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/74a83e9ffbee00288bbc1ddd0e5a40e84a03b4af/handlers.py
self.flags = []
self.flags = 0
def __init__(self):
815d5b934b8e8c0b7832353593050a6db660f517 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/815d5b934b8e8c0b7832353593050a6db660f517/sre_parse.py
def setflag(self, flag): if flag in self.flags: self.flags.append(flag)
def setflag(self, flag):
815d5b934b8e8c0b7832353593050a6db660f517 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/815d5b934b8e8c0b7832353593050a6db660f517/sre_parse.py
self.flags = []
def __init__(self, pattern, data=None):
815d5b934b8e8c0b7832353593050a6db660f517 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/815d5b934b8e8c0b7832353593050a6db660f517/sre_parse.py
lo = lo + i * av[0] hi = hi + j * av[1]
lo = lo + long(i) * av[0] hi = hi + long(j) * av[1]
def getwidth(self):
815d5b934b8e8c0b7832353593050a6db660f517 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/815d5b934b8e8c0b7832353593050a6db660f517/sre_parse.py
def set(self, flag): if not flag in self.flags: self.flags.append(flag) def reset(self, flag): if flag in self.flags: self.flags.remove(flag)
def set(self, flag):
815d5b934b8e8c0b7832353593050a6db660f517 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/815d5b934b8e8c0b7832353593050a6db660f517/sre_parse.py
self.string = list(string)
self.index = 0 self.string = string
def __init__(self, string):
815d5b934b8e8c0b7832353593050a6db660f517 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/815d5b934b8e8c0b7832353593050a6db660f517/sre_parse.py
if not self.string:
if self.index >= len(self.string):
def __next(self):
815d5b934b8e8c0b7832353593050a6db660f517 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/815d5b934b8e8c0b7832353593050a6db660f517/sre_parse.py
char = self.string[0]
char = self.string[self.index]
def __next(self):
815d5b934b8e8c0b7832353593050a6db660f517 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/815d5b934b8e8c0b7832353593050a6db660f517/sre_parse.py
c = self.string[1]
c = self.string[self.index + 1]
def __next(self):
815d5b934b8e8c0b7832353593050a6db660f517 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/815d5b934b8e8c0b7832353593050a6db660f517/sre_parse.py
try: if c == "x": for i in xrange(2, sys.maxint): c = self.string[i] if str(c) not in HEXDIGITS: break char = char + c elif str(c) in DIGITS: for i in xrange(2, sys.maxint): c = self.string[i] if str(c) not in DIGITS: break char = char + c except IndexError: pass del self.string[0:len(char)]
self.index = self.index + len(char)
def __next(self):
815d5b934b8e8c0b7832353593050a6db660f517 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/815d5b934b8e8c0b7832353593050a6db660f517/sre_parse.py
def _fixescape(escape, character_class=0): if character_class: code = ESCAPES.get(escape) if code: return code code = CATEGORIES.get(escape) else: code = CATEGORIES.get(escape) if code: return code code = ESCAPES.get(escape)
def _group(escape, state): try: group = int(escape[1:]) if group and group < state.groups: return group except ValueError: pass return None def _class_escape(source, escape): code = ESCAPES.get(escape)
def _fixescape(escape, character_class=0): # convert escape to (type, value) if character_class: # inside a character class, we'll look in the character # escapes dictionary first code = ESCAPES.get(escape) if code: return code code = CATEGORIES.get(escape) else: code = CATEGORIES.get(escape) if code: return code code = ESCAPES.get(escape) if code: return code if not character_class: try: group = int(escape[1:]) # FIXME: only valid if group <= current number of groups return GROUP, group except ValueError: pass try: if escape[1:2] == "x": escape = escape[2:] return LITERAL, chr(int(escape[-2:], 16) & 0xff) elif str(escape[1:2]) in DIGITS: return LITERAL, chr(int(escape[1:], 8) & 0xff) elif len(escape) == 2: return LITERAL, escape[1] except ValueError: pass raise SyntaxError, "bogus escape: %s" % repr(escape)
815d5b934b8e8c0b7832353593050a6db660f517 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/815d5b934b8e8c0b7832353593050a6db660f517/sre_parse.py
if not character_class: try: group = int(escape[1:]) return GROUP, group except ValueError: pass
code = CATEGORIES.get(escape) if code: return code
def _fixescape(escape, character_class=0): # convert escape to (type, value) if character_class: # inside a character class, we'll look in the character # escapes dictionary first code = ESCAPES.get(escape) if code: return code code = CATEGORIES.get(escape) else: code = CATEGORIES.get(escape) if code: return code code = ESCAPES.get(escape) if code: return code if not character_class: try: group = int(escape[1:]) # FIXME: only valid if group <= current number of groups return GROUP, group except ValueError: pass try: if escape[1:2] == "x": escape = escape[2:] return LITERAL, chr(int(escape[-2:], 16) & 0xff) elif str(escape[1:2]) in DIGITS: return LITERAL, chr(int(escape[1:], 8) & 0xff) elif len(escape) == 2: return LITERAL, escape[1] except ValueError: pass raise SyntaxError, "bogus escape: %s" % repr(escape)
815d5b934b8e8c0b7832353593050a6db660f517 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/815d5b934b8e8c0b7832353593050a6db660f517/sre_parse.py
return LITERAL, chr(int(escape[-2:], 16) & 0xff) elif str(escape[1:2]) in DIGITS: return LITERAL, chr(int(escape[1:], 8) & 0xff) elif len(escape) == 2:
return LITERAL, chr(int(escape[-4:], 16) & 0xff) elif str(escape[1:2]) in OCTDIGITS: while source.next in OCTDIGITS: escape = escape + source.get() escape = escape[1:] return LITERAL, chr(int(escape[-6:], 8) & 0xff) if len(escape) == 2:
def _fixescape(escape, character_class=0): # convert escape to (type, value) if character_class: # inside a character class, we'll look in the character # escapes dictionary first code = ESCAPES.get(escape) if code: return code code = CATEGORIES.get(escape) else: code = CATEGORIES.get(escape) if code: return code code = ESCAPES.get(escape) if code: return code if not character_class: try: group = int(escape[1:]) # FIXME: only valid if group <= current number of groups return GROUP, group except ValueError: pass try: if escape[1:2] == "x": escape = escape[2:] return LITERAL, chr(int(escape[-2:], 16) & 0xff) elif str(escape[1:2]) in DIGITS: return LITERAL, chr(int(escape[1:], 8) & 0xff) elif len(escape) == 2: return LITERAL, escape[1] except ValueError: pass raise SyntaxError, "bogus escape: %s" % repr(escape)
815d5b934b8e8c0b7832353593050a6db660f517 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/815d5b934b8e8c0b7832353593050a6db660f517/sre_parse.py
def _branch(subpattern, items):
def _escape(source, escape, state): code = CATEGORIES.get(escape) if code: return code code = ESCAPES.get(escape) if code: return code try: if escape[1:2] == "x": while source.next in HEXDIGITS: escape = escape + source.get() escape = escape[2:] return LITERAL, chr(int(escape[-4:], 16) & 0xff) elif str(escape[1:2]) in DIGITS: while 1: group = _group(escape, state) if group: if (not source.next or not _group(escape + source.next, state)): return GROUP, group escape = escape + source.get() elif source.next in OCTDIGITS: escape = escape + source.get() else: break escape = escape[1:] return LITERAL, chr(int(escape[-6:], 8) & 0xff) if len(escape) == 2: return LITERAL, escape[1] except ValueError: pass raise SyntaxError, "bogus escape: %s" % repr(escape) def _branch(pattern, items):
def _branch(subpattern, items): # form a branch operator from a set of items (FIXME: move this # optimization to the compiler module!) # check if all items share a common prefix while 1: prefix = None for item in items: if not item: break if prefix is None: prefix = item[0] elif item[0] != prefix: break else: # all subitems start with a common "prefix". # move it out of the branch for item in items: del item[0] subpattern.append(prefix) continue # check next one break # check if the branch can be replaced by a character set for item in items: if len(item) != 1 or item[0][0] != LITERAL: break else: # we can store this as a character set instead of a # branch (FIXME: use a range if possible) set = [] for item in items: set.append(item[0]) subpattern.append((IN, set)) return subpattern.append((BRANCH, (None, items)))
815d5b934b8e8c0b7832353593050a6db660f517 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/815d5b934b8e8c0b7832353593050a6db660f517/sre_parse.py
return
return subpattern
def _branch(subpattern, items): # form a branch operator from a set of items (FIXME: move this # optimization to the compiler module!) # check if all items share a common prefix while 1: prefix = None for item in items: if not item: break if prefix is None: prefix = item[0] elif item[0] != prefix: break else: # all subitems start with a common "prefix". # move it out of the branch for item in items: del item[0] subpattern.append(prefix) continue # check next one break # check if the branch can be replaced by a character set for item in items: if len(item) != 1 or item[0][0] != LITERAL: break else: # we can store this as a character set instead of a # branch (FIXME: use a range if possible) set = [] for item in items: set.append(item[0]) subpattern.append((IN, set)) return subpattern.append((BRANCH, (None, items)))
815d5b934b8e8c0b7832353593050a6db660f517 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/815d5b934b8e8c0b7832353593050a6db660f517/sre_parse.py
def _parse(source, pattern, flags=()):
return subpattern def _parse(source, state, flags=0):
def _branch(subpattern, items): # form a branch operator from a set of items (FIXME: move this # optimization to the compiler module!) # check if all items share a common prefix while 1: prefix = None for item in items: if not item: break if prefix is None: prefix = item[0] elif item[0] != prefix: break else: # all subitems start with a common "prefix". # move it out of the branch for item in items: del item[0] subpattern.append(prefix) continue # check next one break # check if the branch can be replaced by a character set for item in items: if len(item) != 1 or item[0][0] != LITERAL: break else: # we can store this as a character set instead of a # branch (FIXME: use a range if possible) set = [] for item in items: set.append(item[0]) subpattern.append((IN, set)) return subpattern.append((BRANCH, (None, items)))
815d5b934b8e8c0b7832353593050a6db660f517 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/815d5b934b8e8c0b7832353593050a6db660f517/sre_parse.py
subpattern = SubPattern(pattern) this = None
subpattern = SubPattern(state)
def _parse(source, pattern, flags=()): # parse regular expression pattern into an operator list. subpattern = SubPattern(pattern) this = None while 1: if str(source.next) in ("|", ")"): break # end of subpattern this = source.get() if this is None: break # end of pattern if this and this[0] not in SPECIAL_CHARS: subpattern.append((LITERAL, this)) elif this == "[": # character set set = []
815d5b934b8e8c0b7832353593050a6db660f517 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/815d5b934b8e8c0b7832353593050a6db660f517/sre_parse.py
code1 = _fixescape(this, 1)
code1 = _class_escape(source, this)
def _parse(source, pattern, flags=()): # parse regular expression pattern into an operator list. subpattern = SubPattern(pattern) this = None while 1: if str(source.next) in ("|", ")"): break # end of subpattern this = source.get() if this is None: break # end of pattern if this and this[0] not in SPECIAL_CHARS: subpattern.append((LITERAL, this)) elif this == "[": # character set set = []
815d5b934b8e8c0b7832353593050a6db660f517 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/815d5b934b8e8c0b7832353593050a6db660f517/sre_parse.py
code2 = _fixescape(this, 1)
code2 = _class_escape(source, this)
def _parse(source, pattern, flags=()): # parse regular expression pattern into an operator list. subpattern = SubPattern(pattern) this = None while 1: if str(source.next) in ("|", ")"): break # end of subpattern this = source.get() if this is None: break # end of pattern if this and this[0] not in SPECIAL_CHARS: subpattern.append((LITERAL, this)) elif this == "[": # character set set = []
815d5b934b8e8c0b7832353593050a6db660f517 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/815d5b934b8e8c0b7832353593050a6db660f517/sre_parse.py
def _parse(source, pattern, flags=()): # parse regular expression pattern into an operator list. subpattern = SubPattern(pattern) this = None while 1: if str(source.next) in ("|", ")"): break # end of subpattern this = source.get() if this is None: break # end of pattern if this and this[0] not in SPECIAL_CHARS: subpattern.append((LITERAL, this)) elif this == "[": # character set set = []
815d5b934b8e8c0b7832353593050a6db660f517 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/815d5b934b8e8c0b7832353593050a6db660f517/sre_parse.py
min, max = 0, sys.maxint
min, max = 0, MAXREPEAT
def _parse(source, pattern, flags=()): # parse regular expression pattern into an operator list. subpattern = SubPattern(pattern) this = None while 1: if str(source.next) in ("|", ")"): break # end of subpattern this = source.get() if this is None: break # end of pattern if this and this[0] not in SPECIAL_CHARS: subpattern.append((LITERAL, this)) elif this == "[": # character set set = []
815d5b934b8e8c0b7832353593050a6db660f517 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/815d5b934b8e8c0b7832353593050a6db660f517/sre_parse.py
min, max = 1, sys.maxint
min, max = 1, MAXREPEAT
def _parse(source, pattern, flags=()): # parse regular expression pattern into an operator list. subpattern = SubPattern(pattern) this = None while 1: if str(source.next) in ("|", ")"): break # end of subpattern this = source.get() if this is None: break # end of pattern if this and this[0] not in SPECIAL_CHARS: subpattern.append((LITERAL, this)) elif this == "[": # character set set = []
815d5b934b8e8c0b7832353593050a6db660f517 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/815d5b934b8e8c0b7832353593050a6db660f517/sre_parse.py
min, max = 0, sys.maxint
min, max = 0, MAXREPEAT
def _parse(source, pattern, flags=()): # parse regular expression pattern into an operator list. subpattern = SubPattern(pattern) this = None while 1: if str(source.next) in ("|", ")"): break # end of subpattern this = source.get() if this is None: break # end of pattern if this and this[0] not in SPECIAL_CHARS: subpattern.append((LITERAL, this)) elif this == "[": # character set set = []
815d5b934b8e8c0b7832353593050a6db660f517 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/815d5b934b8e8c0b7832353593050a6db660f517/sre_parse.py
def _parse(source, pattern, flags=()): # parse regular expression pattern into an operator list. subpattern = SubPattern(pattern) this = None while 1: if str(source.next) in ("|", ")"): break # end of subpattern this = source.get() if this is None: break # end of pattern if this and this[0] not in SPECIAL_CHARS: subpattern.append((LITERAL, this)) elif this == "[": # character set set = []
815d5b934b8e8c0b7832353593050a6db660f517 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/815d5b934b8e8c0b7832353593050a6db660f517/sre_parse.py
index = len(subpattern)-1 while subpattern[index][0] is MARK: index = index - 1 item = subpattern[index:index+1]
item = subpattern[-1:]
def _parse(source, pattern, flags=()): # parse regular expression pattern into an operator list. subpattern = SubPattern(pattern) this = None while 1: if str(source.next) in ("|", ")"): break # end of subpattern this = source.get() if this is None: break # end of pattern if this and this[0] not in SPECIAL_CHARS: subpattern.append((LITERAL, this)) elif this == "[": # character set set = []
815d5b934b8e8c0b7832353593050a6db660f517 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/815d5b934b8e8c0b7832353593050a6db660f517/sre_parse.py
subpattern[index] = (MIN_REPEAT, (min, max, item))
subpattern[-1] = (MIN_REPEAT, (min, max, item))
def _parse(source, pattern, flags=()): # parse regular expression pattern into an operator list. subpattern = SubPattern(pattern) this = None while 1: if str(source.next) in ("|", ")"): break # end of subpattern this = source.get() if this is None: break # end of pattern if this and this[0] not in SPECIAL_CHARS: subpattern.append((LITERAL, this)) elif this == "[": # character set set = []
815d5b934b8e8c0b7832353593050a6db660f517 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/815d5b934b8e8c0b7832353593050a6db660f517/sre_parse.py
subpattern[index] = (MAX_REPEAT, (min, max, item))
subpattern[-1] = (MAX_REPEAT, (min, max, item))
def _parse(source, pattern, flags=()): # parse regular expression pattern into an operator list. subpattern = SubPattern(pattern) this = None while 1: if str(source.next) in ("|", ")"): break # end of subpattern this = source.get() if this is None: break # end of pattern if this and this[0] not in SPECIAL_CHARS: subpattern.append((LITERAL, this)) elif this == "[": # character set set = []
815d5b934b8e8c0b7832353593050a6db660f517 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/815d5b934b8e8c0b7832353593050a6db660f517/sre_parse.py
def _parse(source, pattern, flags=()): # parse regular expression pattern into an operator list. subpattern = SubPattern(pattern) this = None while 1: if str(source.next) in ("|", ")"): break # end of subpattern this = source.get() if this is None: break # end of pattern if this and this[0] not in SPECIAL_CHARS: subpattern.append((LITERAL, this)) elif this == "[": # character set set = []
815d5b934b8e8c0b7832353593050a6db660f517 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/815d5b934b8e8c0b7832353593050a6db660f517/sre_parse.py
if char is None or char == ">":
if char is None: raise SyntaxError, "unterminated name" if char == ">":
def _parse(source, pattern, flags=()): # parse regular expression pattern into an operator list. subpattern = SubPattern(pattern) this = None while 1: if str(source.next) in ("|", ")"): break # end of subpattern this = source.get() if this is None: break # end of pattern if this and this[0] not in SPECIAL_CHARS: subpattern.append((LITERAL, this)) elif this == "[": # character set set = []
815d5b934b8e8c0b7832353593050a6db660f517 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/815d5b934b8e8c0b7832353593050a6db660f517/sre_parse.py
elif source.match_set("iI"): pattern.setflag("i") elif source.match_set("lL"): pattern.setflag("l") elif source.match_set("mM"): pattern.setflag("m") elif source.match_set("sS"): pattern.setflag("s") elif source.match_set("xX"): pattern.setflag("x")
elif source.match(" while 1: char = source.get() if char is None or char == ")": break else: while FLAGS.has_key(source.next): state.flags = state.flags | FLAGS[source.get()]
def _parse(source, pattern, flags=()): # parse regular expression pattern into an operator list. subpattern = SubPattern(pattern) this = None while 1: if str(source.next) in ("|", ")"): break # end of subpattern this = source.get() if this is None: break # end of pattern if this and this[0] not in SPECIAL_CHARS: subpattern.append((LITERAL, this)) elif this == "[": # character set set = []
815d5b934b8e8c0b7832353593050a6db660f517 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/815d5b934b8e8c0b7832353593050a6db660f517/sre_parse.py
group = pattern.getgroup(name) if group: subpattern.append((MARK, (group-1)*2))
group = state.getgroup(name)
def _parse(source, pattern, flags=()): # parse regular expression pattern into an operator list. subpattern = SubPattern(pattern) this = None while 1: if str(source.next) in ("|", ")"): break # end of subpattern this = source.get() if this is None: break # end of pattern if this and this[0] not in SPECIAL_CHARS: subpattern.append((LITERAL, this)) elif this == "[": # character set set = []
815d5b934b8e8c0b7832353593050a6db660f517 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/815d5b934b8e8c0b7832353593050a6db660f517/sre_parse.py
p = _parse(source, pattern, flags)
p = _parse(source, state, flags)
def _parse(source, pattern, flags=()): # parse regular expression pattern into an operator list. subpattern = SubPattern(pattern) this = None while 1: if str(source.next) in ("|", ")"): break # end of subpattern this = source.get() if this is None: break # end of pattern if this and this[0] not in SPECIAL_CHARS: subpattern.append((LITERAL, this)) elif this == "[": # character set set = []
815d5b934b8e8c0b7832353593050a6db660f517 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/815d5b934b8e8c0b7832353593050a6db660f517/sre_parse.py
_branch(subpattern, b) else: subpattern.append((SUBPATTERN, (group, p)))
p = _branch(state, b) subpattern.append((SUBPATTERN, (group, p)))
def _parse(source, pattern, flags=()): # parse regular expression pattern into an operator list. subpattern = SubPattern(pattern) this = None while 1: if str(source.next) in ("|", ")"): break # end of subpattern this = source.get() if this is None: break # end of pattern if this and this[0] not in SPECIAL_CHARS: subpattern.append((LITERAL, this)) elif this == "[": # character set set = []
815d5b934b8e8c0b7832353593050a6db660f517 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/815d5b934b8e8c0b7832353593050a6db660f517/sre_parse.py
if group: subpattern.append((MARK, (group-1)*2+1))
def _parse(source, pattern, flags=()): # parse regular expression pattern into an operator list. subpattern = SubPattern(pattern) this = None while 1: if str(source.next) in ("|", ")"): break # end of subpattern this = source.get() if this is None: break # end of pattern if this and this[0] not in SPECIAL_CHARS: subpattern.append((LITERAL, this)) elif this == "[": # character set set = []
815d5b934b8e8c0b7832353593050a6db660f517 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/815d5b934b8e8c0b7832353593050a6db660f517/sre_parse.py
def _parse(source, pattern, flags=()): # parse regular expression pattern into an operator list. subpattern = SubPattern(pattern) this = None while 1: if str(source.next) in ("|", ")"): break # end of subpattern this = source.get() if this is None: break # end of pattern if this and this[0] not in SPECIAL_CHARS: subpattern.append((LITERAL, this)) elif this == "[": # character set set = []
815d5b934b8e8c0b7832353593050a6db660f517 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/815d5b934b8e8c0b7832353593050a6db660f517/sre_parse.py
code =_fixescape(this)
code = _escape(source, this, state)
def _parse(source, pattern, flags=()): # parse regular expression pattern into an operator list. subpattern = SubPattern(pattern) this = None while 1: if str(source.next) in ("|", ")"): break # end of subpattern this = source.get() if this is None: break # end of pattern if this and this[0] not in SPECIAL_CHARS: subpattern.append((LITERAL, this)) elif this == "[": # character set set = []
815d5b934b8e8c0b7832353593050a6db660f517 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/815d5b934b8e8c0b7832353593050a6db660f517/sre_parse.py
def parse(source, flags=()): s = Tokenizer(source) g = Pattern()
def parse(pattern, flags=0): source = Tokenizer(pattern) state = State()
def parse(source, flags=()): s = Tokenizer(source) g = Pattern() b = [] while 1: p = _parse(s, g, flags) tail = s.get() if tail == "|": b.append(p) elif tail == ")": raise SyntaxError, "unbalanced parenthesis" elif tail is None: if b: b.append(p) p = SubPattern(g) _branch(p, b) break else: raise SyntaxError, "bogus characters at end of regular expression" return p
815d5b934b8e8c0b7832353593050a6db660f517 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/815d5b934b8e8c0b7832353593050a6db660f517/sre_parse.py
p = _parse(s, g, flags) tail = s.get()
p = _parse(source, state, flags) tail = source.get()
def parse(source, flags=()): s = Tokenizer(source) g = Pattern() b = [] while 1: p = _parse(s, g, flags) tail = s.get() if tail == "|": b.append(p) elif tail == ")": raise SyntaxError, "unbalanced parenthesis" elif tail is None: if b: b.append(p) p = SubPattern(g) _branch(p, b) break else: raise SyntaxError, "bogus characters at end of regular expression" return p
815d5b934b8e8c0b7832353593050a6db660f517 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/815d5b934b8e8c0b7832353593050a6db660f517/sre_parse.py
p = SubPattern(g) _branch(p, b)
p = _branch(state, b)
def parse(source, flags=()): s = Tokenizer(source) g = Pattern() b = [] while 1: p = _parse(s, g, flags) tail = s.get() if tail == "|": b.append(p) elif tail == ")": raise SyntaxError, "unbalanced parenthesis" elif tail is None: if b: b.append(p) p = SubPattern(g) _branch(p, b) break else: raise SyntaxError, "bogus characters at end of regular expression" return p
815d5b934b8e8c0b7832353593050a6db660f517 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/815d5b934b8e8c0b7832353593050a6db660f517/sre_parse.py
def getlongresp(self):
def getlongresp(self,fileHandle=None):
def getlongresp(self): """Internal: get a response plus following text from the server. Raise various errors if the response indicates an error.""" resp = self.getresp() if resp[:3] not in LONGRESP: raise NNTPReplyError(resp) list = [] while 1: line = self.getline() if line == '.': break if line[:2] == '..': line = line[1:] list.append(line) return resp, list
d1d584f4e820dc893175cdde74b901b6808ed3ab /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d1d584f4e820dc893175cdde74b901b6808ed3ab/nntplib.py
resp = self.getresp() if resp[:3] not in LONGRESP: raise NNTPReplyError(resp) list = [] while 1: line = self.getline() if line == '.': break if line[:2] == '..': line = line[1:] list.append(line)
openedFile = None try: if isinstance(fileHandle, types.StringType): openedFile = fileHandle = open(fileHandle, "w") resp = self.getresp() if resp[:3] not in LONGRESP: raise NNTPReplyError(resp) list = [] while 1: line = self.getline() if line == '.': break if line[:2] == '..': line = line[1:] if fileHandle: fileHandle.write(line + "\n") else: list.append(line) finally: if openedFile: openedFile.close()
def getlongresp(self): """Internal: get a response plus following text from the server. Raise various errors if the response indicates an error.""" resp = self.getresp() if resp[:3] not in LONGRESP: raise NNTPReplyError(resp) list = [] while 1: line = self.getline() if line == '.': break if line[:2] == '..': line = line[1:] list.append(line) return resp, list
d1d584f4e820dc893175cdde74b901b6808ed3ab /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d1d584f4e820dc893175cdde74b901b6808ed3ab/nntplib.py
def longcmd(self, line):
def longcmd(self, line, fileHandle=None):
def longcmd(self, line): """Internal: send a command and get the response plus following text.""" self.putcmd(line) return self.getlongresp()
d1d584f4e820dc893175cdde74b901b6808ed3ab /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d1d584f4e820dc893175cdde74b901b6808ed3ab/nntplib.py
return self.getlongresp()
return self.getlongresp(fileHandle)
def longcmd(self, line): """Internal: send a command and get the response plus following text.""" self.putcmd(line) return self.getlongresp()
d1d584f4e820dc893175cdde74b901b6808ed3ab /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d1d584f4e820dc893175cdde74b901b6808ed3ab/nntplib.py
def artcmd(self, line):
def artcmd(self, line, fileHandle=None):
def artcmd(self, line): """Internal: process a HEAD, BODY or ARTICLE command.""" resp, list = self.longcmd(line) resp, nr, id = self.statparse(resp) return resp, nr, id, list
d1d584f4e820dc893175cdde74b901b6808ed3ab /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d1d584f4e820dc893175cdde74b901b6808ed3ab/nntplib.py
resp, list = self.longcmd(line)
resp, list = self.longcmd(line,fileHandle)
def artcmd(self, line): """Internal: process a HEAD, BODY or ARTICLE command.""" resp, list = self.longcmd(line) resp, nr, id = self.statparse(resp) return resp, nr, id, list
d1d584f4e820dc893175cdde74b901b6808ed3ab /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d1d584f4e820dc893175cdde74b901b6808ed3ab/nntplib.py
def body(self, id):
def body(self, id, fileHandle=None):
def body(self, id): """Process a BODY command. Argument: - id: article number or message id Returns: - resp: server response if successful - nr: article number - id: message id - list: the lines of the article's body"""
d1d584f4e820dc893175cdde74b901b6808ed3ab /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d1d584f4e820dc893175cdde74b901b6808ed3ab/nntplib.py
- list: the lines of the article's body""" return self.artcmd('BODY ' + id)
- list: the lines of the article's body or an empty list if fileHandle was used""" return self.artcmd('BODY ' + id, fileHandle)
def body(self, id): """Process a BODY command. Argument: - id: article number or message id Returns: - resp: server response if successful - nr: article number - id: message id - list: the lines of the article's body"""
d1d584f4e820dc893175cdde74b901b6808ed3ab /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d1d584f4e820dc893175cdde74b901b6808ed3ab/nntplib.py
if callable(template): filter = template else: template = _compile_repl(template, pattern) if not template[0] and len(template[1]) == 1: filter = template[1][0] else: def filter(match, template=template): return sre_parse.expand_template(template, match)
template = _compile_repl(template, pattern) if not template[0] and len(template[1]) == 1: return template[1][0] def filter(match, template=template): return sre_parse.expand_template(template, match)
def _subx(pattern, template): # internal: pattern.sub/subn implementation helper if callable(template): filter = template else: template = _compile_repl(template, pattern) if not template[0] and len(template[1]) == 1: # literal replacement filter = template[1][0] else: def filter(match, template=template): return sre_parse.expand_template(template, match) return filter
dac58492aa3bf476fa0b4b586edababfe3aaca53 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/dac58492aa3bf476fa0b4b586edababfe3aaca53/sre.py
def _sub(pattern, template, text, count=0): return _subn(pattern, template, text, count)[0] def _subn(pattern, template, text, count=0): filter = _subx(pattern, template) if not callable(filter): def filter(match, literal=filter): return literal n = i = 0 s = [] append = s.append c = pattern.scanner(text) while not count or n < count: m = c.search() if not m: break b, e = m.span() if i < b: append(text[i:b]) elif i == b == e and n: append(text[i:b]) continue append(filter(m)) i = e n = n + 1 append(text[i:]) return _join(s, text[:0]), n def _split(pattern, text, maxsplit=0): n = i = 0 s = [] append = s.append extend = s.extend c = pattern.scanner(text) g = pattern.groups while not maxsplit or n < maxsplit: m = c.search() if not m: break b, e = m.span() if b == e: if i >= len(text): break continue append(text[i:b]) if g and b != e: extend(list(m.groups())) i = e n = n + 1 append(text[i:]) return s
def filter(match, template=template): return sre_parse.expand_template(template, match)
dac58492aa3bf476fa0b4b586edababfe3aaca53 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/dac58492aa3bf476fa0b4b586edababfe3aaca53/sre.py
if _iscommand("kfm") or _iscommand("konqueror"): register("kfm", Konqueror, Konqueror())
if _iscommand("kfm"): register("kfm", Konqueror, Konqueror("kfm")) elif _iscommand("konqueror"): register("konqueror", Konqueror, Konqueror("konqueror"))
def register_X_browsers(): # First, the Mozilla/Netscape browsers for browser in ("mozilla-firefox", "firefox", "mozilla-firebird", "firebird", "mozilla", "netscape"): if _iscommand(browser): register(browser, None, Mozilla(browser)) # The default Gnome browser if _iscommand("gconftool-2"): # get the web browser string from gconftool gc = 'gconftool-2 -g /desktop/gnome/url-handlers/http/command' out = os.popen(gc) commd = out.read().strip() retncode = out.close() # if successful, register it if retncode == None and len(commd) != 0: register("gnome", None, GenericBrowser( commd + " '%s' >/dev/null &")) # Konqueror/kfm, the KDE browser. if _iscommand("kfm") or _iscommand("konqueror"): register("kfm", Konqueror, Konqueror()) # Gnome's Galeon and Epiphany for browser in ("galeon", "epiphany"): if _iscommand(browser): register(browser, None, Galeon(browser)) # Skipstone, another Gtk/Mozilla based browser if _iscommand("skipstone"): register("skipstone", None, GenericBrowser("skipstone '%s' &")) # Opera, quite popular if _iscommand("opera"): register("opera", None, Opera("opera")) # Next, Mosaic -- old but still in use. if _iscommand("mosaic"): register("mosaic", None, GenericBrowser("mosaic '%s' &")) # Grail, the Python browser. Does anybody still use it? if _iscommand("grail"): register("grail", Grail, None)
b980113a8df699797b837f103ac6d2049a214551 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b980113a8df699797b837f103ac6d2049a214551/webbrowser.py
archive_basename = "%s.win32" % self.distribution.get_fullname()
fullname = self.distribution.get_fullname() archive_basename = os.path.join(self.bdist_dir, "%s.win32" % fullname)
def run (self):
fd9f168bcfea84b39f6bea55f7b57c1a62c162fe /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fd9f168bcfea84b39f6bea55f7b57c1a62c162fe/bdist_wininst.py
self.create_exe (arcname)
self.create_exe (arcname, fullname)
def run (self):
fd9f168bcfea84b39f6bea55f7b57c1a62c162fe /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fd9f168bcfea84b39f6bea55f7b57c1a62c162fe/bdist_wininst.py
def create_exe (self, arcname):
def create_exe (self, arcname, fullname):
def create_exe (self, arcname): import struct, zlib
fd9f168bcfea84b39f6bea55f7b57c1a62c162fe /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fd9f168bcfea84b39f6bea55f7b57c1a62c162fe/bdist_wininst.py
installer_name = "%s.win32.exe" % self.distribution.get_fullname()
installer_name = os.path.join(self.dist_dir, "%s.win32.exe" % fullname)
def create_exe (self, arcname): import struct, zlib
fd9f168bcfea84b39f6bea55f7b57c1a62c162fe /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fd9f168bcfea84b39f6bea55f7b57c1a62c162fe/bdist_wininst.py
if hasattr(m, "__file__"):
if hasattr(m, "__file__") and m.__file__:
def makepath(*paths): dir = os.path.join(*paths) return os.path.normcase(os.path.abspath(dir))
62d248892f8782d01cfeb1951d53eaeac81750fe /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/62d248892f8782d01cfeb1951d53eaeac81750fe/site.py
[here, os.path.join(here, os.pardir), os.curdir])
[os.path.join(here, os.pardir), here, os.curdir])
def __call__(self): self.__setup() prompt = 'Hit Return for more, or q (and Return) to quit: ' lineno = 0 while 1: try: for i in range(lineno, lineno + self.MAXLINES): print self.__lines[i] except IndexError: break else: lineno += self.MAXLINES key = None while key is None: key = raw_input(prompt) if key not in ('', 'q'): key = None if key == 'q': break
62d248892f8782d01cfeb1951d53eaeac81750fe /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/62d248892f8782d01cfeb1951d53eaeac81750fe/site.py
if sys.platform == "darwin": supports_unicode_filenames = True else: supports_unicode_filenames = False
supports_unicode_filenames = False
def realpath(filename): """Return the canonical path of the specified filename, eliminating any
2d4e988c35e5da0bf4bd35ca3eb6851e83970764 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2d4e988c35e5da0bf4bd35ca3eb6851e83970764/posixpath.py
def index(dir): """Return a list of (module-name, synopsis) pairs for a directory tree.""" results = [] for entry in os.listdir(dir): path = os.path.join(dir, entry) if ispackage(path): results.extend(map( lambda (m, s), pkg=entry: (pkg + '.' + m, s), index(path))) elif os.path.isfile(path) and entry[-3:] == '.py': results.append((entry[:-3], synopsis(path))) return results
def index(dir): """Return a list of (module-name, synopsis) pairs for a directory tree.""" results = [] for entry in os.listdir(dir): path = os.path.join(dir, entry) if ispackage(path): results.extend(map( lambda (m, s), pkg=entry: (pkg + '.' + m, s), index(path))) elif os.path.isfile(path) and entry[-3:] == '.py': results.append((entry[:-3], synopsis(path))) return results
66efbc74811f153a02728942adbbfc549bf10398 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/66efbc74811f153a02728942adbbfc549bf10398/pydoc.py
elif lower(filename[-4:]) == '.pyc':
elif lower(filename[-4:]) in ['.pyc', '.pyd', '.pyo']:
def modulename(path): """Return the Python module name for a given path, or None.""" filename = os.path.basename(path) if lower(filename[-3:]) == '.py': return filename[:-3] elif lower(filename[-4:]) == '.pyc': return filename[:-4] elif lower(filename[-11:]) == 'module.so': return filename[:-11] elif lower(filename[-13:]) == 'module.so.1': return filename[:-13]
66efbc74811f153a02728942adbbfc549bf10398 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/66efbc74811f153a02728942adbbfc549bf10398/pydoc.py
if inspect.ismethod(object): return apply(self.docmethod, args) if inspect.isbuiltin(object): return apply(self.docbuiltin, args) if inspect.isfunction(object): return apply(self.docfunction, args)
if inspect.isroutine(object): return apply(self.docroutine, args)
def document(self, object, *args): """Generate documentation for an object.""" args = (object,) + args if inspect.ismodule(object): return apply(self.docmodule, args) if inspect.isclass(object): return apply(self.docclass, args) if inspect.ismethod(object): return apply(self.docmethod, args) if inspect.isbuiltin(object): return apply(self.docbuiltin, args) if inspect.isfunction(object): return apply(self.docfunction, args) raise TypeError, "don't know how to document objects of type " + \ type(object).__name__
66efbc74811f153a02728942adbbfc549bf10398 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/66efbc74811f153a02728942adbbfc549bf10398/pydoc.py
<tr bgcolor="%s"><td colspan=3 valign=bottom><small><small><br></small></small ><font color="%s" face="helvetica, arial">&nbsp;%s</font></td
<tr bgcolor="%s"><td>&nbsp;</td> <td valign=bottom><small><small><br></small></small ><font color="%s" face="helvetica"><br>&nbsp;%s</font></td
def heading(self, title, fgcol, bgcol, extras=''): """Format a page heading.""" return """
66efbc74811f153a02728942adbbfc549bf10398 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/66efbc74811f153a02728942adbbfc549bf10398/pydoc.py
><font color="%s" face="helvetica, arial">&nbsp;%s</font></td></tr></table> """ % (bgcol, fgcol, title, fgcol, extras)
><font color="%s" face="helvetica">%s</font></td><td>&nbsp;</td></tr></table> """ % (bgcol, fgcol, title, fgcol, extras or '&nbsp;')
def heading(self, title, fgcol, bgcol, extras=''): """Format a page heading.""" return """
66efbc74811f153a02728942adbbfc549bf10398 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/66efbc74811f153a02728942adbbfc549bf10398/pydoc.py
<tr bgcolor="%s"><td colspan=3 valign=bottom><small><small><br></small></small
<tr bgcolor="%s"><td rowspan=2>&nbsp;</td> <td colspan=3 valign=bottom><small><small><br></small></small
def section(self, title, fgcol, bgcol, contents, width=20, prelude='', marginalia=None, gap='&nbsp;&nbsp;&nbsp;'): """Format a section with a heading.""" if marginalia is None: marginalia = '&nbsp;' * width result = """
66efbc74811f153a02728942adbbfc549bf10398 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/66efbc74811f153a02728942adbbfc549bf10398/pydoc.py
def footer(self): return """ <table width="100%"><tr><td align=right> <font face="helvetica, arial"><small><small>generated with <strong>htmldoc</strong> by Ka-Ping Yee</a></small></small></font> </td></tr></table> """
def bigsection(self, title, *args): """Format a section with a big heading.""" title = '<big><strong>%s</strong></big>' % title return apply(self.section, (title,) + args)
66efbc74811f153a02728942adbbfc549bf10398 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/66efbc74811f153a02728942adbbfc549bf10398/pydoc.py
result = '' head = '<br><big><big><strong>&nbsp;%s</strong></big></big>' % name
parts = split(name, '.') links = [] for i in range(len(parts)-1): links.append( '<a href="%s.html"><font color=" (join(parts[:i+1], '.'), parts[i])) linkedname = join(links + parts[-1:], '.') head = '<big><big><strong>%s</strong></big></big>' % linkedname
def docmodule(self, object): """Produce HTML documentation for a module object.""" name = object.__name__ result = '' head = '<br><big><big><strong>&nbsp;%s</strong></big></big>' % name try: path = os.path.abspath(inspect.getfile(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 = result + self.heading( head, '#ffffff', '#7799ee', '<a href=".">index</a><br>' + filelink)
66efbc74811f153a02728942adbbfc549bf10398 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/66efbc74811f153a02728942adbbfc549bf10398/pydoc.py
result = result + self.heading(
result = self.heading(
def docmodule(self, object): """Produce HTML documentation for a module object.""" name = object.__name__ result = '' head = '<br><big><big><strong>&nbsp;%s</strong></big></big>' % name try: path = os.path.abspath(inspect.getfile(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 = result + self.heading( head, '#ffffff', '#7799ee', '<a href=".">index</a><br>' + filelink)
66efbc74811f153a02728942adbbfc549bf10398 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/66efbc74811f153a02728942adbbfc549bf10398/pydoc.py