rem
stringlengths 1
322k
| add
stringlengths 0
2.05M
| context
stringlengths 4
228k
| meta
stringlengths 156
215
|
---|---|---|---|
__version__ = " | __version__ = " | def testMultiply(self): self.assertEquals((0 * 10), 0) self.assertEquals((5 * 8), 40) | 743436f26acbebc9e6dea9186e6c7cb7f3e517d1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/743436f26acbebc9e6dea9186e6c7cb7f3e517d1/unittest.py |
self.errors.append((test, self._exc_info_to_string(err))) | self.errors.append((test, self._exc_info_to_string(err, test))) | def addError(self, test, err): """Called when an error has occurred. 'err' is a tuple of values as returned by sys.exc_info(). """ self.errors.append((test, self._exc_info_to_string(err))) | 743436f26acbebc9e6dea9186e6c7cb7f3e517d1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/743436f26acbebc9e6dea9186e6c7cb7f3e517d1/unittest.py |
self.failures.append((test, self._exc_info_to_string(err))) | self.failures.append((test, self._exc_info_to_string(err, test))) | def addFailure(self, test, err): """Called when an error has occurred. 'err' is a tuple of values as returned by sys.exc_info().""" self.failures.append((test, self._exc_info_to_string(err))) | 743436f26acbebc9e6dea9186e6c7cb7f3e517d1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/743436f26acbebc9e6dea9186e6c7cb7f3e517d1/unittest.py |
def _exc_info_to_string(self, err): | def _exc_info_to_string(self, err, test): | def _exc_info_to_string(self, err): """Converts a sys.exc_info()-style tuple of values into a string.""" return ''.join(traceback.format_exception(*err)) | 743436f26acbebc9e6dea9186e6c7cb7f3e517d1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/743436f26acbebc9e6dea9186e6c7cb7f3e517d1/unittest.py |
return ''.join(traceback.format_exception(*err)) | exctype, value, tb = err while tb and self._is_relevant_tb_level(tb): tb = tb.tb_next if exctype is test.failureException: length = self._count_relevant_tb_levels(tb) return ''.join(traceback.format_exception(exctype, value, tb, length)) return ''.join(traceback.format_exception(exctype, value, tb)) def _is_relevant_tb_level(self, tb): return tb.tb_frame.f_globals.has_key('__unittest') def _count_relevant_tb_levels(self, tb): length = 0 while tb and not self._is_relevant_tb_level(tb): length += 1 tb = tb.tb_next return length | def _exc_info_to_string(self, err): """Converts a sys.exc_info()-style tuple of values into a string.""" return ''.join(traceback.format_exception(*err)) | 743436f26acbebc9e6dea9186e6c7cb7f3e517d1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/743436f26acbebc9e6dea9186e6c7cb7f3e517d1/unittest.py |
def __repr__(self): return "<%s run=%i errors=%i failures=%i>" % \ (_strclass(self.__class__), self.testsRun, len(self.errors), len(self.failures)) | 743436f26acbebc9e6dea9186e6c7cb7f3e517d1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/743436f26acbebc9e6dea9186e6c7cb7f3e517d1/unittest.py |
||
newtb = tb.tb_next if newtb is None: return (exctype, excvalue, tb) return (exctype, excvalue, newtb) | return (exctype, excvalue, tb) | def __exc_info(self): """Return a version of sys.exc_info() with the traceback frame minimised; usually the top level of the traceback frame is not needed. """ exctype, excvalue, tb = sys.exc_info() if sys.platform[:4] == 'java': ## tracebacks look different in Jython return (exctype, excvalue, tb) newtb = tb.tb_next if newtb is None: return (exctype, excvalue, tb) return (exctype, excvalue, newtb) | 743436f26acbebc9e6dea9186e6c7cb7f3e517d1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/743436f26acbebc9e6dea9186e6c7cb7f3e517d1/unittest.py |
run_unittest(LongReprTest) | if os.name != 'mac': run_unittest(LongReprTest) | def __repr__(self): raise Exception("This should be caught by Repr.repr_instance") | e8e6fa905b3304f7e8aa5ce245ceaa3a8c42eebb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/e8e6fa905b3304f7e8aa5ce245ceaa3a8c42eebb/test_repr.py |
def __init__(self, *args): apply(URLopener.__init__, (self,) + args) | def __init__(self, *args, **kwargs): apply(URLopener.__init__, (self,) + args, kwargs) | def __init__(self, *args): apply(URLopener.__init__, (self,) + args) self.auth_cache = {} self.tries = 0 self.maxtries = 10 | 2d69fc73408a2d6147074a414980f7d37983d13b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2d69fc73408a2d6147074a414980f7d37983d13b/urllib.py |
revparse_prog = re.compile(r'^(\d{1,3})\.(\d{1-4})$') | revparse_prog = re.compile(r'^(\d{1,3})\.(\d{1,4})$') | def revparse(rev): global revparse_prog if not revparse_prog: revparse_prog = re.compile(r'^(\d{1,3})\.(\d{1-4})$') m = revparse_prog.match(rev) if not m: return None [major, minor] = map(string.atoi, m.group(1, 2)) return major, minor | a861ea8d2ad03bad25e4afc8675f361a57ed2fd4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a861ea8d2ad03bad25e4afc8675f361a57ed2fd4/faqwiz.py |
'.ps': 'application/postscript', | '.pyo': 'application/x-python-code', | def read_mime_types(file): try: f = open(file) except IOError: return None map = {} while 1: line = f.readline() if not line: break words = line.split() for i in range(len(words)): if words[i][0] == '#': del words[i:] break if not words: continue type, suffixes = words[0], words[1:] for suff in suffixes: map['.'+suff] = type f.close() return map | 1fc263487966080a23ac9cc7e3516b76781b94cd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1fc263487966080a23ac9cc7e3516b76781b94cd/mimetypes.py |
self.msg('IAC %d not recognized' % ord(opt)) | self.msg('IAC %d not recognized' % ord(c)) | def process_rawq(self): """Transfer from raw queue to cooked queue. | 034a927aca477b54dda4ca503e138c77b380d007 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/034a927aca477b54dda4ca503e138c77b380d007/telnetlib.py |
raise 'catch me' except: | 1/0 except ZeroDivisionError: | def currentframe(): """Return the frame object for the caller's stack frame.""" try: raise 'catch me' except: return sys.exc_traceback.tb_frame.f_back | d15826c335fa56154e8f7cf4d2c22ff694241886 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d15826c335fa56154e8f7cf4d2c22ff694241886/inspect.py |
f = open(filename, 'rb') | f = open(filename, 'rT') | def showframe(self, stackindex): (frame, lineno) = self.stack[stackindex] W.SetCursor('watch') filename = frame.f_code.co_filename if filename <> self.file: editor = self.geteditor(filename) if editor: self.w.panes.bottom.src.source.set(editor.get(), filename) else: try: f = open(filename, 'rb') data = f.read() f.close() except IOError: if filename[-3:] == '.py': import imp modname = os.path.basename(filename)[:-3] try: f, filename, (suff, mode, dummy) = imp.find_module(modname) except ImportError: self.w.panes.bottom.src.source.set("can't find file") else: if f: f.close() if f and suff == '.py': f = open(filename, 'rb') data = f.read() f.close() self.w.panes.bottom.src.source.set(data, filename) else: self.w.panes.bottom.src.source.set("can't find file") else: self.w.panes.bottom.src.source.set("can't find file") else: self.w.panes.bottom.src.source.set(data, filename) self.file = filename self.w.panes.bottom.srctitle.set('Source: ' + filename + ((lineno > 0) and (' (line %d)' % lineno) or ' ')) self.goto_line(lineno) self.lineno = lineno self.showvars((frame, lineno)) | 894eb041da5659993ba69c5cec8580391c6c4077 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/894eb041da5659993ba69c5cec8580391c6c4077/PyDebugger.py |
f = open(filename, 'rb') | f = open(filename, 'rT') | def showframe(self, stackindex): (frame, lineno) = self.stack[stackindex] W.SetCursor('watch') filename = frame.f_code.co_filename if filename <> self.file: editor = self.geteditor(filename) if editor: self.w.panes.bottom.src.source.set(editor.get(), filename) else: try: f = open(filename, 'rb') data = f.read() f.close() except IOError: if filename[-3:] == '.py': import imp modname = os.path.basename(filename)[:-3] try: f, filename, (suff, mode, dummy) = imp.find_module(modname) except ImportError: self.w.panes.bottom.src.source.set("can't find file") else: if f: f.close() if f and suff == '.py': f = open(filename, 'rb') data = f.read() f.close() self.w.panes.bottom.src.source.set(data, filename) else: self.w.panes.bottom.src.source.set("can't find file") else: self.w.panes.bottom.src.source.set("can't find file") else: self.w.panes.bottom.src.source.set(data, filename) self.file = filename self.w.panes.bottom.srctitle.set('Source: ' + filename + ((lineno > 0) and (' (line %d)' % lineno) or ' ')) self.goto_line(lineno) self.lineno = lineno self.showvars((frame, lineno)) | 894eb041da5659993ba69c5cec8580391c6c4077 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/894eb041da5659993ba69c5cec8580391c6c4077/PyDebugger.py |
filename = tempfilename = tempfile.mktemp() if not self.writefile(filename): | (tfd, tempfilename) = tempfile.mkstemp(prefix='IDLE_tmp_') filename = tempfilename os.close(tfd) if not self.writefile(tempfilename): | def print_window(self, event): tempfilename = None saved = self.get_saved() if saved: filename = self.filename # shell undo is reset after every prompt, looks saved, probably isn't if not saved or filename is None: # XXX KBK 08Jun03 Wouldn't it be better to ask the user to save? filename = tempfilename = tempfile.mktemp() if not self.writefile(filename): os.unlink(tempfilename) return "break" platform=os.name printPlatform=1 if platform == 'posix': #posix platform command = idleConf.GetOption('main','General', 'print-command-posix') command = command + " 2>&1" elif platform == 'nt': #win32 platform command = idleConf.GetOption('main','General','print-command-win') else: #no printing for this platform printPlatform=0 if printPlatform: #we can try to print for this platform command = command % filename pipe = os.popen(command, "r") # things can get ugly on NT if there is no printer available. output = pipe.read().strip() status = pipe.close() if status: output = "Printing failed (exit status 0x%x)\n" % \ status + output if output: output = "Printing command: %s\n" % repr(command) + output tkMessageBox.showerror("Print status", output, master=self.text) else: #no printing for this platform message="Printing is not enabled for this platform: %s" % platform tkMessageBox.showinfo("Print status", message, master=self.text) return "break" | bed77a35b966219bb42954ed97bc42958c2080ad /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/bed77a35b966219bb42954ed97bc42958c2080ad/IOBinding.py |
print `header` | def decode(input, output, resonly=0): if type(input) == type(''): input = open(input, 'rb') # Should we also test for FSSpecs or FSRefs? header = input.read(AS_HEADER_LENGTH) print `header` try: magic, version, dummy, nentry = struct.unpack(AS_HEADER_FORMAT, header) except ValueError, arg: raise Error, "Unpack header error: %s"%arg if verbose: print 'Magic: 0x%8.8x'%magic print 'Version: 0x%8.8x'%version print 'Entries: %d'%nentry if magic != AS_MAGIC: raise Error, 'Unknown AppleSingle magic number 0x%8.8x'%magic if version != AS_VERSION: raise Error, 'Unknown AppleSingle version number 0x%8.8x'%version if nentry <= 0: raise Error, "AppleSingle file contains no forks" headers = [input.read(AS_ENTRY_LENGTH) for i in range(nentry)] didwork = 0 for hdr in headers: try: id, offset, length = struct.unpack(AS_ENTRY_FORMAT, hdr) except ValueError, arg: raise Error, "Unpack entry error: %s"%arg if verbose: print 'Fork %d, offset %d, length %d'%(id, offset, length) input.seek(offset) if length == 0: data = '' else: data = input.read(length) if len(data) != length: raise Error, 'Short read: expected %d bytes got %d'%(length, len(data)) if id == AS_DATAFORK: if verbose: print ' (data fork)' if not resonly: didwork = 1 fp = open(output, 'wb') fp.write(data) fp.close() elif id == AS_RESOURCEFORK: didwork = 1 if verbose: print ' (resource fork)' if resonly: fp = open(output, 'wb') else: fp = MacOS.openrf(output, 'wb') fp.write(data) fp.close() elif id in AS_IGNORE: if verbose: print ' (ignored)' else: raise Error, 'Unknown fork type %d'%id if not didwork: raise Error, 'No useful forks found' | 3a0beeede35f9ea91f2095c1ee92394bd116a68f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/3a0beeede35f9ea91f2095c1ee92394bd116a68f/applesingle.py |
|
return None | return False | def begin(self): self.resetoutput() if use_subprocess: nosub = '' client = self.interp.start_subprocess() if not client: self.close() return None else: nosub = "==== No Subprocess ====" self.write("Python %s on %s\n%s\n%s\nIDLE %s %s\n" % (sys.version, sys.platform, self.COPYRIGHT, self.firewallmessage, idlever.IDLE_VERSION, nosub)) self.showprompt() import Tkinter Tkinter._default_root = None # 03Jan04 KBK What's this? return client | e71f47e040263e02abb05d52f837ce2992abc6a6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/e71f47e040263e02abb05d52f837ce2992abc6a6/PyShell.py |
return client | return True | def begin(self): self.resetoutput() if use_subprocess: nosub = '' client = self.interp.start_subprocess() if not client: self.close() return None else: nosub = "==== No Subprocess ====" self.write("Python %s on %s\n%s\n%s\nIDLE %s %s\n" % (sys.version, sys.platform, self.COPYRIGHT, self.firewallmessage, idlever.IDLE_VERSION, nosub)) self.showprompt() import Tkinter Tkinter._default_root = None # 03Jan04 KBK What's this? return client | e71f47e040263e02abb05d52f837ce2992abc6a6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/e71f47e040263e02abb05d52f837ce2992abc6a6/PyShell.py |
encoding = parts[2] | encoding = parts[2].lower() | def decode(s): """Return a decoded string according to RFC 2047, as a unicode string.""" rtn = [] parts = ecre.split(s, 1) while parts: # If there are less than 4 parts, it can't be encoded and we're done if len(parts) < 5: rtn.extend(parts) break # The first element is any non-encoded leading text rtn.append(parts[0]) charset = parts[1] encoding = parts[2] atom = parts[3] # The next chunk to decode should be in parts[4] parts = ecre.split(parts[4]) # The encoding must be either `q' or `b', case-insensitive if encoding.lower() == 'q': func = _qdecode elif encoding.lower() == 'b': func = _bdecode else: func = _identity # Decode and get the unicode in the charset rtn.append(unicode(func(atom), charset)) # Now that we've decoded everything, we just need to join all the parts # together into the final string. return UEMPTYSTRING.join(rtn) | f74443c37ff70a2813d0e13180ec16b0c19bf77d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/f74443c37ff70a2813d0e13180ec16b0c19bf77d/Utils.py |
if encoding.lower() == 'q': | if encoding == 'q': | def decode(s): """Return a decoded string according to RFC 2047, as a unicode string.""" rtn = [] parts = ecre.split(s, 1) while parts: # If there are less than 4 parts, it can't be encoded and we're done if len(parts) < 5: rtn.extend(parts) break # The first element is any non-encoded leading text rtn.append(parts[0]) charset = parts[1] encoding = parts[2] atom = parts[3] # The next chunk to decode should be in parts[4] parts = ecre.split(parts[4]) # The encoding must be either `q' or `b', case-insensitive if encoding.lower() == 'q': func = _qdecode elif encoding.lower() == 'b': func = _bdecode else: func = _identity # Decode and get the unicode in the charset rtn.append(unicode(func(atom), charset)) # Now that we've decoded everything, we just need to join all the parts # together into the final string. return UEMPTYSTRING.join(rtn) | f74443c37ff70a2813d0e13180ec16b0c19bf77d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/f74443c37ff70a2813d0e13180ec16b0c19bf77d/Utils.py |
elif encoding.lower() == 'b': | elif encoding == 'b': | def decode(s): """Return a decoded string according to RFC 2047, as a unicode string.""" rtn = [] parts = ecre.split(s, 1) while parts: # If there are less than 4 parts, it can't be encoded and we're done if len(parts) < 5: rtn.extend(parts) break # The first element is any non-encoded leading text rtn.append(parts[0]) charset = parts[1] encoding = parts[2] atom = parts[3] # The next chunk to decode should be in parts[4] parts = ecre.split(parts[4]) # The encoding must be either `q' or `b', case-insensitive if encoding.lower() == 'q': func = _qdecode elif encoding.lower() == 'b': func = _bdecode else: func = _identity # Decode and get the unicode in the charset rtn.append(unicode(func(atom), charset)) # Now that we've decoded everything, we just need to join all the parts # together into the final string. return UEMPTYSTRING.join(rtn) | f74443c37ff70a2813d0e13180ec16b0c19bf77d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/f74443c37ff70a2813d0e13180ec16b0c19bf77d/Utils.py |
if encoding.lower() == 'q': | encoding = encoding.lower() if encoding == 'q': | def encode(s, charset='iso-8859-1', encoding='q'): """Encode a string according to RFC 2047.""" if encoding.lower() == 'q': estr = _qencode(s) elif encoding.lower() == 'b': estr = _bencode(s) else: raise ValueError, 'Illegal encoding code: ' + encoding return '=?%s?%s?%s?=' % (charset.lower(), encoding.lower(), estr) | f74443c37ff70a2813d0e13180ec16b0c19bf77d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/f74443c37ff70a2813d0e13180ec16b0c19bf77d/Utils.py |
elif encoding.lower() == 'b': | elif encoding == 'b': | def encode(s, charset='iso-8859-1', encoding='q'): """Encode a string according to RFC 2047.""" if encoding.lower() == 'q': estr = _qencode(s) elif encoding.lower() == 'b': estr = _bencode(s) else: raise ValueError, 'Illegal encoding code: ' + encoding return '=?%s?%s?%s?=' % (charset.lower(), encoding.lower(), estr) | f74443c37ff70a2813d0e13180ec16b0c19bf77d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/f74443c37ff70a2813d0e13180ec16b0c19bf77d/Utils.py |
return '=?%s?%s?%s?=' % (charset.lower(), encoding.lower(), estr) | return '=?%s?%s?%s?=' % (charset.lower(), encoding, estr) | def encode(s, charset='iso-8859-1', encoding='q'): """Encode a string according to RFC 2047.""" if encoding.lower() == 'q': estr = _qencode(s) elif encoding.lower() == 'b': estr = _bencode(s) else: raise ValueError, 'Illegal encoding code: ' + encoding return '=?%s?%s?%s?=' % (charset.lower(), encoding.lower(), estr) | f74443c37ff70a2813d0e13180ec16b0c19bf77d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/f74443c37ff70a2813d0e13180ec16b0c19bf77d/Utils.py |
for checkArgName in expected.keys(): | s = str(e) for checkArgName in expected: | def testAttributes(self): # test that exception attributes are happy try: str(u'Hello \u00E1') except Exception, e: sampleUnicodeEncodeError = e | eb7f68e05bf7b363bbe5678de958f5bc6ce66ba0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/eb7f68e05bf7b363bbe5678de958f5bc6ce66ba0/test_exceptions.py |
for checkArgName in expected.keys(): | for checkArgName in expected: | def testAttributes(self): # test that exception attributes are happy try: str(u'Hello \u00E1') except Exception, e: sampleUnicodeEncodeError = e | eb7f68e05bf7b363bbe5678de958f5bc6ce66ba0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/eb7f68e05bf7b363bbe5678de958f5bc6ce66ba0/test_exceptions.py |
sys.stdout = sys.__stdout__ | sys.stdout = saved_stdout | def assertValid(self, str, symbol='single'): '''succeed iff str is a valid piece of code''' 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) | 3d30dab4d42c106120833125679d259e76357450 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/3d30dab4d42c106120833125679d259e76357450/test_codeop.py |
return code.split('.')[:2] | return tuple(code.split('.')[:2]) | def _parse_localename(localename): """ Parses the locale code for localename and returns the result as tuple (language code, encoding). The localename is normalized and passed through the locale alias engine. A ValueError is raised in case the locale name cannot be parsed. The language code corresponds to RFC 1766. code and encoding can be None in case the values cannot be determined or are unknown to this implementation. """ code = normalize(localename) if '@' in localename: # Deal with locale modifiers code, modifier = code.split('@') if modifier == 'euro' and '.' not in code: # Assume Latin-9 for @euro locales. This is bogus, # since some systems may use other encodings for these # locales. Also, we ignore other modifiers. return code, 'iso-8859-15' if '.' in code: return code.split('.')[:2] elif code == 'C': return None, None raise ValueError, 'unknown locale: %s' % localename | 3c6d34e012d6aaf6fc94b254c7808d697707b459 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/3c6d34e012d6aaf6fc94b254c7808d697707b459/locale.py |
testit('rint(0.7)', math.rint(0.7), 1) testit('rint(-0.3)', math.rint(-0.3), 0) testit('rint(2.5)', math.rint(2.5), 2) testit('rint(3.5)', math.rint(3.5), 4) | try: math.rint except AttributeError: pass else: testit('rint(0.7)', math.rint(0.7), 1) testit('rint(-0.3)', math.rint(-0.3), 0) testit('rint(2.5)', math.rint(2.5), 2) testit('rint(3.5)', math.rint(3.5), 4) | def testmodf(name, (v1, v2), (e1, e2)): if abs(v1-e1) > eps or abs(v2-e2): raise TestFailed, '%s returned %s, expected %s'%\ (name, `v1,v2`, `e1,e2`) | 462445b57e41d82d9d915ee5e0751dece537fbfd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/462445b57e41d82d9d915ee5e0751dece537fbfd/test_math.py |
def __init__(self, flist=None, filename=None, key=None, root=None): currentTheme=idleConf.CurrentTheme() self.flist = flist root = root or flist.root self.root = root self.menubar = Menu(root) self.top = top = self.Toplevel(root, menu=self.menubar) if flist: self.vars = flist.vars #self.top.instanceDict makes flist.inversedict avalable to #configDialog.py so it can access all EditorWindow instaces self.top.instanceDict=flist.inversedict self.recentFilesPath=os.path.join(idleConf.GetUserCfgDir(), 'recent-files.lst') self.vbar = vbar = Scrollbar(top, name='vbar') self.text_frame = text_frame = Frame(top) self.text = text = Text(text_frame, name='text', padx=5, wrap='none', foreground=idleConf.GetHighlight(currentTheme, 'normal',fgBg='fg'), background=idleConf.GetHighlight(currentTheme, 'normal',fgBg='bg'), highlightcolor=idleConf.GetHighlight(currentTheme, 'hilite',fgBg='fg'), highlightbackground=idleConf.GetHighlight(currentTheme, 'hilite',fgBg='bg'), insertbackground=idleConf.GetHighlight(currentTheme, 'cursor',fgBg='fg'), width=idleConf.GetOption('main','EditorWindow','width'), height=idleConf.GetOption('main','EditorWindow','height') ) | c0059c5b74ad5a3d6f68763850950e564e05022f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/c0059c5b74ad5a3d6f68763850950e564e05022f/EditorWindow.py |
||
def __init__(self, flist=None, filename=None, key=None, root=None): currentTheme=idleConf.CurrentTheme() self.flist = flist root = root or flist.root self.root = root self.menubar = Menu(root) self.top = top = self.Toplevel(root, menu=self.menubar) if flist: self.vars = flist.vars #self.top.instanceDict makes flist.inversedict avalable to #configDialog.py so it can access all EditorWindow instaces self.top.instanceDict=flist.inversedict self.recentFilesPath=os.path.join(idleConf.GetUserCfgDir(), 'recent-files.lst') self.vbar = vbar = Scrollbar(top, name='vbar') self.text_frame = text_frame = Frame(top) self.text = text = Text(text_frame, name='text', padx=5, wrap='none', foreground=idleConf.GetHighlight(currentTheme, 'normal',fgBg='fg'), background=idleConf.GetHighlight(currentTheme, 'normal',fgBg='bg'), highlightcolor=idleConf.GetHighlight(currentTheme, 'hilite',fgBg='fg'), highlightbackground=idleConf.GetHighlight(currentTheme, 'hilite',fgBg='bg'), insertbackground=idleConf.GetHighlight(currentTheme, 'cursor',fgBg='fg'), width=idleConf.GetOption('main','EditorWindow','width'), height=idleConf.GetOption('main','EditorWindow','height') ) | c0059c5b74ad5a3d6f68763850950e564e05022f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/c0059c5b74ad5a3d6f68763850950e564e05022f/EditorWindow.py |
||
def addcolorizer(self): if self.color: return ##print "Add colorizer" self.per.removefilter(self.undo) self.color = self.ColorDelegator() self.per.insertfilter(self.color) self.per.insertfilter(self.undo) | c0059c5b74ad5a3d6f68763850950e564e05022f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/c0059c5b74ad5a3d6f68763850950e564e05022f/EditorWindow.py |
||
def rmcolorizer(self): if not self.color: return ##print "Remove colorizer" self.per.removefilter(self.undo) self.per.removefilter(self.color) self.color = None self.per.insertfilter(self.undo) | c0059c5b74ad5a3d6f68763850950e564e05022f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/c0059c5b74ad5a3d6f68763850950e564e05022f/EditorWindow.py |
||
def apply_bindings(self, keydefs=None): if keydefs is None: keydefs = self.Bindings.default_keydefs text = self.text text.keydefs = keydefs for event, keylist in keydefs.items(): ##print>>sys.__stderr__, "event, list: ", event, keylist if keylist: apply(text.event_add, (event,) + tuple(keylist)) | c0059c5b74ad5a3d6f68763850950e564e05022f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/c0059c5b74ad5a3d6f68763850950e564e05022f/EditorWindow.py |
||
def fill_menus(self, defs=None, keydefs=None): """Add appropriate entries to the menus and submenus | c0059c5b74ad5a3d6f68763850950e564e05022f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/c0059c5b74ad5a3d6f68763850950e564e05022f/EditorWindow.py |
||
def fill_menus(self, defs=None, keydefs=None): """Add appropriate entries to the menus and submenus | c0059c5b74ad5a3d6f68763850950e564e05022f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/c0059c5b74ad5a3d6f68763850950e564e05022f/EditorWindow.py |
||
def command(text=text, event=event): text.event_generate(event) | c0059c5b74ad5a3d6f68763850950e564e05022f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/c0059c5b74ad5a3d6f68763850950e564e05022f/EditorWindow.py |
||
for tagName in DESCRIPTOR_ELEMENTS: nodes = find_all_elements(doc, tagName) for node in nodes: rewrite_descriptor(doc, node) | sections = find_all_elements(doc, "section") for section in sections: find_and_fix_descriptors(doc, section) def find_and_fix_descriptors(doc, container): children = container.childNodes for child in children: if child.nodeType == xml.dom.core.ELEMENT: tagName = child.tagName if tagName in DESCRIPTOR_ELEMENTS: rewrite_descriptor(doc, child) elif tagName == "subsection": find_and_fix_descriptors(doc, child) | def fixup_descriptors(doc): for tagName in DESCRIPTOR_ELEMENTS: nodes = find_all_elements(doc, tagName) for node in nodes: rewrite_descriptor(doc, node) | f2e128d793aaf9a4c28388b94c94ec4b9fc4f6f2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/f2e128d793aaf9a4c28388b94c94ec4b9fc4f6f2/docfixer.py |
install = self.distribution.get_command_obj('install') | install = self.reinitialize_command('install') | def run (self): | 55a0bcdecb5b7eab6d26650251d30cd9c382ed52 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/55a0bcdecb5b7eab6d26650251d30cd9c382ed52/bdist_dumb.py |
def zipTest(f, compression, srccontents): zip = zipfile.ZipFile(f, "w", compression) zip.write(srcname, "another"+os.extsep+"name") zip.write(srcname, srcname) zip.close() | TESTFN2 = TESTFN + "2" | def zipTest(f, compression, srccontents): zip = zipfile.ZipFile(f, "w", compression) # Create the ZIP archive zip.write(srcname, "another"+os.extsep+"name") zip.write(srcname, srcname) zip.close() zip = zipfile.ZipFile(f, "r", compression) # Read the ZIP archive readData2 = zip.read(srcname) readData1 = zip.read("another"+os.extsep+"name") zip.close() if readData1 != srccontents or readData2 != srccontents: raise TestFailed, "Written data doesn't equal read data." | 2d2ac3a0a10cdc817f61cb177b9af6e2cc4d5007 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2d2ac3a0a10cdc817f61cb177b9af6e2cc4d5007/test_zipfile.py |
zip = zipfile.ZipFile(f, "r", compression) readData2 = zip.read(srcname) readData1 = zip.read("another"+os.extsep+"name") zip.close() | class TestsWithSourceFile(unittest.TestCase): def setUp(self): line_gen = ("Test of zipfile line %d." % i for i in range(0, 1000)) self.data = '\n'.join(line_gen) | def zipTest(f, compression, srccontents): zip = zipfile.ZipFile(f, "w", compression) # Create the ZIP archive zip.write(srcname, "another"+os.extsep+"name") zip.write(srcname, srcname) zip.close() zip = zipfile.ZipFile(f, "r", compression) # Read the ZIP archive readData2 = zip.read(srcname) readData1 = zip.read("another"+os.extsep+"name") zip.close() if readData1 != srccontents or readData2 != srccontents: raise TestFailed, "Written data doesn't equal read data." | 2d2ac3a0a10cdc817f61cb177b9af6e2cc4d5007 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2d2ac3a0a10cdc817f61cb177b9af6e2cc4d5007/test_zipfile.py |
if readData1 != srccontents or readData2 != srccontents: raise TestFailed, "Written data doesn't equal read data." | fp = open(TESTFN, "wb") fp.write(self.data) fp.close() | def zipTest(f, compression, srccontents): zip = zipfile.ZipFile(f, "w", compression) # Create the ZIP archive zip.write(srcname, "another"+os.extsep+"name") zip.write(srcname, srcname) zip.close() zip = zipfile.ZipFile(f, "r", compression) # Read the ZIP archive readData2 = zip.read(srcname) readData1 = zip.read("another"+os.extsep+"name") zip.close() if readData1 != srccontents or readData2 != srccontents: raise TestFailed, "Written data doesn't equal read data." | 2d2ac3a0a10cdc817f61cb177b9af6e2cc4d5007 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2d2ac3a0a10cdc817f61cb177b9af6e2cc4d5007/test_zipfile.py |
try: fp = open(srcname, "wb") for i in range(0, 1000): fp.write("Test of zipfile line %d.\n" % i) fp.close() | zipfp = zipfile.ZipFile(f, "r", compression) self.assertEqual(zipfp.read(TESTFN), self.data) self.assertEqual(zipfp.read("another"+os.extsep+"name"), self.data) zipfp.close() | def zipTest(f, compression, srccontents): zip = zipfile.ZipFile(f, "w", compression) # Create the ZIP archive zip.write(srcname, "another"+os.extsep+"name") zip.write(srcname, srcname) zip.close() zip = zipfile.ZipFile(f, "r", compression) # Read the ZIP archive readData2 = zip.read(srcname) readData1 = zip.read("another"+os.extsep+"name") zip.close() if readData1 != srccontents or readData2 != srccontents: raise TestFailed, "Written data doesn't equal read data." | 2d2ac3a0a10cdc817f61cb177b9af6e2cc4d5007 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2d2ac3a0a10cdc817f61cb177b9af6e2cc4d5007/test_zipfile.py |
fp = open(srcname, "rb") writtenData = fp.read() fp.close() | def testStored(self): for f in (TESTFN2, TemporaryFile(), StringIO()): self.zipTest(f, zipfile.ZIP_STORED) | def zipTest(f, compression, srccontents): zip = zipfile.ZipFile(f, "w", compression) # Create the ZIP archive zip.write(srcname, "another"+os.extsep+"name") zip.write(srcname, srcname) zip.close() zip = zipfile.ZipFile(f, "r", compression) # Read the ZIP archive readData2 = zip.read(srcname) readData1 = zip.read("another"+os.extsep+"name") zip.close() if readData1 != srccontents or readData2 != srccontents: raise TestFailed, "Written data doesn't equal read data." | 2d2ac3a0a10cdc817f61cb177b9af6e2cc4d5007 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2d2ac3a0a10cdc817f61cb177b9af6e2cc4d5007/test_zipfile.py |
for file in (zipname, tempfile.TemporaryFile(), StringIO.StringIO()): zipTest(file, zipfile.ZIP_STORED, writtenData) | if zlib: def testDeflated(self): for f in (TESTFN2, TemporaryFile(), StringIO()): self.zipTest(f, zipfile.ZIP_DEFLATED) | def zipTest(f, compression, srccontents): zip = zipfile.ZipFile(f, "w", compression) # Create the ZIP archive zip.write(srcname, "another"+os.extsep+"name") zip.write(srcname, srcname) zip.close() zip = zipfile.ZipFile(f, "r", compression) # Read the ZIP archive readData2 = zip.read(srcname) readData1 = zip.read("another"+os.extsep+"name") zip.close() if readData1 != srccontents or readData2 != srccontents: raise TestFailed, "Written data doesn't equal read data." | 2d2ac3a0a10cdc817f61cb177b9af6e2cc4d5007 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2d2ac3a0a10cdc817f61cb177b9af6e2cc4d5007/test_zipfile.py |
for file in (zipname, tempfile.TemporaryFile(), StringIO.StringIO()): zipTest(file, zipfile.ZIP_DEFLATED, writtenData) | def tearDown(self): os.remove(TESTFN) os.remove(TESTFN2) | def zipTest(f, compression, srccontents): zip = zipfile.ZipFile(f, "w", compression) # Create the ZIP archive zip.write(srcname, "another"+os.extsep+"name") zip.write(srcname, srcname) zip.close() zip = zipfile.ZipFile(f, "r", compression) # Read the ZIP archive readData2 = zip.read(srcname) readData1 = zip.read("another"+os.extsep+"name") zip.close() if readData1 != srccontents or readData2 != srccontents: raise TestFailed, "Written data doesn't equal read data." | 2d2ac3a0a10cdc817f61cb177b9af6e2cc4d5007 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2d2ac3a0a10cdc817f61cb177b9af6e2cc4d5007/test_zipfile.py |
finally: if os.path.isfile(srcname): os.unlink(srcname) if os.path.isfile(zipname): os.unlink(zipname) | class OtherTests(unittest.TestCase): def testCloseErroneousFile(self): fp = open(TESTFN, "w") fp.write("this is not a legal zip file\n") fp.close() try: zf = zipfile.ZipFile(TESTFN) except zipfile.BadZipfile: os.unlink(TESTFN) | def zipTest(f, compression, srccontents): zip = zipfile.ZipFile(f, "w", compression) # Create the ZIP archive zip.write(srcname, "another"+os.extsep+"name") zip.write(srcname, srcname) zip.close() zip = zipfile.ZipFile(f, "r", compression) # Read the ZIP archive readData2 = zip.read(srcname) readData1 = zip.read("another"+os.extsep+"name") zip.close() if readData1 != srccontents or readData2 != srccontents: raise TestFailed, "Written data doesn't equal read data." | 2d2ac3a0a10cdc817f61cb177b9af6e2cc4d5007 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2d2ac3a0a10cdc817f61cb177b9af6e2cc4d5007/test_zipfile.py |
fp = open(srcname, "w") fp.write("this is not a legal zip file\n") fp.close() try: zf = zipfile.ZipFile(srcname) except zipfile.BadZipfile: os.unlink(srcname) | self.assertRaises(IOError, zipfile.ZipFile, TESTFN) | def zipTest(f, compression, srccontents): zip = zipfile.ZipFile(f, "w", compression) # Create the ZIP archive zip.write(srcname, "another"+os.extsep+"name") zip.write(srcname, srcname) zip.close() zip = zipfile.ZipFile(f, "r", compression) # Read the ZIP archive readData2 = zip.read(srcname) readData1 = zip.read("another"+os.extsep+"name") zip.close() if readData1 != srccontents or readData2 != srccontents: raise TestFailed, "Written data doesn't equal read data." | 2d2ac3a0a10cdc817f61cb177b9af6e2cc4d5007 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2d2ac3a0a10cdc817f61cb177b9af6e2cc4d5007/test_zipfile.py |
try: zipfile.ZipFile(srcname) except IOError: pass else: raise TestFailed("expected creation of readable ZipFile without\n" " a file to raise an IOError.") | self.assertRaises(RuntimeError, zipf.testzip) | def zipTest(f, compression, srccontents): zip = zipfile.ZipFile(f, "w", compression) # Create the ZIP archive zip.write(srcname, "another"+os.extsep+"name") zip.write(srcname, srcname) zip.close() zip = zipfile.ZipFile(f, "r", compression) # Read the ZIP archive readData2 = zip.read(srcname) readData1 = zip.read("another"+os.extsep+"name") zip.close() if readData1 != srccontents or readData2 != srccontents: raise TestFailed, "Written data doesn't equal read data." | 2d2ac3a0a10cdc817f61cb177b9af6e2cc4d5007 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2d2ac3a0a10cdc817f61cb177b9af6e2cc4d5007/test_zipfile.py |
data = StringIO.StringIO() zipf = zipfile.ZipFile(data, mode="w") zipf.writestr("foo.txt", "O, for a Muse of Fire!") zipf.close() zipf = zipfile.ZipFile(data, mode="r") zipf.close() try: zipf.testzip() except RuntimeError: pass else: raise TestFailed("expected calling .testzip on a closed ZipFile" " to raise a RuntimeError") del data, zipf | if __name__ == "__main__": test_main() | def zipTest(f, compression, srccontents): zip = zipfile.ZipFile(f, "w", compression) # Create the ZIP archive zip.write(srcname, "another"+os.extsep+"name") zip.write(srcname, srcname) zip.close() zip = zipfile.ZipFile(f, "r", compression) # Read the ZIP archive readData2 = zip.read(srcname) readData1 = zip.read("another"+os.extsep+"name") zip.close() if readData1 != srccontents or readData2 != srccontents: raise TestFailed, "Written data doesn't equal read data." | 2d2ac3a0a10cdc817f61cb177b9af6e2cc4d5007 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2d2ac3a0a10cdc817f61cb177b9af6e2cc4d5007/test_zipfile.py |
self.assertEqual(binascii.a2b_qp("= "), "") | self.assertEqual(binascii.a2b_qp("= "), "= ") | def test_qp(self): # A test for SF bug 534347 (segfaults without the proper fix) try: binascii.a2b_qp("", **{1:1}) except TypeError: pass else: self.fail("binascii.a2b_qp(**{1:1}) didn't raise TypeError") self.assertEqual(binascii.a2b_qp("= "), "") self.assertEqual(binascii.a2b_qp("=="), "=") self.assertEqual(binascii.a2b_qp("=AX"), "=AX") self.assertRaises(TypeError, binascii.b2a_qp, foo="bar") self.assertEqual(binascii.a2b_qp("=00\r\n=00"), "\x00\r\n\x00") self.assertEqual( binascii.b2a_qp("\xff\r\n\xff\n\xff"), "=FF\r\n=FF\r\n=FF" ) self.assertEqual( binascii.b2a_qp("0"*75+"\xff\r\n\xff\r\n\xff"), "0"*75+"=\r\n=FF\r\n=FF\r\n=FF" ) | 25a1a2fae20cedd2b65e6df1c815d38a29cd4064 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/25a1a2fae20cedd2b65e6df1c815d38a29cd4064/test_binascii.py |
if forceload and path in sys.modules: if path not in sys.builtin_module_names: info = inspect.getmoduleinfo(sys.modules[path].__file__) if info[3] != imp.C_EXTENSION: cache[path] = sys.modules[path] del sys.modules[path] | def safeimport(path, forceload=0, cache={}): """Import a module; handle errors; return None if the module isn't found. If the module *is* found but an exception occurs, it's wrapped in an ErrorDuringImport exception and reraised. Unlike __import__, if a package path is specified, the module at the end of the path is returned, not the package at the beginning. If the optional 'forceload' argument is 1, we reload the module from disk (unless it's a dynamic extension).""" if forceload and path in sys.modules: # This is the only way to be sure. Checking the mtime of the file # isn't good enough (e.g. what if the module contains a class that # inherits from another module that has changed?). if path not in sys.builtin_module_names: # Python never loads a dynamic extension a second time from the # same path, even if the file is changed or missing. Deleting # the entry in sys.modules doesn't help for dynamic extensions, # so we're not even going to try to keep them up to date. info = inspect.getmoduleinfo(sys.modules[path].__file__) if info[3] != imp.C_EXTENSION: cache[path] = sys.modules[path] # prevent module from clearing del sys.modules[path] try: module = __import__(path) except: # Did the error occur before or after the module was found? (exc, value, tb) = info = sys.exc_info() if path in sys.modules: # An error occurred 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. return None else: # Some other error occurred during the importing process. raise ErrorDuringImport(path, sys.exc_info()) for part in split(path, '.')[1:]: try: module = getattr(module, part) except AttributeError: return None return module | f9929b400793cf586f0113f33d4a8fcd2ff5311d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/f9929b400793cf586f0113f33d4a8fcd2ff5311d/pydoc.py |
|
def __init__(self, locale_time=LocaleTime()): | def __init__(self, locale_time=None): | def __init__(self, locale_time=LocaleTime()): """Init inst with non-locale regexes and store LocaleTime object.""" #XXX: Does 'Y' need to worry about having less or more than 4 digits? base = super(TimeRE, self) base.__init__({ # The " \d" option is to make %c from ANSI C work 'd': r"(?P<d>3[0-1]|[1-2]\d|0[1-9]|[1-9]| [1-9])", 'H': r"(?P<H>2[0-3]|[0-1]\d|\d)", 'I': r"(?P<I>1[0-2]|0[1-9]|[1-9])", 'j': r"(?P<j>36[0-6]|3[0-5]\d|[1-2]\d\d|0[1-9]\d|00[1-9]|[1-9]\d|0[1-9]|[1-9])", 'm': r"(?P<m>1[0-2]|0[1-9]|[1-9])", 'M': r"(?P<M>[0-5]\d|\d)", 'S': r"(?P<S>6[0-1]|[0-5]\d|\d)", 'U': r"(?P<U>5[0-3]|[0-4]\d|\d)", 'w': r"(?P<w>[0-6])", # W is set below by using 'U' 'y': r"(?P<y>\d\d)", 'Y': r"(?P<Y>\d\d\d\d)"}) base.__setitem__('W', base.__getitem__('U')) self.locale_time = locale_time | 0c72a8cd5b15577d6ae7fcee04096c9e7201d14d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/0c72a8cd5b15577d6ae7fcee04096c9e7201d14d/_strptime.py |
self.locale_time = locale_time | if locale_time: self.locale_time = locale_time else: self.locale_time = LocaleTime() | def __init__(self, locale_time=LocaleTime()): """Init inst with non-locale regexes and store LocaleTime object.""" #XXX: Does 'Y' need to worry about having less or more than 4 digits? base = super(TimeRE, self) base.__init__({ # The " \d" option is to make %c from ANSI C work 'd': r"(?P<d>3[0-1]|[1-2]\d|0[1-9]|[1-9]| [1-9])", 'H': r"(?P<H>2[0-3]|[0-1]\d|\d)", 'I': r"(?P<I>1[0-2]|0[1-9]|[1-9])", 'j': r"(?P<j>36[0-6]|3[0-5]\d|[1-2]\d\d|0[1-9]\d|00[1-9]|[1-9]\d|0[1-9]|[1-9])", 'm': r"(?P<m>1[0-2]|0[1-9]|[1-9])", 'M': r"(?P<M>[0-5]\d|\d)", 'S': r"(?P<S>6[0-1]|[0-5]\d|\d)", 'U': r"(?P<U>5[0-3]|[0-4]\d|\d)", 'w': r"(?P<w>[0-6])", # W is set below by using 'U' 'y': r"(?P<y>\d\d)", 'Y': r"(?P<Y>\d\d\d\d)"}) base.__setitem__('W', base.__getitem__('U')) self.locale_time = locale_time | 0c72a8cd5b15577d6ae7fcee04096c9e7201d14d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/0c72a8cd5b15577d6ae7fcee04096c9e7201d14d/_strptime.py |
install = self.find_peer ('install') inputs = install.get_inputs () outputs = install.get_outputs () assert (len (inputs) == len (outputs)) | def run (self): | 54c7c4e402eaf3e8a11e2e86de977bcf04f3870e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/54c7c4e402eaf3e8a11e2e86de977bcf04f3870e/bdist_dumb.py |
|
self.strip_base_dirs (outputs, install) | install = self.distribution.find_command_obj('install') install.root = self.bdist_dir | def run (self): | 54c7c4e402eaf3e8a11e2e86de977bcf04f3870e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/54c7c4e402eaf3e8a11e2e86de977bcf04f3870e/bdist_dumb.py |
build_base = self.get_peer_option ('build', 'build_base') output_dir = os.path.join (build_base, "bdist") self.make_install_tree (output_dir, inputs, outputs) | self.announce ("installing to %s" % self.bdist_dir) install.ensure_ready() install.run() | def run (self): | 54c7c4e402eaf3e8a11e2e86de977bcf04f3870e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/54c7c4e402eaf3e8a11e2e86de977bcf04f3870e/bdist_dumb.py |
print "output_dir = %s" % output_dir | print "self.bdist_dir = %s" % self.bdist_dir | def run (self): | 54c7c4e402eaf3e8a11e2e86de977bcf04f3870e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/54c7c4e402eaf3e8a11e2e86de977bcf04f3870e/bdist_dumb.py |
root_dir=output_dir) | root_dir=self.bdist_dir) | def run (self): | 54c7c4e402eaf3e8a11e2e86de977bcf04f3870e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/54c7c4e402eaf3e8a11e2e86de977bcf04f3870e/bdist_dumb.py |
remove_tree (output_dir, self.verbose, self.dry_run) | remove_tree (self.bdist_dir, self.verbose, self.dry_run) | def run (self): | 54c7c4e402eaf3e8a11e2e86de977bcf04f3870e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/54c7c4e402eaf3e8a11e2e86de977bcf04f3870e/bdist_dumb.py |
def strip_base_dirs (self, outputs, install_cmd): base = install_cmd.install_base + os.sep platbase = install_cmd.install_platbase + os.sep b_len = len (base) pb_len = len (platbase) for i in range (len (outputs)): if outputs[i][0:b_len] == base: outputs[i] = outputs[i][b_len:] elif outputs[i][0:pb_len] == platbase: outputs[i] = outputs[i][pb_len:] else: raise DistutilsInternalError, \ ("installation output filename '%s' doesn't start " + "with either install_base ('%s') or " + "install_platbase ('%s')") % \ (outputs[i], base, platbase) def make_install_tree (self, output_dir, inputs, outputs): assert (len(inputs) == len(outputs)) create_tree (output_dir, outputs, verbose=self.verbose, dry_run=self.dry_run) if hasattr (os, 'link'): link = 'hard' msg = "making hard links in %s..." % output_dir else: link = None msg = "copying files to %s..." % output_dir for i in range (len(inputs)): output = os.path.join (output_dir, outputs[i]) self.copy_file (inputs[i], output, link=link) | def run (self): | 54c7c4e402eaf3e8a11e2e86de977bcf04f3870e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/54c7c4e402eaf3e8a11e2e86de977bcf04f3870e/bdist_dumb.py |
|
vrefnum, dirid = macfs.FindFolder(MACFS.kOnSystemDisk, MACFS.kSharedLibrariesFolderType, 0) fss = macfs.FSSpec((vrefnum, dirid, fname)) | vrefnum, dirid = macfs.FindFolder(MACFS.kLocalDomain, MACFS.kSharedLibrariesFolderType, 1) | def getextensiondirfile(fname): import macfs import MACFS try: vrefnum, dirid = macfs.FindFolder(MACFS.kOnSystemDisk, MACFS.kSharedLibrariesFolderType, 0) fss = macfs.FSSpec((vrefnum, dirid, fname)) except macfs.error: return None return fss.as_pathname() | 4751eaf9562ad3ae1ff0de1880ba5f5514cf63a8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/4751eaf9562ad3ae1ff0de1880ba5f5514cf63a8/ConfigurePython.py |
return None | try: vrefnum, dirid = macfs.FindFolder(MACFS.kOnSystemDisk, MACFS.kSharedLibrariesFolderType, 1) except macfs.error: return None fss = macfs.FSSpec((vrefnum, dirid, fname)) | def getextensiondirfile(fname): import macfs import MACFS try: vrefnum, dirid = macfs.FindFolder(MACFS.kOnSystemDisk, MACFS.kSharedLibrariesFolderType, 0) fss = macfs.FSSpec((vrefnum, dirid, fname)) except macfs.error: return None return fss.as_pathname() | 4751eaf9562ad3ae1ff0de1880ba5f5514cf63a8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/4751eaf9562ad3ae1ff0de1880ba5f5514cf63a8/ConfigurePython.py |
if oldcwd != newcwd: | if verbose: print "Not running as applet: Skipping check for preference file correctness." elif oldcwd != newcwd: sys.path.insert(0, os.path.join(oldcwd, ':Mac:Lib')) | def main(): verbose = 0 try: h = Res.GetResource('DLOG', SPLASH_COPYCORE) del h except Res.Error: verbose = 1 print "Not running as applet: verbose on" oldcwd = os.getcwd() os.chdir(sys.prefix) newcwd = os.getcwd() if oldcwd != newcwd: import Dlg rv = Dlg.CautionAlert(ALERT_NOTPYTHONFOLDER, None) if rv == ALERT_NOTPYTHONFOLDER_REMOVE_QUIT: import pythonprefs, preferences prefpathname = pythonprefs.pref_fss.as_pathname() os.remove(prefpathname) sys.exit(0) elif rv == ALERT_NOTPYTHONFOLDER_QUIT: sys.exit(0) sys.path.append('::Mac:Lib') import macostools # Create the PythonCore alias(es) MacOS.splash(SPLASH_COPYCORE) if verbose: print "Copying PythonCore..." n = 0 n = n + mkcorealias('PythonCore', 'PythonCore') n = n + mkcorealias('PythonCoreCarbon', 'PythonCoreCarbon') if n == 0: import Dlg Dlg.CautionAlert(ALERT_NOCORE, None) if verbose: print "Warning: PythonCore not copied to Extensions folder" if sys.argv[0][-7:] == 'Classic': do_classic = 1 elif sys.argv[0][-6:] == 'Carbon': do_classic = 0 else: print "I don't know the sys.argv[0] function", sys.argv[0] if verbose: print "Configure classic or carbon - ", rv = string.strip(sys.stdin.readline()) while rv and rv != "classic" and rv != "carbon": print "Configure classic or carbon - ", rv = string.strip(sys.stdin.readline()) if rv == "classic": do_classic = 1 elif rv == "carbon": do_classic = 0 else: return else: sys.exit(1) if do_classic: MacOS.splash(SPLASH_COPYCLASSIC) buildcopy(sys.prefix, None, [("PythonInterpreterClassic", "PythonInterpreter")]) else: MacOS.splash(SPLASH_COPYCARBON) buildcopy(sys.prefix, None, [("PythonInterpreterCarbon", "PythonInterpreter")]) MacOS.splash(SPLASH_BUILDAPPLETS) buildapplet(sys.prefix, None, APPLET_LIST) | 4751eaf9562ad3ae1ff0de1880ba5f5514cf63a8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/4751eaf9562ad3ae1ff0de1880ba5f5514cf63a8/ConfigurePython.py |
imageop.mono2grey(img, x, y, 0, 255) | return imageop.mono2grey(img, x, y, 0, 255) | def mono2grey(img, x, y): imageop.mono2grey(img, x, y, 0, 255) | 165ff53e905bd4c64920809458ffae2abf28dad2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/165ff53e905bd4c64920809458ffae2abf28dad2/imgconv.py |
if hasattr(object, '__doc__') and object.__doc__: lines = string.split(string.expandtabs(object.__doc__), '\n') | try: doc = object.__doc__ except AttributeError: return None if not isinstance(doc, (str, unicode)): return None try: lines = string.split(string.expandtabs(doc), '\n') except UnicodeError: return None else: | def getdoc(object): """Get the documentation string for an object. All tabs are expanded to spaces. To clean up docstrings that are indented to line up with blocks of code, any whitespace than can be uniformly removed from the second line onwards is removed.""" if hasattr(object, '__doc__') and object.__doc__: lines = string.split(string.expandtabs(object.__doc__), '\n') margin = None for line in lines[1:]: content = len(string.lstrip(line)) if not content: continue indent = len(line) - content if margin is None: margin = indent else: margin = min(margin, indent) if margin is not None: for i in range(1, len(lines)): lines[i] = lines[i][margin:] return string.join(lines, '\n') | 45c9b11867f6b4c15ace345163d9c82624d22da1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/45c9b11867f6b4c15ace345163d9c82624d22da1/inspect.py |
<style>TT { font-family: lucida console, lucida typewriter, courier }</style> </head><body bgcolor=" | <style type="text/css"><!-- TT { font-family: lucida console, lucida typewriter, courier } --></style></head><body bgcolor=" | def page(self, title, contents): """Format an HTML page.""" return ''' | 74c8389b13d177e8560524598e1bc08247df81b5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/74c8389b13d177e8560524598e1bc08247df81b5/pydoc.py |
if 0 and hasattr(object, '__all__'): | if 0 and hasattr(object, '__all__'): | 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) | 74c8389b13d177e8560524598e1bc08247df81b5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/74c8389b13d177e8560524598e1bc08247df81b5/pydoc.py |
result = result + '<p>%s\n' % self.small(doc) | result = result + '<p>%s</p>\n' % self.small(doc) | 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) | 74c8389b13d177e8560524598e1bc08247df81b5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/74c8389b13d177e8560524598e1bc08247df81b5/pydoc.py |
if not cl.__dict__.has_key(name): | if object.im_class is not cl: | 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 not cl.__dict__.has_key(name): 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 | 74c8389b13d177e8560524598e1bc08247df81b5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/74c8389b13d177e8560524598e1bc08247df81b5/pydoc.py |
reallink = '<a href="%s">%s</a>' % ( | reallink = '<a href=" | 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 not cl.__dict__.has_key(name): 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 | 74c8389b13d177e8560524598e1bc08247df81b5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/74c8389b13d177e8560524598e1bc08247df81b5/pydoc.py |
if not cl.__dict__.has_key(name): | if object.im_class is not cl: | def docroutine(self, object, name=None, cl=None): """Produce text documentation for a function or method object.""" realname = object.__name__ name = name or realname note = '' skipdocs = 0 if inspect.ismethod(object): if cl: if not cl.__dict__.has_key(name): base = object.im_class basename = base.__name__ if base.__module__ != cl.__module__: basename = base.__module__ + '.' + basename note = ' from %s' % basename skipdocs = 1 else: if object.im_self: note = ' method of %s' % self.repr(object.im_self) else: note = ' unbound %s method' % object.im_class.__name__ object = object.im_func | 74c8389b13d177e8560524598e1bc08247df81b5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/74c8389b13d177e8560524598e1bc08247df81b5/pydoc.py |
lib_dirs = self.compiler.library_dirs + ['/lib', '/usr/lib'] | lib_dirs = self.compiler.library_dirs + ['/lib', '/usr/lib', '/usr/lib/lib64'] | 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') | 1d03076a296c26a77058056cec5b3d72bbc2c88c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1d03076a296c26a77058056cec5b3d72bbc2c88c/setup.py |
return not not self.cl.methods | try: return not not self.cl.methods except AttributeError: return False | def IsExpandable(self): if self.cl: return not not self.cl.methods | 484c4b3f9581814f6a35a0384aa24ccdcbaf28f5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/484c4b3f9581814f6a35a0384aa24ccdcbaf28f5/ClassBrowser.py |
if (rframe is frame) and rcur: | if (rframe is not frame) and rcur: | def trace_dispatch_exception(self, frame, t): rt, rtt, rct, rfn, rframe, rcur = self.cur if (rframe is frame) and rcur: return self.trace_dispatch_return(rframe, t) return 0 | 7445ef642aee9f159351de36c9bfc89db630de45 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/7445ef642aee9f159351de36c9bfc89db630de45/profile.py |
"""Like nstransfercmd() but returns only the socket.""" | """Like ntransfercmd() but returns only the socket.""" | def transfercmd(self, cmd, rest=None): """Like nstransfercmd() but returns only the socket.""" return self.ntransfercmd(cmd, rest)[0] | 2af231ed915ea43d8f59608c9a57861032279a4a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2af231ed915ea43d8f59608c9a57861032279a4a/ftplib.py |
return int(resp[3:].strip()) | s = resp[3:].strip() try: return int(s) except OverflowError: return long(s) | def size(self, filename): '''Retrieve the size of a file.''' # Note that the RFC doesn't say anything about 'SIZE' resp = self.sendcmd('SIZE ' + filename) if resp[:3] == '213': return int(resp[3:].strip()) | 2af231ed915ea43d8f59608c9a57861032279a4a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2af231ed915ea43d8f59608c9a57861032279a4a/ftplib.py |
if m: return int(m.group(1)) return None | if not m: return None s = m.group(1) try: return int(s) except OverflowError: return long(s) | def parse150(resp): '''Parse the '150' response for a RETR request. Returns the expected transfer size or None; size is not guaranteed to be present in the 150 message. ''' if resp[:3] != '150': raise error_reply, resp global _150_re if _150_re is None: import re _150_re = re.compile("150 .* \((\d+) bytes\)", re.IGNORECASE) m = _150_re.match(resp) if m: return int(m.group(1)) return None | 2af231ed915ea43d8f59608c9a57861032279a4a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2af231ed915ea43d8f59608c9a57861032279a4a/ftplib.py |
def randrange(self, start, stop=None, step=1, int=int, default=None): """Choose a random item from range(start, stop[, step]). | 4375bb95cb95b6473e8daed25e60b53adfa45b05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/4375bb95cb95b6473e8daed25e60b53adfa45b05/random.py |
||
if istart < istop: return istart + int(self.random() * (istop - istart)) | def randrange(self, start, stop=None, step=1, int=int, default=None): """Choose a random item from range(start, stop[, step]). | 4375bb95cb95b6473e8daed25e60b53adfa45b05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/4375bb95cb95b6473e8daed25e60b53adfa45b05/random.py |
|
"""Return the sum of the two operands. | """Return the difference between the two operands. | def subtract(self, a, b): """Return the sum of the two operands. | 9637d4e9aaa92e64293b9e85f3c7464e9a61549f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9637d4e9aaa92e64293b9e85f3c7464e9a61549f/decimal.py |
u = madunicode(u"12345") verify(unicode(u) == u"12345") | base = u"12345" u = madunicode(base) verify(unicode(u) == base) | def rev(self): if self._rev is not None: return self._rev L = list(self) L.reverse() self._rev = self.__class__(u"".join(L)) return self._rev | 4aad21e293916bb61fd69748457c7a69c56195a5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/4aad21e293916bb61fd69748457c7a69c56195a5/test_descr.py |
currentThread() | def wait(self, timeout=None): currentThread() # for side-effect assert self._is_owned(), "wait() of un-acquire()d lock" waiter = _allocate_lock() waiter.acquire() self.__waiters.append(waiter) saved_state = self._release_save() try: # restore state no matter what (e.g., KeyboardInterrupt) if timeout is None: waiter.acquire() if __debug__: self._note("%s.wait(): got it", self) else: # Balancing act: We can't afford a pure busy loop, so we # have to sleep; but if we sleep the whole timeout time, # we'll be unresponsive. The scheme here sleeps very # little at first, longer as time goes on, but never longer # than 20 times per second (or the timeout time remaining). endtime = _time() + timeout delay = 0.0005 # 500 us -> initial delay of 1 ms while True: gotit = waiter.acquire(0) if gotit: break remaining = endtime - _time() if remaining <= 0: break delay = min(delay * 2, remaining, .05) _sleep(delay) if not gotit: if __debug__: self._note("%s.wait(%s): timed out", self, timeout) try: self.__waiters.remove(waiter) except ValueError: pass else: if __debug__: self._note("%s.wait(%s): got it", self, timeout) finally: self._acquire_restore(saved_state) | 6adbe2bcd5a868c5eacf7fc052b87305c4f34c22 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/6adbe2bcd5a868c5eacf7fc052b87305c4f34c22/threading.py |
|
currentThread() | def notify(self, n=1): currentThread() # for side-effect assert self._is_owned(), "notify() of un-acquire()d lock" __waiters = self.__waiters waiters = __waiters[:n] if not waiters: if __debug__: self._note("%s.notify(): no waiters", self) return self._note("%s.notify(): notifying %d waiter%s", self, n, n!=1 and "s" or "") for waiter in waiters: waiter.release() try: __waiters.remove(waiter) except ValueError: pass | 6adbe2bcd5a868c5eacf7fc052b87305c4f34c22 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/6adbe2bcd5a868c5eacf7fc052b87305c4f34c22/threading.py |
|
"[TARGETDIR]Lib;[TARGETDIR]DLLs;[TARGETDIR]lib-tk", "REGISTRY"), | r"[TARGETDIR]Lib;[TARGETDIR]DLLs;[TARGETDIR]Lib\lib-tk", "REGISTRY"), | # File extensions, associated with the REGISTRY.def component | 2ff13ad8d7fe9b432f5b6375fe1abf0d58ab305b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2ff13ad8d7fe9b432f5b6375fe1abf0d58ab305b/msi.py |
if isclass(object): | if hasattr(object, '__module__'): | def getmodule(object): """Return the module an object was defined in, or None if not found.""" if ismodule(object): return object if isclass(object): return sys.modules.get(object.__module__) try: file = getabsfile(object) except TypeError: return None if file in modulesbyfile: return sys.modules.get(modulesbyfile[file]) for module in sys.modules.values(): if hasattr(module, '__file__'): modulesbyfile[ os.path.realpath( getabsfile(module))] = module.__name__ if file in modulesbyfile: return sys.modules.get(modulesbyfile[file]) main = sys.modules['__main__'] if not hasattr(object, '__name__'): return None if hasattr(main, object.__name__): mainobject = getattr(main, object.__name__) if mainobject is object: return main builtin = sys.modules['__builtin__'] if hasattr(builtin, object.__name__): builtinobject = getattr(builtin, object.__name__) if builtinobject is object: return builtin | 60bc96404095e1f2b87a2014d6f6dfbcd42018f6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/60bc96404095e1f2b87a2014d6f6dfbcd42018f6/inspect.py |
def __init__(self, _class=Message.Message): | def __init__(self, _class=Message.Message, strict=1): | def __init__(self, _class=Message.Message): """Parser of RFC 2822 and MIME email messages. | a181f481971a60b4af42c0324ef552dcdb7800e3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a181f481971a60b4af42c0324ef552dcdb7800e3/Parser.py |
def parse(self, fp): | self._strict = strict def parse(self, fp, headersonly=0): | def __init__(self, _class=Message.Message): """Parser of RFC 2822 and MIME email messages. | a181f481971a60b4af42c0324ef552dcdb7800e3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a181f481971a60b4af42c0324ef552dcdb7800e3/Parser.py |
self._parsebody(root, fp) | if not headersonly: self._parsebody(root, fp) | def parse(self, fp): root = self._class() self._parseheaders(root, fp) self._parsebody(root, fp) return root | a181f481971a60b4af42c0324ef552dcdb7800e3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a181f481971a60b4af42c0324ef552dcdb7800e3/Parser.py |
def parsestr(self, text): return self.parse(StringIO(text)) | def parsestr(self, text, headersonly=0): return self.parse(StringIO(text), headersonly=headersonly) | def parsestr(self, text): return self.parse(StringIO(text)) | a181f481971a60b4af42c0324ef552dcdb7800e3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a181f481971a60b4af42c0324ef552dcdb7800e3/Parser.py |
else: | elif self._strict: | def _parseheaders(self, container, fp): # Parse the headers, returning a list of header/value pairs. None as # the header means the Unix-From header. lastheader = '' lastvalue = [] lineno = 0 while 1: # Don't strip the line before we test for the end condition, # because whitespace-only header lines are RFC compliant # continuation lines. line = fp.readline() if not line: break line = line.splitlines()[0] if not line: break # Ignore the trailing newline lineno += 1 # Check for initial Unix From_ line if line.startswith('From '): if lineno == 1: container.set_unixfrom(line) continue else: raise Errors.HeaderParseError( 'Unix-from in headers after first rfc822 header') # Header continuation line if line[0] in ' \t': if not lastheader: raise Errors.HeaderParseError( 'Continuation line seen before first header') lastvalue.append(line) continue # Normal, non-continuation header. BAW: this should check to make # sure it's a legal header, e.g. doesn't contain spaces. Also, we # should expose the header matching algorithm in the API, and # allow for a non-strict parsing mode (that ignores the line # instead of raising the exception). i = line.find(':') if i < 0: raise Errors.HeaderParseError( 'Not a header, not a continuation') if lastheader: container[lastheader] = NL.join(lastvalue) lastheader = line[:i] lastvalue = [line[i+1:].lstrip()] # Make sure we retain the last header if lastheader: container[lastheader] = NL.join(lastvalue) | a181f481971a60b4af42c0324ef552dcdb7800e3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a181f481971a60b4af42c0324ef552dcdb7800e3/Parser.py |
raise Errors.HeaderParseError( 'Not a header, not a continuation') | if self._strict: raise Errors.HeaderParseError( "Not a header, not a continuation: ``%s''"%line) elif lineno == 1 and line.startswith('--'): continue else: raise Errors.HeaderParseError( "Not a header, not a continuation: ``%s''"%line) | def _parseheaders(self, container, fp): # Parse the headers, returning a list of header/value pairs. None as # the header means the Unix-From header. lastheader = '' lastvalue = [] lineno = 0 while 1: # Don't strip the line before we test for the end condition, # because whitespace-only header lines are RFC compliant # continuation lines. line = fp.readline() if not line: break line = line.splitlines()[0] if not line: break # Ignore the trailing newline lineno += 1 # Check for initial Unix From_ line if line.startswith('From '): if lineno == 1: container.set_unixfrom(line) continue else: raise Errors.HeaderParseError( 'Unix-from in headers after first rfc822 header') # Header continuation line if line[0] in ' \t': if not lastheader: raise Errors.HeaderParseError( 'Continuation line seen before first header') lastvalue.append(line) continue # Normal, non-continuation header. BAW: this should check to make # sure it's a legal header, e.g. doesn't contain spaces. Also, we # should expose the header matching algorithm in the API, and # allow for a non-strict parsing mode (that ignores the line # instead of raising the exception). i = line.find(':') if i < 0: raise Errors.HeaderParseError( 'Not a header, not a continuation') if lastheader: container[lastheader] = NL.join(lastvalue) lastheader = line[:i] lastvalue = [line[i+1:].lstrip()] # Make sure we retain the last header if lastheader: container[lastheader] = NL.join(lastvalue) | a181f481971a60b4af42c0324ef552dcdb7800e3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a181f481971a60b4af42c0324ef552dcdb7800e3/Parser.py |
start += len(mo.group(0)) * (1 + isdigest) | start += len(mo.group(0)) | def _parsebody(self, container, fp): # Parse the body, but first split the payload on the content-type # boundary if present. boundary = container.get_boundary() isdigest = (container.get_type() == 'multipart/digest') # If there's a boundary, split the payload text into its constituent # parts and parse each separately. Otherwise, just parse the rest of # the body as a single message. Note: any exceptions raised in the # recursive parse need to have their line numbers coerced. if boundary: preamble = epilogue = None # Split into subparts. The first boundary we're looking for won't # have the leading newline since we're at the start of the body # text. separator = '--' + boundary payload = fp.read() start = payload.find(separator) if start < 0: raise Errors.BoundaryError( "Couldn't find starting boundary: %s" % boundary) if start > 0: # there's some pre-MIME boundary preamble preamble = payload[0:start] # Find out what kind of line endings we're using start += len(separator) cre = re.compile('\r\n|\r|\n') mo = cre.search(payload, start) if mo: start += len(mo.group(0)) * (1 + isdigest) # We create a compiled regexp first because we need to be able to # specify the start position, and the module function doesn't # support this signature. :( cre = re.compile('(?P<sep>\r\n|\r|\n)' + re.escape(separator) + '--') mo = cre.search(payload, start) if not mo: raise Errors.BoundaryError( "Couldn't find terminating boundary: %s" % boundary) terminator = mo.start() linesep = mo.group('sep') if mo.end() < len(payload): # there's some post-MIME boundary epilogue epilogue = payload[mo.end():] # We split the textual payload on the boundary separator, which # includes the trailing newline. If the container is a # multipart/digest then the subparts are by default message/rfc822 # instead of text/plain. In that case, they'll have an extra # newline before the headers to distinguish the message's headers # from the subpart headers. separator += linesep * (1 + isdigest) parts = payload[start:terminator].split(linesep + separator) for part in parts: msgobj = self.parsestr(part) container.preamble = preamble container.epilogue = epilogue container.attach(msgobj) elif container.get_main_type() == 'multipart': # Very bad. A message is a multipart with no boundary! raise Errors.BoundaryError( 'multipart message with no defined boundary') elif container.get_type() == 'message/delivery-status': # This special kind of type contains blocks of headers separated # by a blank line. We'll represent each header block as a # separate Message object blocks = [] while 1: blockmsg = self._class() self._parseheaders(blockmsg, fp) if not len(blockmsg): # No more header blocks left break blocks.append(blockmsg) container.set_payload(blocks) elif container.get_main_type() == 'message': # Create a container for the payload, but watch out for there not # being any headers left try: msg = self.parse(fp) except Errors.HeaderParseError: msg = self._class() self._parsebody(msg, fp) container.attach(msg) else: container.set_payload(fp.read()) | a181f481971a60b4af42c0324ef552dcdb7800e3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a181f481971a60b4af42c0324ef552dcdb7800e3/Parser.py |
if not mo: | if mo: terminator = mo.start() linesep = mo.group('sep') if mo.end() < len(payload): epilogue = payload[mo.end():] elif self._strict: | def _parsebody(self, container, fp): # Parse the body, but first split the payload on the content-type # boundary if present. boundary = container.get_boundary() isdigest = (container.get_type() == 'multipart/digest') # If there's a boundary, split the payload text into its constituent # parts and parse each separately. Otherwise, just parse the rest of # the body as a single message. Note: any exceptions raised in the # recursive parse need to have their line numbers coerced. if boundary: preamble = epilogue = None # Split into subparts. The first boundary we're looking for won't # have the leading newline since we're at the start of the body # text. separator = '--' + boundary payload = fp.read() start = payload.find(separator) if start < 0: raise Errors.BoundaryError( "Couldn't find starting boundary: %s" % boundary) if start > 0: # there's some pre-MIME boundary preamble preamble = payload[0:start] # Find out what kind of line endings we're using start += len(separator) cre = re.compile('\r\n|\r|\n') mo = cre.search(payload, start) if mo: start += len(mo.group(0)) * (1 + isdigest) # We create a compiled regexp first because we need to be able to # specify the start position, and the module function doesn't # support this signature. :( cre = re.compile('(?P<sep>\r\n|\r|\n)' + re.escape(separator) + '--') mo = cre.search(payload, start) if not mo: raise Errors.BoundaryError( "Couldn't find terminating boundary: %s" % boundary) terminator = mo.start() linesep = mo.group('sep') if mo.end() < len(payload): # there's some post-MIME boundary epilogue epilogue = payload[mo.end():] # We split the textual payload on the boundary separator, which # includes the trailing newline. If the container is a # multipart/digest then the subparts are by default message/rfc822 # instead of text/plain. In that case, they'll have an extra # newline before the headers to distinguish the message's headers # from the subpart headers. separator += linesep * (1 + isdigest) parts = payload[start:terminator].split(linesep + separator) for part in parts: msgobj = self.parsestr(part) container.preamble = preamble container.epilogue = epilogue container.attach(msgobj) elif container.get_main_type() == 'multipart': # Very bad. A message is a multipart with no boundary! raise Errors.BoundaryError( 'multipart message with no defined boundary') elif container.get_type() == 'message/delivery-status': # This special kind of type contains blocks of headers separated # by a blank line. We'll represent each header block as a # separate Message object blocks = [] while 1: blockmsg = self._class() self._parseheaders(blockmsg, fp) if not len(blockmsg): # No more header blocks left break blocks.append(blockmsg) container.set_payload(blocks) elif container.get_main_type() == 'message': # Create a container for the payload, but watch out for there not # being any headers left try: msg = self.parse(fp) except Errors.HeaderParseError: msg = self._class() self._parsebody(msg, fp) container.attach(msg) else: container.set_payload(fp.read()) | a181f481971a60b4af42c0324ef552dcdb7800e3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a181f481971a60b4af42c0324ef552dcdb7800e3/Parser.py |
"Couldn't find terminating boundary: %s" % boundary) terminator = mo.start() linesep = mo.group('sep') if mo.end() < len(payload): epilogue = payload[mo.end():] | "Couldn't find terminating boundary: %s" % boundary) else: endre = re.compile('(?P<sep>\r\n|\r|\n){2}$') mo = endre.search(payload) if not mo: raise Errors.BoundaryError( "Couldn't find terminating boundary, and no "+ "trailing empty line") else: linesep = mo.group('sep') terminator = len(payload) | def _parsebody(self, container, fp): # Parse the body, but first split the payload on the content-type # boundary if present. boundary = container.get_boundary() isdigest = (container.get_type() == 'multipart/digest') # If there's a boundary, split the payload text into its constituent # parts and parse each separately. Otherwise, just parse the rest of # the body as a single message. Note: any exceptions raised in the # recursive parse need to have their line numbers coerced. if boundary: preamble = epilogue = None # Split into subparts. The first boundary we're looking for won't # have the leading newline since we're at the start of the body # text. separator = '--' + boundary payload = fp.read() start = payload.find(separator) if start < 0: raise Errors.BoundaryError( "Couldn't find starting boundary: %s" % boundary) if start > 0: # there's some pre-MIME boundary preamble preamble = payload[0:start] # Find out what kind of line endings we're using start += len(separator) cre = re.compile('\r\n|\r|\n') mo = cre.search(payload, start) if mo: start += len(mo.group(0)) * (1 + isdigest) # We create a compiled regexp first because we need to be able to # specify the start position, and the module function doesn't # support this signature. :( cre = re.compile('(?P<sep>\r\n|\r|\n)' + re.escape(separator) + '--') mo = cre.search(payload, start) if not mo: raise Errors.BoundaryError( "Couldn't find terminating boundary: %s" % boundary) terminator = mo.start() linesep = mo.group('sep') if mo.end() < len(payload): # there's some post-MIME boundary epilogue epilogue = payload[mo.end():] # We split the textual payload on the boundary separator, which # includes the trailing newline. If the container is a # multipart/digest then the subparts are by default message/rfc822 # instead of text/plain. In that case, they'll have an extra # newline before the headers to distinguish the message's headers # from the subpart headers. separator += linesep * (1 + isdigest) parts = payload[start:terminator].split(linesep + separator) for part in parts: msgobj = self.parsestr(part) container.preamble = preamble container.epilogue = epilogue container.attach(msgobj) elif container.get_main_type() == 'multipart': # Very bad. A message is a multipart with no boundary! raise Errors.BoundaryError( 'multipart message with no defined boundary') elif container.get_type() == 'message/delivery-status': # This special kind of type contains blocks of headers separated # by a blank line. We'll represent each header block as a # separate Message object blocks = [] while 1: blockmsg = self._class() self._parseheaders(blockmsg, fp) if not len(blockmsg): # No more header blocks left break blocks.append(blockmsg) container.set_payload(blocks) elif container.get_main_type() == 'message': # Create a container for the payload, but watch out for there not # being any headers left try: msg = self.parse(fp) except Errors.HeaderParseError: msg = self._class() self._parsebody(msg, fp) container.attach(msg) else: container.set_payload(fp.read()) | a181f481971a60b4af42c0324ef552dcdb7800e3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a181f481971a60b4af42c0324ef552dcdb7800e3/Parser.py |
separator += linesep * (1 + isdigest) | separator += linesep | def _parsebody(self, container, fp): # Parse the body, but first split the payload on the content-type # boundary if present. boundary = container.get_boundary() isdigest = (container.get_type() == 'multipart/digest') # If there's a boundary, split the payload text into its constituent # parts and parse each separately. Otherwise, just parse the rest of # the body as a single message. Note: any exceptions raised in the # recursive parse need to have their line numbers coerced. if boundary: preamble = epilogue = None # Split into subparts. The first boundary we're looking for won't # have the leading newline since we're at the start of the body # text. separator = '--' + boundary payload = fp.read() start = payload.find(separator) if start < 0: raise Errors.BoundaryError( "Couldn't find starting boundary: %s" % boundary) if start > 0: # there's some pre-MIME boundary preamble preamble = payload[0:start] # Find out what kind of line endings we're using start += len(separator) cre = re.compile('\r\n|\r|\n') mo = cre.search(payload, start) if mo: start += len(mo.group(0)) * (1 + isdigest) # We create a compiled regexp first because we need to be able to # specify the start position, and the module function doesn't # support this signature. :( cre = re.compile('(?P<sep>\r\n|\r|\n)' + re.escape(separator) + '--') mo = cre.search(payload, start) if not mo: raise Errors.BoundaryError( "Couldn't find terminating boundary: %s" % boundary) terminator = mo.start() linesep = mo.group('sep') if mo.end() < len(payload): # there's some post-MIME boundary epilogue epilogue = payload[mo.end():] # We split the textual payload on the boundary separator, which # includes the trailing newline. If the container is a # multipart/digest then the subparts are by default message/rfc822 # instead of text/plain. In that case, they'll have an extra # newline before the headers to distinguish the message's headers # from the subpart headers. separator += linesep * (1 + isdigest) parts = payload[start:terminator].split(linesep + separator) for part in parts: msgobj = self.parsestr(part) container.preamble = preamble container.epilogue = epilogue container.attach(msgobj) elif container.get_main_type() == 'multipart': # Very bad. A message is a multipart with no boundary! raise Errors.BoundaryError( 'multipart message with no defined boundary') elif container.get_type() == 'message/delivery-status': # This special kind of type contains blocks of headers separated # by a blank line. We'll represent each header block as a # separate Message object blocks = [] while 1: blockmsg = self._class() self._parseheaders(blockmsg, fp) if not len(blockmsg): # No more header blocks left break blocks.append(blockmsg) container.set_payload(blocks) elif container.get_main_type() == 'message': # Create a container for the payload, but watch out for there not # being any headers left try: msg = self.parse(fp) except Errors.HeaderParseError: msg = self._class() self._parsebody(msg, fp) container.attach(msg) else: container.set_payload(fp.read()) | a181f481971a60b4af42c0324ef552dcdb7800e3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a181f481971a60b4af42c0324ef552dcdb7800e3/Parser.py |
msgobj = self.parsestr(part) | if isdigest: if part[0] == linesep: msgobj = self._class() part = part[1:] else: parthdrs, part = part.split(linesep+linesep, 1) msgobj = self.parsestr(parthdrs, headersonly=1) submsgobj = self.parsestr(part) msgobj.attach(submsgobj) msgobj.set_default_type('message/rfc822') else: msgobj = self.parsestr(part) | def _parsebody(self, container, fp): # Parse the body, but first split the payload on the content-type # boundary if present. boundary = container.get_boundary() isdigest = (container.get_type() == 'multipart/digest') # If there's a boundary, split the payload text into its constituent # parts and parse each separately. Otherwise, just parse the rest of # the body as a single message. Note: any exceptions raised in the # recursive parse need to have their line numbers coerced. if boundary: preamble = epilogue = None # Split into subparts. The first boundary we're looking for won't # have the leading newline since we're at the start of the body # text. separator = '--' + boundary payload = fp.read() start = payload.find(separator) if start < 0: raise Errors.BoundaryError( "Couldn't find starting boundary: %s" % boundary) if start > 0: # there's some pre-MIME boundary preamble preamble = payload[0:start] # Find out what kind of line endings we're using start += len(separator) cre = re.compile('\r\n|\r|\n') mo = cre.search(payload, start) if mo: start += len(mo.group(0)) * (1 + isdigest) # We create a compiled regexp first because we need to be able to # specify the start position, and the module function doesn't # support this signature. :( cre = re.compile('(?P<sep>\r\n|\r|\n)' + re.escape(separator) + '--') mo = cre.search(payload, start) if not mo: raise Errors.BoundaryError( "Couldn't find terminating boundary: %s" % boundary) terminator = mo.start() linesep = mo.group('sep') if mo.end() < len(payload): # there's some post-MIME boundary epilogue epilogue = payload[mo.end():] # We split the textual payload on the boundary separator, which # includes the trailing newline. If the container is a # multipart/digest then the subparts are by default message/rfc822 # instead of text/plain. In that case, they'll have an extra # newline before the headers to distinguish the message's headers # from the subpart headers. separator += linesep * (1 + isdigest) parts = payload[start:terminator].split(linesep + separator) for part in parts: msgobj = self.parsestr(part) container.preamble = preamble container.epilogue = epilogue container.attach(msgobj) elif container.get_main_type() == 'multipart': # Very bad. A message is a multipart with no boundary! raise Errors.BoundaryError( 'multipart message with no defined boundary') elif container.get_type() == 'message/delivery-status': # This special kind of type contains blocks of headers separated # by a blank line. We'll represent each header block as a # separate Message object blocks = [] while 1: blockmsg = self._class() self._parseheaders(blockmsg, fp) if not len(blockmsg): # No more header blocks left break blocks.append(blockmsg) container.set_payload(blocks) elif container.get_main_type() == 'message': # Create a container for the payload, but watch out for there not # being any headers left try: msg = self.parse(fp) except Errors.HeaderParseError: msg = self._class() self._parsebody(msg, fp) container.attach(msg) else: container.set_payload(fp.read()) | a181f481971a60b4af42c0324ef552dcdb7800e3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a181f481971a60b4af42c0324ef552dcdb7800e3/Parser.py |
funcid, " ".join(self._subst_format))) | funcid, self._subst_format_str)) | def _bind(self, what, sequence, func, add, needcleanup=1): """Internal function.""" if type(func) is StringType: self.tk.call(what + (sequence, func)) elif func: funcid = self._register(func, self._substitute, needcleanup) cmd = ('%sif {"[%s %s]" == "break"} break\n' % (add and '+' or '', funcid, " ".join(self._subst_format))) self.tk.call(what + (sequence, cmd)) return funcid elif sequence: return self.tk.call(what + (sequence,)) else: return self.tk.splitlist(self.tk.call(what)) | 255a53229d673fcbc8ea01c01fdff6b0cd9dff40 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/255a53229d673fcbc8ea01c01fdff6b0cd9dff40/Tkinter.py |
def startElement(self, name, tagName, attrs): | def startElement(self, name, attrs): | def startElement(self, name, tagName, attrs): if not hasattr(self, "curNode"): # FIXME: hack! self.startDocument() | 2000138a82287e905603626bfdaf81af44e0fcd8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2000138a82287e905603626bfdaf81af44e0fcd8/pulldom.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.