rem
stringlengths 1
322k
| add
stringlengths 0
2.05M
| context
stringlengths 4
228k
| meta
stringlengths 156
215
|
---|---|---|---|
if type(ob)==types.ClassType: | if type(ob) in (types.ClassType, types.TypeType): | def get_arg_text(ob): """Get a string describing the arguments for the given object""" argText = "" if ob is not None: argOffset = 0 if type(ob)==types.ClassType: # Look for the highest __init__ in the class chain. fob = _find_constructor(ob) if fob is None: fob = lambda: None else: argOffset = 1 elif type(ob)==types.MethodType: # bit of a hack for methods - turn it into a function # but we drop the "self" param. fob = ob.im_func argOffset = 1 else: fob = ob # Try and build one for Python defined functions if type(fob) in [types.FunctionType, types.LambdaType]: try: realArgs = fob.func_code.co_varnames[argOffset:fob.func_code.co_argcount] defaults = fob.func_defaults or [] defaults = list(map(lambda name: "=%s" % repr(name), defaults)) defaults = [""] * (len(realArgs)-len(defaults)) + defaults items = map(lambda arg, dflt: arg+dflt, realArgs, defaults) if fob.func_code.co_flags & 0x4: items.append("...") if fob.func_code.co_flags & 0x8: items.append("***") argText = ", ".join(items) argText = "(%s)" % argText except: pass # See if we can use the docstring doc = getattr(ob, "__doc__", "") if doc: doc = doc.lstrip() pos = doc.find("\n") if pos < 0 or pos > 70: pos = 70 if argText: argText += "\n" argText += doc[:pos] return argText | c6bacd5606cbf3f76ae7e116e425a61d291c68fc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c6bacd5606cbf3f76ae7e116e425a61d291c68fc/CallTips.py |
def checkSetMinor(self): | def test_checkSetMinor(self): | def checkSetMinor(self): au = MIMEAudio(self._audiodata, 'fish') self.assertEqual(im.get_type(), 'audio/fish') | 422b10fc259f2f36afbaa2a00b51011d88fbfee3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/422b10fc259f2f36afbaa2a00b51011d88fbfee3/test_email.py |
self.assertEqual(im.get_type(), 'audio/fish') | self.assertEqual(au.get_type(), 'audio/fish') | def checkSetMinor(self): au = MIMEAudio(self._audiodata, 'fish') self.assertEqual(im.get_type(), 'audio/fish') | 422b10fc259f2f36afbaa2a00b51011d88fbfee3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/422b10fc259f2f36afbaa2a00b51011d88fbfee3/test_email.py |
def checkSetMinor(self): | def test_checkSetMinor(self): | def checkSetMinor(self): im = MIMEImage(self._imgdata, 'fish') self.assertEqual(im.get_type(), 'image/fish') | 422b10fc259f2f36afbaa2a00b51011d88fbfee3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/422b10fc259f2f36afbaa2a00b51011d88fbfee3/test_email.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') | 240083177368a929a4ab15098a94b0a6f71aeeed /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/240083177368a929a4ab15098a94b0a6f71aeeed/inspect.py |
This (mostly) supports the API for Cryptographic Hash Functions (PEP 247). | This supports the API for Cryptographic Hash Functions (PEP 247). | def _strxor(s1, s2): """Utility method. XOR the two strings s1 and s2 (must have same length). """ return "".join(map(lambda x, y: chr(ord(x) ^ ord(y)), s1, s2)) | 1ccdff90bb1beb27ff9592fe7d02f80d32b78373 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1ccdff90bb1beb27ff9592fe7d02f80d32b78373/hmac.py |
self.digest_size = digestmod.digest_size | def __init__(self, key, msg = None, digestmod = None): """Create a new HMAC object. | 1ccdff90bb1beb27ff9592fe7d02f80d32b78373 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1ccdff90bb1beb27ff9592fe7d02f80d32b78373/hmac.py |
|
return HMAC(self) | other = HMAC("") other.digestmod = self.digestmod other.inner = self.inner.copy() other.outer = self.outer.copy() return other | def copy(self): """Return a separate copy of this hashing object. | 1ccdff90bb1beb27ff9592fe7d02f80d32b78373 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1ccdff90bb1beb27ff9592fe7d02f80d32b78373/hmac.py |
def test(): def md5test(key, data, digest): h = HMAC(key, data) assert(h.hexdigest().upper() == digest.upper()) md5test(chr(0x0b) * 16, "Hi There", "9294727A3638BB1C13F48EF8158BFC9D") md5test("Jefe", "what do ya want for nothing?", "750c783e6ab0b503eaa86e310a5db738") md5test(chr(0xAA)*16, chr(0xDD)*50, "56be34521d144c88dbb8c733f0e8b3f6") if __name__ == "__main__": test() | def test(): def md5test(key, data, digest): h = HMAC(key, data) assert(h.hexdigest().upper() == digest.upper()) # Test vectors from the RFC md5test(chr(0x0b) * 16, "Hi There", "9294727A3638BB1C13F48EF8158BFC9D") md5test("Jefe", "what do ya want for nothing?", "750c783e6ab0b503eaa86e310a5db738") md5test(chr(0xAA)*16, chr(0xDD)*50, "56be34521d144c88dbb8c733f0e8b3f6") | 1ccdff90bb1beb27ff9592fe7d02f80d32b78373 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1ccdff90bb1beb27ff9592fe7d02f80d32b78373/hmac.py |
|
def _show(title=None, message=None, icon=None, type=None, **options): if icon: options["icon"] = icon if type: options["type"] = type | def _show(title=None, message=None, _icon=None, _type=None, **options): if _icon and "icon" not in options: options["icon"] = _icon if _type and "type" not in options: options["type"] = _type | def _show(title=None, message=None, icon=None, type=None, **options): if icon: options["icon"] = icon if type: options["type"] = type if title: options["title"] = title if message: options["message"] = message res = Message(**options).show() # In some Tcl installations, Tcl converts yes/no into a boolean if isinstance(res, bool): if res: return YES return NO return res | 6fb20aa92ce6497bf5c065ca34e2a9fdf02e300e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6fb20aa92ce6497bf5c065ca34e2a9fdf02e300e/tkMessageBox.py |
return Carbon.Files.ResolveAliasFile(fss, chain) | return Carbon.File.ResolveAliasFile(fss, chain) | def ResolveAliasFile(fss, chain=1): return Carbon.Files.ResolveAliasFile(fss, chain) | e77f58a2be1c70af4cf4dfdb2bca041876de5b49 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e77f58a2be1c70af4cf4dfdb2bca041876de5b49/macfs.py |
if __name__ == "__main__": | def test_main(): | def get_file(): return __file__ | 5c1ba53f8ca219a22d964324abb76a055ad19feb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5c1ba53f8ca219a22d964324abb76a055ad19feb/test_zipimport.py |
if self.compiler.find_library_file(lib_dirs, 'db-3.1'): | if self.compiler.find_library_file(lib_dirs, 'db-3.2'): dblib = ['db-3.2'] elif self.compiler.find_library_file(lib_dirs, 'db-3.1'): | def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.insert(0, '/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.insert(0, '/usr/local/include' ) | f5c76776023e925deac6391546bcb85cd0c2424c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f5c76776023e925deac6391546bcb85cd0c2424c/setup.py |
'$CC -Wl,-t -o /dev/null 2>&1 -l' + name | '$CC -Wl,-t -o ' + ccout + ' 2>&1 -l' + name | def _findLib_gcc(name): expr = '[^\(\)\s]*lib%s\.[^\(\)\s]*' % name cmd = 'if type gcc &>/dev/null; then CC=gcc; else CC=cc; fi;' \ '$CC -Wl,-t -o /dev/null 2>&1 -l' + name try: fdout, outfile = tempfile.mkstemp() fd = os.popen(cmd) trace = fd.read() err = fd.close() finally: try: os.unlink(outfile) except OSError, e: if e.errno != errno.ENOENT: raise res = re.search(expr, trace) if not res: return None return res.group(0) | 2bdf29ec28fa5f5284d57672d63fdd8402030a92 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2bdf29ec28fa5f5284d57672d63fdd8402030a92/util.py |
tabnanny.reset_globals() | def tabnanny(self, filename): import tabnanny import tokenize tabnanny.reset_globals() f = open(filename, 'r') try: tokenize.tokenize(f.readline, tabnanny.tokeneater) except tokenize.TokenError, msg: self.errorbox("Token error", "Token error:\n%s" % str(msg)) return 0 except tabnanny.NannyNag, nag: # The error messages from tabnanny are too confusing... self.editwin.gotoline(nag.get_lineno()) self.errorbox("Tab/space error", indent_message) return 0 return 1 | 44b1e7d8403558e945f796fec897d7862c9cec8a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/44b1e7d8403558e945f796fec897d7862c9cec8a/ScriptBinding.py |
|
tokenize.tokenize(f.readline, tabnanny.tokeneater) | tabnanny.process_tokens(tokenize.generate_tokens(f.readline)) | def tabnanny(self, filename): import tabnanny import tokenize tabnanny.reset_globals() f = open(filename, 'r') try: tokenize.tokenize(f.readline, tabnanny.tokeneater) except tokenize.TokenError, msg: self.errorbox("Token error", "Token error:\n%s" % str(msg)) return 0 except tabnanny.NannyNag, nag: # The error messages from tabnanny are too confusing... self.editwin.gotoline(nag.get_lineno()) self.errorbox("Tab/space error", indent_message) return 0 return 1 | 44b1e7d8403558e945f796fec897d7862c9cec8a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/44b1e7d8403558e945f796fec897d7862c9cec8a/ScriptBinding.py |
if part: self._hit(part) | def hitter(ctl, part, self=self): if part: self._hit(part) | ad1654e03aca95f8d5cad75ad377c3b67cb73f91 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ad1654e03aca95f8d5cad75ad377c3b67cb73f91/Wcontrols.py |
|
fullname = '.'.join(path)+'.'+name | fullname = string.join(path, '.')+'.'+name | def find_module(self, name, path): if path: fullname = '.'.join(path)+'.'+name else: fullname = name if fullname in self.excludes: self.msgout(3, "find_module -> Excluded", fullname) raise ImportError, name | 4f7829e185db9250349917a27be557721b1752ed /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4f7829e185db9250349917a27be557721b1752ed/modulefinder.py |
def seek(self, pos, whence=0): if whence==1: self.pos = self.pos + pos if whence==2: self.pos = self.stop + pos else: self.pos = self.start + pos | def __init__(self, fp, factory=rfc822.Message): self.fp = fp self.seekp = 0 self.factory = factory | 2b5ff073ab9c232307f82dfd1cab0589ef293df5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2b5ff073ab9c232307f82dfd1cab0589ef293df5/mailbox.py |
|
"""Return the creation time of a file, reported by os.stat().""" | """Return the metadata change time of a file, reported by os.stat().""" | def getctime(filename): """Return the creation time of a file, reported by os.stat().""" return os.stat(filename).st_ctime | 1cd6e4dc38c7f7de3b39d93cb503ee2058662bcd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1cd6e4dc38c7f7de3b39d93cb503ee2058662bcd/posixpath.py |
verify (D().meth(4) == "D(4)C(4)B(4)A(4)") | vereq(D().meth(4), "D(4)C(4)B(4)A(4)") class mysuper(super): def __init__(self, *args): return super(mysuper, self).__init__(*args) class E(D): def meth(self, a): return "E(%r)" % a + mysuper(E, self).meth(a) vereq(E().meth(5), "E(5)D(5)C(5)B(5)A(5)") class F(E): def meth(self, a): s = self.__super return "F(%r)[%s]" % (a, s.__class__.__name__) + s.meth(a) F._F__super = mysuper(F) vereq(F().meth(6), "F(6)[mysuper]E(6)D(6)C(6)B(6)A(6)") try: super(D, 42) except TypeError: pass else: raise TestFailed, "shouldn't allow super(D, 42)" try: super(D, C()) except TypeError: pass else: raise TestFailed, "shouldn't allow super(D, C())" try: super(D).__get__(12) except TypeError: pass else: raise TestFailed, "shouldn't allow super(D).__get__(12)" try: super(D).__get__(C()) except TypeError: pass else: raise TestFailed, "shouldn't allow super(D).__get__(C())" | def meth(self, a): return "D(%r)" % a + super(D, self).meth(a) | 5b443c6282e8ffd6873005b62c50e56fa149e277 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5b443c6282e8ffd6873005b62c50e56fa149e277/test_descr.py |
raise SMTPServerDisconnected | raise SMTPServerDisconnected('Server not connected') | def send(self, str): """Send `str' to the server.""" if self.debuglevel > 0: print 'send:', `str` if self.sock: try: self.sock.send(str) except socket.error: raise SMTPServerDisconnected else: raise SMTPServerDisconnected | 40233ea70a1e66e172e8524f3458fff8bd148b4c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/40233ea70a1e66e172e8524f3458fff8bd148b4c/smtplib.py |
raise SMTPServerDisconnected | raise SMTPServerDisconnected('please run connect() first') | def send(self, str): """Send `str' to the server.""" if self.debuglevel > 0: print 'send:', `str` if self.sock: try: self.sock.send(str) except socket.error: raise SMTPServerDisconnected else: raise SMTPServerDisconnected | 40233ea70a1e66e172e8524f3458fff8bd148b4c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/40233ea70a1e66e172e8524f3458fff8bd148b4c/smtplib.py |
raise SMTPServerDisconnected | raise SMTPServerDisconnected("Server not connected") | def ehlo(self, name=''): """ SMTP 'ehlo' command. Hostname to send for this command defaults to the FQDN of the local host. """ name=string.strip(name) if len(name)==0: name=socket.gethostbyaddr(socket.gethostname())[0] self.putcmd("ehlo",name) (code,msg)=self.getreply() # According to RFC1869 some (badly written) # MTA's will disconnect on an ehlo. Toss an exception if # that happens -ddm if code == -1 and len(msg) == 0: raise SMTPServerDisconnected self.ehlo_resp=msg if code<>250: return code self.does_esmtp=1 #parse the ehlo responce -ddm resp=string.split(self.ehlo_resp,'\n') del resp[0] for each in resp: m=re.match(r'(?P<feature>[A-Za-z0-9][A-Za-z0-9\-]*)',each) if m: feature=string.lower(m.group("feature")) params=string.strip(m.string[m.end("feature"):]) self.esmtp_features[feature]=params return code | 40233ea70a1e66e172e8524f3458fff8bd148b4c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/40233ea70a1e66e172e8524f3458fff8bd148b4c/smtplib.py |
raise SMTPSenderRefused | raise SMTPSenderRefused('%s: %s' % (from_addr, resp)) | def sendmail(self, from_addr, to_addrs, msg, mail_options=[], rcpt_options=[]): """This command performs an entire mail transaction. | 40233ea70a1e66e172e8524f3458fff8bd148b4c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/40233ea70a1e66e172e8524f3458fff8bd148b4c/smtplib.py |
raise SMTPRecipientsRefused | raise SMTPRecipientsRefused(string.join( map(lambda x:"%s: %s" % (x[0], x[1][1]), senderrs.items()), '; ')) | def sendmail(self, from_addr, to_addrs, msg, mail_options=[], rcpt_options=[]): """This command performs an entire mail transaction. | 40233ea70a1e66e172e8524f3458fff8bd148b4c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/40233ea70a1e66e172e8524f3458fff8bd148b4c/smtplib.py |
raise SMTPDataError | raise SMTPDataError('data transmission error: %s' % code) | def sendmail(self, from_addr, to_addrs, msg, mail_options=[], rcpt_options=[]): """This command performs an entire mail transaction. | 40233ea70a1e66e172e8524f3458fff8bd148b4c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/40233ea70a1e66e172e8524f3458fff8bd148b4c/smtplib.py |
self.simpleElement("real", str(value)) | self.simpleElement("real", repr(value)) | def writeValue(self, value): if isinstance(value, (str, unicode)): self.simpleElement("string", value) elif isinstance(value, bool): # must switch for bool before int, as bool is a # subclass of int... if value: self.simpleElement("true") else: self.simpleElement("false") elif isinstance(value, int): self.simpleElement("integer", str(value)) elif isinstance(value, float): # should perhaps use repr() for better precision? self.simpleElement("real", str(value)) elif isinstance(value, dict): self.writeDict(value) elif isinstance(value, Data): self.writeData(value) elif isinstance(value, Date): self.simpleElement("date", value.toString()) elif isinstance(value, (tuple, list)): self.writeArray(value) else: raise TypeError("unsuported type: %s" % type(value)) | 95387a18956b2ab60709a79aaa93cfddec8978d9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/95387a18956b2ab60709a79aaa93cfddec8978d9/plistlib.py |
import base64 | def fromBase64(cls, data): import base64 return cls(base64.decodestring(data)) | 95387a18956b2ab60709a79aaa93cfddec8978d9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/95387a18956b2ab60709a79aaa93cfddec8978d9/plistlib.py |
|
import base64 | def asBase64(self): import base64 return base64.encodestring(self.data) | 95387a18956b2ab60709a79aaa93cfddec8978d9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/95387a18956b2ab60709a79aaa93cfddec8978d9/plistlib.py |
|
"""Primitive date wrapper, uses time floats internally, is agnostic about time zones. | """Primitive date wrapper, uses UTC datetime instances internally. | def __repr__(self): return "%s(%s)" % (self.__class__.__name__, repr(self.data)) | 95387a18956b2ab60709a79aaa93cfddec8978d9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/95387a18956b2ab60709a79aaa93cfddec8978d9/plistlib.py |
if isinstance(date, str): from xml.utils.iso8601 import parse date = parse(date) | if isinstance(date, datetime.datetime): pass elif isinstance(date, (float, int)): date = datetime.datetime.fromtimestamp(date) elif isinstance(date, basestring): order = ('year', 'month', 'day', 'hour', 'minute', 'second') gd = _dateParser.match(date).groupdict() lst = [] for key in order: val = gd[key] if val is None: break lst.append(int(val)) date = datetime.datetime(*lst) else: raise ValueError, "Can't convert %r to datetime" % (date,) | def __init__(self, date): if isinstance(date, str): from xml.utils.iso8601 import parse date = parse(date) self.date = date | 95387a18956b2ab60709a79aaa93cfddec8978d9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/95387a18956b2ab60709a79aaa93cfddec8978d9/plistlib.py |
from xml.utils.iso8601 import tostring return tostring(self.date) | d = self.date return '%04d-%02d-%02dT%02d:%02d:%02dZ' % ( d.year, d.month, d.day, d.second, d.minute, d.hour, ) | def toString(self): from xml.utils.iso8601 import tostring return tostring(self.date) | 95387a18956b2ab60709a79aaa93cfddec8978d9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/95387a18956b2ab60709a79aaa93cfddec8978d9/plistlib.py |
elif isinstance(other, (int, float)): return cmp(self.date, other) | elif isinstance(other, (datetime.datetime, float, int, basestring)): return cmp(self.date, Date(other).date) | def __cmp__(self, other): if isinstance(other, self.__class__): return cmp(self.date, other.date) elif isinstance(other, (int, float)): return cmp(self.date, other) else: return cmp(id(self), id(other)) | 95387a18956b2ab60709a79aaa93cfddec8978d9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/95387a18956b2ab60709a79aaa93cfddec8978d9/plistlib.py |
def parse(self, file): | def parse(self, fileobj): | def parse(self, file): from xml.parsers.expat import ParserCreate parser = ParserCreate() parser.StartElementHandler = self.handleBeginElement parser.EndElementHandler = self.handleEndElement parser.CharacterDataHandler = self.handleData parser.ParseFile(file) return self.root | 95387a18956b2ab60709a79aaa93cfddec8978d9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/95387a18956b2ab60709a79aaa93cfddec8978d9/plistlib.py |
parser.ParseFile(file) | parser.ParseFile(fileobj) | def parse(self, file): from xml.parsers.expat import ParserCreate parser = ParserCreate() parser.StartElementHandler = self.handleBeginElement parser.EndElementHandler = self.handleEndElement parser.CharacterDataHandler = self.handleData parser.ParseFile(file) return self.root | 95387a18956b2ab60709a79aaa93cfddec8978d9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/95387a18956b2ab60709a79aaa93cfddec8978d9/plistlib.py |
print __doc__ % globals() | def usage(status, msg=''): if msg: print msg print __doc__ % globals() sys.exit(status) | 14e2cafe21eebd5f6c40c9c0a542ae14a4f21296 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/14e2cafe21eebd5f6c40c9c0a542ae14a4f21296/Main.py |
|
break | if colordb: break | def main(): try: opts, args = getopt.getopt( sys.argv[1:], 'hd:', ['database=', 'help']) except getopt.error, msg: usage(1, msg) if len(args) == 0: initialcolor = 'grey50' elif len(args) == 1: initialcolor = args[0] else: usage(1) for opt, arg in opts: if opt in ('-h', '--help'): usage(0) elif opt in ('-d', '--database'): RGB_TXT.insert(0, arg) # create the windows and go for f in RGB_TXT: try: colordb = ColorDB.get_colordb(f) break except IOError: pass else: raise IOError('No color database file found') # get triplet for initial color try: red, green, blue = colordb.find_byname(initialcolor) except ColorDB.BadColor: # must be a #rrggbb style color try: red, green, blue = ColorDB.rrggbb_to_triplet(initialcolor) except ColorDB.BadColor: print 'Bad initial color, using default: %s' % initialcolor initialcolor = 'grey50' try: red, green, blue = ColorDB.rrggbb_to_triplet(initialcolor) except ColorDB.BadColor: usage(1, 'Cannot find an initial color to use') # create all output widgets s = Switchboard(colordb) # create the application window decorations app = PyncheWidget(__version__, s) parent = app.parent() s.add_view(StripViewer(s, parent)) s.add_view(ChipViewer(s, parent)) s.add_view(TypeinViewer(s, parent)) s.update_views(red, green, blue) try: app.start() except KeyboardInterrupt: pass | 14e2cafe21eebd5f6c40c9c0a542ae14a4f21296 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/14e2cafe21eebd5f6c40c9c0a542ae14a4f21296/Main.py |
raise IOError('No color database file found') | usage(1, 'No color database file found, see the -d option.') | def main(): try: opts, args = getopt.getopt( sys.argv[1:], 'hd:', ['database=', 'help']) except getopt.error, msg: usage(1, msg) if len(args) == 0: initialcolor = 'grey50' elif len(args) == 1: initialcolor = args[0] else: usage(1) for opt, arg in opts: if opt in ('-h', '--help'): usage(0) elif opt in ('-d', '--database'): RGB_TXT.insert(0, arg) # create the windows and go for f in RGB_TXT: try: colordb = ColorDB.get_colordb(f) break except IOError: pass else: raise IOError('No color database file found') # get triplet for initial color try: red, green, blue = colordb.find_byname(initialcolor) except ColorDB.BadColor: # must be a #rrggbb style color try: red, green, blue = ColorDB.rrggbb_to_triplet(initialcolor) except ColorDB.BadColor: print 'Bad initial color, using default: %s' % initialcolor initialcolor = 'grey50' try: red, green, blue = ColorDB.rrggbb_to_triplet(initialcolor) except ColorDB.BadColor: usage(1, 'Cannot find an initial color to use') # create all output widgets s = Switchboard(colordb) # create the application window decorations app = PyncheWidget(__version__, s) parent = app.parent() s.add_view(StripViewer(s, parent)) s.add_view(ChipViewer(s, parent)) s.add_view(TypeinViewer(s, parent)) s.update_views(red, green, blue) try: app.start() except KeyboardInterrupt: pass | 14e2cafe21eebd5f6c40c9c0a542ae14a4f21296 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/14e2cafe21eebd5f6c40c9c0a542ae14a4f21296/Main.py |
if dir not in dirs and os.path.isdir(dir): | normdir = os.path.normcase(dir) if normdir not in normdirs and os.path.isdir(dir): | def pathdirs(): """Convert sys.path into a list of absolute, existing, unique paths.""" dirs = [] for dir in sys.path: dir = os.path.abspath(dir or '.') if dir not in dirs and os.path.isdir(dir): dirs.append(dir) return dirs | 1d384634bf8f9e6180839048207bfd3539bbbc51 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1d384634bf8f9e6180839048207bfd3539bbbc51/pydoc.py |
def cleanid(text): | def stripid(text): | def cleanid(text): """Remove the hexadecimal id from a Python object representation.""" return re.sub(' at 0x[0-9a-f]{5,}>$', '>', text) | 1d384634bf8f9e6180839048207bfd3539bbbc51 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1d384634bf8f9e6180839048207bfd3539bbbc51/pydoc.py |
return re.sub(' at 0x[0-9a-f]{5,}>$', '>', text) | for pattern in [' at 0x[0-9a-f]{6,}>$', ' at [0-9A-F]{8,}>$']: if re.search(pattern, repr(Exception)): return re.sub(pattern, '>', text) return text | def cleanid(text): """Remove the hexadecimal id from a Python object representation.""" return re.sub(' at 0x[0-9a-f]{5,}>$', '>', text) | 1d384634bf8f9e6180839048207bfd3539bbbc51 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1d384634bf8f9e6180839048207bfd3539bbbc51/pydoc.py |
return self.escape(cram(cleanid(repr(x)), self.maxother)) | return self.escape(cram(stripid(repr(x)), self.maxother)) | def repr1(self, x, level): methodname = 'repr_' + join(split(type(x).__name__), '_') if hasattr(self, methodname): return getattr(self, methodname)(x, level) else: return self.escape(cram(cleanid(repr(x)), self.maxother)) | 1d384634bf8f9e6180839048207bfd3539bbbc51 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1d384634bf8f9e6180839048207bfd3539bbbc51/pydoc.py |
return cram(cleanid(repr(x)), self.maxstring) | return cram(stripid(repr(x)), self.maxstring) | def repr_instance(self, x, level): try: return cram(cleanid(repr(x)), self.maxstring) except: return self.escape('<%s instance>' % x.__class__.__name__) | 1d384634bf8f9e6180839048207bfd3539bbbc51 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1d384634bf8f9e6180839048207bfd3539bbbc51/pydoc.py |
file = inspect.getsourcefile(object) filelink = '<a href="file:%s">%s</a>' % (file, file) | path = os.path.abspath(inspect.getfile(object)) filelink = '<a href="file:%s">%s</a>' % (path, path) | def docmodule(self, object): """Produce HTML documentation for a module object.""" name = object.__name__ result = '' head = '<br><big><big><strong> %s</strong></big></big>' % name try: file = inspect.getsourcefile(object) filelink = '<a href="file:%s">%s</a>' % (file, file) 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) | 1d384634bf8f9e6180839048207bfd3539bbbc51 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1d384634bf8f9e6180839048207bfd3539bbbc51/pydoc.py |
info.append('version: %s' % self.escape(version)) | info.append('version %s' % self.escape(version)) | def docmodule(self, object): """Produce HTML documentation for a module object.""" name = object.__name__ result = '' head = '<br><big><big><strong> %s</strong></big></big>' % name try: file = inspect.getsourcefile(object) filelink = '<a href="file:%s">%s</a>' % (file, file) 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) | 1d384634bf8f9e6180839048207bfd3539bbbc51 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1d384634bf8f9e6180839048207bfd3539bbbc51/pydoc.py |
return cram(cleanid(repr(x)), self.maxother) | return cram(stripid(repr(x)), self.maxother) | def repr1(self, x, level): methodname = 'repr_' + join(split(type(x).__name__), '_') if hasattr(self, methodname): return getattr(self, methodname)(x, level) else: return cram(cleanid(repr(x)), self.maxother) | 1d384634bf8f9e6180839048207bfd3539bbbc51 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1d384634bf8f9e6180839048207bfd3539bbbc51/pydoc.py |
return cram(cleanid(repr(x)), self.maxstring) | return cram(stripid(repr(x)), self.maxstring) | def repr_instance(self, x, level): try: return cram(cleanid(repr(x)), self.maxstring) except: return '<%s instance>' % x.__class__.__name__ | 1d384634bf8f9e6180839048207bfd3539bbbc51 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1d384634bf8f9e6180839048207bfd3539bbbc51/pydoc.py |
if version[:11] == '$Revision$': version = version[11:-1] | if version[:11] == '$' + 'Revision: ' and version[-1:] == '$': version = strip(version[11:-1]) | def docmodule(self, object): """Produce text documentation for a given module object.""" result = '' | 1d384634bf8f9e6180839048207bfd3539bbbc51 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1d384634bf8f9e6180839048207bfd3539bbbc51/pydoc.py |
if __name__ == '__main__': | def cli(): | def server_activate(self): self.base.server_activate(self) if self.callback: self.callback() | 1d384634bf8f9e6180839048207bfd3539bbbc51 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1d384634bf8f9e6180839048207bfd3539bbbc51/pydoc.py |
result = interact(handler.load(), 'System-wide preferences') | options = handler.load() if options['noargs']: EasyDialogs.Message('Warning: system-wide sys.argv processing is off.\nIf you dropped an applet I have not seen it.') result = interact(options, 'System-wide preferences') | def edit_preferences(): handler = pythonprefs.PythonOptions() result = interact(handler.load(), 'System-wide preferences') if result: handler.save(result) | 43fd1f75db89d38010dd118b98f0460e958b5b99 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/43fd1f75db89d38010dd118b98f0460e958b5b99/EditPythonPrefs.py |
index = ac_in_buffer.find (self.terminator) | index = self.ac_in_buffer.find(terminator) | def handle_read (self): | b5d1392d9236eae981796cb7ae15d8ecd5035ac6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b5d1392d9236eae981796cb7ae15d8ecd5035ac6/asynchat.py |
SIGNATURE='MOSS' | def openfile(self, path, activate = 1): if activate: self.activate() self.OpenURL("file:///" + string.join(string.split(path,':'), '/')) | cee949f945eacf13b3d780624620f295c351886f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/cee949f945eacf13b3d780624620f295c351886f/PyDocSearch.py |
|
lowertext = string.lower(text) | lowertext = text.lower() | def sucktitle(path): f = open(path) text = f.read(1024) # assume the title is in the first 1024 bytes f.close() lowertext = string.lower(text) matcher = _titlepat.search(lowertext) if matcher: return matcher.group(1) return path | cee949f945eacf13b3d780624620f295c351886f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/cee949f945eacf13b3d780624620f295c351886f/PyDocSearch.py |
self.w.results = TwoLineList((-1, -1, 1, -14), nicehits, self.listhit) | self.w.results = W.TwoLineList((-1, -1, 1, -14), nicehits, self.listhit) | def __init__(self, hits): global _resultscounter hits = map(lambda (path, hits): (sucktitle(path), path, hits), hits) hits.sort() self.hits = hits nicehits = map( lambda (title, path, hits): title + '\r' + string.join( map(lambda (c, p): "%s (%d)" % (p, c), hits), ', '), hits) nicehits.sort() self.w = W.Window((440, 300), "Search results %d" % _resultscounter, minsize = (200, 100)) self.w.results = TwoLineList((-1, -1, 1, -14), nicehits, self.listhit) self.w.open() self.w.bind('return', self.listhit) self.w.bind('enter', self.listhit) _resultscounter = _resultscounter + 1 self.browser = None | cee949f945eacf13b3d780624620f295c351886f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/cee949f945eacf13b3d780624620f295c351886f/PyDocSearch.py |
self.browser = None | def __init__(self, hits): global _resultscounter hits = map(lambda (path, hits): (sucktitle(path), path, hits), hits) hits.sort() self.hits = hits nicehits = map( lambda (title, path, hits): title + '\r' + string.join( map(lambda (c, p): "%s (%d)" % (p, c), hits), ', '), hits) nicehits.sort() self.w = W.Window((440, 300), "Search results %d" % _resultscounter, minsize = (200, 100)) self.w.results = TwoLineList((-1, -1, 1, -14), nicehits, self.listhit) self.w.open() self.w.bind('return', self.listhit) self.w.bind('enter', self.listhit) _resultscounter = _resultscounter + 1 self.browser = None | cee949f945eacf13b3d780624620f295c351886f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/cee949f945eacf13b3d780624620f295c351886f/PyDocSearch.py |
|
if self.browser is None: self.browser = WebBrowser(SIGNATURE, start = 1) self.browser.openfile(self.hits[i][1]) | path = self.hits[i][1] url = "file://" + "/".join(path.split(":")) webbrowser.open(url) | def listhit(self, isdbl = 1): if isdbl: for i in self.w.results.getselection(): if self.browser is None: self.browser = WebBrowser(SIGNATURE, start = 1) self.browser.openfile(self.hits[i][1]) | cee949f945eacf13b3d780624620f295c351886f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/cee949f945eacf13b3d780624620f295c351886f/PyDocSearch.py |
self.w.searching = W.TextBox((4, 4, -4, 16), "DevDev:PyPyDoc 1.5.1:ext:parseTupleAndKeywords.html") | self.w.searching = W.TextBox((4, 4, -4, 16), "") | def __init__(self): self.w = W.Dialog((440, 64), "Searching\xc9") self.w.searching = W.TextBox((4, 4, -4, 16), "DevDev:PyPyDoc 1.5.1:ext:parseTupleAndKeywords.html") self.w.hits = W.TextBox((4, 24, -4, 16), "Hits: 0") self.w.canceltip = W.TextBox((4, 44, -4, 16), "Type cmd-period (.) to cancel.") self.w.open() | cee949f945eacf13b3d780624620f295c351886f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/cee949f945eacf13b3d780624620f295c351886f/PyDocSearch.py |
self.w.setdocfolderbutton = W.Button((10, -30, 80, 16), "Set doc folder", self.setdocpath) | self.w.setdocfolderbutton = W.Button((10, -30, 100, 16), "Set doc folder", self.setdocpath) | def __init__(self): prefs = MacPrefs.GetPrefs(W.getapplication().preffilepath) try: (docpath, kind, case, word, tut, lib, ref, ext, api) = prefs.docsearchengine except: (docpath, kind, case, word, tut, lib, ref, ext, api) = prefs.docsearchengine = \ ("", 0, 0, 0, 1, 1, 0, 0, 0) if docpath and not verifydocpath(docpath): docpath = "" self.w = W.Window((400, 200), "Search the Python Documentation") self.w.searchtext = W.EditText((10, 10, -100, 20), callback = self.checkbuttons) self.w.searchbutton = W.Button((-90, 12, 80, 16), "Search", self.search) buttons = [] gutter = 10 width = 130 bookstart = width + 2 * gutter self.w.phraseradio = W.RadioButton((10, 38, width, 16), "As a phrase", buttons) self.w.allwordsradio = W.RadioButton((10, 58, width, 16), "All words", buttons) self.w.anywordsradio = W.RadioButton((10, 78, width, 16), "Any word", buttons) self.w.casesens = W.CheckBox((10, 98, width, 16), "Case sensitive") self.w.wholewords = W.CheckBox((10, 118, width, 16), "Whole words") self.w.tutorial = W.CheckBox((bookstart, 38, -10, 16), "Tutorial") self.w.library = W.CheckBox((bookstart, 58, -10, 16), "Library reference") self.w.langueref = W.CheckBox((bookstart, 78, -10, 16), "Lanuage reference manual") self.w.extending = W.CheckBox((bookstart, 98, -10, 16), "Extending & embedding") self.w.api = W.CheckBox((bookstart, 118, -10, 16), "C/C++ API") self.w.setdocfolderbutton = W.Button((10, -30, 80, 16), "Set doc folder", self.setdocpath) if docpath: self.w.setdefaultbutton(self.w.searchbutton) else: self.w.setdefaultbutton(self.w.setdocfolderbutton) self.docpath = docpath if not docpath: docpath = "(please select the Python html documentation folder)" self.w.docfolder = W.TextBox((100, -28, -10, 16), docpath) [self.w.phraseradio, self.w.allwordsradio, self.w.anywordsradio][kind].set(1) self.w.casesens.set(case) self.w.wholewords.set(word) self.w.tutorial.set(tut) self.w.library.set(lib) self.w.langueref.set(ref) self.w.extending.set(ext) self.w.api.set(api) self.w.open() self.w.wholewords.enable(0) self.w.bind('<close>', self.close) self.w.searchbutton.enable(0) | cee949f945eacf13b3d780624620f295c351886f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/cee949f945eacf13b3d780624620f295c351886f/PyDocSearch.py |
self.w.docfolder = W.TextBox((100, -28, -10, 16), docpath) | self.w.docfolder = W.TextBox((120, -28, -10, 16), docpath) | def __init__(self): prefs = MacPrefs.GetPrefs(W.getapplication().preffilepath) try: (docpath, kind, case, word, tut, lib, ref, ext, api) = prefs.docsearchengine except: (docpath, kind, case, word, tut, lib, ref, ext, api) = prefs.docsearchengine = \ ("", 0, 0, 0, 1, 1, 0, 0, 0) if docpath and not verifydocpath(docpath): docpath = "" self.w = W.Window((400, 200), "Search the Python Documentation") self.w.searchtext = W.EditText((10, 10, -100, 20), callback = self.checkbuttons) self.w.searchbutton = W.Button((-90, 12, 80, 16), "Search", self.search) buttons = [] gutter = 10 width = 130 bookstart = width + 2 * gutter self.w.phraseradio = W.RadioButton((10, 38, width, 16), "As a phrase", buttons) self.w.allwordsradio = W.RadioButton((10, 58, width, 16), "All words", buttons) self.w.anywordsradio = W.RadioButton((10, 78, width, 16), "Any word", buttons) self.w.casesens = W.CheckBox((10, 98, width, 16), "Case sensitive") self.w.wholewords = W.CheckBox((10, 118, width, 16), "Whole words") self.w.tutorial = W.CheckBox((bookstart, 38, -10, 16), "Tutorial") self.w.library = W.CheckBox((bookstart, 58, -10, 16), "Library reference") self.w.langueref = W.CheckBox((bookstart, 78, -10, 16), "Lanuage reference manual") self.w.extending = W.CheckBox((bookstart, 98, -10, 16), "Extending & embedding") self.w.api = W.CheckBox((bookstart, 118, -10, 16), "C/C++ API") self.w.setdocfolderbutton = W.Button((10, -30, 80, 16), "Set doc folder", self.setdocpath) if docpath: self.w.setdefaultbutton(self.w.searchbutton) else: self.w.setdefaultbutton(self.w.setdocfolderbutton) self.docpath = docpath if not docpath: docpath = "(please select the Python html documentation folder)" self.w.docfolder = W.TextBox((100, -28, -10, 16), docpath) [self.w.phraseradio, self.w.allwordsradio, self.w.anywordsradio][kind].set(1) self.w.casesens.set(case) self.w.wholewords.set(word) self.w.tutorial.set(tut) self.w.library.set(lib) self.w.langueref.set(ref) self.w.extending.set(ext) self.w.api.set(api) self.w.open() self.w.wholewords.enable(0) self.w.bind('<close>', self.close) self.w.searchbutton.enable(0) | cee949f945eacf13b3d780624620f295c351886f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/cee949f945eacf13b3d780624620f295c351886f/PyDocSearch.py |
def search(self): hits = dosearch(self.docpath, self.w.searchtext.get(), self.getsettings()) if hits: Results(hits) elif hasattr(MacOS, 'SysBeep'): MacOS.SysBeep(0) #import PyBrowser #PyBrowser.Browser(hits) | cee949f945eacf13b3d780624620f295c351886f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/cee949f945eacf13b3d780624620f295c351886f/PyDocSearch.py |
||
Returns a list describing the signiture of the method. In the | Returns a list describing the signature of the method. In the | def system_methodSignature(self, method_name): """system.methodSignature('add') => [double, int, int] | b9b5f160ab7c17469c5ff297292275253e4f7570 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b9b5f160ab7c17469c5ff297292275253e4f7570/SimpleXMLRPCServer.py |
def compile_dir(dir, maxlevels=10, ddir=None, force=0, rx=None): | def compile_dir(dir, maxlevels=10, ddir=None, force=0, rx=None, quiet=0): | def compile_dir(dir, maxlevels=10, ddir=None, force=0, rx=None): """Byte-compile all modules in the given directory tree. Arguments (only dir is required): dir: the directory to byte-compile maxlevels: maximum recursion level (default 10) ddir: if given, purported directory name (this is the directory name that will show up in error messages) force: if 1, force compilation, even if timestamps are up-to-date """ print 'Listing', dir, '...' try: names = os.listdir(dir) except os.error: print "Can't list", dir names = [] names.sort() success = 1 for name in names: fullname = os.path.join(dir, name) if ddir: dfile = os.path.join(ddir, name) else: dfile = None if rx: mo = rx.search(fullname) if mo: continue if os.path.isfile(fullname): head, tail = name[:-3], name[-3:] if tail == '.py': cfile = fullname + (__debug__ and 'c' or 'o') ftime = os.stat(fullname)[stat.ST_MTIME] try: ctime = os.stat(cfile)[stat.ST_MTIME] except os.error: ctime = 0 if (ctime > ftime) and not force: continue print 'Compiling', fullname, '...' try: ok = py_compile.compile(fullname, None, dfile) except KeyboardInterrupt: raise KeyboardInterrupt except: # XXX py_compile catches SyntaxErrors if type(sys.exc_type) == type(''): exc_type_name = sys.exc_type else: exc_type_name = sys.exc_type.__name__ print 'Sorry:', exc_type_name + ':', print sys.exc_value success = 0 else: if ok == 0: success = 0 elif maxlevels > 0 and \ name != os.curdir and name != os.pardir and \ os.path.isdir(fullname) and \ not os.path.islink(fullname): if not compile_dir(fullname, maxlevels - 1, dfile, force, rx): success = 0 return success | 5c137c225113764faae183034e7a85175a699ae2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5c137c225113764faae183034e7a85175a699ae2/compileall.py |
print 'Listing', dir, '...' | if not quiet: print 'Listing', dir, '...' | def compile_dir(dir, maxlevels=10, ddir=None, force=0, rx=None): """Byte-compile all modules in the given directory tree. Arguments (only dir is required): dir: the directory to byte-compile maxlevels: maximum recursion level (default 10) ddir: if given, purported directory name (this is the directory name that will show up in error messages) force: if 1, force compilation, even if timestamps are up-to-date """ print 'Listing', dir, '...' try: names = os.listdir(dir) except os.error: print "Can't list", dir names = [] names.sort() success = 1 for name in names: fullname = os.path.join(dir, name) if ddir: dfile = os.path.join(ddir, name) else: dfile = None if rx: mo = rx.search(fullname) if mo: continue if os.path.isfile(fullname): head, tail = name[:-3], name[-3:] if tail == '.py': cfile = fullname + (__debug__ and 'c' or 'o') ftime = os.stat(fullname)[stat.ST_MTIME] try: ctime = os.stat(cfile)[stat.ST_MTIME] except os.error: ctime = 0 if (ctime > ftime) and not force: continue print 'Compiling', fullname, '...' try: ok = py_compile.compile(fullname, None, dfile) except KeyboardInterrupt: raise KeyboardInterrupt except: # XXX py_compile catches SyntaxErrors if type(sys.exc_type) == type(''): exc_type_name = sys.exc_type else: exc_type_name = sys.exc_type.__name__ print 'Sorry:', exc_type_name + ':', print sys.exc_value success = 0 else: if ok == 0: success = 0 elif maxlevels > 0 and \ name != os.curdir and name != os.pardir and \ os.path.isdir(fullname) and \ not os.path.islink(fullname): if not compile_dir(fullname, maxlevels - 1, dfile, force, rx): success = 0 return success | 5c137c225113764faae183034e7a85175a699ae2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5c137c225113764faae183034e7a85175a699ae2/compileall.py |
print 'Compiling', fullname, '...' | if not quiet: print 'Compiling', fullname, '...' | def compile_dir(dir, maxlevels=10, ddir=None, force=0, rx=None): """Byte-compile all modules in the given directory tree. Arguments (only dir is required): dir: the directory to byte-compile maxlevels: maximum recursion level (default 10) ddir: if given, purported directory name (this is the directory name that will show up in error messages) force: if 1, force compilation, even if timestamps are up-to-date """ print 'Listing', dir, '...' try: names = os.listdir(dir) except os.error: print "Can't list", dir names = [] names.sort() success = 1 for name in names: fullname = os.path.join(dir, name) if ddir: dfile = os.path.join(ddir, name) else: dfile = None if rx: mo = rx.search(fullname) if mo: continue if os.path.isfile(fullname): head, tail = name[:-3], name[-3:] if tail == '.py': cfile = fullname + (__debug__ and 'c' or 'o') ftime = os.stat(fullname)[stat.ST_MTIME] try: ctime = os.stat(cfile)[stat.ST_MTIME] except os.error: ctime = 0 if (ctime > ftime) and not force: continue print 'Compiling', fullname, '...' try: ok = py_compile.compile(fullname, None, dfile) except KeyboardInterrupt: raise KeyboardInterrupt except: # XXX py_compile catches SyntaxErrors if type(sys.exc_type) == type(''): exc_type_name = sys.exc_type else: exc_type_name = sys.exc_type.__name__ print 'Sorry:', exc_type_name + ':', print sys.exc_value success = 0 else: if ok == 0: success = 0 elif maxlevels > 0 and \ name != os.curdir and name != os.pardir and \ os.path.isdir(fullname) and \ not os.path.islink(fullname): if not compile_dir(fullname, maxlevels - 1, dfile, force, rx): success = 0 return success | 5c137c225113764faae183034e7a85175a699ae2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5c137c225113764faae183034e7a85175a699ae2/compileall.py |
if not compile_dir(fullname, maxlevels - 1, dfile, force, rx): | if not compile_dir(fullname, maxlevels - 1, dfile, force, rx, quiet): | def compile_dir(dir, maxlevels=10, ddir=None, force=0, rx=None): """Byte-compile all modules in the given directory tree. Arguments (only dir is required): dir: the directory to byte-compile maxlevels: maximum recursion level (default 10) ddir: if given, purported directory name (this is the directory name that will show up in error messages) force: if 1, force compilation, even if timestamps are up-to-date """ print 'Listing', dir, '...' try: names = os.listdir(dir) except os.error: print "Can't list", dir names = [] names.sort() success = 1 for name in names: fullname = os.path.join(dir, name) if ddir: dfile = os.path.join(ddir, name) else: dfile = None if rx: mo = rx.search(fullname) if mo: continue if os.path.isfile(fullname): head, tail = name[:-3], name[-3:] if tail == '.py': cfile = fullname + (__debug__ and 'c' or 'o') ftime = os.stat(fullname)[stat.ST_MTIME] try: ctime = os.stat(cfile)[stat.ST_MTIME] except os.error: ctime = 0 if (ctime > ftime) and not force: continue print 'Compiling', fullname, '...' try: ok = py_compile.compile(fullname, None, dfile) except KeyboardInterrupt: raise KeyboardInterrupt except: # XXX py_compile catches SyntaxErrors if type(sys.exc_type) == type(''): exc_type_name = sys.exc_type else: exc_type_name = sys.exc_type.__name__ print 'Sorry:', exc_type_name + ':', print sys.exc_value success = 0 else: if ok == 0: success = 0 elif maxlevels > 0 and \ name != os.curdir and name != os.pardir and \ os.path.isdir(fullname) and \ not os.path.islink(fullname): if not compile_dir(fullname, maxlevels - 1, dfile, force, rx): success = 0 return success | 5c137c225113764faae183034e7a85175a699ae2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5c137c225113764faae183034e7a85175a699ae2/compileall.py |
def compile_path(skip_curdir=1, maxlevels=0, force=0): | def compile_path(skip_curdir=1, maxlevels=0, force=0, quiet=0): | def compile_path(skip_curdir=1, maxlevels=0, force=0): """Byte-compile all module on sys.path. Arguments (all optional): skip_curdir: if true, skip current directory (default true) maxlevels: max recursion level (default 0) force: as for compile_dir() (default 0) """ success = 1 for dir in sys.path: if (not dir or dir == os.curdir) and skip_curdir: print 'Skipping current directory' else: success = success and compile_dir(dir, maxlevels, None, force) return success | 5c137c225113764faae183034e7a85175a699ae2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5c137c225113764faae183034e7a85175a699ae2/compileall.py |
success = success and compile_dir(dir, maxlevels, None, force) | success = success and compile_dir(dir, maxlevels, None, force, quiet=quiet) | def compile_path(skip_curdir=1, maxlevels=0, force=0): """Byte-compile all module on sys.path. Arguments (all optional): skip_curdir: if true, skip current directory (default true) maxlevels: max recursion level (default 0) force: as for compile_dir() (default 0) """ success = 1 for dir in sys.path: if (not dir or dir == os.curdir) and skip_curdir: print 'Skipping current directory' else: success = success and compile_dir(dir, maxlevels, None, force) return success | 5c137c225113764faae183034e7a85175a699ae2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5c137c225113764faae183034e7a85175a699ae2/compileall.py |
opts, args = getopt.getopt(sys.argv[1:], 'lfd:x:') | opts, args = getopt.getopt(sys.argv[1:], 'lfqd:x:') | def main(): """Script main program.""" import getopt try: opts, args = getopt.getopt(sys.argv[1:], 'lfd:x:') except getopt.error, msg: print msg print "usage: python compileall.py [-l] [-f] [-d destdir] " \ "[-s regexp] [directory ...]" print "-l: don't recurse down" print "-f: force rebuild even if timestamps are up-to-date" print "-d destdir: purported directory name for error messages" print " if no directory arguments, -l sys.path is assumed" print "-x regexp: skip files matching the regular expression regexp" print " the regexp is search for in the full path of the file" sys.exit(2) maxlevels = 10 ddir = None force = 0 rx = None for o, a in opts: if o == '-l': maxlevels = 0 if o == '-d': ddir = a if o == '-f': force = 1 if o == '-x': import re rx = re.compile(a) if ddir: if len(args) != 1: print "-d destdir require exactly one directory argument" sys.exit(2) success = 1 try: if args: for dir in args: if not compile_dir(dir, maxlevels, ddir, force, rx): success = 0 else: success = compile_path() except KeyboardInterrupt: print "\n[interrupt]" success = 0 return success | 5c137c225113764faae183034e7a85175a699ae2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5c137c225113764faae183034e7a85175a699ae2/compileall.py |
print "usage: python compileall.py [-l] [-f] [-d destdir] " \ | print "usage: python compileall.py [-l] [-f] [-q] [-d destdir] " \ | def main(): """Script main program.""" import getopt try: opts, args = getopt.getopt(sys.argv[1:], 'lfd:x:') except getopt.error, msg: print msg print "usage: python compileall.py [-l] [-f] [-d destdir] " \ "[-s regexp] [directory ...]" print "-l: don't recurse down" print "-f: force rebuild even if timestamps are up-to-date" print "-d destdir: purported directory name for error messages" print " if no directory arguments, -l sys.path is assumed" print "-x regexp: skip files matching the regular expression regexp" print " the regexp is search for in the full path of the file" sys.exit(2) maxlevels = 10 ddir = None force = 0 rx = None for o, a in opts: if o == '-l': maxlevels = 0 if o == '-d': ddir = a if o == '-f': force = 1 if o == '-x': import re rx = re.compile(a) if ddir: if len(args) != 1: print "-d destdir require exactly one directory argument" sys.exit(2) success = 1 try: if args: for dir in args: if not compile_dir(dir, maxlevels, ddir, force, rx): success = 0 else: success = compile_path() except KeyboardInterrupt: print "\n[interrupt]" success = 0 return success | 5c137c225113764faae183034e7a85175a699ae2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5c137c225113764faae183034e7a85175a699ae2/compileall.py |
if not compile_dir(dir, maxlevels, ddir, force, rx): | if not compile_dir(dir, maxlevels, ddir, force, rx, quiet): | def main(): """Script main program.""" import getopt try: opts, args = getopt.getopt(sys.argv[1:], 'lfd:x:') except getopt.error, msg: print msg print "usage: python compileall.py [-l] [-f] [-d destdir] " \ "[-s regexp] [directory ...]" print "-l: don't recurse down" print "-f: force rebuild even if timestamps are up-to-date" print "-d destdir: purported directory name for error messages" print " if no directory arguments, -l sys.path is assumed" print "-x regexp: skip files matching the regular expression regexp" print " the regexp is search for in the full path of the file" sys.exit(2) maxlevels = 10 ddir = None force = 0 rx = None for o, a in opts: if o == '-l': maxlevels = 0 if o == '-d': ddir = a if o == '-f': force = 1 if o == '-x': import re rx = re.compile(a) if ddir: if len(args) != 1: print "-d destdir require exactly one directory argument" sys.exit(2) success = 1 try: if args: for dir in args: if not compile_dir(dir, maxlevels, ddir, force, rx): success = 0 else: success = compile_path() except KeyboardInterrupt: print "\n[interrupt]" success = 0 return success | 5c137c225113764faae183034e7a85175a699ae2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5c137c225113764faae183034e7a85175a699ae2/compileall.py |
verify(self.cbcalled == 1, "callback did not properly set 'cbcalled'") verify(ref() is None, "ref2 should be dead after deleting object reference") | self.assert_(self.cbcalled == 1, "callback did not properly set 'cbcalled'") self.assert_(ref() is None, "ref2 should be dead after deleting object reference") | def check_basic_callback(self, factory): self.cbcalled = 0 o = factory() ref = weakref.ref(o, self.callback) del o verify(self.cbcalled == 1, "callback did not properly set 'cbcalled'") verify(ref() is None, "ref2 should be dead after deleting object reference") | 705088e65f67fa242802036ee129972b6d6fda63 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/705088e65f67fa242802036ee129972b6d6fda63/test_weakref.py |
except: pass | except OSError: pass | def nextfile(self): savestdout = self._savestdout self._savestdout = 0 if savestdout: sys.stdout = savestdout | cffac66393c2af89c6546ab081f9098633273a53 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/cffac66393c2af89c6546ab081f9098633273a53/fileinput.py |
except: | except OSError: | def readline(self): try: line = self._buffer[self._bufindex] except IndexError: pass else: self._bufindex += 1 self._lineno += 1 self._filelineno += 1 return line if not self._file: if not self._files: return "" self._filename = self._files[0] self._files = self._files[1:] self._filelineno = 0 self._file = None self._isstdin = False self._backupfilename = 0 if self._filename == '-': self._filename = '<stdin>' self._file = sys.stdin self._isstdin = True else: if self._inplace: self._backupfilename = ( self._filename + (self._backup or os.extsep+"bak")) try: os.unlink(self._backupfilename) except os.error: pass # The next few lines may raise IOError os.rename(self._filename, self._backupfilename) self._file = open(self._backupfilename, "r") try: perm = os.fstat(self._file.fileno()).st_mode except: self._output = open(self._filename, "w") else: fd = os.open(self._filename, os.O_CREAT | os.O_WRONLY | os.O_TRUNC, perm) self._output = os.fdopen(fd, "w") try: os.chmod(self._filename, perm) except: pass self._savestdout = sys.stdout sys.stdout = self._output else: # This may raise IOError self._file = open(self._filename, "r") self._buffer = self._file.readlines(self._bufsize) self._bufindex = 0 if not self._buffer: self.nextfile() # Recursive call return self.readline() | cffac66393c2af89c6546ab081f9098633273a53 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/cffac66393c2af89c6546ab081f9098633273a53/fileinput.py |
except: | except OSError: | def readline(self): try: line = self._buffer[self._bufindex] except IndexError: pass else: self._bufindex += 1 self._lineno += 1 self._filelineno += 1 return line if not self._file: if not self._files: return "" self._filename = self._files[0] self._files = self._files[1:] self._filelineno = 0 self._file = None self._isstdin = False self._backupfilename = 0 if self._filename == '-': self._filename = '<stdin>' self._file = sys.stdin self._isstdin = True else: if self._inplace: self._backupfilename = ( self._filename + (self._backup or os.extsep+"bak")) try: os.unlink(self._backupfilename) except os.error: pass # The next few lines may raise IOError os.rename(self._filename, self._backupfilename) self._file = open(self._backupfilename, "r") try: perm = os.fstat(self._file.fileno()).st_mode except: self._output = open(self._filename, "w") else: fd = os.open(self._filename, os.O_CREAT | os.O_WRONLY | os.O_TRUNC, perm) self._output = os.fdopen(fd, "w") try: os.chmod(self._filename, perm) except: pass self._savestdout = sys.stdout sys.stdout = self._output else: # This may raise IOError self._file = open(self._filename, "r") self._buffer = self._file.readlines(self._bufsize) self._bufindex = 0 if not self._buffer: self.nextfile() # Recursive call return self.readline() | cffac66393c2af89c6546ab081f9098633273a53 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/cffac66393c2af89c6546ab081f9098633273a53/fileinput.py |
mainname = os.path.basename(self.mainprogram) self.files.append((self.mainprogram, pathjoin(resdir, mainname))) mainprogram = self.mainprogram | mainprogram = os.path.basename(self.mainprogram) self.files.append((self.mainprogram, pathjoin(resdir, mainprogram))) | def preProcess(self): resdir = "Contents/Resources" if self.executable is not None: if self.mainprogram is None: execname = self.name else: execname = os.path.basename(self.executable) execpath = pathjoin(self.execdir, execname) if not self.symlink_exec: self.files.append((self.executable, execpath)) self.binaries.append(execpath) self.execpath = execpath | 24884f76c6b59aa9cd716174907a02d5d172c2fc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/24884f76c6b59aa9cd716174907a02d5d172c2fc/bundlebuilder.py |
mainwrapperpath = pathjoin(execdir, self.name) | bootstrappath = pathjoin(execdir, self.name) | def preProcess(self): resdir = "Contents/Resources" if self.executable is not None: if self.mainprogram is None: execname = self.name else: execname = os.path.basename(self.executable) execpath = pathjoin(self.execdir, execname) if not self.symlink_exec: self.files.append((self.executable, execpath)) self.binaries.append(execpath) self.execpath = execpath | 24884f76c6b59aa9cd716174907a02d5d172c2fc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/24884f76c6b59aa9cd716174907a02d5d172c2fc/bundlebuilder.py |
open(mainwrapperpath, "w").write(BOOTSTRAP_SCRIPT % locals()) os.chmod(mainwrapperpath, 0775) | open(bootstrappath, "w").write(BOOTSTRAP_SCRIPT % locals()) os.chmod(bootstrappath, 0775) | def preProcess(self): resdir = "Contents/Resources" if self.executable is not None: if self.mainprogram is None: execname = self.name else: execname = os.path.basename(self.executable) execpath = pathjoin(self.execdir, execname) if not self.symlink_exec: self.files.append((self.executable, execpath)) self.binaries.append(execpath) self.execpath = execpath | 24884f76c6b59aa9cd716174907a02d5d172c2fc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/24884f76c6b59aa9cd716174907a02d5d172c2fc/bundlebuilder.py |
ScrolledList.__init__(self, master, width=80) | if macosxSupport.runningAsOSXApp(): ScrolledList.__init__(self, master) else: ScrolledList.__init__(self, master, width=80) | def __init__(self, master, flist, gui): ScrolledList.__init__(self, master, width=80) self.flist = flist self.gui = gui self.stack = [] | 53f1a943eca54f4ce1af1071998b3d56f79cc00f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/53f1a943eca54f4ce1af1071998b3d56f79cc00f/Debugger.py |
def test_warning(self): warnings.filterwarnings("error", category=RuntimeWarning, message="mktemp") self.assertRaises(RuntimeWarning, tempfile.mktemp, (), { 'dir': self.dir }) | def test_warning(self): # mktemp issues a warning when used warnings.filterwarnings("error", category=RuntimeWarning, message="mktemp") self.assertRaises(RuntimeWarning, tempfile.mktemp, (), { 'dir': self.dir }) | 8bec48316b1ffb4ea153e78b9119d7e77b98f3eb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8bec48316b1ffb4ea153e78b9119d7e77b98f3eb/test_tempfile.py |
|
no elements are considered to be junk. For examples, pass | no elements are considered to be junk. For example, pass | def __init__(self, isjunk=None, a='', b=''): """Construct a SequenceMatcher. | f1da6287fc90a068da8487dc5564b35f194d74b9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f1da6287fc90a068da8487dc5564b35f194d74b9/difflib.py |
default, an empty string. The elements of a must be hashable. See | default, an empty string. The elements of b must be hashable. See | def __init__(self, isjunk=None, a='', b=''): """Construct a SequenceMatcher. | f1da6287fc90a068da8487dc5564b35f194d74b9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f1da6287fc90a068da8487dc5564b35f194d74b9/difflib.py |
raise ValueError("n must be > 0: %s" % `n`) | raise ValueError("n must be > 0: " + `n`) | def get_close_matches(word, possibilities, n=3, cutoff=0.6): """Use SequenceMatcher to return list of the best "good enough" matches. word is a sequence for which close matches are desired (typically a string). possibilities is a list of sequences against which to match word (typically a list of strings). Optional arg n (default 3) is the maximum number of close matches to return. n must be > 0. Optional arg cutoff (default 0.6) is a float in [0, 1]. Possibilities that don't score at least that similar to word are ignored. The best (no more than n) matches among the possibilities are returned in a list, sorted by similarity score, most similar first. >>> get_close_matches("appel", ["ape", "apple", "peach", "puppy"]) ['apple', 'ape'] >>> import keyword >>> get_close_matches("wheel", keyword.kwlist) ['while'] >>> get_close_matches("apple", keyword.kwlist) [] >>> get_close_matches("accept", keyword.kwlist) ['except'] """ if not n > 0: raise ValueError("n must be > 0: %s" % `n`) if not 0.0 <= cutoff <= 1.0: raise ValueError("cutoff must be in [0.0, 1.0]: %s" % `cutoff`) result = [] s = SequenceMatcher() s.set_seq2(word) for x in possibilities: s.set_seq1(x) if s.real_quick_ratio() >= cutoff and \ s.quick_ratio() >= cutoff and \ s.ratio() >= cutoff: result.append((s.ratio(), x)) # Sort by score. result.sort() # Retain only the best n. result = result[-n:] # Move best-scorer to head of list. result.reverse() # Strip scores. return [x for score, x in result] | f1da6287fc90a068da8487dc5564b35f194d74b9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f1da6287fc90a068da8487dc5564b35f194d74b9/difflib.py |
raise ValueError("cutoff must be in [0.0, 1.0]: %s" % `cutoff`) | raise ValueError("cutoff must be in [0.0, 1.0]: " + `cutoff`) | def get_close_matches(word, possibilities, n=3, cutoff=0.6): """Use SequenceMatcher to return list of the best "good enough" matches. word is a sequence for which close matches are desired (typically a string). possibilities is a list of sequences against which to match word (typically a list of strings). Optional arg n (default 3) is the maximum number of close matches to return. n must be > 0. Optional arg cutoff (default 0.6) is a float in [0, 1]. Possibilities that don't score at least that similar to word are ignored. The best (no more than n) matches among the possibilities are returned in a list, sorted by similarity score, most similar first. >>> get_close_matches("appel", ["ape", "apple", "peach", "puppy"]) ['apple', 'ape'] >>> import keyword >>> get_close_matches("wheel", keyword.kwlist) ['while'] >>> get_close_matches("apple", keyword.kwlist) [] >>> get_close_matches("accept", keyword.kwlist) ['except'] """ if not n > 0: raise ValueError("n must be > 0: %s" % `n`) if not 0.0 <= cutoff <= 1.0: raise ValueError("cutoff must be in [0.0, 1.0]: %s" % `cutoff`) result = [] s = SequenceMatcher() s.set_seq2(word) for x in possibilities: s.set_seq1(x) if s.real_quick_ratio() >= cutoff and \ s.quick_ratio() >= cutoff and \ s.ratio() >= cutoff: result.append((s.ratio(), x)) # Sort by score. result.sort() # Retain only the best n. result = result[-n:] # Move best-scorer to head of list. result.reverse() # Strip scores. return [x for score, x in result] | f1da6287fc90a068da8487dc5564b35f194d74b9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f1da6287fc90a068da8487dc5564b35f194d74b9/difflib.py |
def test_wide(self): | def test_width(self): | def test_wide(self): self.assertEqual(u''.width(), 0) self.assertEqual(u'abcd'.width(), 4) self.assertEqual(u'\u0187\u01c9'.width(), 2) self.assertEqual(u'\u2460\u2329'.width(), 3) self.assertEqual(u'\u2329\u2460'.width(), 3) self.assertEqual(u'\ud55c\uae00'.width(), 4) self.assertEqual(u'\ud55c\u2606\uae00'.width(), 5) | 7bd860655f8343fe02439a457bc59f7cd7d9eda8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7bd860655f8343fe02439a457bc59f7cd7d9eda8/test_unicode.py |
_monthnames = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] _daynames = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] | _monthnames = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec', 'january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'] _daynames = ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'] | def dump_address_pair(pair): """Dump a (name, address) pair in a canonicalized form.""" if pair[0]: return '"' + pair[0] + '" <' + pair[1] + '>' else: return pair[1] | db01ee0e22c348b642143dbb728517ca7e13f526 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/db01ee0e22c348b642143dbb728517ca7e13f526/rfc822.py |
if data[0][-1] == ',' or data[0] in _daynames: | if data[0][-1] in (',', '.') or string.lower(data[0]) in _daynames: | def parsedate_tz(data): """Convert a date string to a time tuple. Accounts for military timezones. """ data = string.split(data) if data[0][-1] == ',' or data[0] in _daynames: # There's a dayname here. Skip it del data[0] if len(data) == 3: # RFC 850 date, deprecated stuff = string.split(data[0], '-') if len(stuff) == 3: data = stuff + data[1:] if len(data) == 4: s = data[3] i = string.find(s, '+') if i > 0: data[3:] = [s[:i], s[i+1:]] else: data.append('') # Dummy tz if len(data) < 5: return None data = data[:5] [dd, mm, yy, tm, tz] = data if not mm in _monthnames: dd, mm, yy, tm, tz = mm, dd, tm, yy, tz if not mm in _monthnames: return None mm = _monthnames.index(mm)+1 tm = string.splitfields(tm, ':') if len(tm) == 2: [thh, tmm] = tm tss = '0' elif len(tm) == 3: [thh, tmm, tss] = tm else: return None try: yy = string.atoi(yy) dd = string.atoi(dd) thh = string.atoi(thh) tmm = string.atoi(tmm) tss = string.atoi(tss) except string.atoi_error: return None tzoffset=None tz=string.upper(tz) if _timezones.has_key(tz): tzoffset=_timezones[tz] else: try: tzoffset=string.atoi(tz) except string.atoi_error: pass # Convert a timezone offset into seconds ; -0500 -> -18000 if tzoffset: if tzoffset < 0: tzsign = -1 tzoffset = -tzoffset else: tzsign = 1 tzoffset = tzsign * ( (tzoffset/100)*3600 + (tzoffset % 100)*60) tuple = (yy, mm, dd, thh, tmm, tss, 0, 0, 0, tzoffset) return tuple | db01ee0e22c348b642143dbb728517ca7e13f526 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/db01ee0e22c348b642143dbb728517ca7e13f526/rfc822.py |
dd, mm, yy, tm, tz = mm, dd, tm, yy, tz | dd, mm = mm, string.lower(dd) | def parsedate_tz(data): """Convert a date string to a time tuple. Accounts for military timezones. """ data = string.split(data) if data[0][-1] == ',' or data[0] in _daynames: # There's a dayname here. Skip it del data[0] if len(data) == 3: # RFC 850 date, deprecated stuff = string.split(data[0], '-') if len(stuff) == 3: data = stuff + data[1:] if len(data) == 4: s = data[3] i = string.find(s, '+') if i > 0: data[3:] = [s[:i], s[i+1:]] else: data.append('') # Dummy tz if len(data) < 5: return None data = data[:5] [dd, mm, yy, tm, tz] = data if not mm in _monthnames: dd, mm, yy, tm, tz = mm, dd, tm, yy, tz if not mm in _monthnames: return None mm = _monthnames.index(mm)+1 tm = string.splitfields(tm, ':') if len(tm) == 2: [thh, tmm] = tm tss = '0' elif len(tm) == 3: [thh, tmm, tss] = tm else: return None try: yy = string.atoi(yy) dd = string.atoi(dd) thh = string.atoi(thh) tmm = string.atoi(tmm) tss = string.atoi(tss) except string.atoi_error: return None tzoffset=None tz=string.upper(tz) if _timezones.has_key(tz): tzoffset=_timezones[tz] else: try: tzoffset=string.atoi(tz) except string.atoi_error: pass # Convert a timezone offset into seconds ; -0500 -> -18000 if tzoffset: if tzoffset < 0: tzsign = -1 tzoffset = -tzoffset else: tzsign = 1 tzoffset = tzsign * ( (tzoffset/100)*3600 + (tzoffset % 100)*60) tuple = (yy, mm, dd, thh, tmm, tss, 0, 0, 0, tzoffset) return tuple | db01ee0e22c348b642143dbb728517ca7e13f526 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/db01ee0e22c348b642143dbb728517ca7e13f526/rfc822.py |
if not self.__ensure_WMAvailable(): raise RuntimeError, "No window manager access, cannot send AppleEvent" | def sendevent(self, event): """Send a pre-created appleevent, await the reply and unpack it""" reply = event.AESend(self.send_flags, self.send_priority, self.send_timeout) parameters, attributes = unpackevent(reply, self._moduleName) return reply, parameters, attributes | 397e9142096d5ccd2b4a63bc04d3b05b3c86cc48 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/397e9142096d5ccd2b4a63bc04d3b05b3c86cc48/aetools.py |
|
"""Check the LaTex formatting in a sequence of lines. | """Check the LaTeX formatting in a sequence of lines. | def checkit(source, opts, morecmds=[]): """Check the LaTex formatting in a sequence of lines. Opts is a mapping of options to option values if any: -m munge parenthesis and brackets -f forward slash warnings to be skipped -d delimiters only checking -v verbose listing on delimiters -s lineno: linenumber to start scan (default is 1). Morecmds is a sequence of LaTex commands (without backslashes) that are to be considered valid in the scan. """ texcmd = re.compile(r'\\[A-Za-z]+') validcmds = sets.Set(cmdstr.split()) for cmd in morecmds: validcmds.add('\\' + cmd) openers = [] # Stack of pending open delimiters if '-m' in opts: pairmap = {']':'[(', ')':'(['} # Munged openers else: pairmap = {']':'[', ')':'('} # Normal opener for a given closer openpunct = sets.Set('([') # Set of valid openers delimiters = re.compile(r'\\(begin|end){([_a-zA-Z]+)}|([()\[\]])') startline = int(opts.get('-s', '1')) lineno = 0 for lineno, line in izip(count(startline), islice(source, startline-1, None)): line = line.rstrip() if '-f' not in opts and '/' in line: # Warn whenever forward slashes encountered line = line.rstrip() print 'Warning, forward slash on line %d: %s' % (lineno, line) if '-d' not in opts: # Validate commands nc = line.find(r'\newcommand') if nc != -1: start = line.find('{', nc) end = line.find('}', start) validcmds.add(line[start+1:end]) for cmd in texcmd.findall(line): if cmd not in validcmds: print r'Warning, unknown tex cmd on line %d: \%s' % (lineno, cmd) # Check balancing of open/close markers (parens, brackets, etc) for begend, name, punct in delimiters.findall(line): if '-v' in opts: print lineno, '|', begend, name, punct, if begend == 'begin' and '-d' not in opts: openers.append((lineno, name)) elif punct in openpunct: openers.append((lineno, punct)) elif begend == 'end' and '-d' not in opts: matchclose(lineno, name, openers, pairmap) elif punct in pairmap: matchclose(lineno, punct, openers, pairmap) if '-v' in opts: print ' --> ', openers for lineno, symbol in openers: print "Unmatched open delimiter '%s' on line %d", (symbol, lineno) print 'Done checking %d lines.' % (lineno,) return 0 | 0fd525fd1c8e2b3374c7acda0facbdce9dfbb63e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0fd525fd1c8e2b3374c7acda0facbdce9dfbb63e/texcheck.py |
Morecmds is a sequence of LaTex commands (without backslashes) that | Morecmds is a sequence of LaTeX commands (without backslashes) that | def checkit(source, opts, morecmds=[]): """Check the LaTex formatting in a sequence of lines. Opts is a mapping of options to option values if any: -m munge parenthesis and brackets -f forward slash warnings to be skipped -d delimiters only checking -v verbose listing on delimiters -s lineno: linenumber to start scan (default is 1). Morecmds is a sequence of LaTex commands (without backslashes) that are to be considered valid in the scan. """ texcmd = re.compile(r'\\[A-Za-z]+') validcmds = sets.Set(cmdstr.split()) for cmd in morecmds: validcmds.add('\\' + cmd) openers = [] # Stack of pending open delimiters if '-m' in opts: pairmap = {']':'[(', ')':'(['} # Munged openers else: pairmap = {']':'[', ')':'('} # Normal opener for a given closer openpunct = sets.Set('([') # Set of valid openers delimiters = re.compile(r'\\(begin|end){([_a-zA-Z]+)}|([()\[\]])') startline = int(opts.get('-s', '1')) lineno = 0 for lineno, line in izip(count(startline), islice(source, startline-1, None)): line = line.rstrip() if '-f' not in opts and '/' in line: # Warn whenever forward slashes encountered line = line.rstrip() print 'Warning, forward slash on line %d: %s' % (lineno, line) if '-d' not in opts: # Validate commands nc = line.find(r'\newcommand') if nc != -1: start = line.find('{', nc) end = line.find('}', start) validcmds.add(line[start+1:end]) for cmd in texcmd.findall(line): if cmd not in validcmds: print r'Warning, unknown tex cmd on line %d: \%s' % (lineno, cmd) # Check balancing of open/close markers (parens, brackets, etc) for begend, name, punct in delimiters.findall(line): if '-v' in opts: print lineno, '|', begend, name, punct, if begend == 'begin' and '-d' not in opts: openers.append((lineno, name)) elif punct in openpunct: openers.append((lineno, punct)) elif begend == 'end' and '-d' not in opts: matchclose(lineno, name, openers, pairmap) elif punct in pairmap: matchclose(lineno, punct, openers, pairmap) if '-v' in opts: print ' --> ', openers for lineno, symbol in openers: print "Unmatched open delimiter '%s' on line %d", (symbol, lineno) print 'Done checking %d lines.' % (lineno,) return 0 | 0fd525fd1c8e2b3374c7acda0facbdce9dfbb63e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0fd525fd1c8e2b3374c7acda0facbdce9dfbb63e/texcheck.py |
print "Unmatched open delimiter '%s' on line %d", (symbol, lineno) | print "Unmatched open delimiter '%s' on line %d" % (symbol, lineno) | def checkit(source, opts, morecmds=[]): """Check the LaTex formatting in a sequence of lines. Opts is a mapping of options to option values if any: -m munge parenthesis and brackets -f forward slash warnings to be skipped -d delimiters only checking -v verbose listing on delimiters -s lineno: linenumber to start scan (default is 1). Morecmds is a sequence of LaTex commands (without backslashes) that are to be considered valid in the scan. """ texcmd = re.compile(r'\\[A-Za-z]+') validcmds = sets.Set(cmdstr.split()) for cmd in morecmds: validcmds.add('\\' + cmd) openers = [] # Stack of pending open delimiters if '-m' in opts: pairmap = {']':'[(', ')':'(['} # Munged openers else: pairmap = {']':'[', ')':'('} # Normal opener for a given closer openpunct = sets.Set('([') # Set of valid openers delimiters = re.compile(r'\\(begin|end){([_a-zA-Z]+)}|([()\[\]])') startline = int(opts.get('-s', '1')) lineno = 0 for lineno, line in izip(count(startline), islice(source, startline-1, None)): line = line.rstrip() if '-f' not in opts and '/' in line: # Warn whenever forward slashes encountered line = line.rstrip() print 'Warning, forward slash on line %d: %s' % (lineno, line) if '-d' not in opts: # Validate commands nc = line.find(r'\newcommand') if nc != -1: start = line.find('{', nc) end = line.find('}', start) validcmds.add(line[start+1:end]) for cmd in texcmd.findall(line): if cmd not in validcmds: print r'Warning, unknown tex cmd on line %d: \%s' % (lineno, cmd) # Check balancing of open/close markers (parens, brackets, etc) for begend, name, punct in delimiters.findall(line): if '-v' in opts: print lineno, '|', begend, name, punct, if begend == 'begin' and '-d' not in opts: openers.append((lineno, name)) elif punct in openpunct: openers.append((lineno, punct)) elif begend == 'end' and '-d' not in opts: matchclose(lineno, name, openers, pairmap) elif punct in pairmap: matchclose(lineno, punct, openers, pairmap) if '-v' in opts: print ' --> ', openers for lineno, symbol in openers: print "Unmatched open delimiter '%s' on line %d", (symbol, lineno) print 'Done checking %d lines.' % (lineno,) return 0 | 0fd525fd1c8e2b3374c7acda0facbdce9dfbb63e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0fd525fd1c8e2b3374c7acda0facbdce9dfbb63e/texcheck.py |
for key in ('LDFLAGS', 'BASECFLAGS'): | for key in ('LDFLAGS', 'BASECFLAGS', 'CFLAGS', 'PY_CFLAGS', 'BLDSHARED'): | def get_config_vars(*args): """With no arguments, return a dictionary of all configuration variables relevant for the current platform. Generally this includes everything needed to build extensions and install both pure modules and extensions. On Unix, this means every variable defined in Python's installed Makefile; on Windows and Mac OS it's a much smaller set. With arguments, return a list of values that result from looking up each argument in the configuration variable dictionary. """ global _config_vars if _config_vars is None: func = globals().get("_init_" + os.name) if func: func() else: _config_vars = {} # Normalized versions of prefix and exec_prefix are handy to have; # in fact, these are the standard versions used most places in the # Distutils. _config_vars['prefix'] = PREFIX _config_vars['exec_prefix'] = EXEC_PREFIX if sys.platform == 'darwin': kernel_version = os.uname()[2] # Kernel version (8.4.3) major_version = int(kernel_version.split('.')[0]) if major_version < 8: # On Mac OS X before 10.4, check if -arch and -isysroot # are in CFLAGS or LDFLAGS and remove them if they are. # This is needed when building extensions on a 10.3 system # using a universal build of python. for key in ('LDFLAGS', 'BASECFLAGS'): flags = _config_vars[key] flags = re.sub('-arch\s+\w+\s', ' ', flags) flags = re.sub('-isysroot [^ \t]*', ' ', flags) _config_vars[key] = flags if args: vals = [] for name in args: vals.append(_config_vars.get(name)) return vals else: return _config_vars | d610369e8b63930b5a7b1bdafebd3c64af6b4b28 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d610369e8b63930b5a7b1bdafebd3c64af6b4b28/sysconfig.py |
To understand what this class does, it helps to have a copy of RFC-822 in front of you. | To understand what this class does, it helps to have a copy of RFC 2822 in front of you. | def quote(str): """Add quotes around a string.""" return str.replace('\\', '\\\\').replace('"', '\\"') | 1fb22bb24fd395a12a225b2418ea8d22d5b37610 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1fb22bb24fd395a12a225b2418ea8d22d5b37610/_parseaddr.py |
ad = self.getaddress() if ad: return ad + self.getaddrlist() else: return [] | result = [] while 1: ad = self.getaddress() if ad: result += ad else: break return result | def getaddrlist(self): """Parse all addresses. | 1fb22bb24fd395a12a225b2418ea8d22d5b37610 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1fb22bb24fd395a12a225b2418ea8d22d5b37610/_parseaddr.py |
expectaddrspec = 1 | def getrouteaddr(self): """Parse a route address (Return-path value). | 1fb22bb24fd395a12a225b2418ea8d22d5b37610 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1fb22bb24fd395a12a225b2418ea8d22d5b37610/_parseaddr.py |
|
"""Parse an RFC-822 addr-spec.""" | """Parse an RFC 2822 addr-spec.""" | def getaddrspec(self): """Parse an RFC-822 addr-spec.""" aslist = [] | 1fb22bb24fd395a12a225b2418ea8d22d5b37610 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1fb22bb24fd395a12a225b2418ea8d22d5b37610/_parseaddr.py |
If `allowcomments' is non-zero, embedded RFC-822 comments are allowed within the parsed fragment. | If `allowcomments' is non-zero, embedded RFC 2822 comments are allowed within the parsed fragment. | def getdelimited(self, beginchar, endchars, allowcomments = 1): """Parse a header fragment delimited by special characters. | 1fb22bb24fd395a12a225b2418ea8d22d5b37610 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1fb22bb24fd395a12a225b2418ea8d22d5b37610/_parseaddr.py |
"""Parse an RFC-822 domain-literal.""" | """Parse an RFC 2822 domain-literal.""" | def getdomainliteral(self): """Parse an RFC-822 domain-literal.""" return '[%s]' % self.getdelimited('[', ']\r', 0) | 1fb22bb24fd395a12a225b2418ea8d22d5b37610 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1fb22bb24fd395a12a225b2418ea8d22d5b37610/_parseaddr.py |
def getatom(self): """Parse an RFC-822 atom.""" | def getatom(self, atomends=None): """Parse an RFC 2822 atom. Optional atomends specifies a different set of end token delimiters (the default is to use self.atomends). This is used e.g. in getphraselist() since phrase endings must not include the `.' (which is legal in phrases).""" | def getatom(self): """Parse an RFC-822 atom.""" atomlist = [''] | 1fb22bb24fd395a12a225b2418ea8d22d5b37610 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1fb22bb24fd395a12a225b2418ea8d22d5b37610/_parseaddr.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.