rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
return [(k, Utils.unquote(v)) for k, v in params] | return [(k, _unquotevalue(v)) for k, v in params] | def get_params(self, failobj=None, header='content-type', unquote=1): """Return the message's Content-Type: parameters, as a list. |
return Utils.unquote(v) | return _unquotevalue(v) | def get_param(self, param, failobj=None, header='content-type', unquote=1): """Return the parameter value if found in the Content-Type: header. |
return Utils.unquote(filename.strip()) | if isinstance(filename, TupleType): newvalue = _unquotevalue(filename) return unicode(newvalue[2], newvalue[0]) else: newvalue = _unquotevalue(filename.strip()) return newvalue | def get_filename(self, failobj=None): """Return the filename associated with the payload if present. |
return Utils.unquote(boundary.strip()) | return _unquotevalue(boundary.strip()) | def get_boundary(self, failobj=None): """Return the boundary associated with the payload if present. |
self.compile = 0 | self.compile = None | def initialize_options (self): |
except: pass | except OSError: pass | def nextfile(self): savestdout = self._savestdout self._savestdout = 0 if savestdout: sys.stdout = savestdout |
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._i... |
dbgmsg("%s<%s> at %s" % (" "*depth, name, point)) | dbgmsg("pushing <%s> at %s" % (name, point)) | def pushing(name, point, depth): dbgmsg("%s<%s> at %s" % (" "*depth, name, point)) |
dbgmsg("%s</%s> at %s" % (" "*depth, name, point)) class Conversion: def __init__(self, ifp, ofp, table=None, discards=(), autoclosing=()): | dbgmsg("popping </%s> at %s" % (name, point)) class _Stack(UserList.UserList): StringType = type('') def append(self, entry): if type(entry) is not self.StringType: raise LaTeXFormatError("cannot push non-string on stack: " + `entry`) sys.stderr.write("%s<%s>\n" % (" "*len(self.data), entry)) self.data.append(entry)... | def popping(name, point, depth): dbgmsg("%s</%s> at %s" % (" "*depth, name, point)) |
self.err_write = sys.stderr.write | def __init__(self, ifp, ofp, table=None, discards=(), autoclosing=()): self.ofp_stack = [ofp] self.pop_output() self.table = table self.discards = discards self.autoclosing = autoclosing self.line = string.join(map(string.rstrip, ifp.readlines()), "\n") self.err_write = sys.stderr.write self.preamble = 1 | |
stack = [] | stack = self.stack | 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 DEBUG and endchar: self.err_write( "subconvert(%s)\n line = %s\n" % (`endchar`, `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 DEBUG: self.err_write("subconvert() --> %s\n" % `line[1:21]`) | 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... | |
stack = [] | 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... | |
self.err_write("stack: %s\n" % `stack`) raise LaTeXFormatError( "environment close for %s doesn't match" % envname) | raise LaTeXStackError(envname, stack) | 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... |
pushing(macroname, "a", depth + len(stack)) | 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... | |
pushing(macroname, "b", len(stack) + depth) | 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... | |
def convert(self): self.subconvert() | def convert(self): self.subconvert() | |
def convert(ifp, ofp, table={}, discards=(), autoclosing=()): | class NewConversion(BaseConversion): def __init__(self, ifp, ofp, table={}): BaseConversion.__init__(self, ifp, ofp, table) self.discards = [] def subconvert(self, endchar=None, depth=0): stack = new_stack() line = self.line while line: if line[0] == endchar and not stack: self.line = line return line m = _commen... | def convert(ifp, ofp, table={}, discards=(), autoclosing=()): c = Conversion(ifp, ofp, table, discards, autoclosing) try: c.convert() except IOError, (err, msg): if err != errno.EPIPE: raise |
while line and line[0] in " %\n\t": | while line and line[0] in " %\n\t\r": | def skip_white(line): while line and line[0] in " %\n\t": line = string.lstrip(line[1:]) return line |
if len(sys.argv) == 2: ifp = open(sys.argv[1]) | global DEBUG convert = new_convert newstyle = 1 opts, args = getopt.getopt(sys.argv[1:], "Dn", ["debug", "new"]) for opt, arg in opts: if opt in ("-n", "--new"): convert = new_convert newstyle = 1 elif opt in ("-o", "--old"): convert = old_convert newstyle = 0 elif opt in ("-D", "--debug"): DEBUG = DEBUG + 1 if len(ar... | def main(): if len(sys.argv) == 2: ifp = open(sys.argv[1]) ofp = sys.stdout elif len(sys.argv) == 3: ifp = open(sys.argv[1]) ofp = open(sys.argv[2], "w") else: usage() sys.exit(2) convert(ifp, ofp, { # entries have the form: # name: ([attribute names], is1stOptional, isEmpty, isEnv, nocontent) # attribute names can be:... |
elif len(sys.argv) == 3: ifp = open(sys.argv[1]) ofp = open(sys.argv[2], "w") | elif len(args) == 1: ifp = open(args) ofp = sys.stdout elif len(args) == 2: ifp = open(args[0]) ofp = open(args[1], "w") | def main(): if len(sys.argv) == 2: ifp = open(sys.argv[1]) ofp = sys.stdout elif len(sys.argv) == 3: ifp = open(sys.argv[1]) ofp = open(sys.argv[2], "w") else: usage() sys.exit(2) convert(ifp, ofp, { # entries have the form: # name: ([attribute names], is1stOptional, isEmpty, isEnv, nocontent) # attribute names can be:... |
convert(ifp, ofp, { | table = { | def main(): if len(sys.argv) == 2: ifp = open(sys.argv[1]) ofp = sys.stdout elif len(sys.argv) == 3: ifp = open(sys.argv[1]) ofp = open(sys.argv[2], "w") else: usage() sys.exit(2) convert(ifp, ofp, { # entries have the form: # name: ([attribute names], is1stOptional, isEmpty, isEnv, nocontent) # attribute names can be:... |
"appendix": ([], 0, 1, 0, 0), | def main(): if len(sys.argv) == 2: ifp = open(sys.argv[1]) ofp = sys.stdout elif len(sys.argv) == 3: ifp = open(sys.argv[1]) ofp = open(sys.argv[2], "w") else: usage() sys.exit(2) convert(ifp, ofp, { # entries have the form: # name: ([attribute names], is1stOptional, isEmpty, isEnv, nocontent) # attribute names can be:... | |
"catcode": ([], 0, 1, 0, 0), | def main(): if len(sys.argv) == 2: ifp = open(sys.argv[1]) ofp = sys.stdout elif len(sys.argv) == 3: ifp = open(sys.argv[1]) ofp = open(sys.argv[2], "w") else: usage() sys.exit(2) convert(ifp, ofp, { # entries have the form: # name: ([attribute names], is1stOptional, isEmpty, isEnv, nocontent) # attribute names can be:... | |
}, | } if newstyle: table = load_table(open(os.path.join(sys.path[0], 'conversion.xml'))) convert(ifp, ofp, table, | def main(): if len(sys.argv) == 2: ifp = open(sys.argv[1]) ofp = sys.stdout elif len(sys.argv) == 3: ifp = open(sys.argv[1]) ofp = open(sys.argv[2], "w") else: usage() sys.exit(2) convert(ifp, ofp, { # entries have the form: # name: ([attribute names], is1stOptional, isEmpty, isEnv, nocontent) # attribute names can be:... |
test.test_support.run_unittest(XrangeTest) | test.test_support.run_unittest(BytesTest) | def test_main(): test.test_support.run_unittest(XrangeTest) |
name = `id(self)` | Image._last_id += 1 name = "pyimage" +`Image._last_id` | def __init__(self, imgtype, name=None, cnf={}, master=None, **kw): self.name = None if not master: master = _default_root if not master: raise RuntimeError, 'Too early to create image' self.tk = master.tk if not name: name = `id(self)` # The following is needed for systems where id(x) # can return a negative number, su... |
(e[0], e[2], str(error)) | (e[0], e[2], str(result)) | def strftest(now): if verbose: print "strftime test for", time.ctime(now) nowsecs = int(now) gmt = time.gmtime(now) now = time.localtime(now) if now[3] < 12: ampm='AM' else: ampm='PM' jan1 = time.localtime(time.mktime((now[0], 1, 1) + (0,)*6)) if now[8]: tz = time.tzname[1] else: tz = time.tzname[0] if now[3] > 12:... |
the local hostname is found using gethostbyname(). | the local hostname is found using socket.getfqdn(). | def __init__(self, host = '', port = 0, local_hostname = None): """Initialize a new instance. |
self.transient(parent) | if parent.winfo_viewable(): self.transient(parent) | def __init__(self, parent, title = None): |
def list(self, which=None): | def list(self, msg=None): | def list(self, which=None): """Request listing, return result. Result is in form ['response', ['mesg_num octets', ...]]. |
Result is in form ['response', ['mesg_num octets', ...]]. Unsure what the optional 'msg' arg does. | Result without a msg argument is in form ['response', ['mesg_num octets', ...]]. Result when a msg argument is given is a single response: the "scan listing" for that message. | def list(self, which=None): """Request listing, return result. Result is in form ['response', ['mesg_num octets', ...]]. |
return self._longcmd('LIST %s' % which) | return self._shortcmd('LIST %s' % which) | def list(self, which=None): """Request listing, return result. Result is in form ['response', ['mesg_num octets', ...]]. |
if not strm: | if strm is None: | def __init__(self, strm=None): """ Initialize the handler. |
__contains__ = has_key | def __contains__(self, key): return self.has_key(key) | def has_key(self, key): try: value = self[key] except KeyError: return False return True |
iterkeys = __iter__ | def iterkeys(self): return self.__iter__() | def iteritems(self): for k in self: yield (k, self[k]) |
if ((template_exists and (template_newer or setup_newer)) or self.force_manifest or self.manifest_only): | if manifest_outofdate or neither_exists or force_regen: | def get_file_list (self): """Figure out the list of files to include in the source distribution, and put it in 'self.filelist'. This might involve reading the manifest template (and writing the manifest), or just reading the manifest, or just using the default file set -- it all depends on the user's options and the s... |
standards = [('README', 'README.txt'), 'setup.py'] | standards = [('README', 'README.txt'), self.distribution.script_name] | def add_defaults (self): """Add all the default files to self.filelist: - README or README.txt - setup.py - test/test*.py - all pure Python modules mentioned in setup script - all C sources listed as part of extensions or C libraries in the setup script (doesn't catch C headers!) Warns if (README or README.txt) or setu... |
or code in (302, 303) and m == "POST"): | or code in (301, 302, 303) and m == "POST"): | def redirect_request(self, req, fp, code, msg, headers, newurl): """Return a Request or None in response to a redirect. |
"The last 302 error message was:\n" | "The last 30x error message was:\n" | def http_error_302(self, req, fp, code, msg, headers): if 'location' in headers: newurl = headers['location'] elif 'uri' in headers: newurl = headers['uri'] else: return newurl = urlparse.urljoin(req.get_full_url(), newurl) |
def powtest(type): if type != float: print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if pow(type(i), 0) != 1: raise ValueError, 'pow('+str(i)+',0) != 1' if pow(type(i), 1) != type(i): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if pow(type(0), 1) != type(0): raise ValueError, 'pow(0,'... | def test_main(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(PowTest)) test.test_support.run_suite(suite) | def powtest(type): if type != float: print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if pow(type(i), 0) != 1: raise ValueError, 'pow('+str(i)+',0) != 1' if pow(type(i), 1) != type(i): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if pow(type(0), 1) != type(0): raise ValueError, 'pow(0,'... |
for i in range(-100, 100): if pow(type(i), 3) != i*i*i: raise ValueError, 'pow('+str(i)+',3) != '+str(i*i*i) pow2 = 1 for i in range(0,31): if pow(2, i) != pow2: raise ValueError, 'pow(2,'+str(i)+') != '+str(pow2) if i != 30 : pow2 = pow2*2 for othertype in int, long: for i in range(-10, 0) + range(1, 10): ii = type(... | if __name__ == "__main__": test_main() | def powtest(type): if type != float: print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if pow(type(i), 0) != 1: raise ValueError, 'pow('+str(i)+',0) != 1' if pow(type(i), 1) != type(i): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if pow(type(0), 1) != type(0): raise ValueError, 'pow(0,'... |
if len(text) <= 1: text = ' '+text | if not text: text = ' ' | def record_sub_info(match_object,sub_info=sub_info): sub_info.append([match_object.group(1)[0],match_object.span()]) return match_object.group(1) |
return '[Errno %d] %s: %s' % (self.errno, self.strerror, | return '[Errno %s] %s: %s' % (self.errno, self.strerror, | def __str__(self): if self.filename: return '[Errno %d] %s: %s' % (self.errno, self.strerror, self.filename) elif self.errno and self.strerror: return '[Errno %d] %s' % (self.errno, self.strerror) else: return StandardError.__str__(self) |
return '[Errno %d] %s' % (self.errno, self.strerror) | return '[Errno %s] %s' % (self.errno, self.strerror) | def __str__(self): if self.filename: return '[Errno %d] %s: %s' % (self.errno, self.strerror, self.filename) elif self.errno and self.strerror: return '[Errno %d] %s' % (self.errno, self.strerror) else: return StandardError.__str__(self) |
else: | elif tokentype in (NAME, OP) and level == 1: | def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initi... |
print '\tnew IMAP4 connection, tag=%s' % self.tagpre | _mesg('new IMAP4 connection, tag=%s' % self.tagpre) | def __init__(self, host = '', port = IMAP4_PORT): self.host = host self.port = port self.debug = Debug self.state = 'LOGOUT' self.literal = None # A literal argument to a command self.tagged_commands = {} # Tagged commands awaiting response self.untagged_responses = {} # {typ: [data, ...], ...} self.continuation_respo... |
print '\tCAPABILITIES: %s' % `self.capabilities` | _mesg('CAPABILITIES: %s' % `self.capabilities`) | def __init__(self, host = '', port = IMAP4_PORT): self.host = host self.port = port self.debug = Debug self.state = 'LOGOUT' self.literal = None # A literal argument to a command self.tagged_commands = {} # Tagged commands awaiting response self.untagged_responses = {} # {typ: [data, ...], ...} self.continuation_respo... |
def __getattr__(self, attr): """Allow UPPERCASE variants of all following IMAP4 commands.""" if Commands.has_key(attr): return eval("self.%s" % string.lower(attr)) raise AttributeError("Unknown IMAP4 command: '%s'" % attr) | def recent(self): """Return most recent 'RECENT' responses if any exist, else prompt server for an update using the 'NOOP' command. (typ, [data]) = <instance>.recent() 'data' is None if no new messages, else list of RECENT responses, most recent last. """ name = 'RECENT' typ, dat = self._untagged_response('OK', [None... | def __getattr__(self, attr): """Allow UPPERCASE variants of all following IMAP4 commands.""" if Commands.has_key(attr): return eval("self.%s" % string.lower(attr)) raise AttributeError("Unknown IMAP4 command: '%s'" % attr) |
raise self.error(dat) | raise self.error(dat[-1]) | def authenticate(self, mechanism, authobject): """Authenticate command - requires response processing. |
try: typ, dat = self._simple_command('CLOSE') except EOFError: typ, dat = None, [None] | typ, dat = self._simple_command('CLOSE') | def close(self): """Close currently selected mailbox. |
return self._untagged_response(typ, name) | return self._untagged_response(typ, dat, name) | def expunge(self): """Permanently remove deleted items from selected mailbox. |
return self._untagged_response(typ, name) | return self._untagged_response(typ, dat, name) | def fetch(self, message_set, message_parts): """Fetch (parts of) messages. |
return self._untagged_response(typ, name) | return self._untagged_response(typ, dat, name) | def list(self, directory='""', pattern='*'): """List mailbox names in directory matching pattern. |
raise self.error(dat) | raise self.error(dat[-1]) | def login(self, user, password): """Identify client using plaintext password. |
except EOFError: typ, dat = None, [None] | except: typ, dat = 'NO', ['%s: %s' % sys.exc_info()[:2]] | def logout(self): """Shutdown connection to server. |
return self._untagged_response(typ, name) | return self._untagged_response(typ, dat, name) | def lsub(self, directory='""', pattern='*'): """List 'subscribed' mailbox names in directory matching pattern. |
print '\tuntagged responses: %s' % `self.untagged_responses` | _dump_ur(self.untagged_responses) | def noop(self): """Send NOOP command. |
return self._untagged_response(typ, 'FETCH') def recent(self): """Return most recent 'RECENT' responses if any exist, else prompt server for an update using the 'NOOP' command, and flush all untagged responses. (typ, [data]) = <instance>.recent() 'data' is None if no new messages, else list of RECENT responses, mos... | return self._untagged_response(typ, dat, 'FETCH') | def partial(self, message_num, message_part, start, length): """Fetch truncated part of a message. |
def response(self, code): """Return data for response 'code' if received, or None. Old value for response 'code' is cleared. (code, [data]) = <instance>.response(code) """ return self._untagged_response(code, string.upper(code)) | def rename(self, oldmailbox, newmailbox): """Rename old mailbox name to new. | |
return self._untagged_response(typ, name) | return self._untagged_response(typ, dat, name) | def search(self, charset, criteria): """Search mailbox for matching messages. |
if typ == 'OK': self.state = 'SELECTED' elif typ == 'NO': self.state = 'AUTH' if not readonly and not self.untagged_responses.has_key('READ-WRITE'): raise self.error('%s is not writable' % mailbox) | if typ != 'OK': self.state = 'AUTH' return typ, dat self.state = 'SELECTED' if not self.untagged_responses.has_key('READ-WRITE') \ and not readonly: if __debug__ and self.debug >= 1: _dump_ur(self.untagged_responses) raise self.readonly('%s is not writable' % mailbox) | def select(self, mailbox='INBOX', readonly=None): """Select a mailbox. |
def socket(self): """Return socket instance used to connect to IMAP4 server. socket = <instance>.socket() """ return self.sock | def select(self, mailbox='INBOX', readonly=None): """Select a mailbox. | |
return self._untagged_response(typ, name) | return self._untagged_response(typ, dat, name) | def status(self, mailbox, names): """Request named status conditions for mailbox. |
return self._untagged_response(typ, 'FETCH') | return self._untagged_response(typ, dat, 'FETCH') | def store(self, message_set, command, flag_list): """Alters flag dispositions for messages in mailbox. |
typ, dat2 = self._untagged_response(typ, name) if dat2[-1]: dat = dat2 return typ, dat | return self._untagged_response(typ, dat, name) | def uid(self, command, *args): """Execute "command arg ..." with messages identified by UID, rather than message number. |
if __debug__ and self.debug >= 5: print '\tuntagged_responses[%s] %s += %s' % (typ, len(`ur[typ]`), _trunc(20, `dat`)) | def _append_untagged(self, typ, dat): | |
if self.untagged_responses.has_key('OK'): del self.untagged_responses['OK'] | for typ in ('OK', 'NO', 'BAD'): if self.untagged_responses.has_key(typ): del self.untagged_responses[typ] if self.untagged_responses.has_key('READ-WRITE') \ and self.untagged_responses.has_key('READ-ONLY'): del self.untagged_responses['READ-WRITE'] raise self.readonly('mailbox status changed to READ-ONLY') | def _command(self, name, *args): |
print '\t> %s' % data | _mesg('> %s' % data) | def _command(self, name, *args): |
print '\twrite literal size %s' % len(literal) | _mesg('write literal size %s' % len(literal)) | def _command(self, name, *args): |
print '\tread literal size %s' % size | _mesg('read literal size %s' % size) | def _get_response(self): |
raise EOFError | raise self.abort('socket error: EOF') | def _get_line(self): |
print '\t< %s' % line | _mesg('< %s' % line) | def _get_line(self): |
print "\tmatched r'%s' => %s" % (cre.pattern, `self.mo.groups()`) | _mesg("\tmatched r'%s' => %s" % (cre.pattern, `self.mo.groups()`)) | def _match(self, cre, s): |
def _untagged_response(self, typ, name): | def _untagged_response(self, typ, dat, name): if typ == 'NO': return typ, dat | def _untagged_response(self, typ, name): |
print '\tuntagged_responses[%s] => %s' % (name, _trunc(20, `data`)) | _mesg('untagged_responses[%s] => %s' % (name, data)) | def _untagged_response(self, typ, name): |
def _trunc(m, s): if len(s) <= m: return s return '%.*s..' % (m, s) | def _mesg(s): sys.stderr.write('\t'+s+'\n') sys.stderr.flush() def _dump_ur(dict): l = dict.items() if not l: return t = '\n\t\t' j = string.join l = map(lambda x,j=j:'%s: "%s"' % (x[0], x[1][0] and j(x[1], '" "') or ''), l) _mesg('untagged responses dump:%s%s' % (t, j(l, t))) | def _trunc(m, s): if len(s) <= m: return s return '%.*s..' % (m, s) |
print ' %s %s\n => %s %s' % (cmd, args, typ, dat) | _mesg(' %s %s\n => %s %s' % (cmd, args, typ, dat)) | def run(cmd, args): typ, dat = apply(eval('M.%s' % cmd), args) print ' %s %s\n => %s %s' % (cmd, args, typ, dat) return dat |
print 'PROTOCOL_VERSION = %s' % M.PROTOCOL_VERSION | _mesg('PROTOCOL_VERSION = %s' % M.PROTOCOL_VERSION) | def run(cmd, args): typ, dat = apply(eval('M.%s' % cmd), args) print ' %s %s\n => %s %s' % (cmd, args, typ, dat) return dat |
if map(max, Squares(3), Squares(2)) != [0, 1, None]: | if map(max, Squares(3), Squares(2)) != [0, 1, 4]: | def plus(*v): accu = 0 for i in v: accu = accu + i return accu |
print>>sys.__stderr__, "Idle accepted connection from ", address | def accept(self): working_sock, address = self.listening_sock.accept() if address[0] == '127.0.0.1': print>>sys.__stderr__, "Idle accepted connection from ", address SocketIO.__init__(self, working_sock) else: print>>sys.__stderr__, "Invalid host: ", address raise socket.error | |
print>>sys.__stderr__, "Invalid host: ", address | print>>sys.__stderr__, "** Invalid host: ", address | def accept(self): working_sock, address = self.listening_sock.accept() if address[0] == '127.0.0.1': print>>sys.__stderr__, "Idle accepted connection from ", address SocketIO.__init__(self, working_sock) else: print>>sys.__stderr__, "Invalid host: ", address raise socket.error |
def nuke_release_tree (self, base_dir): try: self.execute (rmtree, (base_dir,), "removing %s" % base_dir) except (IOError, OSError), exc: if exc.filename: msg = "error removing %s: %s (%s)" % \ (base_dir, exc.strerror, exc.filename) else: msg = "error removing %s: %s" % (base_dir, exc.strerror) self.warn (msg) | def make_release_tree (self, base_dir, files): | |
self.nuke_release_tree (base_dir) | remove_tree (base_dir, self.verbose, self.dry_run) | def make_distribution (self): |
print "\n<PRE>Cookies:", cookies, "</PRE>" | def get_cookie(self): | |
mime_header = re.compile('([ \t(]|^)([-a-zA-Z0-9_+]*[\177-\377][-a-zA-Z0-9_+\177-\377]*)([ \t)]|\n)') | mime_header = re.compile('([ \t(]|^)([-a-zA-Z0-9_+]*[\177-\377][-a-zA-Z0-9_+\177-\377]*)(?=[ \t)]|\n)') | def mime_encode(line, header): """Code a single line as quoted-printable. If header is set, quote some extra characters.""" if header: reg = mime_header_char else: reg = mime_char newline = '' pos = 0 if len(line) >= 5 and line[:5] == 'From ': # quote 'From ' at the start of a line for stupid mailers newline = ('=%02x'... |
newline = '%s%s%s=?%s?Q?%s?=%s' % \ | newline = '%s%s%s=?%s?Q?%s?=' % \ | def mime_encode_header(line): """Code a single header line as quoted-printable.""" newline = '' pos = 0 while 1: res = mime_header.search(line, pos) if res is None: break newline = '%s%s%s=?%s?Q?%s?=%s' % \ (newline, line[pos:res.start(0)], res.group(1), CHARSET, mime_encode(res.group(2), 1), res.group(3)) pos = res.en... |
CHARSET, mime_encode(res.group(2), 1), res.group(3)) | CHARSET, mime_encode(res.group(2), 1)) | def mime_encode_header(line): """Code a single header line as quoted-printable.""" newline = '' pos = 0 while 1: res = mime_header.search(line, pos) if res is None: break newline = '%s%s%s=?%s?Q?%s?=%s' % \ (newline, line[pos:res.start(0)], res.group(1), CHARSET, mime_encode(res.group(2), 1), res.group(3)) pos = res.en... |
host = [host] try: addr = socket.gethostbyname(host[0]) if addr != host: | rawHost, port = splitport(host) host = [rawHost] try: addr = socket.gethostbyname(rawHost) if addr != rawHost: | def proxy_bypass(host): try: import _winreg import re except ImportError: # Std modules, so should be around - but you never know! return 0 try: internetSettings = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, r'Software\Microsoft\Windows\CurrentVersion\Internet Settings') proxyEnable = _winreg.QueryValueEx(internetSettin... |
except: | except IOError: | def is_zipfile(filename): """Quickly see if file is a ZIP file by checking the magic number. Will not accept a ZIP archive with an ending comment. """ try: fpin = open(filename, "rb") fpin.seek(-22, 2) # Seek to end-of-file record endrec = fpin.read() fpin.close() if endrec[0:4] == "PK\005\006" and endre... |
import os | def verisnot(a, b): if a is b: raise TestFailed, "%r is %r" % (a, b) | |
if cl.super: | if hasattr(cl, "super") and cl.super: | def listclasses(self): dir, file = os.path.split(self.file) name, ext = os.path.splitext(file) if os.path.normcase(ext) != ".py": return [] try: dict = pyclbr.readmodule_ex(name, [dir] + sys.path) except ImportError, msg: return [] items = [] self.classes = {} for key, cl in dict.items(): if cl.module == name: s = key ... |
path = sys.path | path = sys.path[:] | def main(): # overridable context prefix = None # settable with -p option exec_prefix = None # settable with -P option extensions = [] path = sys.path modargs = 0 debug = 1 odir = '' win = sys.platform[:3] == 'win' # modules that are imported by the Python runtime implicits = ["s... |
if args[0][-3:] != ".py": usage('the script name must have a .py suffix') | def main(): # overridable context prefix = None # settable with -p option exec_prefix = None # settable with -P option extensions = [] path = sys.path modargs = 0 debug = 1 odir = '' win = sys.platform[:3] == 'win' # modules that are imported by the Python runtime implicits = ["s... | |
import StringIO f = StringIO.StringIO(s) g = StringIO.StringIO() encode(f, g) return g.getvalue() | pieces = [] for i in range(0, len(s), MAXBINSIZE): chunk = s[i : i + MAXBINSIZE] pieces.append(binascii.b2a_base64(chunk)) return "".join(pieces) | def encodestring(s): """Encode a string.""" import StringIO f = StringIO.StringIO(s) g = StringIO.StringIO() encode(f, g) return g.getvalue() |
import StringIO f = StringIO.StringIO(s) g = StringIO.StringIO() decode(f, g) return g.getvalue() | return binascii.a2b_base64(s) | def decodestring(s): """Decode a string.""" import StringIO f = StringIO.StringIO(s) g = StringIO.StringIO() decode(f, g) return g.getvalue() |
dict = {} | r=[] | def parse_qs(qs, keep_blank_values=0, strict_parsing=0): """Parse a query given as a string argument. Arguments: qs: URL-encoded query string to be parsed keep_blank_values: flag indicating whether blank values in URL encoded queries should be treated as blank strings. A true value inicates that blanks should be ret... |
if len(value) or keep_blank_values: if dict.has_key (name): dict[name].append(value) else: dict[name] = [value] return dict | r.append(name, value) return r | def parse_qs(qs, keep_blank_values=0, strict_parsing=0): """Parse a query given as a string argument. Arguments: qs: URL-encoded query string to be parsed keep_blank_values: flag indicating whether blank values in URL encoded queries should be treated as blank strings. A true value inicates that blanks should be ret... |
dict = parse_qs(qs, self.keep_blank_values, self.strict_parsing) self.list = [] for key, valuelist in dict.items(): for value in valuelist: self.list.append(MiniFieldStorage(key, value)) | self.list = list = [] for key, value in parse_qsl(qs, self.keep_blank_values, self.strict_parsing): list.append(MiniFieldStorage(key, value)) | def read_urlencoded(self): """Internal: read data in query string format.""" qs = self.fp.read(self.length) dict = parse_qs(qs, self.keep_blank_values, self.strict_parsing) self.list = [] for key, valuelist in dict.items(): for value in valuelist: self.list.append(MiniFieldStorage(key, value)) self.skip_lines() |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.