rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
def loop(timeout=30.0, use_poll=0, map=None):
def loop(timeout=30.0, use_poll=False, map=None):
def loop(timeout=30.0, use_poll=0, map=None): if map is None: map = socket_map if use_poll and hasattr(select, 'poll'): poll_fun = poll2 else: poll_fun = poll while map: poll_fun(timeout, map)
debug = 0 connected = 0 accepting = 0 closing = 0
debug = False connected = False accepting = False closing = False
def loop(timeout=30.0, use_poll=0, map=None): if map is None: map = socket_map if use_poll and hasattr(select, 'poll'): poll_fun = poll2 else: poll_fun = poll while map: poll_fun(timeout, map)
self.connected = 1
self.connected = True
def __init__(self, sock=None, map=None): if map is None: self._map = socket_map else: self._map = map
self.accepting = 1
self.accepting = True
def listen(self, num): self.accepting = 1 if os.name == 'nt' and num > 5: num = 1 return self.socket.listen(num)
self.connected = 0
self.connected = False
def connect(self, address): self.connected = 0 err = self.socket.connect_ex(address) # XXX Should interpret Winsock return values if err in (EINPROGRESS, EALREADY, EWOULDBLOCK): return if err in (0, EISCONN): self.addr = address self.connected = 1 self.handle_connect() else: raise socket.error, err
self.connected = 1
self.connected = True
def connect(self, address): self.connected = 0 err = self.socket.connect_ex(address) # XXX Should interpret Winsock return values if err in (EINPROGRESS, EALREADY, EWOULDBLOCK): return if err in (0, EISCONN): self.addr = address self.connected = 1 self.handle_connect() else: raise socket.error, err
self.connected = 1
self.connected = True
def handle_read_event(self): if self.accepting: # for an accepting socket, getting a read implies # that we are connected if not self.connected: self.connected = 1 self.handle_accept() elif not self.connected: self.handle_connect() self.connected = 1 self.handle_read() else: self.handle_read()
self.connected = 1
self.connected = True
def handle_write_event(self): # getting a write implies that we are connected if not self.connected: self.handle_connect() self.connected = 1 self.handle_write()
self.connected = 1
self.connected = True
def __init__(self, fd): dispatcher.__init__(self) self.connected = 1 # set it to non-blocking mode flags = fcntl.fcntl(fd, fcntl.F_GETFL, 0) flags = flags | os.O_NONBLOCK fcntl.fcntl(fd, fcntl.F_SETFL, flags) self.set_file(fd)
try: import win32api import win32con except ImportError:
if not _can_read_reg:
def get_devstudio_versions (): """Get list of devstudio versions from the Windows registry. Return a list of strings containing version numbers; the list will be empty if we were unable to access the registry (eg. couldn't import a registry-access module) or the appropriate registry keys weren't found.""" try: import...
for base in (win32con.HKEY_CLASSES_ROOT, win32con.HKEY_LOCAL_MACHINE, win32con.HKEY_CURRENT_USER, win32con.HKEY_USERS):
for base in (_HKEY_CLASSES_ROOT, _HKEY_LOCAL_MACHINE, _HKEY_CURRENT_USER, _HKEY_USERS):
def get_devstudio_versions (): """Get list of devstudio versions from the Windows registry. Return a list of strings containing version numbers; the list will be empty if we were unable to access the registry (eg. couldn't import a registry-access module) or the appropriate registry keys weren't found.""" try: import...
k = win32api.RegOpenKeyEx(base,K)
k = _RegOpenKeyEx(base,K)
def get_devstudio_versions (): """Get list of devstudio versions from the Windows registry. Return a list of strings containing version numbers; the list will be empty if we were unable to access the registry (eg. couldn't import a registry-access module) or the appropriate registry keys weren't found.""" try: import...
p = win32api.RegEnumKey(k,i)
p = _RegEnumKey(k,i)
def get_devstudio_versions (): """Get list of devstudio versions from the Windows registry. Return a list of strings containing version numbers; the list will be empty if we were unable to access the registry (eg. couldn't import a registry-access module) or the appropriate registry keys weren't found.""" try: import...
except win32api.error:
except _RegError:
def get_devstudio_versions (): """Get list of devstudio versions from the Windows registry. Return a list of strings containing version numbers; the list will be empty if we were unable to access the registry (eg. couldn't import a registry-access module) or the appropriate registry keys weren't found.""" try: import...
try: import win32api import win32con except ImportError:
if not _can_read_reg:
def get_msvc_paths (path, version='6.0', platform='x86'): """Get a list of devstudio directories (include, lib or path). Return a list of strings; will be empty list if unable to access the registry or appropriate registry keys not found.""" try: import win32api import win32con except ImportError: return [] L = [] i...
for base in (win32con.HKEY_CLASSES_ROOT, win32con.HKEY_LOCAL_MACHINE, win32con.HKEY_CURRENT_USER, win32con.HKEY_USERS):
for base in (_HKEY_CLASSES_ROOT, _HKEY_LOCAL_MACHINE, _HKEY_CURRENT_USER, _HKEY_USERS):
def get_msvc_paths (path, version='6.0', platform='x86'): """Get a list of devstudio directories (include, lib or path). Return a list of strings; will be empty list if unable to access the registry or appropriate registry keys not found.""" try: import win32api import win32con except ImportError: return [] L = [] i...
k = win32api.RegOpenKeyEx(base,K)
k = _RegOpenKeyEx(base,K)
def get_msvc_paths (path, version='6.0', platform='x86'): """Get a list of devstudio directories (include, lib or path). Return a list of strings; will be empty list if unable to access the registry or appropriate registry keys not found.""" try: import win32api import win32con except ImportError: return [] L = [] i...
(p,v,t) = win32api.RegEnumValue(k,i)
(p,v,t) = _RegEnumValue(k,i)
def get_msvc_paths (path, version='6.0', platform='x86'): """Get a list of devstudio directories (include, lib or path). Return a list of strings; will be empty list if unable to access the registry or appropriate registry keys not found.""" try: import win32api import win32con except ImportError: return [] L = [] i...
except win32api.error:
except _RegError:
def get_msvc_paths (path, version='6.0', platform='x86'): """Get a list of devstudio directories (include, lib or path). Return a list of strings; will be empty list if unable to access the registry or appropriate registry keys not found.""" try: import win32api import win32con except ImportError: return [] L = [] i...
return None
return self.pimpprefs.check()
def setuppimp(self, url): self.pimpprefs = pimp.PimpPreferences() self.pimpdb = pimp.PimpDatabase(self.pimpprefs) self.pimpinstaller = pimp.PimpInstaller(self.pimpdb) if not url: url = self.pimpprefs.pimpDatabase try: self.pimpdb.appendURL(url) except IOError, arg: return "Cannot open %s: %s" % (url, arg) return None
"""Return a random string usable as a multipart boundary. The method used is so that it is *very* unlikely that the same string of characters will every occur again in the Universe, so the caller needn't check the data it is packing for the occurrence of the boundary.
"""Return a string usable as a multipart boundary. The string chosen is unique within a single program run, and incorporates the user id (if available), process id (if available), and current time. So it's very unlikely the returned string appears in message text, but there's no guarantee.
def choose_boundary(): """Return a random string usable as a multipart boundary. The method used is so that it is *very* unlikely that the same string of characters will every occur again in the Universe, so the caller needn't check the data it is packing for the occurrence of the boundary. The boundary contains dots ...
timestamp = '%.3f' % time.time() seed = `random.randint(0, 32767)` return _prefix + '.' + timestamp + '.' + seed
return "%s.%.3f.%d" % (_prefix, time.time(), _get_next_counter())
def choose_boundary(): """Return a random string usable as a multipart boundary. The method used is so that it is *very* unlikely that the same string of characters will every occur again in the Universe, so the caller needn't check the data it is packing for the occurrence of the boundary. The boundary contains dots ...
editor.ted.WEUseText(Res.Resource(Text)) editor.ted.WECalText() editor.SetPort() editor.GetWindow().InvalWindowRect(editor._bounds)
editor.set(Text)
def replaceall(self): editor = findeditor(self) if not editor: return if self.visible: self.getparmsfromwindow() W.SetCursor("watch") find = self.parms["find"] if not find: return findlen = len(find) replace = self.parms["replace"] replacelen = len(replace) Text = editor.get() if not self.parms["casesens"]: find = stri...
tmpdir = os.path.realpath(tmpdir)
cwd = os.getcwd() os.chdir(tmpdir) tmpdir = os.getcwd() os.chdir(cwd)
def test_cwd(self): tmpdir = os.getenv("TEMP", "/tmp") tmpdir = os.path.realpath(tmpdir) p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' \ 'sys.stdout.write(os.getcwd())'], stdout=subprocess.PIPE, cwd=tmpdir) normcase = os.path.normcase self.assertEqual(normcase(p.stdout.read()), normcase(tmpdir))
+ If you continue a line via backslashing in an interactive session, or for any other reason use a backslash, you need to double the backslash in the docstring version. This is simply because you're in a string, and so the backslash must be escaped for it to survive intact. Like: >>> if "yes" == \\ ... "y" + \...
+ If you continue a line via backslashing in an interactive session, or for any other reason use a backslash, you should use a raw docstring, which will preserve your backslahses exactly as you type them: >>> def f(x): ... r'''Backslashes in a raw docstring: m\n''' >>> print f.__doc__ Backslashes in a raw docstrin...
def _test(): import doctest import sys verbose = "-v" in sys.argv for mod in modules: doctest.testmod(mod, verbose=verbose, report=0) doctest.master.summarize()
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...
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...
def __init__(self, sock, debuglevel=0):
def __init__(self, sock, debuglevel=0, strict=0):
def __init__(self, sock, debuglevel=0): self.fp = sock.makefile('rb', 0) self.debuglevel = debuglevel
version = "HTTP/0.9" status = "200" reason = "" if version[:5] != 'HTTP/': self.close() raise BadStatusLine(line)
version = "" if not version.startswith('HTTP/'): if self.strict: self.close() raise BadStatusLine(line) else: self.fp = LineAndFileWrapper(line, self.fp) return "HTTP/0.9", 200, ""
def _read_status(self): line = self.fp.readline() if self.debuglevel > 0: print "reply:", repr(line) try: [version, status, reason] = line.split(None, 2) except ValueError: try: [version, status] = line.split(None, 1) reason = "" except ValueError: version = "HTTP/0.9" status = "200" reason = "" if version[:5] != 'HTTP...
def __init__(self, host, port=None):
strict = 0 def __init__(self, host, port=None, strict=None):
def getheader(self, name, default=None): if self.msg is None: raise ResponseNotReady() return self.msg.getheader(name, default)
response = self.response_class(self.sock, self.debuglevel) else: response = self.response_class(self.sock)
response = self.response_class(self.sock, self.debuglevel, strict=self.strict) else: response = self.response_class(self.sock, strict=self.strict)
def getresponse(self): "Get the response from the server."
def __init__(self, host, port=None, key_file=None, cert_file=None): HTTPConnection.__init__(self, host, port)
def __init__(self, host, port=None, key_file=None, cert_file=None, strict=None): HTTPConnection.__init__(self, host, port, strict)
def __init__(self, host, port=None, key_file=None, cert_file=None): HTTPConnection.__init__(self, host, port) self.key_file = key_file self.cert_file = cert_file
def __init__(self, host='', port=None):
def __init__(self, host='', port=None, strict=None):
def __init__(self, host='', port=None): "Provide a default host, since the superclass requires one."
self._setup(self._connection_class(host, port))
self._setup(self._connection_class(host, port, strict))
def __init__(self, host='', port=None): "Provide a default host, since the superclass requires one."
def __init__(self, host='', port=None, **x509):
def __init__(self, host='', port=None, key_file=None, cert_file=None, strict=None):
def __init__(self, host='', port=None, **x509): # provide a default host, pass the X509 cert info
self._setup(self._connection_class(host, port, **x509))
self._setup(self._connection_class(host, port, key_file, cert_file, strict))
def __init__(self, host='', port=None, **x509): # provide a default host, pass the X509 cert info
self.key_file = x509.get('key_file') self.cert_file = x509.get('cert_file')
self.key_file = key_file self.cert_file = cert_file
def __init__(self, host='', port=None, **x509): # provide a default host, pass the X509 cert info
supported_dists=('SuSE','debian','redhat','mandrake')):
supported_dists=('SuSE', 'debian', 'fedora', 'redhat', 'mandrake')):
def dist(distname='',version='',id='', supported_dists=('SuSE','debian','redhat','mandrake')): """ Tries to determine the name of the Linux OS distribution name. The function first looks for a distribution release file in /etc and then reverts to _dist_try_harder() in case no suitable files are found. Returns a tup...
info = metadata.long_description + '\n'
info = metadata.long_description or '' + '\n'
def create_inifile (self): # Create an inifile containing data describing the installation. # This could be done without creating a real file, but # a file is (at least) useful for debugging bdist_wininst.
inifile.write ("pyc_compile=%d\n" % self.target_compile) inifile.write ("pyo_compile=%d\n" % self.target_optimize)
def create_inifile (self): # Create an inifile containing data describing the installation. # This could be done without creating a real file, but # a file is (at least) useful for debugging bdist_wininst.
vers_minor = string.split (self.target_version, '.')[1] inifile.write ("vers_minor=%s\n" % vers_minor)
inifile.write ("target_version=%s\n" % self.target_version)
def create_inifile (self): # Create an inifile containing data describing the installation. # This could be done without creating a real file, but # a file is (at least) useful for debugging bdist_wininst.
import struct, zlib
import struct
def create_exe (self, arcname, fullname): import struct, zlib
comp_method = zlib.DEFLATED co = zlib.compressobj (zlib.Z_DEFAULT_COMPRESSION, comp_method, -15) zcfgdata = co.compress (cfgdata) + co.flush()
def create_exe (self, arcname, fullname): import struct, zlib
file.write (zcfgdata) crc32 = zlib.crc32 (cfgdata) header = struct.pack ("<iiiiiiii", 0x12345678, comp_method, crc32, len (cfgdata), len (zcfgdata), 0, 0, 0)
file.write (cfgdata) header = struct.pack ("<ii", 0x12345679, len (cfgdata))
def create_exe (self, arcname, fullname): import struct, zlib
import zlib, base64 return zlib.decompress (base64.decodestring (EXEDATA))
import base64 return base64.decodestring (EXEDATA)
def get_exe_bytes (self): import zlib, base64 return zlib.decompress (base64.decodestring (EXEDATA))
import zlib, base64 file = r"c:\wininst\wininst.exe"
import base64 file = r"..\..\misc\wininst.exe"
def get_exe_bytes (self): import zlib, base64 return zlib.decompress (base64.decodestring (EXEDATA))
cdata = zlib.compress (data, 9) bdata = base64.encodestring (cdata)
bdata = base64.encodestring (data)
def get_exe_bytes (self): import zlib, base64 return zlib.decompress (base64.decodestring (EXEDATA))
print "%d %d %d" % (len (data), len (cdata), len (bdata)) EXEDATA = """ eNrtfQt4U9eV7pEl28IIJIJNlMRJlCBaN3JcE5uMiYDK2HJMsI1s2TIkDsbYMrLwK9IRj4akENkT DhvlMU06aW/bSZp2pnMnM5OZ5jY0bYONSQzkwcMp0JJpIO1NZQyEJATMU/df+2z5BalnvszMN/f7 fPi29jl7r7X2WmuvvdbaW0em9P6nJK0kSTqUWEyStknq5ZDGv46iTL31tanSK5PeuW2bpuSd2yp9 TUFLe6BtVaCuxVJf...
print "%d %d" % (len (data), len (bdata)) EXEDATA = """\ TVqQAAMAAAAEAAAA//8AALgAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAA4AAAAA4fug4AtAnNIbgBTM0hVGhpcyBwcm9ncmFtIGNhbm5vdCBiZSBydW4gaW4gRE9TIG1v ZGUuDQ0KJAAAAAAAAADq0pWMrrP7366z+9+us/vf1a/336+z+98tr/XfrLP731GT/9+ss/vfzKzo 36az+9+us/rf9rP7366z+9+js/vfUZP...
def get_exe_bytes (self): import zlib, base64 return zlib.decompress (base64.decodestring (EXEDATA))
pat = r'''[l-]..x..x..x
pat = r'''d.........
def test_getstatus(self): # This pattern should match 'ls -ld /bin/ls' on any posix # system, however perversely configured. pat = r'''[l-]..x..x..x # It is executable. (May be a symlink.) \s+\d+ # It has some number of links. \s+\w+\s+\w+ # It has a user and group, which may # be named anything. [^/]* ...
/bin/ls
/.
def test_getstatus(self): # This pattern should match 'ls -ld /bin/ls' on any posix # system, however perversely configured. pat = r'''[l-]..x..x..x # It is executable. (May be a symlink.) \s+\d+ # It has some number of links. \s+\w+\s+\w+ # It has a user and group, which may # be named anything. [^/]* ...
self.assert_(re.match(pat, getstatus("/bin/ls"), re.VERBOSE))
self.assert_(re.match(pat, getstatus("/."), re.VERBOSE))
def test_getstatus(self): # This pattern should match 'ls -ld /bin/ls' on any posix # system, however perversely configured. pat = r'''[l-]..x..x..x # It is executable. (May be a symlink.) \s+\d+ # It has some number of links. \s+\w+\s+\w+ # It has a user and group, which may # be named anything. [^/]* ...
a = -1 b = -1 c = -1
Unpack list
def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError
if verbose: print 'unpack tuple' a, b, c = t if a != 1 or b != 2 or c != 3: raise TestFailed
>>> l = [4, 5, 6] >>> a, b, c = l >>> a == 4 and b == 5 and c == 6 True
def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError
if verbose: print 'unpack list' a, b, c = l if a != 4 or b != 5 or c != 6: raise TestFailed
Unpack implied tuple
def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError
if verbose: print 'unpack implied tuple' a, b, c = 7, 8, 9 if a != 7 or b != 8 or c != 9: raise TestFailed
>>> a, b, c = 7, 8, 9 >>> a == 7 and b == 8 and c == 9 True
def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError
if verbose: print 'unpack string' a, b, c = 'one' if a != 'o' or b != 'n' or c != 'e': raise TestFailed
Unpack string... fun!
def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError
if verbose: print 'unpack sequence' a, b, c = Seq() if a != 0 or b != 1 or c != 2: raise TestFailed
>>> a, b, c = 'one' >>> a == 'o' and b == 'n' and c == 'e' True
def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError
if verbose: print 'unpack single tuple/list' st = (99,) sl = [100] a, = st if a != 99: raise TestFailed b, = sl if b != 100: raise TestFailed
Unpack generic sequence
def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError
>>> class Seq: ... def __getitem__(self, i): ... if i >= 0 and i < 3: return i ... raise IndexError ... >>> a, b, c = Seq() >>> a == 0 and b == 1 and c == 2 True
def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError
if verbose: print 'unpack non-sequence' try: a, b, c = 7 raise TestFailed except TypeError: pass
Single element unpacking, with extra syntax
def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError
if verbose: print 'unpack tuple wrong size' try: a, b = t raise TestFailed except ValueError: pass
Now for some failures
def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError
if verbose: print 'unpack list wrong size' try: a, b = l raise TestFailed except ValueError: pass
Unpacking non-sequence
def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError
if verbose: print 'unpack sequence too short' try: a, b, c, d = Seq() raise TestFailed except ValueError: pass
Unpacking tuple of wrong size
def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError
if verbose: print 'unpack sequence too long' try: a, b = Seq() raise TestFailed except ValueError: pass
Unpacking tuple of wrong size
def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError
class BozoError(Exception): pass
Unpacking sequence too short
def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError
class BadSeq: def __getitem__(self, i): if i >= 0 and i < 3: return i elif i == 3: raise BozoError else: raise IndexError
>>> a, b, c, d = Seq() Traceback (most recent call last): ... ValueError: need more than 3 values to unpack
def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError
if verbose: print 'unpack sequence too long, wrong error' try: a, b, c, d, e = BadSeq() raise TestFailed except BozoError: pass
>>> a, b = Seq() Traceback (most recent call last): ... ValueError: too many values to unpack
def __getitem__(self, i): if i >= 0 and i < 3: return i elif i == 3: raise BozoError else: raise IndexError
if verbose: print 'unpack sequence too short, wrong error' try: a, b, c = BadSeq() raise TestFailed except BozoError: pass
Unpacking a sequence where the test for too long raises a different kind of error >>> class BozoError(Exception): ... pass ... >>> class BadSeq: ... def __getitem__(self, i): ... if i >= 0 and i < 3: ... return i ... elif i == 3: ... raise BozoError ... else: ......
def __getitem__(self, i): if i >= 0 and i < 3: return i elif i == 3: raise BozoError else: raise IndexError
return copy.copy(self)
data = self.data try: self.data = {} c = copy.copy(self) finally: self.data = data c.update(self) return c
def copy(self): if self.__class__ is UserDict: return UserDict(self.data) import copy return copy.copy(self)
eq(value, 'text/plain; charset=us-ascii; boundary="BOUNDARY"')
eq(value, 'text/plain; charset="us-ascii"; boundary="BOUNDARY"')
def test_set_boundary(self): eq = self.assertEqual # This one has no existing boundary parameter, but the Content-Type: # header appears fifth. msg = self._msgobj('msg_01.txt') msg.set_boundary('BOUNDARY') header, value = msg.items()[4] eq(header.lower(), 'content-type') eq(value, 'text/plain; charset=us-ascii; boundar...
self._writeBody(msg) else: specific = UNDERSCORE.join(ctype.split('/')).replace('-', '_') meth = getattr(self, '_handle_' + specific, None)
ctype = msg.get_default_type() assert ctype in ('text/plain', 'message/rfc822') main, sub = ctype.split('/') specific = UNDERSCORE.join((main, sub)).replace('-', '_') meth = getattr(self, '_handle_' + specific, None) if meth is None: generic = main.replace('-', '_') meth = getattr(self, '_handle_' + generic, None)
def _dispatch(self, msg): # Get the Content-Type: for the message, then try to dispatch to # self._handle_maintype_subtype(). If there's no handler for the full # MIME type, then dispatch to self._handle_maintype(). If that's # missing too, then dispatch to self._writeBody(). ctype = msg.get_type() if ctype is None: ...
generic = msg.get_main_type().replace('-', '_') meth = getattr(self, '_handle_' + generic, None) if meth is None: meth = self._writeBody meth(msg)
meth = self._writeBody meth(msg)
def _dispatch(self, msg): # Get the Content-Type: for the message, then try to dispatch to # self._handle_maintype_subtype(). If there's no handler for the full # MIME type, then dispatch to self._handle_maintype(). If that's # missing too, then dispatch to self._writeBody(). ctype = msg.get_type() if ctype is None: ...
def _handle_multipart(self, msg, isdigest=0):
def _handle_multipart(self, msg):
def _handle_multipart(self, msg, isdigest=0): # The trick here is to write out each part separately, merge them all # together, and then make sure that the boundary we've chosen isn't # present in the payload. msgtexts = [] subparts = msg.get_payload() if subparts is None: # Nothing has every been attached boundary = m...
g = self.__class__(s, self._mangle_from_, self.__maxheaderlen)
g = self.clone(s)
def _handle_multipart(self, msg, isdigest=0): # The trick here is to write out each part separately, merge them all # together, and then make sure that the boundary we've chosen isn't # present in the payload. msgtexts = [] subparts = msg.get_payload() if subparts is None: # Nothing has every been attached boundary = m...
if isdigest: print >> self._fp
def _handle_multipart(self, msg, isdigest=0): # The trick here is to write out each part separately, merge them all # together, and then make sure that the boundary we've chosen isn't # present in the payload. msgtexts = [] subparts = msg.get_payload() if subparts is None: # Nothing has every been attached boundary = m...
if isdigest: joiner += '\n'
def _handle_multipart(self, msg, isdigest=0): # The trick here is to write out each part separately, merge them all # together, and then make sure that the boundary we've chosen isn't # present in the payload. msgtexts = [] subparts = msg.get_payload() if subparts is None: # Nothing has every been attached boundary = m...
def _handle_multipart_digest(self, msg): self._handle_multipart(msg, isdigest=1)
def _handle_multipart_digest(self, msg): self._handle_multipart(msg, isdigest=1)
g = self.__class__(s, self._mangle_from_, self.__maxheaderlen)
g = self.clone(s)
def _handle_message_delivery_status(self, msg): # We can't just write the headers directly to self's file object # because this will leave an extra newline between the last header # block and the boundary. Sigh. blocks = [] for part in msg.get_payload(): s = StringIO() g = self.__class__(s, self._mangle_from_, self.__...
g = self.__class__(s, self._mangle_from_, self.__maxheaderlen)
g = self.clone(s)
def _handle_message(self, msg): s = StringIO() g = self.__class__(s, self._mangle_from_, self.__maxheaderlen) # The payload of a message/rfc822 part should be a multipart sequence # of length 1. The zeroth element of the list should be the Message # object for the subpart.Extract that object, stringify it, and write #...
"can't pickle %s objects" % `t.__name__`
"can't pickle %s object: %s" % (`t.__name__`, `object`)
def save(self, object, pers_save = 0): memo = self.memo
SIGNATURE='MOSS'
def openfile(self, path, activate = 1): if activate: self.activate() self.OpenURL("file:///" + string.join(string.split(path,':'), '/'))
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
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, 30...
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, 30...
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])
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()
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...
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...
d = new.code(3, 3, 3, 3, codestr, (), (), (), "<string>", "<name>", 1, "", (), ())
def f(a): pass c = f.func_code argcount = c.co_argcount nlocals = c.co_nlocals stacksize = c.co_stacksize flags = c.co_flags codestring = c.co_code constants = c.co_consts names = c.co_names varnames = c.co_varnames filename = c.co_filename name = c.co_name firstlineno = c.co_firstlineno lnotab = c.co_lnotab freevars ...
def test_closure(func, closure, exc): try: new.function(func.func_code, {}, "", None, closure) except exc: pass else: print "corrupt closure accepted"
d = new.code(3, 3, 3, 3, codestr, (), (), (), "<string>", "<name>", 1, "")
d = new.code(argcount, nlocals, stacksize, flags, codestring, constants, names, varnames, filename, name, firstlineno, lnotab) try: d = new.code(-argcount, nlocals, stacksize, flags, codestring, constants, names, varnames, filename, name, firstlineno, lnotab) except ValueError: pass else: raise TestFailed, "negative c...
def test_closure(func, closure, exc): try: new.function(func.func_code, {}, "", None, closure) except exc: pass else: print "corrupt closure accepted"
if v == "1": g[n] = 1 else: g[n] = v
try: v = string.atoi(v) except ValueError: pass g[n] = v
undef_rx = re.compile("/[*] #undef ([A-Z][A-Z0-9_]+) [*]/\n")
done[name] = value
try: value = string.atoi(value) except ValueError: pass done[name] = string.strip(value)
undef_rx = re.compile("/[*] #undef ([A-Z][A-Z0-9_]+) [*]/\n")
raise UnimplementedError
raise NotImplementedError
def process_message(self, peer, mailfrom, rcpttos, data): """Override this abstract method to handle messages from the client.
The optional second argument can specify an alternative default."""
The optional second argument can specify an alternate default."""
def getenv(key, default=None): """Get an environment variable, return None if it doesn't exist. The optional second argument can specify an alternative default.""" return environ.get(key, default)
assert mode[:1] in ("b", "t")
def popen2(cmd, mode="t", bufsize=-1): assert mode[:1] in ("b", "t") import popen2 stdout, stdin = popen2.popen2(cmd, bufsize) return stdin, stdout
if status != 100:
if status != CONTINUE:
def begin(self): if self.msg is not None: # we've already started reading the response return
if (status == 204 or status == 304 or
if (status == NO_CONTENT or status == NOT_MODIFIED or
def begin(self): if self.msg is not None: # we've already started reading the response return
return unittest.TestSuite((sqlite_type_suite, decltypes_type_suite, colnames_type_suite, adaptation_suite, date_suite))
return unittest.TestSuite((sqlite_type_suite, decltypes_type_suite, colnames_type_suite, adaptation_suite, bin_suite, date_suite))
def suite(): sqlite_type_suite = unittest.makeSuite(SqliteTypeTests, "Check") decltypes_type_suite = unittest.makeSuite(DeclTypesTests, "Check") colnames_type_suite = unittest.makeSuite(ColNamesTests, "Check") adaptation_suite = unittest.makeSuite(ObjectAdaptationTests, "Check") date_suite = unittest.makeSuite(DateTime...
filter = callable
filter = template
def _subn(pattern, template, string, count=0): # internal: pattern.subn implementation hook if callable(template): filter = callable else: # FIXME: prepare template def filter(match, template=template): return _expand(match, template) n = i = 0 s = [] append = s.append c = pattern.cursor(string) while not count or n < ...
def __init__(self, root=None, font=None, name=None, **options):
def __init__(self, root=None, font=None, name=None, exists=False, **options):
def __init__(self, root=None, font=None, name=None, **options): if not root: root = Tkinter._default_root if font: # get actual settings corresponding to the given font font = root.tk.splitlist(root.tk.call("font", "actual", font)) else: font = self._set(options) if not name: name = "font" + str(id(self)) self.name = n...