rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
db.readfp(f) return db.types_map | db.readfp(f, True) return db.types_map[True] | def read_mime_types(file): try: f = open(file) except IOError: return None db = MimeTypes() db.readfp(f) return db.types_map |
codecs.StreamReader.__init__(self,strict,errors) | codecs.StreamReader.__init__(self,stream,errors) | def __init__(self,stream,errors='strict',mapping=None): |
if optional and len(params) == 1: line = line[m.end():] else: | def subconvert(self, endchar=None, depth=0): stack = [] line = self.line if DEBUG and endchar: self.err_write( "subconvert(%s)\n line = %s\n" % (`endchar`, `line[:20]`)) while line: if line[0] == endchar and not stack: if DEBUG: self.err_write("subconvert() --> %s\n" % `line[1:21]`) self.line = line return line m = _c... | |
if optional and type(params[0]) is type(()): | if optional and type(params[0]) is TupleType: | def subconvert(self, endchar=None, depth=0): stack = [] line = self.line if DEBUG and endchar: self.err_write( "subconvert(%s)\n line = %s\n" % (`endchar`, `line[:20]`)) while line: if line[0] == endchar and not stack: if DEBUG: self.err_write("subconvert() --> %s\n" % `line[1:21]`) self.line = line return line m = _c... |
if type(attrname) is type(""): | if type(attrname) is StringType: | def subconvert(self, endchar=None, depth=0): stack = [] line = self.line if DEBUG and endchar: self.err_write( "subconvert(%s)\n line = %s\n" % (`endchar`, `line[:20]`)) while line: if line[0] == endchar and not stack: if DEBUG: self.err_write("subconvert() --> %s\n" % `line[1:21]`) self.line = line return line m = _c... |
elif type(attrname) is type(()): | elif type(attrname) is TupleType: | def subconvert(self, endchar=None, depth=0): stack = [] line = self.line if DEBUG and endchar: self.err_write( "subconvert(%s)\n line = %s\n" % (`endchar`, `line[:20]`)) while line: if line[0] == endchar and not stack: if DEBUG: self.err_write("subconvert() --> %s\n" % `line[1:21]`) self.line = line return line m = _c... |
elif type(attrname) is type([]): | elif type(attrname) is ListType: | def subconvert(self, endchar=None, depth=0): stack = [] line = self.line if DEBUG and endchar: self.err_write( "subconvert(%s)\n line = %s\n" % (`endchar`, `line[:20]`)) while line: if line[0] == endchar and not stack: if DEBUG: self.err_write("subconvert() --> %s\n" % `line[1:21]`) self.line = line return line m = _c... |
dbgmsg("subconvert() ==> " + `line[:20]`) | def subconvert(self, endchar=None, depth=0): stack = [] line = self.line if DEBUG and endchar: self.err_write( "subconvert(%s)\n line = %s\n" % (`endchar`, `line[:20]`)) while line: if line[0] == endchar and not stack: if DEBUG: self.err_write("subconvert() --> %s\n" % `line[1:21]`) self.line = line return line m = _c... | |
if params and type(params[-1]) is type('') \ | if params and type(params[-1]) is StringType \ | def subconvert(self, endchar=None, depth=0): stack = [] line = self.line if DEBUG and endchar: self.err_write( "subconvert(%s)\n line = %s\n" % (`endchar`, `line[:20]`)) while line: if line[0] == endchar and not stack: if DEBUG: self.err_write("subconvert() --> %s\n" % `line[1:21]`) self.line = line return line m = _c... |
and type(conversion) is not type(""): | and type(conversion) is not StringType: | def subconvert(self, endchar=None, depth=0): stack = [] line = self.line if DEBUG and endchar: self.err_write( "subconvert(%s)\n line = %s\n" % (`endchar`, `line[:20]`)) while line: if line[0] == endchar and not stack: if DEBUG: self.err_write("subconvert() --> %s\n" % `line[1:21]`) self.line = line return line m = _c... |
dummy, fp = os.popen4(cmd, "r") dummy.close() | child = popen2.Popen4(cmd) child.tochild.close() | def _cmd(self, output, dir, *cmditems): """Internal routine to run a shell command in a given directory.""" cmd = ("cd \"%s\"; " % dir) + " ".join(cmditems) if output: output.write("+ %s\n" % cmd) if NO_EXECUTE: return 0 dummy, fp = os.popen4(cmd, "r") dummy.close() while 1: line = fp.readline() if not line: break if ... |
line = fp.readline() | line = child.fromchild.readline() | def _cmd(self, output, dir, *cmditems): """Internal routine to run a shell command in a given directory.""" cmd = ("cd \"%s\"; " % dir) + " ".join(cmditems) if output: output.write("+ %s\n" % cmd) if NO_EXECUTE: return 0 dummy, fp = os.popen4(cmd, "r") dummy.close() while 1: line = fp.readline() if not line: break if ... |
rv = fp.close() return rv | return child.wait() | def _cmd(self, output, dir, *cmditems): """Internal routine to run a shell command in a given directory.""" cmd = ("cd \"%s\"; " % dir) + " ".join(cmditems) if output: output.write("+ %s\n" % cmd) if NO_EXECUTE: return 0 dummy, fp = os.popen4(cmd, "r") dummy.close() while 1: line = fp.readline() if not line: break if ... |
return "install %s: running \"%s\" failed" % self.fullname() | return "install %s: running \"%s\" failed" % \ (self.fullname(), installcmd) | def installPackageOnly(self, output=None): """Install a single source package. If output is given it should be a file-like object and it will receive a log of what happened.""" if self._dict.has_key('Pre-install-command'): if self._cmd(output, self._buildDirname, self._dict['Pre-install-command']): return "pre-instal... |
except error_proto(val): | except error_proto, val: | def quit(self): """Signoff: commit changes on server, unlock mailbox, close connection.""" try: resp = self._shortcmd('QUIT') except error_proto(val): resp = val self.file.close() self.sock.close() del self.file, self.sock return resp |
strip_dir=python_build, | strip_dir=0, | def _setup_compile(self, outdir, macros, incdirs, sources, depends, extra): """Process arguments and decide which source files to compile. |
objects = self.object_filenames(sources, strip_dir=python_build, output_dir=output_dir) | objects = self.object_filenames(sources, output_dir=output_dir) | def _prep_compile(self, sources, output_dir, depends=None): """Decide which souce files must be recompiled. |
_platform_cache = None _platform_aliased_cache = None | _platform_cache = {True:None, False:None} _platform_aliased_cache = {True:None, False:None} | def python_compiler(): """ Returns a string identifying the compiler used for compiling Python. """ return _sys_version()[3] |
if not aliased and (_platform_cache is not None): return _platform_cache elif _platform_aliased_cache is not None: return _platform_aliased_cache | if not aliased and (_platform_cache[bool(terse)] is not None): return _platform_cache[bool(terse)] elif _platform_aliased_cache[bool(terse)] is not None: return _platform_aliased_cache[bool(terse)] | def platform(aliased=0, terse=0): """ Returns a single string identifying the underlying platform with as much useful information as possible (but no more :). The output is intended to be human readable rather than machine parseable. It may look different on different platforms and this is intended. If "aliased" is ... |
_platform_aliased_cache = platform | _platform_aliased_cache[bool(terse)] = platform | def platform(aliased=0, terse=0): """ Returns a single string identifying the underlying platform with as much useful information as possible (but no more :). The output is intended to be human readable rather than machine parseable. It may look different on different platforms and this is intended. If "aliased" is ... |
_platform_cache = platform | _platform_cache[bool(terse)] = platform | def platform(aliased=0, terse=0): """ Returns a single string identifying the underlying platform with as much useful information as possible (but no more :). The output is intended to be human readable rather than machine parseable. It may look different on different platforms and this is intended. If "aliased" is ... |
ok_sys_names = ('ps1', 'ps2', 'copyright', 'version', | ok_sys_names = ('ps1', 'ps2', 'copyright', 'version', 'hexversion', | def default_path(self): return self.rexec.modules['sys'].path |
if cache.has_key(path): return cache[path] cache[path] = ret = os.stat(path) | ret = cache.get(path, None) if ret is None: cache[path] = ret = _os.stat(path) | def stat(path): """Stat a file, possibly out of the cache.""" if cache.has_key(path): return cache[path] cache[path] = ret = os.stat(path) return ret |
def reset(): """Reset the cache completely.""" global cache cache = {} | def reset(): """Reset the cache completely.""" global cache cache = {} | |
if cache.has_key(path): | try: | def forget(path): """Remove a given item from the cache, if it exists.""" if cache.has_key(path): del cache[path] |
except KeyError: pass | def forget(path): """Remove a given item from the cache, if it exists.""" if cache.has_key(path): del cache[path] | |
n = len(prefix) | def forget_prefix(prefix): """Remove all pathnames with a given prefix.""" n = len(prefix) for path in cache.keys(): if path[:n] == prefix: del cache[path] | |
if path[:n] == prefix: del cache[path] | if path.startswith(prefix): forget(path) | def forget_prefix(prefix): """Remove all pathnames with a given prefix.""" n = len(prefix) for path in cache.keys(): if path[:n] == prefix: del cache[path] |
if prefix[-1:] == '/' and prefix != '/': prefix = prefix[:-1] | from os.path import split, join prefix = split(join(prefix, "xxx"))[0] | def forget_dir(prefix): """Forget about a directory and all entries in it, but not about entries in subdirectories.""" if prefix[-1:] == '/' and prefix != '/': prefix = prefix[:-1] forget(prefix) if prefix[-1:] != '/': prefix = prefix + '/' n = len(prefix) for path in cache.keys(): if path[:n] == prefix: rest = path[n:... |
if prefix[-1:] != '/': prefix = prefix + '/' n = len(prefix) | def forget_dir(prefix): """Forget about a directory and all entries in it, but not about entries in subdirectories.""" if prefix[-1:] == '/' and prefix != '/': prefix = prefix[:-1] forget(prefix) if prefix[-1:] != '/': prefix = prefix + '/' n = len(prefix) for path in cache.keys(): if path[:n] == prefix: rest = path[n:... | |
if path[:n] == prefix: rest = path[n:] if rest[-1:] == '/': rest = rest[:-1] if '/' not in rest: del cache[path] | if path.startswith(prefix) and split(path)[0] == prefix: forget(path) | def forget_dir(prefix): """Forget about a directory and all entries in it, but not about entries in subdirectories.""" if prefix[-1:] == '/' and prefix != '/': prefix = prefix[:-1] forget(prefix) if prefix[-1:] != '/': prefix = prefix + '/' n = len(prefix) for path in cache.keys(): if path[:n] == prefix: rest = path[n:... |
Normally used with prefix = '/' after a chdir().""" n = len(prefix) | Normally used with prefix = '/' after a chdir(). """ | def forget_except_prefix(prefix): """Remove all pathnames except with a given prefix. Normally used with prefix = '/' after a chdir().""" n = len(prefix) for path in cache.keys(): if path[:n] != prefix: del cache[path] |
if path[:n] != prefix: del cache[path] | if not path.startswith(prefix): forget(path) | def forget_except_prefix(prefix): """Remove all pathnames except with a given prefix. Normally used with prefix = '/' after a chdir().""" n = len(prefix) for path in cache.keys(): if path[:n] != prefix: del cache[path] |
weekdayname = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] monthname = [None, 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] def date_time(self): """Return the current date and time formatted for a MIME header.""" year, month, day, hh, mm, ss, wd, y, z = time.gmtime(time.time... | def getSubject(self, record): """ Determine the subject for the email. | |
self.date_time(), msg) | formatdate(), msg) | def emit(self, record): """ Emit a record. |
print 'XXX', (_function, (_object,), _parameters) | def callback_wrapper(self, _request, _reply): _parameters, _attributes = aetools.unpackevent(_request) _class = _attributes['evcl'].type _type = _attributes['evid'].type if self.ae_handlers.has_key((_class, _type)): _function = self.ae_handlers[(_class, _type)] elif self.ae_handlers.has_key((_class, '****')): _functio... | |
des = "_%s__%s" % (klass.__name__, name) | des = "1" | def adaptgetter(name, klass, getter): kind, des = getter if kind == 1: # AV happens when stepping from this line to next if des == "": des = "_%s__%s" % (klass.__name__, name) return lambda obj: getattr(obj, des) |
print "20. eval with free variables" | print "20. eval and exec with free variables" | def adaptgetter(name, klass, getter): kind, des = getter if kind == 1: # AV happens when stepping from this line to next if des == "": des = "_%s__%s" % (klass.__name__, name) return lambda obj: getattr(obj, des) |
return apply(pow, params) | return pow(*params) | def _dispatch(self, method, params): if method == 'pow': return apply(pow, params) elif method == 'add': return params[0] + params[1] else: raise 'bad method' |
4. Subclass SimpleXMLRPCRequestHandler: class MathHandler(SimpleXMLRPCRequestHandler): | 4. Subclass SimpleXMLRPCServer: class MathServer(SimpleXMLRPCServer): | def _dispatch(self, method, params): if method == 'pow': return apply(pow, params) elif method == 'add': return params[0] + params[1] else: raise 'bad method' |
return apply(func, params) def log_message(self, format, *args): pass | return func(*params) | def _dispatch(self, method, params): try: # We are forcing the 'export_' prefix on methods that are # callable through XML-RPC to prevent potential security # problems func = getattr(self, 'export_' + method) except AttributeError: raise Exception('method "%s" is not supported' % method) else: return apply(func, params... |
server = SimpleXMLRPCServer(("localhost", 8000), MathHandler) | server = MathServer(("localhost", 8000)) | def export_add(self, x, y): return x + y |
import types import os def resolve_dotted_attribute(obj, attr): """resolve_dotted_attribute(a, 'b.c.d') => a.b.c.d Resolves a dotted attribute name to an object. Raises an AttributeError if any attribute in the chain starts with a '_'. """ for i in attr.split('.'): if i.startswith('_'): raise AttributeError( 'attem... | def export_add(self, x, y): return x + y | |
XML-RPC requests are dispatched to the _dispatch method, which may be overriden by subclasses. The default implementation attempts to dispatch XML-RPC calls to the functions or instance installed in the server. | def export_add(self, x, y): return x + y | |
which are forwarded to the _dispatch method for handling. """ | which are forwarded to the server's _dispatch method for handling. """ | def do_POST(self): """Handles the HTTP POST request. |
params, method = xmlrpclib.loads(data) try: response = self._dispatch(method, params) response = (response,) except: response = xmlrpclib.dumps( xmlrpclib.Fault(1, "%s:%s" % (sys.exc_type, sys.exc_value)) ) else: response = xmlrpclib.dumps(response, methodresponse=1) except: | response = self.server._marshaled_dispatch( data, getattr(self, '_dispatch', None) ) except: | def do_POST(self): """Handles the HTTP POST request. |
def _dispatch(self, method, params): """Dispatches the XML-RPC method. XML-RPC calls are forwarded to a registered function that matches the called XML-RPC method name. If no such function exists then the call is forwarded to the registered instance, if available. If the registered instance has a _dispatch method the... | def do_POST(self): """Handles the HTTP POST request. | |
def _resolve_dotted_attribute(obj, attr): """Resolves a dotted attribute name to an object. Raises an AttributeError if any attribute in the chain starts with a '_'. """ for i in attr.split('.'): if i.startswith('_'): raise AttributeError( 'attempt to access private attribute "%s"' % i ) else: obj = getattr(obj,i) ret... | class SimpleXMLRPCServer(SocketServer.TCPServer, SimpleXMLRPCDispatcher): | def log_request(self, code='-', size='-'): """Selectively log an accepted request.""" |
to be installed to handle requests. | to be installed to handle requests. The default implementation attempts to dispatch XML-RPC calls to the functions or instance installed in the server. Override the _dispatch method inhereted from SimpleXMLRPCDispatcher to change this behavior. | def _resolve_dotted_attribute(obj, attr): """Resolves a dotted attribute name to an object. Raises an AttributeError if any attribute in the chain starts with a '_'. """ for i in attr.split('.'): if i.startswith('_'): raise AttributeError( 'attempt to access private attribute "%s"' % i ) else: obj = getattr(obj,i) ret... |
self.funcs = {} | def __init__(self, addr, requestHandler=SimpleXMLRPCRequestHandler, logRequests=1): self.funcs = {} self.logRequests = logRequests self.instance = None SocketServer.TCPServer.__init__(self, addr, requestHandler) | |
self.instance = None | SimpleXMLRPCDispatcher.__init__(self) | def __init__(self, addr, requestHandler=SimpleXMLRPCRequestHandler, logRequests=1): self.funcs = {} self.logRequests = logRequests self.instance = None SocketServer.TCPServer.__init__(self, addr, requestHandler) |
def register_instance(self, instance): """Registers an instance to respond to XML-RPC requests. Only one instance can be installed at a time. If the registered instance has a _dispatch method then that method will be called with the name of the XML-RPC method and it's parameters as a tuple e.g. instance._dispatch('ad... | class CGIXMLRPCRequestHandler(SimpleXMLRPCDispatcher): """Simple handler for XML-RPC data passed through CGI.""" def __init__(self): SimpleXMLRPCDispatcher.__init__(self) def handle_xmlrpc(self, request_text): """Handle a single XML-RPC request""" response = self._marshaled_dispatch(request_text) print 'Content-Typ... | def __init__(self, addr, requestHandler=SimpleXMLRPCRequestHandler, logRequests=1): self.funcs = {} self.logRequests = logRequests self.instance = None SocketServer.TCPServer.__init__(self, addr, requestHandler) |
def do_clear_break(self, arg): if not arg: self.do_clear("") return arg = string.strip(arg) args = string.split(arg) if len(args) < 2: print '*** Specify file and line number.' return try: line = int(args[1]) except: print '*** line number must be an integer.' return result =self.clear_break(args[0], line) if result: ... | def do_clear(self, arg): # Three possibilities, tried in this order: # clear -> clear all breaks, ask for confirmation # clear file:lineno -> clear all breaks at file:lineno # clear bpno bpno ... -> clear breakpoints by number if not arg: try: reply = raw_input('Clear all breaks? ') except EOFError: reply = 'no' reply ... | |
return apply(Open, (), options).show() | return Open(**options).show() | def askopenfilename(**options): "Ask for a filename to open" return apply(Open, (), options).show() |
return apply(SaveAs, (), options).show() | return SaveAs(**options).show() | def asksaveasfilename(**options): "Ask for a filename to save as" return apply(SaveAs, (), options).show() |
filename = apply(Open, (), options).show() | filename = Open(**options).show() | def askopenfile(mode = "r", **options): "Ask for a filename to open, and returned the opened file" filename = apply(Open, (), options).show() if filename: return open(filename, mode) return None |
filename = apply(SaveAs, (), options).show() | filename = SaveAs(**options).show() | def asksaveasfile(mode = "w", **options): "Ask for a filename to save as, and returned the opened file" filename = apply(SaveAs, (), options).show() if filename: return open(filename, mode) return None |
- reuse_address | - allow_reuse_address | def handle_error(self, request, client_address): """Handle an error gracefully. May be overridden. |
Technically, only a <mailbox> is allowed. In addition, email addresses without a domain are permitted. Addresses will not be modified if they are already quoted (actually if they begin with '<' and end with '>'.""" if re.match('(?s)\A<.*>\Z', addr): | Should be able to handle anything rfc822.parseaddr can handle.""" m=None try: m=rfc822.parseaddr(addr)[1] except AttributeError: pass if not m: | def quoteaddr(addr): """Quote a subset of the email addresses defined by RFC 821. Technically, only a <mailbox> is allowed. In addition, email addresses without a domain are permitted. Addresses will not be modified if they are already quoted (actually if they begin with '<' and end with '>'.""" if re.match('(?s)\A<... |
localpart = None domain = '' try: at = string.rindex(addr, '@') localpart = addr[:at] domain = addr[at:] except ValueError: localpart = addr pat = re.compile(r'([<>()\[\]\\,;:@\"\001-\037\177])') return '<%s%s>' % (pat.sub(r'\\\1', localpart), domain) | else: return "<%s>" % m | def quoteaddr(addr): """Quote a subset of the email addresses defined by RFC 821. Technically, only a <mailbox> is allowed. In addition, email addresses without a domain are permitted. Addresses will not be modified if they are already quoted (actually if they begin with '<' and end with '>'.""" if re.match('(?s)\A<... |
Double leading '.', and change Unix newline '\n' into | Double leading '.', and change Unix newline '\n', or Mac '\r' into | def quotedata(data): """Quote data for email. Double leading '.', and change Unix newline '\n' into Internet CRLF end-of-line.""" return re.sub(r'(?m)^\.', '..', re.sub(r'\r?\n', CRLF, data)) |
re.sub(r'\r?\n', CRLF, data)) | re.sub(r'(?:\r\n|\n|\r(?!\n))', CRLF, data)) | def quotedata(data): """Quote data for email. Double leading '.', and change Unix newline '\n' into Internet CRLF end-of-line.""" return re.sub(r'(?m)^\.', '..', re.sub(r'\r?\n', CRLF, data)) |
esmtp_features = [] | does_esmtp = 0 | def quotedata(data): """Quote data for email. Double leading '.', and change Unix newline '\n' into Internet CRLF end-of-line.""" return re.sub(r'(?m)^\.', '..', re.sub(r'\r?\n', CRLF, data)) |
def verify(self, address): """ SMTP 'verify' command. Checks for address validity. """ self.putcmd("vrfy", address) return self.getreply() | def verify(self, address): """ SMTP 'verify' command. Checks for address validity. """ self.putcmd("vrfy", address) return self.getreply() | |
that suffix will be stripped off and the number interpreted as the port number to use. | and there is no port specified, that suffix will be stripped off and the number interpreted as the port number to use. | def connect(self, host='localhost', port = 0): """Connect to a host on a given port. |
self.sock.send(str) | try: self.sock.send(str) except socket.error: raise SMTPServerDisconnected | def send(self, str): """Send `str' to the server.""" if self.debuglevel > 0: print 'send:', `str` if self.sock: self.sock.send(str) else: raise SMTPServerDisconnected |
def getreply(self, linehook=None): | def getreply(self): | def getreply(self, linehook=None): """Get a reply from the server. Returns a tuple consisting of: - server response code (e.g. '250', or such, if all goes well) Note: returns -1 if it can't read response code. - server response string corresponding to response code (note : multiline responses converted to a single, mu... |
elif linehook: linehook(line) | def getreply(self, linehook=None): """Get a reply from the server. Returns a tuple consisting of: - server response code (e.g. '250', or such, if all goes well) Note: returns -1 if it can't read response code. - server response string corresponding to response code (note : multiline responses converted to a single, mu... | |
defaults to the FQDN of the local host """ | defaults to the FQDN of the local host. """ | 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(self.ehlo_hook) self.ehlo_resp=msg return code |
(code,msg)=self.getreply(self.ehlo_hook) | (code,msg)=self.getreply() if code == -1 and len(msg) == 0: raise SMTPServerDisconnected | 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(self.ehlo_hook) self.ehlo_resp=msg return code |
def ehlo_hook(self, line): if line[4] in string.uppercase+string.digits: self.esmtp_features.append(string.lower(string.strip(line)[4:])) def has_option(self, opt): """Does the server support a given SMTP option?""" return opt in self.esmtp_features | def has_extn(self, opt): """Does the server support a given SMTP service extension?""" return self.esmtp_features.has_key(string.lower(opt)) | def ehlo_hook(self, line): # Interpret EHLO response lines if line[4] in string.uppercase+string.digits: self.esmtp_features.append(string.lower(string.strip(line)[4:])) |
if options: options = " " + string.joinfields(options, ' ') else: options = '' self.putcmd("mail", "from:" + quoteaddr(sender) + options) | optionlist = '' if options and self.does_esmtp: optionlist = string.join(options, ' ') self.putcmd("mail", "FROM:%s %s" % (quoteaddr(sender) ,optionlist)) | def mail(self,sender,options=[]): """ SMTP 'mail' command. Begins mail xfer session. """ if options: options = " " + string.joinfields(options, ' ') else: options = '' self.putcmd("mail", "from:" + quoteaddr(sender) + options) return self.getreply() |
def rcpt(self,recip): | def rcpt(self,recip,options=[]): | def rcpt(self,recip): """ SMTP 'rcpt' command. Indicates 1 recipient for this mail. """ self.putcmd("rcpt","to:%s" % quoteaddr(recip)) return self.getreply() |
self.putcmd("rcpt","to:%s" % quoteaddr(recip)) | optionlist = '' if options and self.does_esmtp: optionlist = string.join(options, ' ') self.putcmd("rcpt","TO:%s %s" % (quoteaddr(recip),optionlist)) | def rcpt(self,recip): """ SMTP 'rcpt' command. Indicates 1 recipient for this mail. """ self.putcmd("rcpt","to:%s" % quoteaddr(recip)) return self.getreply() |
def sendmail(self,from_addr,to_addrs,msg,options=[]): | def sendmail(self,from_addr,to_addrs,msg,mail_options=[],rcpt_options=[]): | def sendmail(self,from_addr,to_addrs,msg,options=[]): """ This command performs an entire mail transaction. The arguments are: - from_addr : The address sending this mail. - to_addrs : a list of addresses to send this mail to - msg : the message to send. - encoding : list of ESMTP options (such as 8bitmime) |
- encoding : list of ESMTP options (such as 8bitmime) | - mail_options : list of ESMTP options (such as 8bitmime) for the mail command - rcpt_options : List of ESMTP options (such as DSN commands) for all the rcpt commands | def sendmail(self,from_addr,to_addrs,msg,options=[]): """ This command performs an entire mail transaction. The arguments are: - from_addr : The address sending this mail. - to_addrs : a list of addresses to send this mail to - msg : the message to send. - encoding : list of ESMTP options (such as 8bitmime) |
size and each of the specified options will be passed to it (if the option is in the feature set the server advertises). If EHLO fails, HELO will be tried and ESMTP options suppressed. | size and each of the specified options will be passed to it. If EHLO fails, HELO will be tried and ESMTP options suppressed. | def sendmail(self,from_addr,to_addrs,msg,options=[]): """ This command performs an entire mail transaction. The arguments are: - from_addr : The address sending this mail. - to_addrs : a list of addresses to send this mail to - msg : the message to send. - encoding : list of ESMTP options (such as 8bitmime) |
if self.esmtp_features: self.esmtp_features.append('7bit') | def sendmail(self,from_addr,to_addrs,msg,options=[]): """ This command performs an entire mail transaction. The arguments are: - from_addr : The address sending this mail. - to_addrs : a list of addresses to send this mail to - msg : the message to send. - encoding : list of ESMTP options (such as 8bitmime) | |
if 'size' in self.esmtp_features: esmtp_opts.append("size=" + `len(msg)`) for option in options: if option in self.esmtp_features: | if self.does_esmtp: if self.has_extn('size'): esmtp_opts.append("size=" + `len(msg)`) for option in mail_options: | def sendmail(self,from_addr,to_addrs,msg,options=[]): """ This command performs an entire mail transaction. The arguments are: - from_addr : The address sending this mail. - to_addrs : a list of addresses to send this mail to - msg : the message to send. - encoding : list of ESMTP options (such as 8bitmime) |
(code,resp)=self.rcpt(each) | (code,resp)=self.rcpt(each, rcpt_options) | def sendmail(self,from_addr,to_addrs,msg,options=[]): """ This command performs an entire mail transaction. The arguments are: - from_addr : The address sending this mail. - to_addrs : a list of addresses to send this mail to - msg : the message to send. - encoding : list of ESMTP options (such as 8bitmime) |
rm(filename + '.dir') rm(filename + '.dat') rm(filename + '.bak') | def test_dumbdbm_read(self): f = dumbdbm.open(self._fname, 'r') self.read_helper(f) f.close() def test_dumbdbm_keys(self): f = dumbdbm.open(self._fname) keys = self.keys_helper(f) f.close() def read_helper(self, f): keys = self.keys_helper(f) for key in self._dict: self.assertEqual(self._dict[key], f[key]) def keys_... | def rm(fn): try: os.unlink(fn) except os.error: pass |
kControlProgressBarIndeterminateTag = 'inde' | def AskYesNoCancel(question, default = 0, yes=None, no=None, cancel=None, id=262): """Display a QUESTION string which can be answered with Yes or No. Return 1 when the user clicks the Yes button. Return 0 when the user clicks the No button. Return -1 when the user clicks the Cancel button. When the user presses Retur... | |
def __init__(self, title="Working...", maxval=100, label="", id=263): | def __init__(self, title="Working...", maxval=0, label="", id=263): | def __init__(self, title="Working...", maxval=100, label="", id=263): self.w = None self.d = None self.maxval = maxval self.curval = -1 self.d = GetNewDialog(id, -1) self.w = self.d.GetDialogWindow() self.label(label) self._update(0) self.d.AutoSizeDialog() self.title(title) self.w.ShowWindow() self.d.DrawDialog() |
self.maxval = maxval self.curval = -1 | def __init__(self, title="Working...", maxval=100, label="", id=263): self.w = None self.d = None self.maxval = maxval self.curval = -1 self.d = GetNewDialog(id, -1) self.w = self.d.GetDialogWindow() self.label(label) self._update(0) self.d.AutoSizeDialog() self.title(title) self.w.ShowWindow() self.d.DrawDialog() | |
self._update(0) | self.title(title) self.set(0, maxval) | def __init__(self, title="Working...", maxval=100, label="", id=263): self.w = None self.d = None self.maxval = maxval self.curval = -1 self.d = GetNewDialog(id, -1) self.w = self.d.GetDialogWindow() self.label(label) self._update(0) self.d.AutoSizeDialog() self.title(title) self.w.ShowWindow() self.d.DrawDialog() |
self.title(title) | def __init__(self, title="Working...", maxval=100, label="", id=263): self.w = None self.d = None self.maxval = maxval self.curval = -1 self.d = GetNewDialog(id, -1) self.w = self.d.GetDialogWindow() self.label(label) self._update(0) self.d.AutoSizeDialog() self.title(title) self.w.ShowWindow() self.d.DrawDialog() | |
if maxval == 0: value = 0 maxval = 1 if maxval > 32767: value = int(value/(maxval/32767.0)) maxval = 32767 progbar = self.d.GetDialogItemAsControl(3) progbar.SetControlMaximum(maxval) progbar.SetControlValue(value) | if maxval == 0: Ctl.IdleControls(self.w) else: if maxval > 32767: value = int(value/(maxval/32767.0)) maxval = 32767 progbar = self.d.GetDialogItemAsControl(3) progbar.SetControlMaximum(maxval) progbar.SetControlValue(value) | def _update(self, value): maxval = self.maxval if maxval == 0: # XXXX Quick fix. Should probably display an unknown duration value = 0 maxval = 1 if maxval > 32767: value = int(value/(maxval/32767.0)) maxval = 32767 progbar = self.d.GetDialogItemAsControl(3) progbar.SetControlMaximum(maxval) progbar.SetControlValue(val... |
if value < 0: value = 0 if value > self.maxval: value = self.maxval | bar = self.d.GetDialogItemAsControl(3) if max <= 0: bar.SetControlData(0,kControlProgressBarIndeterminateTag,'\x01') else: bar.SetControlData(0,kControlProgressBarIndeterminateTag,'\x00') if value < 0: value = 0 elif value > self.maxval: value = self.maxval | def set(self, value, max=None): """set(value) - Set progress bar position""" if max != None: self.maxval = max if value < 0: value = 0 if value > self.maxval: value = self.maxval self.curval = value self._update(value) |
bar = ProgressBar("Progress, progress...", 100) | bar = ProgressBar("Progress, progress...", 0, label="Ramping up...") | def test(): import time, sys Message("Testing EasyDialogs.") optionlist = (('v', 'Verbose'), ('verbose', 'Verbose as long option'), ('flags=', 'Valued option'), ('f:', 'Short valued option')) commandlist = (('start', 'Start something'), ('stop', 'Stop something')) argv = GetArgv(optionlist=optionlist, commandlist=comm... |
for i in range(100): | for i in xrange(20): bar.inc() time.sleep(0.05) bar.set(0,100) for i in xrange(100): | def test(): import time, sys Message("Testing EasyDialogs.") optionlist = (('v', 'Verbose'), ('verbose', 'Verbose as long option'), ('flags=', 'Valued option'), ('f:', 'Short valued option')) commandlist = (('start', 'Start something'), ('stop', 'Stop something')) argv = GetArgv(optionlist=optionlist, commandlist=comm... |
time.sleep(0.1) | time.sleep(0.05) | def test(): import time, sys Message("Testing EasyDialogs.") optionlist = (('v', 'Verbose'), ('verbose', 'Verbose as long option'), ('flags=', 'Valued option'), ('f:', 'Short valued option')) commandlist = (('start', 'Start something'), ('stop', 'Stop something')) argv = GetArgv(optionlist=optionlist, commandlist=comm... |
time.sleep(0.3) | time.sleep(1.0) | def test(): import time, sys Message("Testing EasyDialogs.") optionlist = (('v', 'Verbose'), ('verbose', 'Verbose as long option'), ('flags=', 'Valued option'), ('f:', 'Short valued option')) commandlist = (('start', 'Start something'), ('stop', 'Stop something')) argv = GetArgv(optionlist=optionlist, commandlist=comm... |
"install-base or install-platbase supplied, but " + \ "installation scheme is incomplete" | ("install-base or install-platbase supplied, but " "installation scheme is incomplete") | def finalize_unix (self): |
"'extra_path' option must be a list, tuple, or " + \ "comma-separated string with 1 or 2 elements" | ("'extra_path' option must be a list, tuple, or " "comma-separated string with 1 or 2 elements") | def handle_extra_path (self): |
self.warn(("modules installed to '%s', which is not in " + "Python's module search path (sys.path) -- " + "you'll have to change the search path yourself") % self.install_lib) | log.debug(("modules installed to '%s', which is not in " "Python's module search path (sys.path) -- " "you'll have to change the search path yourself"), self.install_lib) | def run (self): |
data, width, height, bytesperpixel = jpeg.decompress(data) | data, width, height, bytesperpixel = jpeg.decompress(img) | def jpeggrey2grey(img, width, height): import jpeg data, width, height, bytesperpixel = jpeg.decompress(data) if bytesperpixel <> 1: raise RuntimeError, 'not grayscale jpeg' return data |
data, width, height, bytesperpixel = jpeg.decompress(data) | data, width, height, bytesperpixel = jpeg.decompress(img) | def jpeg2rgb(img, width, height): import cl, CL import jpeg data, width, height, bytesperpixel = jpeg.decompress(data) if bytesperpixel <> 4: raise RuntimeError, 'not rgb jpeg' return data |
('grey', 'jpeggrey',grey2jpeggrey, NOT_LOSSY), \ | ('grey', 'jpeggrey',grey2jpeggrey, LOSSY), \ | def jpeg2rgb(img, width, height): import cl, CL import jpeg data, width, height, bytesperpixel = jpeg.decompress(data) if bytesperpixel <> 4: raise RuntimeError, 'not rgb jpeg' return data |
('rgb', 'jpeg', rgb2jpeg, NOT_LOSSY), \ | ('rgb', 'jpeg', rgb2jpeg, LOSSY), \ | def jpeg2rgb(img, width, height): import cl, CL import jpeg data, width, height, bytesperpixel = jpeg.decompress(data) if bytesperpixel <> 4: raise RuntimeError, 'not rgb jpeg' return data |
def constant_red_generator(numchips, rgbtuple): red = rgbtuple[0] | def constant_cyan_generator(numchips, rgbtuple): red, green, blue = rgbtuple | def constant_red_generator(numchips, rgbtuple): red = rgbtuple[0] seq = constant(numchips) return map(None, [red] * numchips, seq, seq) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.