rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
SimpleXMLRPCDispatcher.__init__(self) | SimpleXMLRPCDispatcher.__init__(self, allow_none) | def __init__(self, addr, requestHandler=SimpleXMLRPCRequestHandler, logRequests=1): self.logRequests = logRequests |
def __init__(self): SimpleXMLRPCDispatcher.__init__(self) | def __init__(self, allow_none=False): SimpleXMLRPCDispatcher.__init__(self, allow_none) | def __init__(self): SimpleXMLRPCDispatcher.__init__(self) |
if value is not None and value != 'C': | if value not in (None, '', 'C'): | def setlocale(category, value=None): """ setlocale(integer,string=None) -> string. Activates/queries locale processing. """ if value is not None and value != 'C': raise Error, '_locale emulation only supports "C" locale' return 'C' |
parts = resp[left+1].split(resp[left + 1:right]) | parts = resp[left + 1:right].split(resp[left+1]) | def parse229(resp, peer): '''Parse the '229' response for a EPSV request. Raises error_proto if it does not contain '(|||port|)' Return ('host.addr.as.numbers', port#) tuple.''' if resp[:3] <> '229': raise error_reply, resp left = resp.find('(') if left < 0: raise error_proto, resp right = resp.find(')', left + 1) if ... |
elif isize != self.size: | elif isize != LOWU32(self.size): | def _read_eof(self): # We've read to the end of the file, so we have to rewind in order # to reread the 8 bytes containing the CRC and the file size. # We check the that the computed CRC and size of the # uncompressed data matches the stored values. self.fileobj.seek(-8, 1) crc32 = read32(self.fileobj) isize = U32(read... |
write32u(self.fileobj, self.size) | write32u(self.fileobj, LOWU32(self.size)) | def close(self): if self.mode == WRITE: self.fileobj.write(self.compress.flush()) write32(self.fileobj, self.crc) # self.size may exceed 2GB write32u(self.fileobj, self.size) self.fileobj = None elif self.mode == READ: self.fileobj = None if self.myfileobj: self.myfileobj.close() self.myfileobj = None |
while args and args[0][:1] == '-' and args[0] != '-': | while args and args[0].startswith('-') and args[0] != '-': | def getopt(args, shortopts, longopts = []): """getopt(args, options[, long_options]) -> opts, args Parses command line options and parameter list. args is the argument list to be parsed, without the leading reference to the running program. Typically, this means "sys.argv[1:]". shortopts is the string of option let... |
opt, optarg = opt[:i], opt[i+1:] | def do_longs(opts, opt, longopts, args): try: i = opt.index('=') opt, optarg = opt[:i], opt[i+1:] except ValueError: optarg = None has_arg, opt = long_has_args(opt, longopts) if has_arg: if optarg is None: if not args: raise GetoptError('option --%s requires argument' % opt, opt) optarg, args = args[0], args[1:] elif ... | |
optlen = len(opt) | def long_has_args(opt, longopts): optlen = len(opt) for i in range(len(longopts)): x, y = longopts[i][:optlen], longopts[i][optlen:] if opt != x: continue if y != '' and y != '=' and i+1 < len(longopts): if opt == longopts[i+1][:optlen]: raise GetoptError('option --%s not a unique prefix' % opt, opt) if longopts[i][-1:... | |
x, y = longopts[i][:optlen], longopts[i][optlen:] if opt != x: continue if y != '' and y != '=' and i+1 < len(longopts): if opt == longopts[i+1][:optlen]: raise GetoptError('option --%s not a unique prefix' % opt, opt) if longopts[i][-1:] in ('=', ): return 1, longopts[i][:-1] return 0, longopts[i] raise GetoptError('o... | if longopts[i].startswith(opt): break else: raise GetoptError('option --%s not recognized' % opt, opt) j = i+1 while j < len(longopts) and longopts[j].startswith(opt): j += 1 possibilities = longopts[i:j] if opt in possibilities: return 0, opt elif opt + '=' in possibilities: return 1, opt if len(possibilities) > 1... | def long_has_args(opt, longopts): optlen = len(opt) for i in range(len(longopts)): x, y = longopts[i][:optlen], longopts[i][optlen:] if opt != x: continue if y != '' and y != '=' and i+1 < len(longopts): if opt == longopts[i+1][:optlen]: raise GetoptError('option --%s not a unique prefix' % opt, opt) if longopts[i][-1:... |
while True: | while 1: | def normalvariate(self, mu, sigma): """Normal distribution. |
while True: | while 1: | def vonmisesvariate(self, mu, kappa): """Circular data distribution. |
if not (u2 >= c * (2.0 - c) and u2 > c * _exp(1.0 - c)): | if u2 < c * (2.0 - c) or u2 <= c * _exp(1.0 - c): | def vonmisesvariate(self, mu, kappa): """Circular data distribution. |
while True: | while 1: | def gammavariate(self, alpha, beta): """Gamma distribution. Not the gamma function! |
x = pow(p, 1.0/alpha) | x = p ** (1.0/alpha) | def gammavariate(self, alpha, beta): """Gamma distribution. Not the gamma function! |
if not (((p <= 1.0) and (u1 > _exp(-x))) or ((p > 1) and (u1 > pow(x, alpha - 1.0)))): | if p > 1.0: if u1 <= x ** (alpha - 1.0): break elif u1 <= _exp(-x): | def gammavariate(self, alpha, beta): """Gamma distribution. Not the gamma function! |
data += self.sslobj.read(len(data)-size) | data += self.sslobj.read(size-len(data)) | def read(self, size): """Read 'size' bytes from remote.""" # sslobj.read() sometimes returns < size bytes data = self.sslobj.read(size) while len(data) < size: data += self.sslobj.read(len(data)-size) |
expected = compile(str, "<input>", symbol, PyCF_DONT_IMPLY_DEDENT) self.assertEquals( compile_command(str, "<input>", symbol), expected) | if is_jython: code = compile_command(str, "<input>", symbol) self.assert_(code) if symbol == "single": d,r = {},{} sys.stdout = cStringIO.StringIO() try: exec code in d exec compile(str,"<input>","single") in r finally: sys.stdout = sys.__stdout__ elif symbol == 'eval': ctx = {'a': 2} d = { 'value': eval(code,ctx) } r ... | def assertValid(self, str, symbol='single'): '''succeed iff str is a valid piece of code''' expected = compile(str, "<input>", symbol, PyCF_DONT_IMPLY_DEDENT) self.assertEquals( compile_command(str, "<input>", symbol), expected) |
self.assertEquals(compile_command(""), compile("pass", "<input>", 'single', PyCF_DONT_IMPLY_DEDENT)) | av("a = 9+ \\\n3") | av("def x():\n pass\n") |
ai("def x():\n") | ai("def x():\n") | |
ai("a = (") | ai("if 1:") ai("if 1:\n") ai("if 1:\n pass\n if 1:\n pass\n else:") ai("if 1:\n pass\n if 1:\n pass\n else:\n") ai("if 1:\n pass\n if 1:\n pass\n else:\n pass") ai("def x():") ai("def x():\n") ai("def x():\n\n") ai("def x():\n pass") ai("def x():\n pass\n ") ai("def x():\n pass\n ") ai("\n\ndef x():\n pass") | ai("def x():\n") |
elif ord(c) < 32 or c in ' "*+,:;<=>?[]|': | elif ord(c) < 32 or c in ' ",:;<=>': | def normcase(s): res, s = splitdrive(s) for c in s: if c in '/\\': res = res + os.sep elif c == '.' and res[-1:] == os.sep: res = res + mapchar + c elif ord(c) < 32 or c in ' "*+,:;<=>?[]|': if res[-1:] != mapchar: res = res + mapchar else: res = res + c return string.lower(res) |
def redirect_request(self, req, fp, code, msg, headers): | def redirect_request(self, req, fp, code, msg, headers, newurl): | def redirect_request(self, req, fp, code, msg, headers): """Return a Request or None in response to a redirect. |
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 redirect_request(self, req, fp, code, msg, headers): """Return a Request or None in response to a redirect. | |
new = self.redirect_request(req, fp, code, msg, headers) | new = self.redirect_request(req, fp, code, msg, headers, newurl) | 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) |
map(lambda t: apply(priDB.put, t), ProductIndex) | map(lambda t, priDB=priDB: apply(priDB.put, t), ProductIndex) | def test01_join(self): if verbose: print '\n', '-=' * 30 print "Running %s.test01_join..." % \ self.__class__.__name__ |
map(lambda t: apply(secDB.put, t), ColorIndex) | map(lambda t, secDB=secDB: apply(secDB.put, t), ColorIndex) | def test01_join(self): if verbose: print '\n', '-=' * 30 print "Running %s.test01_join..." % \ self.__class__.__name__ |
finalized. This gives provides the opportunity to sneak option | finalized. This provides the opportunity to sneak option | def reinitialize_command (self, command): """Reinitializes a command to the state it was in when first returned by 'get_command_obj()': ie., initialized but not yet finalized. This gives provides the opportunity to sneak option values in programmatically, overriding or supplementing user-supplied values from the confi... |
self.text = text = Text(text_frame, name='text', padx=5, wrap=None, | self.text = text = Text(text_frame, name='text', padx=5, wrap='none', | def __init__(self, flist=None, filename=None, key=None, root=None): currentTheme=idleConf.CurrentTheme() self.flist = flist root = root or flist.root self.root = root self.menubar = Menu(root) self.top = top = self.Toplevel(root, menu=self.menubar) if flist: self.vars = flist.vars #self.top.instanceDict makes flist.inv... |
return self.data.has_key(ref(key)) | try: wr = ref(key) except TypeError: return 0 return self.data.has_key(wr) | def has_key(self, key): return self.data.has_key(ref(key)) |
MIN_SQLITE_VERSION = 3002002 | MIN_SQLITE_VERSION_NUMBER = 3000008 MIN_SQLITE_VERSION = "3.0.8" | def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') |
if db_setup_debug: print "found %s"%f | if sqlite_setup_debug: print "sqlite: found %s"%f | def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') |
if sqlite_version >= MIN_SQLITE_VERSION: | if sqlite_version >= MIN_SQLITE_VERSION_NUMBER: | def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') |
if db_setup_debug: | if sqlite_setup_debug: | def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') |
def grid_location(self, x, y): """Return a tuple of column and row which identify the cell at which the pixel at position X and Y inside the master widget is located.""" return self._getints( self.tk.call( 'grid', 'location', self._w, x, y)) or None location = grid_location | location = grid_location = Misc.grid_location | def grid_location(self, x, y): """Return a tuple of column and row which identify the cell at which the pixel at position X and Y inside the master widget is located.""" return self._getints( self.tk.call( 'grid', 'location', self._w, x, y)) or None |
gl.RGBmode() gl.gconfig() | self.set_rgbmode() | def initcolormap(self): self.colormapinited = 1 self.color0 = None self.fixcolor0 = 0 if self.format in ('rgb', 'jpeg', 'compress'): self.set_rgbmode() gl.RGBcolor(200, 200, 200) # XXX rather light grey gl.clear() return # This only works on an Entry-level Indigo from IRIX 4.0.5 if self.format == 'rgb8' and is_entry_in... |
gl.mapcolor(index, r, g, b) | map.append(index, r, g, b) | def _initcmap(self): if self.format in ('mono', 'grey4') and self.mustunpack: convcolor = conv_grey else: convcolor = choose_conversion(self.format) maxbits = gl.getgdesc(GL.GD_BITS_NORM_SNG_CMODE) if maxbits > 11: maxbits = 11 c0bits = self.c0bits c1bits = self.c1bits c2bits = self.c2bits if c0bits+c1bits+c2bits > max... |
lookup = getattr(self, "handle_"+condition) elif condition in ["response", "request"]: | lookup = self.handle_open elif condition == "response": | def add_handler(self, handler): added = False for meth in dir(handler): i = meth.find("_") protocol = meth[:i] condition = meth[i+1:] |
lookup = getattr(self, "process_"+condition) | lookup = self.process_response elif condition == "request": kind = protocol lookup = self.process_request | def add_handler(self, handler): added = False for meth in dir(handler): i = meth.find("_") protocol = meth[:i] condition = meth[i+1:] |
print sys.exc_value | def test(name, input, output): f = getattr(strop, name) try: value = f(input) except: value = sys.exc_type print sys.exc_value if value != output: print f, `input`, `output`, `value` | |
def __init__(self): self.data = {} def __repr__(self): return repr(self.data) def __cmp__(self, dict): if type(dict) == type(self.data): return cmp(self.data, dict) else: return cmp(self.data, dict.data) def __len__(self): return len(self.data) def __getitem__(self, key): return self.data[key] def __setitem__(self, key... | def __init__(self): self.data = {} def __repr__(self): return repr(self.data) def __cmp__(self, dict): if type(dict) == type(self.data): return cmp(self.data, dict) else: return cmp(self.data, dict.data) def __len__(self): return len(self.data) def __getitem__(self, key): return self.data[key] def __setitem__(self, key... | def __init__(self): self.data = {} |
debian_tcl_include = [ '/usr/include/tcl' + version ] debian_tk_include = [ '/usr/include/tk' + version ] + \ debian_tcl_include tcl_includes = find_file('tcl.h', inc_dirs, debian_tcl_include) tk_includes = find_file('tk.h', inc_dirs, debian_tk_include) | dotversion = version if '.' not in dotversion and "bsd" in sys.platform.lower(): dotversion = dotversion[:-1] + '.' + dotversion[-1] tcl_include_sub = [] tk_include_sub = [] for dir in inc_dirs: tcl_include_sub += [dir + os.sep + "tcl" + dotversion] tk_include_sub += [dir + os.sep + "tk" + dotversion] tk_include_sub ... | def detect_tkinter(self, inc_dirs, lib_dirs): # The _tkinter module. |
self.announce("INFO: Can't locate Tcl/Tk libs and/or headers", 2) | def detect_tkinter(self, inc_dirs, lib_dirs): # The _tkinter module. | |
self.formatter.end_paragraph(0) | self.formatter.end_paragraph(1) | def end_blockquote(self): self.formatter.end_paragraph(0) self.formatter.pop_margin() |
self.formatter.end_paragraph(0) | self.formatter.end_paragraph(1) | def start_dl(self, attrs): self.formatter.end_paragraph(0) self.list_stack.append(['dl', '', 0]) |
self.ddpop() | self.ddpop(1) | def end_dl(self): self.ddpop() if self.list_stack: del self.list_stack[-1] |
def ddpop(self): self.formatter.end_paragraph(0) | def ddpop(self, bl=0): self.formatter.end_paragraph(bl) | def ddpop(self): self.formatter.end_paragraph(0) if self.list_stack: if self.list_stack[-1][0] == 'dd': |
def start_string(self, attrs): self.start_b(attrs) def end_b(self): self.end_b() | def start_strong(self, attrs): self.start_b(attrs) def end_strong(self): self.end_b() | def start_string(self, attrs): self.start_b(attrs) |
def end_var(self): self.end_var() | def end_var(self): self.end_i() | def end_var(self): self.end_var() |
if ModalDialog(self._filterfunc) == 1: | if ModalDialog(_ProgressBar_filterfunc) == 1: | def _update(self, value): tp, h, bar_rect = self.d.GetDialogItem(3) Qd.SetPort(self.d) Qd.FrameRect(bar_rect) # Draw outline inner_rect = Qd.InsetRect(bar_rect, 1, 1) Qd.ForeColor(QuickDraw.whiteColor) Qd.BackColor(QuickDraw.whiteColor) Qd.PaintRect(inner_rect) # Clear internal l, t, r, b = inner_rect r = int(l + (r... |
def _filterfunc(self, d, e, *more): return 2 | def _filterfunc(self, d, e, *more): return 2 # XXXX For now, this disables the cancel button | |
def _ProgressBar_filterfunc(*args): return 2 | def set(self, value): if value < 0: value = 0 if value > self.maxval: value = self.maxval self._update(value) | |
u = u''.join(map(unichr, xrange(1024))) for encoding in ('utf-7', 'utf-8', 'utf-16', 'utf-16-le', 'utf-16-be', 'raw_unicode_escape', 'unicode_escape', 'unicode_internal'): self.assertEqual(unicode(u.encode(encoding),encoding), u) | for c in xrange(1024): u = unichr(c) for encoding in ('utf-7', 'utf-8', 'utf-16', 'utf-16-le', 'utf-16-be', 'raw_unicode_escape', 'unicode_escape', 'unicode_internal'): self.assertEqual(unicode(u.encode(encoding),encoding), u) | def test_codecs(self): # Encoding self.assertEqual(u'hello'.encode('ascii'), 'hello') self.assertEqual(u'hello'.encode('utf-7'), 'hello') self.assertEqual(u'hello'.encode('utf-8'), 'hello') self.assertEqual(u'hello'.encode('utf8'), 'hello') self.assertEqual(u'hello'.encode('utf-16-le'), 'h\000e\000l\000l\000o\000') sel... |
u = u''.join(map(unichr, xrange(256))) for encoding in ('latin-1',): self.assertEqual(unicode(u.encode(encoding),encoding), u) | for c in xrange(256): u = unichr(c) for encoding in ('latin-1',): self.assertEqual(unicode(u.encode(encoding),encoding), u) | def test_codecs(self): # Encoding self.assertEqual(u'hello'.encode('ascii'), 'hello') self.assertEqual(u'hello'.encode('utf-7'), 'hello') self.assertEqual(u'hello'.encode('utf-8'), 'hello') self.assertEqual(u'hello'.encode('utf8'), 'hello') self.assertEqual(u'hello'.encode('utf-16-le'), 'h\000e\000l\000l\000o\000') sel... |
u = u''.join(map(unichr, xrange(128))) for encoding in ('ascii',): self.assertEqual(unicode(u.encode(encoding),encoding), u) | for c in xrange(128): u = unichr(c) for encoding in ('ascii',): self.assertEqual(unicode(u.encode(encoding),encoding), u) | def test_codecs(self): # Encoding self.assertEqual(u'hello'.encode('ascii'), 'hello') self.assertEqual(u'hello'.encode('utf-7'), 'hello') self.assertEqual(u'hello'.encode('utf-8'), 'hello') self.assertEqual(u'hello'.encode('utf8'), 'hello') self.assertEqual(u'hello'.encode('utf-16-le'), 'h\000e\000l\000l\000o\000') sel... |
return strftime(self.format, (item,)*8+(0,)).capitalize() | t = (2001, 1, item+1, 12, 0, 0, item, item+1, 0) return strftime(self.format, t).capitalize() | def __getitem__(self, item): if isinstance(item, int): if item < 0: item += self.len if not 0 <= item < self.len: raise IndexError, "out of range" return strftime(self.format, (item,)*8+(0,)).capitalize() elif isinstance(item, type(slice(0))): return [self[e] for e in range(self.len)].__getslice__(item.start, item.stop... |
[frozenmain_c, frozen_c], target) | [frozenmain_c, os.path.basename(frozen_c)], os.path.basename(target)) | 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 = ... |
The 'quotetabs' flag indicates whether tabs should be quoted.""" if c == '\t': return not quotetabs return c == ESCAPE or not(' ' <= c <= '~') | The 'quotetabs' flag indicates whether embedded tabs and spaces should be quoted. Note that line-ending tabs and spaces are always encoded, as per RFC 1521. """ if c in ' \t': return quotetabs return c == ESCAPE or not (' ' <= c <= '~') | def needsquoting(c, quotetabs): """Decide whether a particular character needs to be quoted. The 'quotetabs' flag indicates whether tabs should be quoted.""" if c == '\t': return not quotetabs return c == ESCAPE or not(' ' <= c <= '~') |
The 'quotetabs' flag indicates whether tabs should be quoted. """ | The 'quotetabs' flag indicates whether embedded tabs and spaces should be quoted. Note that line-ending tabs and spaces are always encoded, as per RFC 1521. """ def write(s, output=output, lineEnd='\n'): if s and s[-1:] in ' \t': output.write(s[:-1] + quote(s[-1]) + lineEnd) else: output.write(s + lineEnd) prevline... | def encode(input, output, quotetabs): """Read 'input', apply quoted-printable encoding, and write to 'output'. 'input' and 'output' are files with readline() and write() methods. The 'quotetabs' flag indicates whether tabs should be quoted. """ while 1: line = input.readline() if not line: break new = '' last = line[-... |
new = '' last = line[-1:] if last == '\n': | outline = [] stripped = '' if line[-1:] == '\n': | def encode(input, output, quotetabs): """Read 'input', apply quoted-printable encoding, and write to 'output'. 'input' and 'output' are files with readline() and write() methods. The 'quotetabs' flag indicates whether tabs should be quoted. """ while 1: line = input.readline() if not line: break new = '' last = line[-... |
else: last = '' prev = '' | stripped = '\n' | def encode(input, output, quotetabs): """Read 'input', apply quoted-printable encoding, and write to 'output'. 'input' and 'output' are files with readline() and write() methods. The 'quotetabs' flag indicates whether tabs should be quoted. """ while 1: line = input.readline() if not line: break new = '' last = line[-... |
if len(new) + len(c) >= MAXLINESIZE: output.write(new + ESCAPE + '\n') new = '' new = new + c prev = c if prev in (' ', '\t'): output.write(new + ESCAPE + '\n\n') else: output.write(new + '\n') | if linelen + len(c) >= MAXLINESIZE: if prevline is not None: write(prevline) prevline = EMPTYSTRING.join(outline) linelen = 0 outline = [] outline.append(c) linelen += len(c) if prevline is not None: write(prevline) prevline = EMPTYSTRING.join(outline) linelen = 0 outline = [] if prevline is not None: write(prevline... | def encode(input, output, quotetabs): """Read 'input', apply quoted-printable encoding, and write to 'output'. 'input' and 'output' are files with readline() and write() methods. The 'quotetabs' flag indicates whether tabs should be quoted. """ while 1: line = input.readline() if not line: break new = '' last = line[-... |
def test(): | def main(): | def test(): import sys import getopt try: opts, args = getopt.getopt(sys.argv[1:], 'td') except getopt.error, msg: sys.stdout = sys.stderr print msg print "usage: quopri [-t | -d] [file] ..." print "-t: quote tabs" print "-d: decode; default encode" sys.exit(2) deco = 0 tabs = 0 for o, a in opts: if o == '-t': tabs = 1... |
test() | main() | def test(): import sys import getopt try: opts, args = getopt.getopt(sys.argv[1:], 'td') except getopt.error, msg: sys.stdout = sys.stderr print msg print "usage: quopri [-t | -d] [file] ..." print "-t: quote tabs" print "-d: decode; default encode" sys.exit(2) deco = 0 tabs = 0 for o, a in opts: if o == '-t': tabs = 1... |
_tryorder = ["galeon", "mozilla", "netscape", "kfm", "grail", "links", "lynx", "w3m",] | _tryorder = ["links", "lynx", "w3m"] | def open_new(self, url): self.open(url) |
if tr_enc: if tr_enc.lower() != 'chunked': raise UnknownTransferEncoding() | if tr_enc and tr_enc.lower() == "chunked": | def begin(self): if self.msg is not None: # we've already started reading the response return |
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp) | raise HTTPError(req.get_full_url(), code, msg, headers, fp) | def redirect_request(self, req, fp, code, msg, headers, newurl): """Return a Request or None in response to a redirect. |
if terminator is None: | if terminator is None or terminator == '': | def handle_read (self): |
meta = '\n <meta name="aesop" content="%s">' | meta = '<meta name="aesop" content="%s">\n ' % self.aesop_type | def get_header(self): s = HEAD % self.variables if self.uplink: if self.uptitle: link = ('<link rel="up" href="%s" title="%s">' % (self.uplink, self.uptitle)) else: link = '<link rel="up" href="%s">' % self.uplink repl = " %s\n</head>" % link s = s.replace("</head>", repl, 1) if self.aesop_type: meta = '\n <meta name... |
if not dircase in _dirs_in_sys_path and os.path.exists(dir): | if not dircase in _dirs_in_sys_path: | def makepath(*paths): dir = os.path.abspath(os.path.join(*paths)) return dir, os.path.normcase(dir) |
created_dirs = [] | def mkpath (name, mode=0777, verbose=0, dry_run=0): """Create a directory and any missing ancestor directories. If the directory already exists, return silently. Raise DistutilsFileError if unable to create some directory along the way (eg. some sub-path exists, but is a file rather than a directory). If 'verbose' i... | |
return | return created_dirs | def mkpath (name, mode=0777, verbose=0, dry_run=0): """Create a directory and any missing ancestor directories. If the directory already exists, return silently. Raise DistutilsFileError if unable to create some directory along the way (eg. some sub-path exists, but is a file rather than a directory). If 'verbose' i... |
if msg[:3] != '500': raise error_perm, msg | if msg.args[0][:3] != '500': raise | def cwd(self, dirname): '''Change to a directory.''' if dirname == '..': try: return self.voidcmd('CDUP') except error_perm, msg: if msg[:3] != '500': raise error_perm, msg elif dirname == '': dirname = '.' # does nothing, but could return error cmd = 'CWD ' + dirname return self.voidcmd(cmd) |
tcltkdata = [(tcltk.id, "REGISTRY.tcl"), | tcldata = [(tcltk.id, "REGISTRY.tcl"), | # File extensions, associated with the REGISTRY.def component |
[("py", "open", 1, None, r'-n -e "%1"'), ("pyw", "open", 1, None, r'-n -e "%1"'), ("pyc", "open", 1, None, r'-n -e "%1"'), ("pyo", "open", 1, None, r'-n -e "%1"')]) | [("py", "open", 1, None, r'"%1"'), ("pyw", "open", 1, None, r'"%1"'), ("pyc", "open", 1, None, r'"%1"'), ("pyo", "open", 1, None, r'"%1"')]) | # File extensions, associated with the REGISTRY.def component |
screenbounds = Qd.qd.screenBits.bounds screenbounds = screenbounds[0]+4, screenbounds[1]+4, \ screenbounds[2]-4, screenbounds[3]-4 | def AskYesNoCancel(question, default = 0): | |
def __init__(self, label="Working...", maxval=100): self.label = label | def __init__(self, title="Working...", maxval=100, label=""): | def __init__(self, label="Working...", maxval=100): self.label = label self.maxval = maxval self.curval = -1 self.d = GetNewDialog(259, -1) tp, text_h, rect = self.d.GetDialogItem(2) SetDialogItemText(text_h, label) self._update(0) |
SetDialogItemText(text_h, label) self._update(0) | SetDialogItemText(text_h, self._label) | def __init__(self, label="Working...", maxval=100): self.label = label self.maxval = maxval self.curval = -1 self.d = GetNewDialog(259, -1) tp, text_h, rect = self.d.GetDialogItem(2) SetDialogItemText(text_h, label) self._update(0) |
if ModalDialog(_ProgressBar_filterfunc) == 1: raise KeyboardInterrupt | ready, ev = Evt.WaitNextEvent( Events.mDownMask, 1 ) if ready : what,msg,when,where,mod = ev part = Win.FindWindow(where)[0] if Dlg.IsDialogEvent(ev): ds = Dlg.DialogSelect(ev) if ds[0] and ds[1] == self.d and ds[-1] == 1: raise KeyboardInterrupt, ev else: if part == 4: self.d.DragWindow(where, screenbounds) else: Mac... | def _update(self, value): tp, h, bar_rect = self.d.GetDialogItem(3) Qd.SetPort(self.d) Qd.FrameRect(bar_rect) # Draw outline inner_rect = Qd.InsetRect(bar_rect, 1, 1) l, t, r, b = inner_rect |
def _ProgressBar_filterfunc(*args): return 2 | def inc(self, n=1): """inc(amt) - Increment progress bar position""" self.set(self.curval + n) | def set(self, value): if value < 0: value = 0 if value > self.maxval: value = self.maxval self._update(value) |
bar = ProgressBar("Counting...", 100) for i in range(100): bar.set(i) del bar | text = ( "Working Hard...", "Hardly Working..." , "So far, so good!", "Keep on truckin'" ) bar = ProgressBar("Progress, progress...", 100) try: appsw = MacOS.EnableAppswitch(0) for i in range(100): bar.set(i) time.sleep(0.1) if i % 10 == 0: bar.label(text[(i/10) % 4]) bar.label("Done.") time.sleep(0.3) finally: del bar... | def test(): Message("Testing EasyDialogs.") ok = AskYesNoCancel("Do you want to proceed?") if ok > 0: s = AskString("Enter your first name") Message("Thank you,\015%s" % `s`) bar = ProgressBar("Counting...", 100) for i in range(100): bar.set(i) del bar |
test() | try: test() except KeyboardInterrupt: Message("Operation Canceled.") | def test(): Message("Testing EasyDialogs.") ok = AskYesNoCancel("Do you want to proceed?") if ok > 0: s = AskString("Enter your first name") Message("Thank you,\015%s" % `s`) bar = ProgressBar("Counting...", 100) for i in range(100): bar.set(i) del bar |
if not os.isatty(slave_fd) and sys.platform not in fickle_isatty: | if not os.isatty(slave_fd): | def test_basic_pty(): try: debug("Calling master_open()") master_fd, slave_name = pty.master_open() debug("Got master_fd '%d', slave_name '%s'"%(master_fd, slave_name)) debug("Calling slave_open(%r)"%(slave_name,)) slave_fd = pty.slave_open(slave_name) debug("Got slave_fd '%d'"%slave_fd) except OSError: # " An optional... |
if nodelist[3][0] != symbol.except_clause: return self.com_try_finally(nodelist) return self.com_try_except(nodelist) | return self.com_try_except_finally(nodelist) | def try_stmt(self, nodelist): # 'try' ':' suite (except_clause ':' suite)+ ['else' ':' suite] # | 'try' ':' suite 'finally' ':' suite if nodelist[3][0] != symbol.except_clause: return self.com_try_finally(nodelist) |
def com_try_finally(self, nodelist): return TryFinally(self.com_node(nodelist[2]), self.com_node(nodelist[5]), lineno=nodelist[0][2]) def com_try_except(self, nodelist): | def com_try_except_finally(self, nodelist): if nodelist[3][0] == token.NAME: return TryFinally(self.com_node(nodelist[2]), self.com_node(nodelist[5]), lineno=nodelist[0][2]) | def com_try_finally(self, nodelist): # try_fin_stmt: "try" ":" suite "finally" ":" suite return TryFinally(self.com_node(nodelist[2]), self.com_node(nodelist[5]), lineno=nodelist[0][2]) |
stmt = self.com_node(nodelist[2]) | def com_try_except(self, nodelist): # try_except: 'try' ':' suite (except_clause ':' suite)* ['else' suite] #tryexcept: [TryNode, [except_clauses], elseNode)] stmt = self.com_node(nodelist[2]) clauses = [] elseNode = None for i in range(3, len(nodelist), 3): node = nodelist[i] if node[0] == symbol.except_clause: # exc... | |
elseNode = self.com_node(nodelist[i+2]) return TryExcept(self.com_node(nodelist[2]), clauses, elseNode, lineno=nodelist[0][2]) | if node[1] == 'else': elseNode = self.com_node(nodelist[i+2]) elif node[1] == 'finally': finallyNode = self.com_node(nodelist[i+2]) try_except = TryExcept(self.com_node(nodelist[2]), clauses, elseNode, lineno=nodelist[0][2]) if finallyNode: return TryFinally(try_except, finallyNode, lineno=nodelist[0][2]) else: return ... | def com_try_except(self, nodelist): # try_except: 'try' ':' suite (except_clause ':' suite)* ['else' suite] #tryexcept: [TryNode, [except_clauses], elseNode)] stmt = self.com_node(nodelist[2]) clauses = [] elseNode = None for i in range(3, len(nodelist), 3): node = nodelist[i] if node[0] == symbol.except_clause: # exc... |
prefix = get_config_vars('prefix', 'exec_prefix') | (prefix, exec_prefix) = get_config_vars('prefix', 'exec_prefix') | def finalize_options (self): |
def unpack(self, archive, output=None): | def unpack(self, archive, output=None, package=None): | def unpack(self, archive, output=None): return None |
def unpack(self, archive, output=None): | def unpack(self, archive, output=None, package=None): | def unpack(self, archive, output=None): cmd = self.argument % archive if _cmd(output, self._dir, cmd): return "unpack command failed" |
def unpack(self, archive, output=None): | def unpack(self, archive, output=None, package=None): | def unpack(self, archive, output=None): tf = tarfile.open(archive, "r") members = tf.getmembers() skip = [] if self._renames: for member in members: for oldprefix, newprefix in self._renames: if oldprefix[:len(self._dir)] == self._dir: oldprefix2 = oldprefix[len(self._dir):] else: oldprefix2 = None if member.name[:len(... |
"MD5Sum" | "MD5Sum", "User-install-skips", "Systemwide-only", | def find(self, ident): """Find a package. The package can be specified by name or as a dictionary with name, version and flavor entries. Only name is obligatory. If there are multiple matches the best one (higher version number, flavors ordered according to users' preference) is returned.""" if type(ident) == str: # ... |
rv = unpacker.unpack(self.archiveFilename, output=output) | rv = unpacker.unpack(self.archiveFilename, output=output, package=self) | 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('Install-command'): return "%s: Binary package cannot have Install-command" % self.fullname() if self._dict.has_key('P... |
def test_it(self): def tr(frame, event, arg): | def trace(self, frame, event, arg): """A trace function that raises an exception in response to a specific trace event.""" if event == self.raiseOnEvent: | def test_it(self): def tr(frame, event, arg): raise ValueError # just something that isn't RuntimeError def f(): return 1 try: for i in xrange(sys.getrecursionlimit() + 1): sys.settrace(tr) try: f() except ValueError: pass else: self.fail("exception not thrown!") except RuntimeError: self.fail("recursion counter not re... |
def f(): | else: return self.trace def f(self): """The function to trace; raises an exception if that's the case we're testing, so that the 'exception' trace event fires.""" if self.raiseOnEvent == 'exception': x = 0 y = 1/x else: | def f(): return 1 |
sys.settrace(tr) | sys.settrace(self.trace) | def f(): return 1 |
f() | self.f() | def f(): return 1 |
def test_call(self): self.run_test_for_event('call') def test_line(self): self.run_test_for_event('line') def test_return(self): self.run_test_for_event('return') def test_exception(self): self.run_test_for_event('exception') | def f(): return 1 | |
'Down Arrow': 'Down', 'Tab':'tab'} | 'Down Arrow': 'Down', 'Tab':'Tab'} | def TranslateKey(self, key, modifiers): "Translate from keycap symbol to the Tkinter keysym" translateDict = {'Space':'space', '~':'asciitilde','!':'exclam','@':'at','#':'numbersign', '%':'percent','^':'asciicircum','&':'ampersand','*':'asterisk', '(':'parenleft',')':'parenright','_':'underscore','-':'minus', '+':'plus... |
effective = (effective / tabwidth + 1) * tabwidth | effective = (int(effective / tabwidth) + 1) * tabwidth | def classifyws(s, tabwidth): raw = effective = 0 for ch in s: if ch == ' ': raw = raw + 1 effective = effective + 1 elif ch == '\t': raw = raw + 1 effective = (effective / tabwidth + 1) * tabwidth else: break return raw, effective |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.