rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
for key, value in headers.iteritems(): | for key, value in headers.items(): | def __init__(self, url, data=None, headers={}): # unwrap('<URL:type://host/path>') --> 'type://host/path' self.__original = unwrap(url) self.type = None # self.__r_type is what's left after doing the splittype self.host = None self.port = None self.data = data self.headers = {} for key, value in headers.iteritems(): se... |
for k, v in self.timeout.iteritems(): | for k, v in self.timeout.items(): | def check_cache(self): # first check for old ones t = time.time() if self.soonest <= t: for k, v in self.timeout.iteritems(): if v < t: self.cache[k].close() del self.cache[k] del self.timeout[k] self.soonest = min(self.timeout.values()) |
return self.readlines().join('') | return ''.join(self.readlines()) | def read(self): # Note: no size argument -- read until EOF only! return self.readlines().join('') |
if not host: return addinfourl(open(url2pathname(file), 'r'), noheaders(), self.openedurl) | if not host: return addinfourl(open(url2pathname(file), 'r'), noheaders(), 'file:'+file) | def open_local_file(self, url): host, file = splithost(url) if not host: return addinfourl(open(url2pathname(file), 'r'), noheaders(), self.openedurl) host, port = splitport(host) if not port and socket.gethostbyname(host) in ( localhost(), thishost()): file = unquote(file) return addinfourl(open(url2pathname(file), 'r... |
return addinfourl(open(url2pathname(file), 'r'), noheaders(), self.openedurl) | return addinfourl(open(url2pathname(file), 'r'), noheaders(), 'file:'+file) | def open_local_file(self, url): host, file = splithost(url) if not host: return addinfourl(open(url2pathname(file), 'r'), noheaders(), self.openedurl) host, port = splitport(host) if not port and socket.gethostbyname(host) in ( localhost(), thishost()): file = unquote(file) return addinfourl(open(url2pathname(file), 'r... |
buf = '' | buf = ['', ''] | def process_rawq(self): """Transfer from raw queue to cooked queue. |
if c == theNULL: continue if c == "\021": continue if c != IAC: buf = buf + c continue c = self.rawq_getchar() if c == IAC: buf = buf + c elif c in (DO, DONT): opt = self.rawq_getchar() self.msg('IAC %s %d', c == DO and 'DO' or 'DONT', ord(opt)) if self.option_callback: self.option_callback(self.sock, c, opt) | if not self.iacseq: if c == theNULL: continue if c == "\021": continue if c != IAC: buf[self.sb] = buf[self.sb] + c continue | def process_rawq(self): """Transfer from raw queue to cooked queue. |
self.sock.sendall(IAC + WONT + opt) elif c in (WILL, WONT): opt = self.rawq_getchar() self.msg('IAC %s %d', c == WILL and 'WILL' or 'WONT', ord(opt)) if self.option_callback: self.option_callback(self.sock, c, opt) | self.iacseq += c elif len(self.iacseq) == 1: 'IAC: IAC CMD [OPTION only for WILL/WONT/DO/DONT]' if c in (DO, DONT, WILL, WONT): self.iacseq += c continue self.iacseq = '' if c == IAC: buf[self.sb] = buf[self.sb] + c | def process_rawq(self): """Transfer from raw queue to cooked queue. |
self.sock.sendall(IAC + DONT + opt) else: self.msg('IAC %d not recognized' % ord(c)) | if c == SB: self.sb = 1 self.sbdataq = '' elif c == SE: self.sb = 0 self.sbdataq = self.sbdataq + buf[1] buf[1] = '' if self.option_callback: self.option_callback(self.sock, c, NOOPT) else: self.msg('IAC %d not recognized' % ord(c)) elif len(self.iacseq) == 2: cmd = self.iacseq[1] self.iacseq = '' opt = c if cmd i... | def process_rawq(self): """Transfer from raw queue to cooked queue. |
self.cookedq = self.cookedq + buf | self.cookedq = self.cookedq + buf[0] self.sbdataq = self.sbdataq + buf[1] | def process_rawq(self): """Transfer from raw queue to cooked queue. |
self.ted.WEInsert(stuff, None, None) | try: self.ted.WEInsert(stuff, None, None) finally: self._buf = "" | def flush(self): stuff = string.split(self._buf, '\n') stuff = string.join(stuff, '\r') self.setselection_at_end() self.ted.WEInsert(stuff, None, None) selstart, selend = self.getselection() self._inputstart = selstart self._buf = "" self.ted.WEClearUndo() self.updatescrollbars() if self._parentwindow.wid.GetWindowPort... |
self._buf = "" | def flush(self): stuff = string.split(self._buf, '\n') stuff = string.join(stuff, '\r') self.setselection_at_end() self.ted.WEInsert(stuff, None, None) selstart, selend = self.getselection() self._inputstart = selstart self._buf = "" self.ted.WEClearUndo() self.updatescrollbars() if self._parentwindow.wid.GetWindowPort... | |
self.w.outputtext.ted.WEInsert(stuff, None, None) self._buf = "" | try: self.w.outputtext.ted.WEInsert(stuff, None, None) finally: self._buf = "" | def flush(self): self.show() stuff = string.split(self._buf, '\n') stuff = string.join(stuff, '\r') end = self.w.outputtext.ted.WEGetTextLength() self.w.outputtext.setselection(end, end) self.w.outputtext.ted.WEFeatureFlag(WASTEconst.weFReadOnly, 0) self.w.outputtext.ted.WEInsert(stuff, None, None) self._buf = "" self.... |
class BadException: | class BadException(Exception): | def ckmsg(src, msg): try: compile(src, '<fragment>', 'exec') except SyntaxError, e: print e.msg if e.msg == msg: print "ok" else: print "expected:", msg else: print "failed to get expected SyntaxError" |
if (self.compiler.find_library_file(lib_dirs, 'z')): exts.append( Extension('zlib', ['zlibmodule.c'], libraries = ['z']) ) | zlib_inc = find_file('zlib.h', [], inc_dirs) if zlib_inc is not None: zlib_h = zlib_inc[0] + '/zlib.h' version = '"0.0.0"' version_req = '"1.1.3"' fp = open(zlib_h) while 1: line = fp.readline() if not line: break if line.find(' version = line.split()[2] break if version >= version_req: if (self.compiler.find_library_f... | def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.insert(0, '/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.insert(0, '/usr/local/include' ) |
command = interpolate(SH_LOCK, file=file) p = os.popen(command) output = p.read() | def commit(self, entry): file = entry.file # Normalize line endings in body if '\r' in self.ui.body: self.ui.body = re.sub('\r\n?', '\n', self.ui.body) # Normalize whitespace in title self.ui.title = string.join(string.split(self.ui.title)) # Check that there were any changes if self.ui.body == entry.body and self.ui.t... | |
command = interpolate( SH_LOCK + '\n' + SH_CHECKIN, file=file, tfn=tfn) | command = interpolate(SH_CHECKIN, file=file, tfn=tfn) log("\n\n" + command) | def commit(self, entry): file = entry.file # Normalize line endings in body if '\r' in self.ui.body: self.ui.body = re.sub('\r\n?', '\n', self.ui.body) # Normalize whitespace in title self.ui.title = string.join(string.split(self.ui.title)) # Check that there were any changes if self.ui.body == entry.body and self.ui.t... |
log("output: " + output) log("done: " + str(sts)) log("TempFile:\n" + open(tfn).read() + "end") | def commit(self, entry): file = entry.file # Normalize line endings in body if '\r' in self.ui.body: self.ui.body = re.sub('\r\n?', '\n', self.ui.body) # Normalize whitespace in title self.ui.title = string.join(string.split(self.ui.title)) # Check that there were any changes if self.ui.body == entry.body and self.ui.t... | |
self.assertRaises(ValueError, time.strftime, '', (1900, 0, 1, 0, 0, 0, 0, 1, -1)) | self.assertRaises(ValueError, time.strftime, '', (1900, -1, 1, 0, 0, 0, 0, 1, -1)) | def test_strftime_bounds_checking(self): # Make sure that strftime() checks the bounds of the various parts #of the time tuple. |
self.assertRaises(ValueError, time.strftime, '', (1900, 1, 0, 0, 0, 0, 0, 1, -1)) | self.assertRaises(ValueError, time.strftime, '', (1900, 1, -1, 0, 0, 0, 0, 1, -1)) | def test_strftime_bounds_checking(self): # Make sure that strftime() checks the bounds of the various parts #of the time tuple. |
self.assertRaises(ValueError, time.strftime, '', (1900, 1, 1, 0, 0, 0, 0, 0, -1)) | self.assertRaises(ValueError, time.strftime, '', (1900, 1, 1, 0, 0, 0, 0, -1, -1)) | def test_strftime_bounds_checking(self): # Make sure that strftime() checks the bounds of the various parts #of the time tuple. |
out_fn = string.replace (f, '.py', '.pyc') | out_fn = f + (__debug__ and "c" or "o") compile_msg = "byte-compiling %s to %s" % \ (f, os.path.basename (out_fn)) skip_msg = "byte-compilation of %s skipped" % f | def run (self): |
"byte-compiling %s" % f, "byte-compilation of %s skipped" % f) | compile_msg, skip_msg) | def run (self): |
if len_nodelist != 2 and isinstance(result, GenExpr): | if len_nodelist != 2 and isinstance(result, GenExpr) \ and len(node) == 3 and node[2][0] == symbol.gen_for: | def com_call_function(self, primaryNode, nodelist): if nodelist[0] == token.RPAR: return CallFunc(primaryNode, [], lineno=extractLineNo(nodelist)) args = [] kw = 0 len_nodelist = len(nodelist) for i in range(1, len_nodelist, 2): node = nodelist[i] if node[0] == token.STAR or node[0] == token.DOUBLESTAR: break kw, resul... |
if (isinstance (filename, str)): new_base = base.decode(TESTFN_ENCODING) file_list = [f.decode(TESTFN_ENCODING) for f in os.listdir(path)] else: new_base = base file_list = os.listdir(path) | if isinstance(base, str): base = base.decode(TESTFN_ENCODING) file_list = os.listdir(path) if file_list and isinstance(file_list[0], str): file_list = [f.decode(TESTFN_ENCODING) for f in file_list] | def _do_single(self, filename): self.failUnless(os.path.exists(filename)) self.failUnless(os.path.isfile(filename)) self.failUnless(os.path.exists(os.path.abspath(filename))) self.failUnless(os.path.isfile(os.path.abspath(filename))) os.chmod(filename, 0777) os.utime(filename, None) os.utime(filename, (time.time(), tim... |
new_base = unicodedata.normalize("NFD", new_base) | base = unicodedata.normalize("NFD", base) | def _do_single(self, filename): self.failUnless(os.path.exists(filename)) self.failUnless(os.path.isfile(filename)) self.failUnless(os.path.exists(os.path.abspath(filename))) self.failUnless(os.path.isfile(os.path.abspath(filename))) os.chmod(filename, 0777) os.utime(filename, None) os.utime(filename, (time.time(), tim... |
self.failUnless(new_base in file_list) | self.failUnless(base in file_list) | def _do_single(self, filename): self.failUnless(os.path.exists(filename)) self.failUnless(os.path.isfile(filename)) self.failUnless(os.path.exists(os.path.abspath(filename))) self.failUnless(os.path.isfile(os.path.abspath(filename))) os.chmod(filename, 0777) os.utime(filename, None) os.utime(filename, (time.time(), tim... |
Instantiate with: IMAP4_SSL([, host[, port[, keyfile[, certfile]]]]) | Instantiate with: IMAP4_SSL([host[, port[, keyfile[, certfile]]]]) | def print_log(self): self._mesg('last %d IMAP4 interactions:' % len(self._cmd_log)) i, n = self._cmd_log_idx, self._cmd_log_len while n: try: apply(self._mesg, self._cmd_log[i]) except: pass i += 1 if i >= self._cmd_log_len: i = 0 n -= 1 |
':action':'file_upload', 'protcol_version':'1', 'name':self.distribution.get_name(), 'version':self.distribution.get_version(), 'content':(os.path.basename(filename),content), 'filetype':command, 'pyversion':pyversion, 'md5_digest':md5(content).hexdigest(), | ':action': 'file_upload', 'protcol_version': '1', 'name': meta.get_name(), 'version': meta.get_version(), 'content': (os.path.basename(filename),content), 'filetype': command, 'pyversion': pyversion, 'md5_digest': md5(content).hexdigest(), 'metadata_version' : '1.0', 'summary': meta.get_description(), 'home_page'... | def upload_file(self, command, pyversion, filename): # Sign if requested if self.sign: spawn(("gpg", "--detach-sign", "-a", filename), dry_run=self.dry_run) |
class PackBufferTestCase(unittest.TestCase): """ Test the packing methods that work on buffers. """ def test_unpack_from( self ): test_string = 'abcd01234' fmt = '4s' s = struct.Struct(fmt) for cls in (str, buffer): data = cls(test_string) self.assertEquals(s.unpack_from(data), ('abcd',)) self.assertEquals(s.unpack_fr... | def assertRaises(excClass, callableObj, *args, **kwargs): try: callableObj(*args, **kwargs) except excClass: return else: raise RuntimeError("%s not raised." % excClass) def test_unpack_from(): test_string = 'abcd01234' fmt = '4s' s = struct.Struct(fmt) for cls in (str, buffer): data = cls(test_string) assert s.unpack... | def test_1229380(): import sys for endian in ('', '>', '<'): for cls in (int, long): for fmt in ('B', 'H', 'I', 'L'): deprecated_err(struct.pack, endian + fmt, cls(-1)) deprecated_err(struct.pack, endian + 'B', cls(300)) deprecated_err(struct.pack, endian + 'H', cls(70000)) deprecated_err(struct.pack, endian + 'I', s... |
if __debug__: stderr = re.sub(r"\[\d+ refs\]\r?\n?$", "", stderr) return stderr | return re.sub(r"\[\d+ refs\]\r?\n?$", "", stderr) | def remove_stderr_debug_decorations(stderr): if __debug__: stderr = re.sub(r"\[\d+ refs\]\r?\n?$", "", stderr) return stderr |
return Decimal((sign, self._int, self._exp))._fix(context=context) | return Decimal((sign, self._int, self._exp))._fix(context) | def __neg__(self, context=None): """Returns a copy with the sign switched. |
ans = self._fix(context=context) | ans = self._fix(context) | def __pos__(self, context=None): """Returns a copy, unless it is a sNaN. |
ans = ans._fix(context=context) | ans = ans._fix(context) | def __add__(self, other, context=None): """Returns self + other. |
ans = ans._fix(context=context) | ans = ans._fix(context) | def _increment(self, round=1, context=None): """Special case of add, adding 1eExponent |
ans = ans._fix(context=context) | ans = ans._fix(context) | def __mul__(self, other, context=None): """Return self * other. |
ans2 = ans2._fix(context=context) | ans2 = ans2._fix(context) | def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision. |
otherside = otherside._fix(context=context) | otherside = otherside._fix(context) | def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision. |
ans = ans._fix(context=context) | ans = ans._fix(context) | def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision. |
return r._fix(context=context) | return r._fix(context) | def remainder_near(self, other, context=None): """ Remainder nearest to 0- abs(remainder-near) <= other/2 """ other = _convert_other(other) |
def _fix(self, prec=None, rounding=None, folddown=None, context=None): | def _fix(self, context): | def _fix(self, prec=None, rounding=None, folddown=None, context=None): """Round if it is necessary to keep self within prec precision. |
prec - precision to which to round. By default, the context decides. rounding - Rounding method. By default, the context decides. folddown - Fold down high elements, by default context._clamp | def _fix(self, prec=None, rounding=None, folddown=None, context=None): """Round if it is necessary to keep self within prec precision. | |
if prec is None: prec = context.prec ans = Decimal(self) ans = ans._fixexponents(prec, rounding, folddown=folddown, context=context) | prec = context.prec ans = self._fixexponents(prec, context) | def _fix(self, prec=None, rounding=None, folddown=None, context=None): """Round if it is necessary to keep self within prec precision. |
ans = ans._round(prec, rounding, context=context) ans = ans._fixexponents(prec, rounding, folddown=folddown, context=context) | ans = ans._round(prec, context=context) ans = ans._fixexponents(prec, context) | def _fix(self, prec=None, rounding=None, folddown=None, context=None): """Round if it is necessary to keep self within prec precision. |
def _fixexponents(self, prec=None, rounding=None, folddown=None, context=None): """Fix the exponents and return a copy with the exponent in bounds.""" if self._is_special: return self if context is None: context = getcontext() if prec is None: prec = context.prec if folddown is None: folddown = context._clamp | def _fixexponents(self, prec, context): """Fix the exponents and return a copy with the exponent in bounds. Only call if known to not be a special value. """ folddown = context._clamp | def _fixexponents(self, prec=None, rounding=None, folddown=None, context=None): """Fix the exponents and return a copy with the exponent in bounds.""" if self._is_special: return self if context is None: context = getcontext() if prec is None: prec = context.prec if folddown is None: folddown = context._clamp Emin = co... |
return val._fix(context=context) | return val._fix(context) | def __pow__(self, n, modulo = None, context=None): """Return self ** n (mod modulo) |
dup = self._fix(context=context) | dup = self._fix(context) | def normalize(self, context=None): """Normalize- strip trailing 0s, change anything equal to 0 to 0e0""" |
ans = ans._fix(context=context) | ans = ans._fix(context) | def sqrt(self, context=None): """Return the square root of self. |
return ans._fix(context=context) | return ans._fix(context) | def sqrt(self, context=None): """Return the square root of self. |
return ans._fix(context=context) | return ans._fix(context) | def max(self, other, context=None): """Returns the larger value. |
return ans._fix(context=context) | return ans._fix(context) | def min(self, other, context=None): """Returns the smaller value. |
return d._fix(context=self) | return d._fix(self) | def create_decimal(self, num='0'): """Creates a new Decimal instance but using self as context.""" d = Decimal(num, context=self) return d._fix(context=self) |
return str(a._fix(context=self)) | return str(a._fix(self)) | def _apply(self, a): return str(a._fix(context=self)) |
self.__buf = '' | self.__buf = _StringIO() | def reset(self): self.__buf = '' |
return self.__buf | return self.__buf.getvalue() | def get_buffer(self): return self.__buf |
self.__buf = self.__buf + struct.pack('>L', x) | self.__buf.write(struct.pack('>L', x)) | def pack_uint(self, x): self.__buf = self.__buf + struct.pack('>L', x) |
if x: self.__buf = self.__buf + '\0\0\0\1' else: self.__buf = self.__buf + '\0\0\0\0' | if x: self.__buf.write('\0\0\0\1') else: self.__buf.write('\0\0\0\0') | def pack_bool(self, x): if x: self.__buf = self.__buf + '\0\0\0\1' else: self.__buf = self.__buf + '\0\0\0\0' |
try: self.__buf = self.__buf + struct.pack('>f', x) | try: self.__buf.write(struct.pack('>f', x)) | def pack_float(self, x): try: self.__buf = self.__buf + struct.pack('>f', x) except struct.error, msg: raise ConversionError, msg |
try: self.__buf = self.__buf + struct.pack('>d', x) | try: self.__buf.write(struct.pack('>d', x)) | def pack_double(self, x): try: self.__buf = self.__buf + struct.pack('>d', x) except struct.error, msg: raise ConversionError, msg |
self.__buf = self.__buf + data | self.__buf.write(data) | def pack_fstring(self, n, s): if n < 0: raise ValueError, 'fstring size must be nonnegative' n = ((n+3)/4)*4 data = s[:n] data = data + (n - len(data)) * '\0' self.__buf = self.__buf + data |
verify(str(s).__class__ is str) | def rev(self): if self._rev is not None: return self._rev L = list(self) L.reverse() self._rev = self.__class__("".join(L)) return self._rev | |
chmfile = os.path.join(sys.prefix, "Python%d%d.chm" % sys.version_info[:2]) | chmfile = os.path.join(sys.prefix, 'Doc', 'Python%d%d.chm' % sys.version_info[:2]) | def __init__(self, flist=None, filename=None, key=None, root=None): if EditorWindow.help_url is None: dochome = os.path.join(sys.prefix, 'Doc', 'index.html') if sys.platform.count('linux'): # look for html docs in a couple of standard places pyver = 'python-docs-' + '%s.%s.%s' % sys.version_info[:3] if os.path.isdir('... |
self.copy_file(name, outfile, preserve_mode = 0) | self.copy_file(os.path.join(package_dir, name), outfile, preserve_mode = 0) | def run(self): # Copies all .py files, then also copies the txt and gif files build_py.run(self) assert self.packages == [idlelib] for name in txt_files: outfile = self.get_plain_outfile(self.build_lib, [idlelib], name) dir = os.path.dirname(outfile) self.mkpath(dir) self.copy_file(name, outfile, preserve_mode = 0) for... |
icons = [os.path.join("Icons",name) for name in Icons] | icons = [os.path.join(package_dir, "Icons",name) for name in Icons] txts = [os.path.join(package_dir, name) for name in txt_files] | def get_source_files(self): # returns the .py files, the .txt files, and the icons icons = [os.path.join("Icons",name) for name in Icons] return build_py.get_source_files(self)+txt_files+icons |
package_dir = {idlelib:'.'}, | package_dir = {idlelib: package_dir}, | def _bytecode_filenames(self, files): files = [n for n in files if n.endswith('.py')] return install_lib._bytecode_filenames(self,files) |
scripts = ['idle'] | scripts = [os.path.join(package_dir, 'idle')] | def _bytecode_filenames(self, files): files = [n for n in files if n.endswith('.py')] return install_lib._bytecode_filenames(self,files) |
expectedchecksum = 'b45b79f3203ee1a896d9b5655484adaff5d4964b' | expectedchecksum = '4e389f97e9f88b8b7ab743121fd643089116f9f2' | def tearDown(self): del self.db |
test('replace', 'one!two!three!', 'one@two@three@', '!', '@', 0) | test('replace', 'one!two!three!', 'one!two!three!', '!', '@', 0) | def __getitem__(self, i): return self.seq[i] |
if cfg_target != cur_target: | elif map(int, cfg_target.split('.')) > map(int, cur_target.split('.')): | def _init_posix(): """Initialize the module as appropriate for POSIX systems.""" g = {} # load the installed Makefile: try: filename = get_makefile_filename() parse_makefile(filename, g) except IOError, msg: my_msg = "invalid Python installation: unable to open %s" % filename if hasattr(msg, "strerror"): my_msg = my_ms... |
if os.name in ('nt', 'os2'): | if os.name in ('nt', 'os2') or sys.platform == 'cygwin': | def setUp(self): TestMailbox.setUp(self) if os.name in ('nt', 'os2'): self._box.colon = '!' |
self.assertRaises(mailbox.ExternalClashError, self._box.lock) exited_pid, status = os.waitpid(pid, 0) | try: self.assertRaises(mailbox.ExternalClashError, self._box.lock) finally: exited_pid, status = os.waitpid(pid, 0) | def test_lock_conflict(self): # Fork off a subprocess that will lock the file for 2 seconds, # unlock it, and then exit. if not hasattr(os, 'fork'): return pid = os.fork() if pid == 0: # In the child, lock the mailbox. self._box.lock() time.sleep(2) self._box.unlock() os._exit(0) |
expected = longx // longy got = x // y | expected = longx / longy got = x / y | def checkit(*args): # Heavy use of nested scopes here! verify(got == expected, "for %r expected %r got %r" % (args, expected, got)) |
if importer in (None, True, False): | if importer is None: | def get_importer(path_item): """Retrieve a PEP 302 importer for the given path item The returned importer is cached in sys.path_importer_cache if it was newly created by a path hook. If there is no importer, a wrapper around the basic import machinery is returned. This wrapper is never inserted into the importer cach... |
tcl_version = self.tk.getvar('tcl_version') | tcl_version = str(self.tk.getvar('tcl_version')) | def __init__(self, screenName=None, baseName=None, className='Tk'): """Return a new Toplevel widget on screen SCREENNAME. A new Tcl interpreter will be created. BASENAME will be used for the identification of the profile file (see readprofile). It is constructed from sys.argv[0] without extensions if None is given. CLA... |
except: | except ValueError: | 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 = ... |
def test_monotonic(self): data = hamlet_scene * 8 * 16 last = length = len(zlib.compress(data, 0)) self.failUnless(last > len(data), "compress level 0 always expands") for level in range(10): length = len(zlib.compress(data, level)) self.failUnless(length <= last, 'compress level %d more effective than %d!' % ( level-... | def test_monotonic(self): # higher compression levels should not expand compressed size data = hamlet_scene * 8 * 16 last = length = len(zlib.compress(data, 0)) self.failUnless(last > len(data), "compress level 0 always expands") for level in range(10): length = len(zlib.compress(data, level)) self.failUnless(length <=... | |
def urlencode(dict): """Encode a dictionary of form entries into a URL query string.""" | def urlencode(dict,doseq=0): """Encode a dictionary of form entries into a URL query string. If any values in the dict are sequences and doseq is true, each sequence element is converted to a separate parameter. """ | def urlencode(dict): """Encode a dictionary of form entries into a URL query string.""" l = [] for k, v in dict.items(): k = quote_plus(str(k)) v = quote_plus(str(v)) l.append(k + '=' + v) return '&'.join(l) |
for k, v in dict.items(): k = quote_plus(str(k)) v = quote_plus(str(v)) l.append(k + '=' + v) | if not doseq: for k, v in dict.items(): k = quote_plus(str(k)) v = quote_plus(str(v)) l.append(k + '=' + v) else: for k, v in dict.items(): k = quote_plus(str(k)) if type(v) == types.StringType: v = quote_plus(v) l.append(k + '=' + v) elif type(v) == types.UnicodeType: v = quote_plus(v.encode("ASCII","replace")) l.... | def urlencode(dict): """Encode a dictionary of form entries into a URL query string.""" l = [] for k, v in dict.items(): k = quote_plus(str(k)) v = quote_plus(str(v)) l.append(k + '=' + v) return '&'.join(l) |
_mesg('abort exception ignored: %s' % val) | def _get_tagged_response(self, tag): | |
code = compile(line + '\n', '<stdin>', 'single') | def default(self, line): if line[:1] == '!': line = line[1:] locals = self.curframe.f_locals globals = self.curframe.f_globals globals['__privileged__'] = 1 code = compile(line + '\n', '<stdin>', 'single') try: exec code in globals, locals except: if type(sys.exc_type) == type(''): exc_type_name = sys.exc_type else: ex... | |
import imp | def _visit_pyfiles(list, dirname, names): """ Helper for getFilesForName(). """ # get extension for python source files if not globals().has_key('_py_ext'): import imp global _py_ext _py_ext = [triple[0] for triple in imp.get_suffixes() if triple[2] == imp.PY_SOURCE][0] # don't recurse into CVS directories if 'CVS' in... | |
import imp | def _get_modpkg_path(dotted_name, pathlist=None): """ Get the filesystem path for a module or a package. Return the file system path to a file for a module, and to a directory for a package. Return None if the name is not found, or is a builtin or extension module. """ import imp # split off top-most name parts = dot... | |
import imp | def getFilesForName(name): """ Get a list of module files for a filename, a module or package name, or a directory. """ import imp if not os.path.exists(name): # check for glob chars if containsAny(name, "*?[]"): import glob files = glob.glob(name) list = [] for file in files: list.extend(getFilesForName(file)) return... | |
import glob | def getFilesForName(name): """ Get a list of module files for a filename, a module or package name, or a directory. """ import imp if not os.path.exists(name): # check for glob chars if containsAny(name, "*?[]"): import glob files = glob.glob(name) list = [] for file in files: list.extend(getFilesForName(file)) return... | |
_('*** Seen unexpected token "%(token)s"' % {'token': 'test'}) | _('*** Seen unexpected token "%(token)s"') % {'token': 'test'} | def main(): global default_keywords try: opts, args = getopt.getopt( sys.argv[1:], 'ad:DEhk:Kno:p:S:Vvw:x:X:', ['extract-all', 'default-domain=', 'escape', 'help', 'keyword=', 'no-default-keywords', 'add-location', 'no-location', 'output=', 'output-dir=', 'style=', 'verbose', 'version', 'width=', 'exclude-file=', 'docs... |
self.assertEqual(stderr, "pineapple") | self.assert_(stderr.startswith("pineapple")) | def test_communicate_stderr(self): p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stderr.write("pineapple")'], stderr=subprocess.PIPE) (stdout, stderr) = p.communicate() self.assertEqual(stdout, None) self.assertEqual(stderr, "pineapple") |
import string if len(id) == 0: | global _idprog if not _idprog: _idprog = compile(r"[a-zA-Z_]\w*$") if _idprog.match(id): return 1 else: | def valid_identifier(id): import string if len(id) == 0: return 0 if id[0] not in string.letters+'_': return 0 for char in id[1:]: if not syntax_table[char] & word: return 0 return 1 |
if id[0] not in string.letters+'_': return 0 for char in id[1:]: if not syntax_table[char] & word: return 0 return 1 | def valid_identifier(id): import string if len(id) == 0: return 0 if id[0] not in string.letters+'_': return 0 for char in id[1:]: if not syntax_table[char] & word: return 0 return 1 | |
without effecting this threads data: | without affecting this thread's data: | ... def squared(self): |
if err[0] = errno.EINTR: | if err[0] == errno.EINTR: | def makefile(self, mode, bufsize=None): """Return a readable file-like object with data from socket. |
'Header', 'Iterators', 'MIMEAudio', 'MIMEBase', 'MIMEImage', 'MIMEMessage', 'MIMEText', 'Message', 'Parser', 'Utils', 'base64MIME', | 'Header', 'Iterators', 'MIMEAudio', 'MIMEBase', 'MIMEImage', 'MIMEMessage', 'MIMEMultipart', 'MIMENonMultipart', 'MIMEText', 'Message', 'Parser', 'Utils', 'base64MIME', | def test__all__(self): module = __import__('email') all = module.__all__ all.sort() self.assertEqual(all, ['Charset', 'Encoders', 'Errors', 'Generator', 'Header', 'Iterators', 'MIMEAudio', 'MIMEBase', 'MIMEImage', 'MIMEMessage', 'MIMEText', 'Message', 'Parser', 'Utils', 'base64MIME', 'message_from_file', 'message_from_... |
test_support.run_unittest(TestSFbugs) test_support.run_doctest(difflib) | Doctests = doctest.DocTestSuite(difflib) test_support.run_unittest(TestSFbugs, Doctests) | def test_ratio_for_null_seqn(self): # Check clearing of SF bug 763023 s = difflib.SequenceMatcher(None, [], []) self.assertEqual(s.ratio(), 1) self.assertEqual(s.quick_ratio(), 1) self.assertEqual(s.real_quick_ratio(), 1) |
self.badmodules[name] = {m.__name__:None} | if not self.badmodules.has_key(name): self.badmodules[name] = {} self.badmodules[name][m.__name__] = None | def scan_code(self, co, m): code = co.co_code n = len(code) i = 0 lastname = None while i < n: c = code[i] i = i+1 op = ord(c) if op >= dis.HAVE_ARGUMENT: oparg = ord(code[i]) + ord(code[i+1])*256 i = i+2 if op == IMPORT_NAME: name = lastname = co.co_names[oparg] if not self.badmodules.has_key(lastname): try: self.impo... |
self.badmodules[fullname] = {m.__name__:None} | if not self.badmodules.has_key(fullname): self.badmodules[fullname] = {} self.badmodules[fullname][m.__name__] = None | def scan_code(self, co, m): code = co.co_code n = len(code) i = 0 lastname = None while i < n: c = code[i] i = i+1 op = ord(c) if op >= dis.HAVE_ARGUMENT: oparg = ord(code[i]) + ord(code[i+1])*256 i = i+2 if op == IMPORT_NAME: name = lastname = co.co_names[oparg] if not self.badmodules.has_key(lastname): try: self.impo... |
def AskPassword(prompt, default='', id=264): | def AskPassword(prompt, default='', id=264, ok=None, cancel=None): | def AskPassword(prompt, default='', id=264): """Display a PROMPT string and a text entry field with a DEFAULT string. The string is displayed as bullets only. Return the contents of the text entry field when the user clicks the OK button or presses Return. Return None when the user clicks the Cancel button. If omitt... |
h = d.GetDialogItemAsControl(4) | pwd = d.GetDialogItemAsControl(4) | def AskPassword(prompt, default='', id=264): """Display a PROMPT string and a text entry field with a DEFAULT string. The string is displayed as bullets only. Return the contents of the text entry field when the user clicks the OK button or presses Return. Return None when the user clicks the Cancel button. If omitt... |
SetDialogItemText(h, bullets ) d.SelectDialogItemText(4, 999, 999) | SetControlData(pwd, kControlEditTextPart, kControlEditTextPasswordTag, default) d.SelectDialogItemText(4, 0, 999) Ctl.SetKeyboardFocus(d, pwd, kControlEditTextPart) if ok != None: h = d.GetDialogItemAsControl(1) h.SetControlTitle(ok) if cancel != None: h = d.GetDialogItemAsControl(2) h.SetControlTitle(cancel) | def AskPassword(prompt, default='', id=264): """Display a PROMPT string and a text entry field with a DEFAULT string. The string is displayed as bullets only. Return the contents of the text entry field when the user clicks the OK button or presses Return. Return None when the user clicks the Cancel button. If omitt... |
string = default oldschedparams = MacOS.SchedParams(0,0) | def AskPassword(prompt, default='', id=264): """Display a PROMPT string and a text entry field with a DEFAULT string. The string is displayed as bullets only. Return the contents of the text entry field when the user clicks the OK button or presses Return. Return None when the user clicks the Cancel button. If omitt... | |
ready,ev = Evt.WaitNextEvent(Events.everyEvent, 6) if not ready: continue what,msg,when,where,mod = ev if what == 0 : Dlg.DialogSelect(ev) elif Dlg.IsDialogEvent(ev): if what in (Events.keyDown, Events.autoKey): charcode = msg & Events.charCodeMask if ( mod & Events.cmdKey ): MacOS.SysBeep() continue else: if charcode ... | n = ModalDialog(None) if n == 1: h = d.GetDialogItemAsControl(4) return cr2lf(GetControlData(pwd, kControlEditTextPart, kControlEditTextPasswordTag)) if n == 2: return None | def AskPassword(prompt, default='', id=264): """Display a PROMPT string and a text entry field with a DEFAULT string. The string is displayed as bullets only. Return the contents of the text entry field when the user clicks the OK button or presses Return. Return None when the user clicks the Cancel button. If omitt... |
ok = AskYesNoCancel("Do you want to identify?", yes="Indentify", no="Don't identify") | ok = AskYesNoCancel("Do you want to identify?", yes="Identify", no="No") | def test(): import time Message("Testing EasyDialogs.") ok = AskYesNoCancel("Do you want to proceed?") ok = AskYesNoCancel("Do you want to identify?", yes="Indentify", no="Don't identify") if ok > 0: s = AskString("Enter your first name", "Joe") Message("Thank you,\n%s" % `s`) text = ( "Working Hard...", "Hardly Worki... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.