rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
pass | def popen2(cmd, bufsize=-1, mode='t'): """Execute the shell command 'cmd' in a sub-process. If 'bufsize' is specified, it sets the buffer size for the I/O pipes. The file objects (child_stdout, child_stdin) are returned.""" inst = Popen3(cmd, 0, bufsize) return inst.fromchild, inst.tochild def popen3(cmd, bufsize=-1... | def popen4(cmd, mode='t', bufsize=-1): """Execute the shell command 'cmd' in a sub-process. If 'bufsize' is specified, it sets the buffer size for the I/O pipes. The file objects (child_stdout_stderr, child_stdin) are returned.""" w, r = os.popen4(cmd, mode, bufsize) return r, w |
dir = f[0] | dir = convert_path(f[0]) | def run (self): self.mkpath(self.install_dir) for f in self.data_files: if type(f) == StringType: # it's a simple file, so copy it if self.warn_dir: self.warn("setup script did not provide a directory for " "'%s' -- installing right in '%s'" % (f, self.install_dir)) (out, _) = self.copy_file(f, self.install_dir) self.o... |
if _os.name != 'posix': | if _os.name != 'posix' or _os.sys.platform == 'cygwin': | def NamedTemporaryFile(mode='w+b', bufsize=-1, suffix="", prefix=template, dir=gettempdir()): """Create and return a temporary file. Arguments: 'prefix', 'suffix', 'dir' -- as for mkstemp. 'mode' -- the mode argument to os.fdopen (default "w+b"). 'bufsize' -- the buffer size argument to os.fdopen (default -1). The file... |
login = account = password = None | login = '' account = password = None | # Look for a machine, default, or macdef top-level keyword |
if login and password: | if password: | # Look for a machine, default, or macdef top-level keyword |
self.add_library ( "python" + sys.version[0] + sys.version[2] ) | def __init__ (self, verbose=0, dry_run=0, force=0): | |
cc_args = self.compile_options + \ | cc_args = compile_options + \ | def compile (self, sources, output_dir=None, macros=None, include_dirs=None, debug=0, extra_preargs=None, extra_postargs=None): |
if debug: pass | def compile (self, sources, output_dir=None, macros=None, include_dirs=None, debug=0, extra_preargs=None, extra_postargs=None): | |
self.shared_library_name(output_libname)) | self.shared_library_name(output_libname), output_dir=output_dir, libraries=libraries, library_dirs=library_dirs, debug=debug, extra_preargs=extra_preargs, extra_postargs=extra_postargs) | def link_shared_lib (self, objects, output_libname, output_dir=None, libraries=None, library_dirs=None, debug=0, extra_preargs=None, extra_postargs=None): |
ld_args = self.ldflags_shared + lib_opts + \ | if debug: ldflags = self.ldflags_shared_debug basename, ext = os.path.splitext (output_filename) output_filename = basename + '_d' + ext else: ldflags = self.ldflags_shared ld_args = ldflags + lib_opts + \ | def link_shared_object (self, objects, output_filename, output_dir=None, libraries=None, library_dirs=None, extra_preargs=None, extra_postargs=None): """Link a bunch of stuff together to create a shared object file. Much like 'link_shared_lib()', except the output filename is explicitly supplied as 'output_filename'."... |
if debug: pass | def link_shared_object (self, objects, output_filename, output_dir=None, libraries=None, library_dirs=None, extra_preargs=None, extra_postargs=None): """Link a bunch of stuff together to create a shared object file. Much like 'link_shared_lib()', except the output filename is explicitly supplied as 'output_filename'."... | |
self.todo[url].append(origin) | if origin not in self.todo[url]: self.todo[url].append(origin) | def newtodolink(self, url, origin): if self.todo.has_key(url): self.todo[url].append(origin) self.note(3, " Seen todo link %s", url) else: self.todo[url] = [origin] self.note(3, " New todo link %s", url) |
The request should be stored in self.raw_request; the results | The request should be stored in self.raw_requestline; the results | def parse_request(self): """Parse a request (internal). |
self.assertRaises(IndexError, s.__setitem__, -1, "bar") self.assertRaises(IndexError, s.__setitem__, 3, "bar") | self.assertRaises(IndexError, s.__delitem__, -1) self.assertRaises(IndexError, s.__delitem__, 3) | def test_delitem(self): s = self.type2test("foo") self.assertRaises(IndexError, s.__setitem__, -1, "bar") self.assertRaises(IndexError, s.__setitem__, 3, "bar") del s[0] self.assertEqual(s, "oo") del s[1] self.assertEqual(s, "o") del s[0] self.assertEqual(s, "") |
verify(str(msg).find("weakly") >= 0) | verify(str(msg).find("weak reference") >= 0) | def weakrefs(): if verbose: print "Testing weak references..." import weakref class C(object): pass c = C() r = weakref.ref(c) verify(r() is c) del c verify(r() is None) del r class NoWeak(object): __slots__ = ['foo'] no = NoWeak() try: weakref.ref(no) except TypeError, msg: verify(str(msg).find("weakly") >= 0) else: v... |
if self.debuglevel > 0: print>>stderr, 'connect:', (host, port) | if self.debuglevel > 0: print>>stderr, 'connect:', sa | def connect(self, host='localhost', port = 0): """Connect to a host on a given port. |
if self.debuglevel > 0: print>>stderr, 'connect fail:', (host, port) | if self.debuglevel > 0: print>>stderr, 'connect fail:', msg | def connect(self, host='localhost', port = 0): """Connect to a host on a given port. |
typ, val, tb = sys.exc_info() | typ, val, tb = excinfo = sys.exc_info() sys.last_type, sys.last_value, sys.last_traceback = excinfo | def print_exception(): flush_stdout() efile = sys.stderr typ, val, tb = sys.exc_info() tbe = traceback.extract_tb(tb) print >>efile, '\nTraceback (most recent call last):' exclude = ("run.py", "rpc.py", "threading.py", "Queue.py", "RemoteDebugger.py", "bdb.py") cleanup_traceback(tbe, exclude) traceback.print_list(tbe, ... |
def test_getitem(self): class GetItem(object): | def _getitem_helper(self, base): class GetItem(base): | def test_getitem(self): class GetItem(object): def __len__(self): return maxint def __getitem__(self, key): return key def __getslice__(self, i, j): return i, j x = GetItem() self.assertEqual(x[self.pos], self.pos) self.assertEqual(x[self.neg], self.neg) self.assertEqual(x[self.neg:self.pos], (-1, maxint)) self.assertE... |
if not _type_to_name_map: | if _type_to_name_map=={}: | def type_to_name(gtype): global _type_to_name_map if not _type_to_name_map: for name in _names: if name[:2] == 'A_': _type_to_name_map[eval(name)] = name[2:] if _type_to_name_map.has_key(gtype): return _type_to_name_map[gtype] return 'TYPE=' + `gtype` |
self.sock.connect((host, port)) | try: self.sock.connect((host, port)) except socket.error: self.close() raise | def connect(self, host='localhost', port = 0): """Connect to a host on a given port. |
print """q(uit) Quit from the debugger. | print """q(uit) or exit - Quit from the debugger. | def help_q(self): print """q(uit) Quit from the debugger. |
- prepend _ if the result is a python keyword | - append _ if the result is a python keyword | def identify(str): """Turn any string into an identifier: - replace space by _ - replace other illegal chars by _xx_ (hex code) - prepend _ if the result is a python keyword """ if not str: return "empty_ae_name_" rv = '' ok = string.ascii_letters + '_' ok2 = ok + string.digits for c in str: if c in ok: rv = rv + c eli... |
for module in sys.modules.values(): | for module in (sys, os, __builtin__): | def test_abs__file__(self): # Make sure all imported modules have their __file__ attribute # as an absolute path. # Handled by abs__file__() site.abs__file__() for module in sys.modules.values(): try: self.failUnless(os.path.isabs(module.__file__)) except AttributeError: continue |
self.failUnless(os.path.isabs(module.__file__)) | self.failUnless(os.path.isabs(module.__file__), `module`) | def test_abs__file__(self): # Make sure all imported modules have their __file__ attribute # as an absolute path. # Handled by abs__file__() site.abs__file__() for module in sys.modules.values(): try: self.failUnless(os.path.isabs(module.__file__)) except AttributeError: continue |
from pprint import pprint print "config vars:" pprint (self.config_vars) | if DEBUG: from pprint import pprint print "config vars:" pprint (self.config_vars) | def finalize_options (self): |
from distutils.fancy_getopt import longopt_xlate print msg + ":" for opt in self.user_options: opt_name = opt[0] if opt_name[-1] == "=": opt_name = opt_name[0:-1] opt_name = string.translate (opt_name, longopt_xlate) val = getattr (self, opt_name) print " %s: %s" % (opt_name, val) | if DEBUG: from distutils.fancy_getopt import longopt_xlate print msg + ":" for opt in self.user_options: opt_name = opt[0] if opt_name[-1] == "=": opt_name = opt_name[0:-1] opt_name = string.translate (opt_name, longopt_xlate) val = getattr (self, opt_name) print " %s: %s" % (opt_name, val) | def dump_dirs (self, msg): from distutils.fancy_getopt import longopt_xlate print msg + ":" for opt in self.user_options: opt_name = opt[0] if opt_name[-1] == "=": opt_name = opt_name[0:-1] opt_name = string.translate (opt_name, longopt_xlate) val = getattr (self, opt_name) print " %s: %s" % (opt_name, val) |
import os, fcntl | import os try: import fcntl except ImportError: fcntl = None | def export_add(self, x, y): return x + y |
if hasattr(fcntl, 'FD_CLOEXEC'): | if fcntl is not None and hasattr(fcntl, 'FD_CLOEXEC'): | def __init__(self, addr, requestHandler=SimpleXMLRPCRequestHandler, logRequests=True, allow_none=False, encoding=None): self.logRequests = logRequests |
if self.compiler.find_library_file(lib_dirs, 'db-3.1'): | if self.compiler.find_library_file(lib_dirs, 'db-3.2'): dblib = ['db-3.2'] elif self.compiler.find_library_file(lib_dirs, 'db-3.1'): | 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' ) |
print 'Deleted breakpoint %s ' % (i,) | print 'Deleted breakpoint', i | def do_clear(self, arg): """Three possibilities, tried in this order: clear -> clear all breaks, ask for confirmation clear file:lineno -> clear all breaks at file:lineno clear bpno bpno ... -> clear breakpoints by number""" if not arg: try: reply = raw_input('Clear all breaks? ') except EOFError: reply = 'no' reply = ... |
return result = MenuKey(ord(c)) id = (result>>16) & 0xffff item = result & 0xffff if id: self.do_rawmenu(id, item, None, event) else: if DEBUG: print "Command-" +`c` | return | def do_key(self, event): (what, message, when, where, modifiers) = event c = chr(message & charCodeMask) if modifiers & cmdKey: if c == '.': raise self else: if not self.menubar: MacOS.HandleEvent(event) return result = MenuKey(ord(c)) id = (result>>16) & 0xffff # Hi word item = result & 0xffff # Lo word if id: self.d... |
self.menu.SetMenuItem | self.menu.SetMenuItemKeyGlyph(item, shortcut[2]) | def additem(self, label, shortcut=None, callback=None, kind=None): self.menu.AppendMenu('x') # add a dummy string self.items.append(label, shortcut, callback, kind) item = len(self.items) self.menu.SetMenuItemText(item, label) # set the actual text if shortcut and type(shortcut) == type(()): modifiers, char = shortcu... |
r = typ.__repr__ | r = getattr(typ, "__repr__", None) | def _format(self, object, stream, indent, allowance, context, level): level = level + 1 objid = _id(object) if objid in context: stream.write(_recursion(object)) self._recursive = True self._readable = False return rep = self._repr(object, context, level - 1) typ = _type(object) sepLines = _len(rep) > (self._width - 1 ... |
r = typ.__repr__ | r = getattr(typ, "__repr__", None) | def _safe_repr(object, context, maxlevels, level): typ = _type(object) if typ is str: if 'locale' not in _sys.modules: return repr(object), True, False if "'" in object and '"' not in object: closure = '"' quotes = {'"': '\\"'} else: closure = "'" quotes = {"'": "\\'"} qget = quotes.get sio = _StringIO() write = sio.wr... |
def find_library_file (self, dirs, lib): | def find_library_file (self, dirs, lib, debug=0): if debug: try_names = [lib + "_d", lib] else: try_names = [lib] | def find_library_file (self, dirs, lib): |
libfile = os.path.join (dir, self.library_filename (lib)) if os.path.exists (libfile): return libfile | for name in try_names: libfile = os.path.join(dir, self.library_filename (name)) if os.path.exists(libfile): return libfile | def find_library_file (self, dirs, lib): |
if self.text.get("insert-1c") not in (')',']','}'): | closer = self.text.get("insert-1c") if closer not in _openers: | def paren_closed_event(self, event): # If it was a shortcut and not really a closing paren, quit. if self.text.get("insert-1c") not in (')',']','}'): return hp = HyperParser(self.editwin, "insert-1c") if not hp.is_in_code(): return indices = hp.get_surrounding_brackets(keysym_opener[event.keysym], True) if indices is N... |
indices = hp.get_surrounding_brackets(keysym_opener[event.keysym], True) | indices = hp.get_surrounding_brackets(_openers[closer], True) | def paren_closed_event(self, event): # If it was a shortcut and not really a closing paren, quit. if self.text.get("insert-1c") not in (')',']','}'): return hp = HyperParser(self.editwin, "insert-1c") if not hp.is_in_code(): return indices = hp.get_surrounding_brackets(keysym_opener[event.keysym], True) if indices is N... |
self.assertEqual(rem, 0) self.assertEqual(r1, r2) | self.assertEqual(rem, 0, '%s != 0 for %s' % (rem, i)) self.assertEqual(r1, r2, '%s != %s for %s' % (r1, r2, i)) | def test_count(self): self.checkequal(3, 'aaa', 'count', 'a') self.checkequal(0, 'aaa', 'count', 'b') self.checkequal(3, 'aaa', 'count', 'a') self.checkequal(0, 'aaa', 'count', 'b') self.checkequal(3, 'aaa', 'count', 'a') self.checkequal(0, 'aaa', 'count', 'b') self.checkequal(0, 'aaa', 'count', 'b') self.checkequal(2,... |
if url[:2] == '//' and url[2:3] != '/': | if url[:2] == '//' and url[2:3] != '/' and url[2:12] != 'localhost/': | def open_file(self, url): """Use local file or FTP depending on form of URL.""" if url[:2] == '//' and url[2:3] != '/': return self.open_ftp(url) else: return self.open_local_file(url) |
ra = (dir, 0, 16) | ra = (dir, 0, 2000) | def Listdir(self, dir): list = [] ra = (dir, 0, 16) while 1: (status, rest) = self.Readdir(ra) if status <> NFS_OK: break entries, eof = rest last_cookie = None for fileid, name, cookie in entries: print (fileid, name, cookie) # XXX list.append(fileid, name) last_cookie = cookie if eof or not last_cookie: break ra = (r... |
print (fileid, name, cookie) | def Listdir(self, dir): list = [] ra = (dir, 0, 16) while 1: (status, rest) = self.Readdir(ra) if status <> NFS_OK: break entries, eof = rest last_cookie = None for fileid, name, cookie in entries: print (fileid, name, cookie) # XXX list.append(fileid, name) last_cookie = cookie if eof or not last_cookie: break ra = (r... | |
if eof or not last_cookie: | if eof or last_cookie == None: | def Listdir(self, dir): list = [] ra = (dir, 0, 16) while 1: (status, rest) = self.Readdir(ra) if status <> NFS_OK: break entries, eof = rest last_cookie = None for fileid, name, cookie in entries: print (fileid, name, cookie) # XXX list.append(fileid, name) last_cookie = cookie if eof or not last_cookie: break ra = (r... |
self.spawn ([self.rc] + | self.spawn ([self.rc] + pp_opts + | def compile(self, sources, output_dir=None, macros=None, include_dirs=None, debug=0, extra_preargs=None, extra_postargs=None, depends=None): |
>>> pik = pickle.dumps(x, 0) >>> dis(pik) | >>> pkl = pickle.dumps(x, 0) >>> dis(pkl) | def dis(pickle, out=None, indentlevel=4): """Produce a symbolic disassembly of a pickle. 'pickle' is a file-like object, or string, containing a (at least one) pickle. The pickle is disassembled from the current position, through the first STOP opcode encountered. Optional arg 'out' is a file-like object to which th... |
>>> pik = pickle.dumps(x, 1) >>> dis(pik) | >>> pkl = pickle.dumps(x, 1) >>> dis(pkl) | def dis(pickle, out=None, indentlevel=4): """Produce a symbolic disassembly of a pickle. 'pickle' is a file-like object, or string, containing a (at least one) pickle. The pickle is disassembled from the current position, through the first STOP opcode encountered. Optional arg 'out' is a file-like object to which th... |
49: p PUT 4 52: s SETITEM 53: b BUILD 54: a APPEND 55: g GET 1 58: a APPEND 59: . STOP | 49: s SETITEM 50: b BUILD 51: a APPEND 52: g GET 1 55: a APPEND 56: . STOP | def dis(pickle, out=None, indentlevel=4): """Produce a symbolic disassembly of a pickle. 'pickle' is a file-like object, or string, containing a (at least one) pickle. The pickle is disassembled from the current position, through the first STOP opcode encountered. Optional arg 'out' is a file-like object to which th... |
__test__ = {'dissassembler_test': _dis_test, | __test__ = {'disassembler_test': _dis_test, | def dis(pickle, out=None, indentlevel=4): """Produce a symbolic disassembly of a pickle. 'pickle' is a file-like object, or string, containing a (at least one) pickle. The pickle is disassembled from the current position, through the first STOP opcode encountered. Optional arg 'out' is a file-like object to which th... |
def getdefaultlocale(envvars=('LANGUAGE', 'LC_ALL', 'LC_CTYPE', 'LANG')): | def getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')): | def getdefaultlocale(envvars=('LANGUAGE', 'LC_ALL', 'LC_CTYPE', 'LANG')): """ Tries to determine the default locale settings and returns them as tuple (language code, encoding). According to POSIX, a program which has not called setlocale(LC_ALL, "") runs using the portable 'C' locale. Calling setlocale(LC_ALL, "") l... |
target_version = self.target_version if not target_version: assert self.skip_build, "Should have already checked this" target_version = sys.version[0:3] plat_specifier = ".%s-%s" % (get_platform(), target_version) build = self.get_finalized_command('build') build.build_lib = os.path.join(build.build_base, 'lib' + plat_... | if self.distribution.has_ext_modules(): target_version = self.target_version if not target_version: assert self.skip_build, "Should have already checked this" target_version = sys.version[0:3] plat_specifier = ".%s-%s" % (get_platform(), target_version) build = self.get_finalized_command('build') build.build_lib ... | def run (self): if (sys.platform != "win32" and (self.distribution.has_ext_modules() or self.distribution.has_c_libraries())): raise DistutilsPlatformError \ ("distribution contains extensions and/or C libraries; " "must be compiled on a Windows 32 platform") |
flags = _checkflag(flag) | flags = _checkflag(flag, file) | def hashopen(file, flag='c', mode=0666, pgsize=None, ffactor=None, nelem=None, cachesize=None, lorder=None, hflags=0): flags = _checkflag(flag) e = _openDBEnv() d = db.DB(e) d.set_flags(hflags) if cachesize is not None: d.set_cachesize(0, cachesize) if pgsize is not None: d.set_pagesize(pgsize) if lorder is not Non... |
flags = _checkflag(flag) | flags = _checkflag(flag, file) | def btopen(file, flag='c', mode=0666, btflags=0, cachesize=None, maxkeypage=None, minkeypage=None, pgsize=None, lorder=None): flags = _checkflag(flag) e = _openDBEnv() d = db.DB(e) if cachesize is not None: d.set_cachesize(0, cachesize) if pgsize is not None: d.set_pagesize(pgsize) if lorder is not None: d.set_lorder(... |
flags = _checkflag(flag) | flags = _checkflag(flag, file) | def rnopen(file, flag='c', mode=0666, rnflags=0, cachesize=None, pgsize=None, lorder=None, rlen=None, delim=None, source=None, pad=None): flags = _checkflag(flag) e = _openDBEnv() d = db.DB(e) if cachesize is not None: d.set_cachesize(0, cachesize) if pgsize is not None: d.set_pagesize(pgsize) if lorder is not None: d... |
def _checkflag(flag): | def _checkflag(flag, file): | def _checkflag(flag): if flag == 'r': flags = db.DB_RDONLY elif flag == 'rw': flags = 0 elif flag == 'w': flags = db.DB_CREATE elif flag == 'c': flags = db.DB_CREATE elif flag == 'n': flags = db.DB_CREATE | db.DB_TRUNCATE else: raise error, "flags should be one of 'r', 'w', 'c' or 'n'" return flags | db.DB_THREAD |
flags = db.DB_CREATE | db.DB_TRUNCATE | flags = db.DB_CREATE if os.path.isfile(file): os.unlink(file) | def _checkflag(flag): if flag == 'r': flags = db.DB_RDONLY elif flag == 'rw': flags = 0 elif flag == 'w': flags = db.DB_CREATE elif flag == 'c': flags = db.DB_CREATE elif flag == 'n': flags = db.DB_CREATE | db.DB_TRUNCATE else: raise error, "flags should be one of 'r', 'w', 'c' or 'n'" return flags | db.DB_THREAD |
pointer = -1 | if self.cyclic: pointer = -1 else: self.text.bell() return | def history_do(self, reverse): nhist = len(self.history) pointer = self.history_pointer prefix = self.history_prefix if pointer is not None and prefix is not None: if self.text.compare("insert", "!=", "end-1c") or \ self._get_source("iomark", "end-1c") != self.history[pointer]: pointer = prefix = None if pointer is Non... |
if self._get_source("iomark", "end-1c") != prefix: self.text.delete("iomark", "end-1c") self._put_source("iomark", prefix) pointer = prefix = None | if not self.cyclic and pointer < 0: return else: if self._get_source("iomark", "end-1c") != prefix: self.text.delete("iomark", "end-1c") self._put_source("iomark", prefix) pointer = prefix = None | def history_do(self, reverse): nhist = len(self.history) pointer = self.history_pointer prefix = self.history_prefix if pointer is not None and prefix is not None: if self.text.compare("insert", "!=", "end-1c") or \ self._get_source("iomark", "end-1c") != self.history[pointer]: pointer = prefix = None if pointer is Non... |
(self.ac_out_buffer is '') and | (self.ac_out_buffer == '') and | def writable (self): "predicate for inclusion in the writable for select()" # return len(self.ac_out_buffer) or len(self.producer_fifo) or (not self.connected) # this is about twice as fast, though not as clear. return not ( (self.ac_out_buffer is '') and self.producer_fifo.is_empty() and self.connected ) |
return t + data[9] - time.timezone | return t - data[9] - time.timezone | def mktime_tz(data): """Turn a 10-tuple as returned by parsedate_tz() into a UTC timestamp. Minor glitch: this first interprets the first 8 elements as a local time and then compensates for the timezone difference; this may yield a slight error around daylight savings time switch dates. Not enough to worry about for ... |
self.tk.call('destroy', self._w) | def destroy(self): """Destroy this and all descendants widgets.""" for c in self.children.values(): c.destroy() if self.master.children.has_key(self._name): del self.master.children[self._name] self.tk.call('destroy', self._w) Misc.destroy(self) | |
def MultiCallIterator(results): | class MultiCallIterator: | def MultiCallIterator(results): """Iterates over the results of a multicall. Exceptions are thrown in response to xmlrpc faults.""" for i in results: if type(i) == type({}): raise Fault(i['faultCode'], i['faultString']) elif type(i) == type([]): yield i[0] else: raise ValueError,\ "unexpected type in multicall result"... |
for i in results: if type(i) == type({}): raise Fault(i['faultCode'], i['faultString']) elif type(i) == type([]): yield i[0] | def __init__(self, results): self.results = results def __getitem__(self, i): item = self.results[i] if type(item) == type({}): raise Fault(item['faultCode'], item['faultString']) elif type(item) == type([]): return item[0] | def MultiCallIterator(results): """Iterates over the results of a multicall. Exceptions are thrown in response to xmlrpc faults.""" for i in results: if type(i) == type({}): raise Fault(i['faultCode'], i['faultString']) elif type(i) == type([]): yield i[0] else: raise ValueError,\ "unexpected type in multicall result"... |
server = ServerProxy("http://betty.userland.com") | server = ServerProxy("http://time.xmlrpc.com/RPC2") | def __getattr__(self, name): # magic method dispatcher return _Method(self.__request, name) |
print server.examples.getStateName(41) | print server.currentTime.getCurrentTime() | def __getattr__(self, name): # magic method dispatcher return _Method(self.__request, name) |
if platform in ['cygwin', 'aix4']: | data = open('pyconfig.h').read() m = re.search(r" if m is not None: | 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 type(cmd) == type(''): | if isinstance(cmd, types.StringTypes): | def _run_child(self, cmd): if type(cmd) == type(''): cmd = ['/bin/sh', '-c', cmd] for i in range(3, MAXFD): try: os.close(i) except: pass try: os.execvp(cmd[0], cmd) finally: os._exit(1) |
if verbose or generate: | if verbose: | def runtest(test, generate, verbose, quiet, testdir = None): """Run a single test. test -- the name of the test generate -- if true, generate output, instead of running the test and comparing it to a previously created output file verbose -- if true, print more messages quiet -- if true, don't print 'skipped' messages ... |
raises(TypeError, "MRO conflict among bases ", | raises(TypeError, mro_err_msg, | def raises(exc, expected, callable, *args): try: callable(*args) except exc, msg: if not str(msg).startswith(expected): raise TestFailed, "Message %r, expected %r" % (str(msg), expected) else: raise TestFailed, "Expected %s" % exc |
for tz in ('UTC','GMT','Luna/Tycho'): environ['TZ'] = 'US/Eastern' time.tzset() environ['TZ'] = tz time.tzset() self.failUnlessEqual( time.gmtime(xmas2002),time.localtime(xmas2002) ) self.failUnlessEqual(time.timezone,time.altzone) self.failUnlessEqual(time.daylight,0) self.failUnlessEqual(time.timezone,0) self.failUnl... | environ['TZ'] = eastern time.tzset() environ['TZ'] = utc time.tzset() self.failUnlessEqual( time.gmtime(xmas2002), time.localtime(xmas2002) ) self.failUnlessEqual(time.daylight, 0) self.failUnlessEqual(time.timezone, 0) self.failUnlessEqual(time.localtime(xmas2002).tm_isdst, 0) | def test_tzset(self): if not hasattr(time, "tzset"): return # Can't test this; don't want the test suite to fail |
environ['TZ'] = 'US/Eastern' | environ['TZ'] = eastern | def test_tzset(self): if not hasattr(time, "tzset"): return # Can't test this; don't want the test suite to fail |
environ['TZ'] = 'Australia/Melbourne' | environ['TZ'] = victoria | def test_tzset(self): if not hasattr(time, "tzset"): return # Can't test this; don't want the test suite to fail |
self.failIfEqual(time.gmtime(xmas2002),time.localtime(xmas2002)) self.failUnless(time.tzname[0] in ('EST','AEST')) self.failUnless(time.tzname[1] in ('EST','EDT','AEDT')) self.failUnlessEqual(len(time.tzname),2) self.failUnlessEqual(time.daylight,1) self.failUnlessEqual(time.timezone,-36000) self.failUnlessEqual(time.a... | self.failIfEqual(time.gmtime(xmas2002), time.localtime(xmas2002)) self.failUnless(time.tzname[0] == 'AEST', str(time.tzname[0])) self.failUnless(time.tzname[1] == 'AEDT', str(time.tzname[1])) self.failUnlessEqual(len(time.tzname), 2) self.failUnlessEqual(time.daylight, 1) self.failUnlessEqual(time.timezone, -36000) sel... | def test_tzset(self): if not hasattr(time, "tzset"): return # Can't test this; don't want the test suite to fail |
del environ['TZ'] time.tzset() if time.timezone == 0: environ['TZ'] = 'US/Eastern' else: environ['TZ'] = 'UTC' time.tzset() nonlocal = time.localtime(xmas2002) del environ['TZ'] time.tzset() local = time.localtime(xmas2002) self.failIfEqual(local,nonlocal) self.failUnlessEqual(len(time.tzname),2) time.daylight ti... | def test_tzset(self): if not hasattr(time, "tzset"): return # Can't test this; don't want the test suite to fail | |
vsbase = r"Software\Microsoft\VisualStudio\%s.0" % version | vsbase = r"Software\Microsoft\VisualStudio\%0.1f" % version | def load_macros(self, version): vsbase = r"Software\Microsoft\VisualStudio\%s.0" % version self.set_macro("VCInstallDir", vsbase + r"\Setup\VC", "productdir") self.set_macro("VSInstallDir", vsbase + r"\Setup\VS", "productdir") net = r"Software\Microsoft\.NETFramework" self.set_macro("FrameworkDir", net, "installroot") ... |
self.set_macro("FrameworkSDKDir", net, "sdkinstallroot") | if version > 7.0: self.set_macro("FrameworkSDKDir", net, "sdkinstallrootv1.1") else: self.set_macro("FrameworkSDKDir", net, "sdkinstallroot") | def load_macros(self, version): vsbase = r"Software\Microsoft\VisualStudio\%s.0" % version self.set_macro("VCInstallDir", vsbase + r"\Setup\VC", "productdir") self.set_macro("VSInstallDir", vsbase + r"\Setup\VS", "productdir") net = r"Software\Microsoft\.NETFramework" self.set_macro("FrameworkDir", net, "installroot") ... |
n = int(s[:-2]) if n == 12: return 6 elif n == 13: return 7 | majorVersion = int(s[:-2]) - 6 minorVersion = int(s[2:3]) / 10.0 if majorVersion == 6: minorVersion = 0 if majorVersion >= 6: return majorVersion + minorVersion | def get_build_version(): """Return the version of MSVC that was used to build Python. For Python 2.3 and up, the version number is included in sys.version. For earlier versions, assume the compiler is MSVC 6. """ prefix = "MSC v." i = string.find(sys.version, prefix) if i == -1: return 6 i = i + len(prefix) s, rest ... |
if self.__version == 7: | if self.__version >= 7: | def __init__ (self, verbose=0, dry_run=0, force=0): CCompiler.__init__ (self, verbose, dry_run, force) self.__version = get_build_version() if self.__version == 7: self.__root = r"Software\Microsoft\VisualStudio" self.__macros = MacroExpander(self.__version) else: self.__root = r"Software\Microsoft\Devstudio" self.__pa... |
if self.__version == 7: key = (r"%s\7.0\VC\VC_OBJECTS_PLATFORM_INFO\Win32\Directories" % (self.__root,)) | if self.__version >= 7: key = (r"%s\%0.1f\VC\VC_OBJECTS_PLATFORM_INFO\Win32\Directories" % (self.__root, self.__version)) | def get_msvc_paths(self, path, platform='x86'): """Get a list of devstudio directories (include, lib or path). |
if self.__version == 7: | if self.__version >= 7: | def get_msvc_paths(self, path, platform='x86'): """Get a list of devstudio directories (include, lib or path). |
def gen_id(self, dir, file): | def gen_id(self, file): | def gen_id(self, dir, file): logical = _logical = make_id(file) pos = 1 while logical in self.filenames: logical = "%s.%d" % (_logical, pos) pos += 1 self.filenames.add(logical) return logical |
def append(self, full, logical): | def append(self, full, file, logical): | def append(self, full, logical): if os.path.isdir(full): return self.index += 1 self.files.append((full, logical)) return self.index, logical |
sequence, logical = self.cab.append(absolute, logical) | sequence, logical = self.cab.append(absolute, file, logical) | def add_file(self, file, src=None, version=None, language=None): """Add a file to the current component of the directory, starting a new one one if there is no current component. By default, the file name in the source and the file table will be identical. If the src file is specified, it is interpreted relative to the... |
def mapping(self, mapping, attribute): | def mapping(self, event, attribute): | def mapping(self, mapping, attribute): add_data(self.dlg.db, "EventMapping", [(self.dlg.name, self.name, event, attribute)]) |
print >> DEBUGSTREAM, 'we got some refusals' | print >> DEBUGSTREAM, 'we got some refusals:', refused | def process_message(self, peer, mailfrom, rcpttos, data): lines = data.split('\n') # Look for the last header i = 0 for line in lines: if not line: break i += 1 lines.insert(i, 'X-Peer: %s' % peer[0]) data = NEWLINE.join(lines) refused = self._deliver(mailfrom, rcpttos, data) # TBD: what to do with refused addresses? p... |
print >> DEBUGSTREAM, 'we got refusals' | print >> DEBUGSTREAM, 'we got refusals:', refused | def process_message(self, peer, mailfrom, rcpttos, data): from cStringIO import StringIO from Mailman import Utils from Mailman import Message from Mailman import MailList # If the message is to a Mailman mailing list, then we'll invoke the # Mailman script directly, without going through the real smtpd. # Otherwise we... |
mode = (os.stat(file)[ST_MODE]) | 0111 | mode = ((os.stat(file)[ST_MODE]) | 0111) & 07777 | def run (self): if not self.skip_build: self.run_command('build_scripts') self.outfiles = self.copy_tree(self.build_dir, self.install_dir) if os.name == 'posix': # Set the executable bits (owner, group, and world) on # all the scripts we just installed. for file in self.get_outputs(): if self.dry_run: self.announce("ch... |
if sys.maxint == 2**32-1: | if sys.maxint == 2**31-1: | def test_exc(formatstr, args, exception, excmsg): try: testformat(formatstr, args) except exception, exc: if str(exc) == excmsg: if verbose: print "yes" else: if verbose: print 'no' print 'Unexpected ', exception, ':', repr(str(exc)) except: if verbose: print 'no' print 'Unexpected exception' raise else: raise TestFail... |
def read(self, wtd): | def read(self, totalwtd): | def read(self, wtd): |
wtd = wtd - len(decdata) | wtd = totalwtd - len(decdata) | def read(self, wtd): |
if filecrc != self.crc: raise Error, 'CRC error, computed %x, read %x'%(self.crc, filecrc) | def _checkcrc(self): | |
if not (self.have_fork or self.have_popen2): | if not (self.have_fork or self.have_popen2 or self.have_popen3): | def run_cgi(self): """Execute a CGI script.""" dir, rest = self.cgi_info i = rest.rfind('?') if i >= 0: rest, query = rest[:i], rest[i+1:] else: query = '' i = rest.find('/') if i >= 0: script, rest = rest[:i], rest[i:] else: script, rest = rest, '' scriptname = dir + '/' + script scriptfile = self.translate_path(scrip... |
elif self.have_popen2: | elif self.have_popen2 or self.have_popen3: | def run_cgi(self): """Execute a CGI script.""" dir, rest = self.cgi_info i = rest.rfind('?') if i >= 0: rest, query = rest[:i], rest[i+1:] else: query = '' i = rest.find('/') if i >= 0: script, rest = rest[:i], rest[i:] else: script, rest = rest, '' scriptname = dir + '/' + script scriptfile = self.translate_path(scrip... |
fi, fo = os.popen2(cmdline, 'b') | files = popenx(cmdline, 'b') fi = files[0] fo = files[1] if self.have_popen3: fe = files[2] | def run_cgi(self): """Execute a CGI script.""" dir, rest = self.cgi_info i = rest.rfind('?') if i >= 0: rest, query = rest[:i], rest[i+1:] else: query = '' i = rest.find('/') if i >= 0: script, rest = rest[:i], rest[i:] else: script, rest = rest, '' scriptname = dir + '/' + script scriptfile = self.translate_path(scrip... |
if result[0] == '%': | if not result or result[0] == '%': | def strftest(now): if verbose: print "strftime test for", time.ctime(now) nowsecs = str(long(now))[:-1] 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)) try: if now[8]: tz = time.tzname[1] else: tz = time.tzname[0] ... |
sf = open(slave, 'rb') | sf = open(slave, 'r') | def compare(slave, master): try: sf = open(slave, 'rb') except IOError: sf = None try: mf = open(master, 'rb') except IOError: mf = None if not sf: if not mf: print "Not updating missing master", master return print "Creating missing slave", slave copy(master, slave, answer=create_files) return if sf and mf: if identic... |
print "Not updating missing master", master | print "Neither master nor slave exists", master | def compare(slave, master): try: sf = open(slave, 'rb') except IOError: sf = None try: mf = open(master, 'rb') except IOError: mf = None if not sf: if not mf: print "Not updating missing master", master return print "Creating missing slave", slave copy(master, slave, answer=create_files) return if sf and mf: if identic... |
fp = open(pathname, "U") | if hasattr(sys.stdout, "newlines"): fp = open(pathname, "U") else: fp = open(pathname, "r") | def run_script(self, pathname): self.msg(2, "run_script", pathname) fp = open(pathname, "U") stuff = ("", "r", imp.PY_SOURCE) self.load_module('__main__', fp, pathname, stuff) |
fp = open(pathname, "U") | if hasattr(sys.stdout, "newlines"): fp = open(pathname, "U") else: fp = open(pathname, "r") | def load_file(self, pathname): dir, name = os.path.split(pathname) name, ext = os.path.splitext(name) fp = open(pathname, "U") stuff = (ext, "r", imp.PY_SOURCE) self.load_module(name, fp, pathname, stuff) |
if string.find (args[i], ' ') == -1: | if string.find (args[i], ' ') != -1: | def _nt_quote_args (args): """Obscure quoting command line arguments on NT. Simply quote every argument which contains blanks.""" # XXX this doesn't seem very robust to me -- but if the Windows guys # say it'll work, I guess I'll have to accept it. (What if an arg # contains quotes? What other magic characters, othe... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.