bugged
stringlengths 4
228k
| fixed
stringlengths 0
96.3M
| __index_level_0__
int64 0
481k
|
|---|---|---|
def decode(self, input, final=False): return codecs.mbs_decode(input,self.errors)[0]
|
def decode(self, input, final=False): return codecs.mbs_decode(input,self.errors)[0]
| 13,900
|
def split(s, sep=None, maxsplit=-1): """split(s [,sep [,maxsplit]]) -> list of strings Return a list of the words in the string s, using sep as the delimiter string. If maxsplit is given, splits into at most maxsplit words. If sep is not specified, any whitespace string is a separator. (split and splitfields are synonymous) """ return s.split(sep, maxsplit)
|
def split(s, sep=None, maxsplit=-1): """split(s [,sep [,maxsplit]]) -> list of strings Return a list of the words in the string s, using sep as the delimiter string. If maxsplit is given, splits at no more than maxsplit places (resulting in at most maxsplit+1 words). If sep is not specified, any whitespace string is a separator. (split and splitfields are synonymous) """ return s.split(sep, maxsplit)
| 13,901
|
def guess_type(url): """Guess the type of a file based on its URL. Return value is a tuple (type, encoding) where type is None if the type can't be guessed (no or unknown suffix) or a string of the form type/subtype, usable for a MIME Content-type header; and encoding is None for no encoding or the name of the program used to encode (e.g. compress or gzip). The mappings are table driven. Encoding suffixes are case sensitive; type suffixes are first tried case sensitive, then case insensitive. The suffixes .tgz, .taz and .tz (case sensitive!) are all mapped to ".tar.gz". (This is table-driven too, using the dictionary suffixes_map). """ if not inited: init() base, ext = posixpath.splitext(url) while suffix_map.has_key(ext): base, ext = posixpath.splitext(base + suffix_map[ext]) if encodings_map.has_key(ext): encoding = encodings_map[ext] base, ext = posixpath.splitext(base) else: encoding = None if types_map.has_key(ext): return types_map[ext], encoding elif types_map.has_key(string.lower(ext)): return types_map[string.lower(ext)], encoding else: return None, encoding
|
def guess_type(url): """Guess the type of a file based on its URL. Return value is a tuple (type, encoding) where type is None if the type can't be guessed (no or unknown suffix) or a string of the form type/subtype, usable for a MIME Content-type header; and encoding is None for no encoding or the name of the program used to encode (e.g. compress or gzip). The mappings are table driven. Encoding suffixes are case sensitive; type suffixes are first tried case sensitive, then case insensitive. The suffixes .tgz, .taz and .tz (case sensitive!) are all mapped to ".tar.gz". (This is table-driven too, using the dictionary suffix_map). """ if not inited: init() base, ext = posixpath.splitext(url) while suffix_map.has_key(ext): base, ext = posixpath.splitext(base + suffix_map[ext]) if encodings_map.has_key(ext): encoding = encodings_map[ext] base, ext = posixpath.splitext(base) else: encoding = None if types_map.has_key(ext): return types_map[ext], encoding elif types_map.has_key(string.lower(ext)): return types_map[string.lower(ext)], encoding else: return None, encoding
| 13,902
|
def __init__(self, sock): self.fp = sock.makefile('rb', 0)
|
def __init__(self, sock, debuglevel=0): self.fp = sock.makefile('rb', 0)
| 13,903
|
def begin(self): if self.msg is not None: # we've already started reading the response return
|
def begin(self): if self.msg is not None: # we've already started reading the response return
| 13,904
|
def read(self, amt=None): if self.fp is None: return ''
|
def read(self, amt=None): if self.fp is None: return ''
| 13,905
|
def getresponse(self): "Get the response from the server."
|
def getresponse(self): "Get the response from the server."
| 13,906
|
def set_debuglevel(self, debuglevel): "The class no longer supports the debuglevel." pass
|
def set_debuglevel(self, debuglevel): "The class no longer supports the debuglevel." pass
| 13,907
|
def get_namespace(self): """Returns the single namespace bound to this name.
|
def get_namespace(self): """Returns the single namespace bound to this name.
| 13,908
|
def writeln(self, *args): if args: self.write(*args) self.write('\n') # text-mode streams translate to \r\n if needed
|
def writeln(self, arg=None): if arg: self.write(arg) self.write('\n') # text-mode streams translate to \r\n if needed
| 13,909
|
def encode_plain(user, password): return encode_base64("%s\0%s\0%s" % (user, user, password), eol="")
|
def encode_plain(user, password): return encode_base64("%s\0%s\0%s" % (user, user, password), eol="")
| 13,910
|
def setUp (self): fp = open(temp_filename, 'wt') fp.write(TEST_NETRC) fp.close() self.netrc = netrc.netrc(temp_filename)
|
def setUp (self): mode = 'w' if sys.platform not in ['cygwin']: mode += 't' fp = open(temp_filename, mode) fp.write(TEST_NETRC) fp.close() self.netrc = netrc.netrc(temp_filename)
| 13,911
|
def addpackage(sitedir, name): fullname = os.path.join(sitedir, name) try: f = open(fullname) except IOError: return while 1: dir = f.readline() if not dir: break if dir[0] == '#': continue if dir.startswith("import"): exec dir continue if dir[-1] == '\n': dir = dir[:-1] dir, dircase = makepath(sitedir, dir) if not dirs_in_sys_path.has_key(dircase) and os.path.exists(dir): sys.path.append(dir) dirs_in_sys_path[dircase] = 1
|
def addpackage(sitedir, name): fullname = os.path.join(sitedir, name) try: f = open(fullname) except IOError: return while 1: dir = f.readline() if not dir: break if dir[0] == '#': continue if dir.startswith("import"): exec dir continue if dir[-1] == '\n': dir = dir[:-1] dir, dircase = makepath(sitedir, dir) if not dirs_in_sys_path.has_key(dircase) and os.path.exists(dir): sys.path.append(dir) dirs_in_sys_path[dircase] = 1
| 13,912
|
def do_POST(self): """Handles the HTTP POST request.
|
def do_POST(self): """Handles the HTTP POST request.
| 13,913
|
def run__test__(self, d, name): """d, name -> Treat dict d like module.__test__.
|
def run__test__(self, d, name): """d, name -> Treat dict d like module.__test__.
| 13,914
|
def run__test__(self, d, name): """d, name -> Treat dict d like module.__test__.
|
def run__test__(self, d, name): """d, name -> Treat dict d like module.__test__.
| 13,915
|
exec 'def f(a, a): pass'
|
exec 'def f(a, a): pass'
| 13,916
|
exec 'def f(a, a): pass'
|
exec 'def f(a, a): pass'
| 13,917
|
exec 'def f(a, a): pass'
|
exec 'def f(a, a): pass'
| 13,918
|
exec 'def f(a = 0, a = 1): pass'
|
exec 'def f(a = 0, a = 1): pass'
| 13,919
|
exec 'def f(a): global a; a = 1'
|
exec 'def f(a): global a; a = 1'
| 13,920
|
def comp_args((a, b)): print a,b
|
def test_argument_order(self): try: exec 'def f(a=1, (b, c)): pass' self.fail("non-default args after default") except SyntaxError: pass
| 13,921
|
def comp_args((a, b)): print a,b
|
def comp_args((a, b)): print a,b
| 13,922
|
def comp_args((a, b)=(3, 4)): print a, b
|
def comp_args((a, b)=(3, 4)): print a, b
| 13,923
|
def expect_error(s): try: eval(s) raise TestFailed("%r accepted" % s) except SyntaxError: pass
|
def expect_error(s): try: eval(s) raise TestFailed("%r accepted" % s) except SyntaxError: pass
| 13,924
|
def expect_error(s): try: eval(s) raise TestFailed("%r accepted" % s) except SyntaxError: pass
|
def expect_error(s): try: eval(s) raise TestFailed("%r accepted" % s) except SyntaxError: pass
| 13,925
|
def expect_same(test_source, expected): got = eval(test_source) if got != expected: raise TestFailed("eval(%r) gave %r, but expected %r" % (test_source, got, expected))
|
def expect_same(test_source, expected): got = eval(test_source) if got != expected: raise TestFailed("eval(%r) gave %r, but expected %r" % (test_source, got, expected))
| 13,926
|
def reraise_unmasked_exceptions(unmasked=()): # There are a few catch-all except: statements in this module, for # catching input that's bad in unexpected ways. # This function re-raises some exceptions we don't want to trap. unmasked = unmasked + (KeyboardInterrupt, SystemExit, MemoryError) etype = sys.exc_info()[0] if issubclass(etype, unmasked): raise # swallowed an exception import warnings warnings.warn("cookielib bug!", stacklevel=2) import traceback traceback.print_exc()
|
def reraise_unmasked_exceptions(unmasked=()): # There are a few catch-all except: statements in this module, for # catching input that's bad in unexpected ways. # This function re-raises some exceptions we don't want to trap. unmasked = unmasked + (KeyboardInterrupt, SystemExit, MemoryError) etype = sys.exc_info()[0] if issubclass(etype, unmasked): raise # swallowed an exception import warnings, traceback, StringIO f = StringIO.StringIO() traceback.print_exc(None, f) msg = f.getvalue() warnings.warn("cookielib bug!\n%s" % msg, stacklevel=2)
| 13,927
|
def wait(self, timeout=None): me = currentThread() assert self._is_owned(), "wait() of un-acquire()d lock" waiter = _allocate_lock() waiter.acquire() self.__waiters.append(waiter) saved_state = self._release_save() if timeout is None: waiter.acquire() if __debug__: self._note("%s.wait(): got it", self) else: endtime = _time() + timeout delay = 0.000001 # 1 usec while 1: gotit = waiter.acquire(0) if gotit or _time() >= endtime: break _sleep(delay) if delay < 1.0: delay = delay * 2.0 if not gotit: if __debug__: self._note("%s.wait(%s): timed out", self, timeout) try: self.__waiters.remove(waiter) except ValueError: pass else: if __debug__: self._note("%s.wait(%s): got it", self, timeout) self._acquire_restore(saved_state)
|
def wait(self, timeout=None): me = currentThread() assert self._is_owned(), "wait() of un-acquire()d lock" waiter = _allocate_lock() waiter.acquire() self.__waiters.append(waiter) saved_state = self._release_save() if timeout is None: waiter.acquire() if __debug__: self._note("%s.wait(): got it", self) else: endtime = _time() + timeout delay = 0.000001 # 1 usec while 1: gotit = waiter.acquire(0) if gotit or _time() >= endtime: break _sleep(delay) if delay < 1.0: delay = delay * 2.0 if not gotit: if __debug__: self._note("%s.wait(%s): timed out", self, timeout) try: self.__waiters.remove(waiter) except ValueError: pass else: if __debug__: self._note("%s.wait(%s): got it", self, timeout) self._acquire_restore(saved_state)
| 13,928
|
def wait(self, timeout=None): me = currentThread() assert self._is_owned(), "wait() of un-acquire()d lock" waiter = _allocate_lock() waiter.acquire() self.__waiters.append(waiter) saved_state = self._release_save() if timeout is None: waiter.acquire() if __debug__: self._note("%s.wait(): got it", self) else: endtime = _time() + timeout delay = 0.000001 # 1 usec while 1: gotit = waiter.acquire(0) if gotit or _time() >= endtime: break _sleep(delay) if delay < 1.0: delay = delay * 2.0 if not gotit: if __debug__: self._note("%s.wait(%s): timed out", self, timeout) try: self.__waiters.remove(waiter) except ValueError: pass else: if __debug__: self._note("%s.wait(%s): got it", self, timeout) self._acquire_restore(saved_state)
|
def wait(self, timeout=None): me = currentThread() assert self._is_owned(), "wait() of un-acquire()d lock" waiter = _allocate_lock() waiter.acquire() self.__waiters.append(waiter) saved_state = self._release_save() if timeout is None: waiter.acquire() if __debug__: self._note("%s.wait(): got it", self) else: endtime = _time() + timeout delay = 0.000001 # 1 usec while 1: gotit = waiter.acquire(0) if gotit or _time() >= endtime: break _sleep(delay) if delay < 1.0: delay = delay * 2.0 if not gotit: if __debug__: self._note("%s.wait(): got it", self) else: if __debug__: self._note("%s.wait(%s): got it", self, timeout) self._acquire_restore(saved_state)
| 13,929
|
def wait(self, timeout=None): me = currentThread() assert self._is_owned(), "wait() of un-acquire()d lock" waiter = _allocate_lock() waiter.acquire() self.__waiters.append(waiter) saved_state = self._release_save() if timeout is None: waiter.acquire() if __debug__: self._note("%s.wait(): got it", self) else: endtime = _time() + timeout delay = 0.000001 # 1 usec while 1: gotit = waiter.acquire(0) if gotit or _time() >= endtime: break _sleep(delay) if delay < 1.0: delay = delay * 2.0 if not gotit: if __debug__: self._note("%s.wait(%s): timed out", self, timeout) try: self.__waiters.remove(waiter) except ValueError: pass else: if __debug__: self._note("%s.wait(%s): got it", self, timeout) self._acquire_restore(saved_state)
|
def wait(self, timeout=None): me = currentThread() assert self._is_owned(), "wait() of un-acquire()d lock" waiter = _allocate_lock() waiter.acquire() self.__waiters.append(waiter) saved_state = self._release_save() if timeout is None: waiter.acquire() if __debug__: self._note("%s.wait(): got it", self) else: endtime = _time() + timeout delay = 0.000001 # 1 usec while 1: gotit = waiter.acquire(0) if gotit or _time() >= endtime: break _sleep(delay) if delay < 1.0: delay = delay * 2.0 if not gotit: if __debug__: self._note("%s.wait(%s): timed out", self, timeout) try: self.__waiters.remove(waiter) except ValueError: pass else: if __debug__: self._note("%s.wait(%s): got it", self, timeout) self._acquire_restore(saved_state)
| 13,930
|
def d22v(a, b, c=1, d=2, *rest): pass
|
def d22v(a, b, c=1, d=2, *rest): pass
| 13,931
|
def slow_format(self, x, base): if (x, base) == (0, 8): # this is an oddball! return "0L" digits = [] sign = 0 if x < 0: sign, x = 1, -x while x: x, r = divmod(x, base) digits.append(int(r)) digits.reverse() digits = digits or [0] return '-'[:sign] + \ {8: '0', 10: '', 16: '0x'}[base] + \ "".join(map(lambda i: "0123456789ABCDEF"[i], digits)) + "L"
|
def slow_format(self, x, base): if (x, base) == (0, 8): # this is an oddball! return "0L" digits = [] sign = 0 if x < 0: sign, x = 1, -x while x: x, r = divmod(x, base) digits.append(int(r)) digits.reverse() digits = digits or [0] return '-'[:sign] + \ {8: '0', 10: '', 16: '0x'}[base] + \ "".join(map(lambda i: "0123456789ABCDEF"[i], digits)) + "L"
| 13,932
|
def flush(self): self.fileobj.flush()
|
def flush(self,zlib_mode=zlib.Z_SYNC_FLUSH): if self.mode == WRITE: self.fileobj.write(self.compress.flush(zlib_mode)) self.fileobj.flush()
| 13,933
|
def dump(*stuff): sys.__stdout__.write(string.join(map(str, stuff), " ") + "\n")
|
def dump(*stuff): sys.__stdout__.write(string.join(map(str, stuff), " ") + "\n")
| 13,934
|
def dump(*stuff): sys.__stdout__.write(string.join(map(str, stuff), " ") + "\n")
|
def dump(*stuff): sys.__stdout__.write(string.join(map(str, stuff), " ") + "\n")
| 13,935
|
def _study2(self, _rfind=string.rfind, _find=string.find, _ws=string.whitespace): if self.study_level >= 2: return self._study1() self.study_level = 2
|
def _study2(self, _rfind=string.rfind, _find=string.find, _ws=string.whitespace): if self.study_level >= 2: return self._study1() self.study_level = 2
| 13,936
|
def _study2(self, _rfind=string.rfind, _find=string.find, _ws=string.whitespace): if self.study_level >= 2: return self._study1() self.study_level = 2
|
def _study2(self, _rfind=string.rfind, _find=string.find, _ws=string.whitespace): if self.study_level >= 2: return self._study1() self.study_level = 2
| 13,937
|
def main(): rcfile = os.path.join(os.path.dirname(refcounts.__file__), os.pardir, "api", "refcounts.dat") outfile = "-" opts, args = getopt.getopt(sys.argv[1:], "o:r:", ["output=", "refcounts="]) for opt, arg in opts: if opt in ("-o", "--output"): outfile = arg elif opt in ("-r", "--refcounts"): rcfile = arg rcdict = refcounts.load(rcfile) if outfile == "-": output = sys.stdout else: output = open(outfile, "w") if not args: args = ["-"] prefix = PREFIX prefix_len = len(prefix) for infile in args: if infile == "-": input = sys.stdin else: input = open(infile) while 1: line = input.readline() if not line: break if line[:prefix_len] == prefix: s = string.split(line[prefix_len:], '}', 1)[0] try: info = rcdict[s] except KeyError: sys.stderr.write("No refcount data for %s\n" % s) else: if info.result_type in ("PyObject*", "PyVarObject*"): if info.result_refs is None: rc = "Always \NULL{}" else: rc = info.result_refs and "New" or "Borrowed" rc = rc + " reference" line = (r"\begin{cfuncdesc}[%s]{%s}{" % (rc, info.result_type)) \ + line[prefix_len:] output.write(line) if infile != "-": input.close() if outfile != "-": output.close()
|
def main(): rcfile = os.path.join(os.path.dirname(refcounts.__file__), os.pardir, "api", "refcounts.dat") outfile = "-" opts, args = getopt.getopt(sys.argv[1:], "o:r:", ["output=", "refcounts="]) for opt, arg in opts: if opt in ("-o", "--output"): outfile = arg elif opt in ("-r", "--refcounts"): rcfile = arg rcdict = refcounts.load(rcfile) if outfile == "-": output = sys.stdout else: output = open(outfile, "w") if not args: args = ["-"] for infile in args: if infile == "-": input = sys.stdin else: input = open(infile) while 1: line = input.readline() if not line: break if line[:prefix_len] == prefix: s = string.split(line[prefix_len:], '}', 1)[0] try: info = rcdict[s] except KeyError: sys.stderr.write("No refcount data for %s\n" % s) else: if info.result_type in ("PyObject*", "PyVarObject*"): if info.result_refs is None: rc = "Always \NULL{}" else: rc = info.result_refs and "New" or "Borrowed" rc = rc + " reference" line = (r"\begin{cfuncdesc}[%s]{%s}{" % (rc, info.result_type)) \ + line[prefix_len:] output.write(line) if infile != "-": input.close() if outfile != "-": output.close()
| 13,938
|
def main(): rcfile = os.path.join(os.path.dirname(refcounts.__file__), os.pardir, "api", "refcounts.dat") outfile = "-" opts, args = getopt.getopt(sys.argv[1:], "o:r:", ["output=", "refcounts="]) for opt, arg in opts: if opt in ("-o", "--output"): outfile = arg elif opt in ("-r", "--refcounts"): rcfile = arg rcdict = refcounts.load(rcfile) if outfile == "-": output = sys.stdout else: output = open(outfile, "w") if not args: args = ["-"] prefix = PREFIX prefix_len = len(prefix) for infile in args: if infile == "-": input = sys.stdin else: input = open(infile) while 1: line = input.readline() if not line: break if line[:prefix_len] == prefix: s = string.split(line[prefix_len:], '}', 1)[0] try: info = rcdict[s] except KeyError: sys.stderr.write("No refcount data for %s\n" % s) else: if info.result_type in ("PyObject*", "PyVarObject*"): if info.result_refs is None: rc = "Always \NULL{}" else: rc = info.result_refs and "New" or "Borrowed" rc = rc + " reference" line = (r"\begin{cfuncdesc}[%s]{%s}{" % (rc, info.result_type)) \ + line[prefix_len:] output.write(line) if infile != "-": input.close() if outfile != "-": output.close()
|
def main(): rcfile = os.path.join(os.path.dirname(refcounts.__file__), os.pardir, "api", "refcounts.dat") outfile = "-" opts, args = getopt.getopt(sys.argv[1:], "o:r:", ["output=", "refcounts="]) for opt, arg in opts: if opt in ("-o", "--output"): outfile = arg elif opt in ("-r", "--refcounts"): rcfile = arg rcdict = refcounts.load(rcfile) if outfile == "-": output = sys.stdout else: output = open(outfile, "w") if not args: args = ["-"] prefix = PREFIX prefix_len = len(prefix) for infile in args: if infile == "-": input = sys.stdin else: input = open(infile) while 1: line = input.readline() if not line: break prefix = None if line.startswith(PREFIX_1): prefix = PREFIX_1 elif line.startswith(PREFIX_2): prefix = PREFIX_2 if prefix: s = line[len(prefix):].split('}', 1)[0] try: info = rcdict[s] except KeyError: sys.stderr.write("No refcount data for %s\n" % s) else: if info.result_type in ("PyObject*", "PyVarObject*"): if info.result_refs is None: rc = "Always \NULL{}" else: rc = info.result_refs and "New" or "Borrowed" rc = rc + " reference" line = (r"\begin{cfuncdesc}[%s]{%s}{" % (rc, info.result_type)) \ + line[prefix_len:] output.write(line) if infile != "-": input.close() if outfile != "-": output.close()
| 13,939
|
def main(): rcfile = os.path.join(os.path.dirname(refcounts.__file__), os.pardir, "api", "refcounts.dat") outfile = "-" opts, args = getopt.getopt(sys.argv[1:], "o:r:", ["output=", "refcounts="]) for opt, arg in opts: if opt in ("-o", "--output"): outfile = arg elif opt in ("-r", "--refcounts"): rcfile = arg rcdict = refcounts.load(rcfile) if outfile == "-": output = sys.stdout else: output = open(outfile, "w") if not args: args = ["-"] prefix = PREFIX prefix_len = len(prefix) for infile in args: if infile == "-": input = sys.stdin else: input = open(infile) while 1: line = input.readline() if not line: break if line[:prefix_len] == prefix: s = string.split(line[prefix_len:], '}', 1)[0] try: info = rcdict[s] except KeyError: sys.stderr.write("No refcount data for %s\n" % s) else: if info.result_type in ("PyObject*", "PyVarObject*"): if info.result_refs is None: rc = "Always \NULL{}" else: rc = info.result_refs and "New" or "Borrowed" rc = rc + " reference" line = (r"\begin{cfuncdesc}[%s]{%s}{" % (rc, info.result_type)) \ + line[prefix_len:] output.write(line) if infile != "-": input.close() if outfile != "-": output.close()
|
def main(): rcfile = os.path.join(os.path.dirname(refcounts.__file__), os.pardir, "api", "refcounts.dat") outfile = "-" opts, args = getopt.getopt(sys.argv[1:], "o:r:", ["output=", "refcounts="]) for opt, arg in opts: if opt in ("-o", "--output"): outfile = arg elif opt in ("-r", "--refcounts"): rcfile = arg rcdict = refcounts.load(rcfile) if outfile == "-": output = sys.stdout else: output = open(outfile, "w") if not args: args = ["-"] prefix = PREFIX prefix_len = len(prefix) for infile in args: if infile == "-": input = sys.stdin else: input = open(infile) while 1: line = input.readline() if not line: break if line[:prefix_len] == prefix: s = string.split(line[prefix_len:], '}', 1)[0] try: info = rcdict[s] except KeyError: sys.stderr.write("No refcount data for %s\n" % s) else: if info.result_type in ("PyObject*", "PyVarObject*"): if info.result_refs is None: rc = "Always \NULL{}" else: rc = info.result_refs and "New" or "Borrowed" rc = rc + " reference" line = (r"\begin{cfuncdesc}[%s]{%s}{" % (rc, info.result_type)) \ + line[len(prefix):] output.write(line) if infile != "-": input.close() if outfile != "-": output.close()
| 13,940
|
def main(del_exitfunc=False): """Start the Python execution server in a subprocess In the Python subprocess, RPCServer is instantiated with handlerclass MyHandler, which inherits register/unregister methods from RPCHandler via the mix-in class SocketIO. When the RPCServer 'server' is instantiated, the TCPServer initialization creates an instance of run.MyHandler and calls its handle() method. handle() instantiates a run.Executive object, passing it a reference to the MyHandler object. That reference is saved as attribute rpchandler of the Executive instance. The Executive methods have access to the reference and can pass it on to entities that they command (e.g. RemoteDebugger.Debugger.start_debugger()). The latter, in turn, can call MyHandler(SocketIO) register/unregister methods via the reference to register and unregister themselves. """ global exit_now global quitting global no_exitfunc no_exitfunc = del_exitfunc port = 8833 #time.sleep(15) # test subprocess not responding if sys.argv[1:]: port = int(sys.argv[1]) sys.argv[:] = [""] sockthread = threading.Thread(target=manage_socket, name='SockThread', args=((LOCALHOST, port),)) sockthread.setDaemon(True) sockthread.start() while 1: try: if exit_now: try: exit() except KeyboardInterrupt: # exiting but got an extra KBI? Try again! continue try: seq, request = rpc.request_queue.get(0) except Queue.Empty: time.sleep(0.05) continue method, args, kwargs = request ret = method(*args, **kwargs) rpc.response_queue.put((seq, ret)) except KeyboardInterrupt: if quitting: exit_now = True continue except SystemExit: raise except: type, value, tb = sys.exc_info() try: print_exception() rpc.response_queue.put((seq, None)) except: # Link didn't work, print same exception to __stderr__ traceback.print_exception(type, value, tb, file=sys.__stderr__) exit() else: continue
|
def main(del_exitfunc=False): """Start the Python execution server in a subprocess In the Python subprocess, RPCServer is instantiated with handlerclass MyHandler, which inherits register/unregister methods from RPCHandler via the mix-in class SocketIO. When the RPCServer 'server' is instantiated, the TCPServer initialization creates an instance of run.MyHandler and calls its handle() method. handle() instantiates a run.Executive object, passing it a reference to the MyHandler object. That reference is saved as attribute rpchandler of the Executive instance. The Executive methods have access to the reference and can pass it on to entities that they command (e.g. RemoteDebugger.Debugger.start_debugger()). The latter, in turn, can call MyHandler(SocketIO) register/unregister methods via the reference to register and unregister themselves. """ global exit_now global quitting global no_exitfunc no_exitfunc = del_exitfunc port = 8833 #time.sleep(15) # test subprocess not responding if sys.argv[1:]: port = int(sys.argv[1]) sys.argv[:] = [""] sockthread = threading.Thread(target=manage_socket, name='SockThread', args=((LOCALHOST, port),)) sockthread.setDaemon(True) sockthread.start() while 1: try: if exit_now: try: exit() except KeyboardInterrupt: # exiting but got an extra KBI? Try again! continue try: seq, request = rpc.request_queue.get(block=True, timeout=0.05) except Queue.Empty: time.sleep(0.05) continue method, args, kwargs = request ret = method(*args, **kwargs) rpc.response_queue.put((seq, ret)) except KeyboardInterrupt: if quitting: exit_now = True continue except SystemExit: raise except: type, value, tb = sys.exc_info() try: print_exception() rpc.response_queue.put((seq, None)) except: # Link didn't work, print same exception to __stderr__ traceback.print_exception(type, value, tb, file=sys.__stderr__) exit() else: continue
| 13,941
|
def main(del_exitfunc=False): """Start the Python execution server in a subprocess In the Python subprocess, RPCServer is instantiated with handlerclass MyHandler, which inherits register/unregister methods from RPCHandler via the mix-in class SocketIO. When the RPCServer 'server' is instantiated, the TCPServer initialization creates an instance of run.MyHandler and calls its handle() method. handle() instantiates a run.Executive object, passing it a reference to the MyHandler object. That reference is saved as attribute rpchandler of the Executive instance. The Executive methods have access to the reference and can pass it on to entities that they command (e.g. RemoteDebugger.Debugger.start_debugger()). The latter, in turn, can call MyHandler(SocketIO) register/unregister methods via the reference to register and unregister themselves. """ global exit_now global quitting global no_exitfunc no_exitfunc = del_exitfunc port = 8833 #time.sleep(15) # test subprocess not responding if sys.argv[1:]: port = int(sys.argv[1]) sys.argv[:] = [""] sockthread = threading.Thread(target=manage_socket, name='SockThread', args=((LOCALHOST, port),)) sockthread.setDaemon(True) sockthread.start() while 1: try: if exit_now: try: exit() except KeyboardInterrupt: # exiting but got an extra KBI? Try again! continue try: seq, request = rpc.request_queue.get(0) except Queue.Empty: time.sleep(0.05) continue method, args, kwargs = request ret = method(*args, **kwargs) rpc.response_queue.put((seq, ret)) except KeyboardInterrupt: if quitting: exit_now = True continue except SystemExit: raise except: type, value, tb = sys.exc_info() try: print_exception() rpc.response_queue.put((seq, None)) except: # Link didn't work, print same exception to __stderr__ traceback.print_exception(type, value, tb, file=sys.__stderr__) exit() else: continue
|
def main(del_exitfunc=False): """Start the Python execution server in a subprocess In the Python subprocess, RPCServer is instantiated with handlerclass MyHandler, which inherits register/unregister methods from RPCHandler via the mix-in class SocketIO. When the RPCServer 'server' is instantiated, the TCPServer initialization creates an instance of run.MyHandler and calls its handle() method. handle() instantiates a run.Executive object, passing it a reference to the MyHandler object. That reference is saved as attribute rpchandler of the Executive instance. The Executive methods have access to the reference and can pass it on to entities that they command (e.g. RemoteDebugger.Debugger.start_debugger()). The latter, in turn, can call MyHandler(SocketIO) register/unregister methods via the reference to register and unregister themselves. """ global exit_now global quitting global no_exitfunc no_exitfunc = del_exitfunc port = 8833 #time.sleep(15) # test subprocess not responding if sys.argv[1:]: port = int(sys.argv[1]) sys.argv[:] = [""] sockthread = threading.Thread(target=manage_socket, name='SockThread', args=((LOCALHOST, port),)) sockthread.setDaemon(True) sockthread.start() while 1: try: if exit_now: try: exit() except KeyboardInterrupt: # exiting but got an extra KBI? Try again! continue try: seq, request = rpc.request_queue.get(0) except Queue.Empty: continue method, args, kwargs = request ret = method(*args, **kwargs) rpc.response_queue.put((seq, ret)) except KeyboardInterrupt: if quitting: exit_now = True continue except SystemExit: raise except: type, value, tb = sys.exc_info() try: print_exception() rpc.response_queue.put((seq, None)) except: # Link didn't work, print same exception to __stderr__ traceback.print_exception(type, value, tb, file=sys.__stderr__) exit() else: continue
| 13,942
|
def group(self, *groups):
|
def group(self, *groups):
| 13,943
|
def powtest(type): if (type!=float): print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if (pow(type(i),0)!=1): raise ValueError, 'pow('+str(i)+',0) != 1' if (pow(type(i),1)!=type(i)): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if (pow(type(0),1)!=type(0)): raise ValueError, 'pow(0,'+str(i)+') != 0' if (pow(type(1),1)!=type(1)): raise ValueError, 'pow(1,'+str(i)+') != 1' for i in range(-100, 100): if (pow(type(i),3)!=i*i*i): raise ValueError, 'pow('+str(i)+',3) != '+str(i*i*i) pow2=1 for i in range(0,31): if (pow(2,i)!=pow2): raise ValueError, 'pow(2,'+str(i)+') != '+str(pow2) if (i!=30): pow2=pow2*2 print " Testing 3-argument pow() function..." il, ih = -20, 20 jl, jh = -5, 5 kl, kh = -10, 10 compare = cmp if (type==float): il=1 compare = test_support.fcmp elif (type==int): jl=0 elif (type==long): jl,jh = 0, 15 for i in range(il, ih+1): for j in range(jl,jh+1): for k in range(kl, kh+1): if (k!=0): if compare(pow(type(i),j,k), pow(type(i),j)% type(k)): raise ValueError, "pow(" +str(i)+ "," +str(j)+ \ "," +str(k)+ ") != pow(" +str(i)+ "," + \ str(j)+ ") % " +str(k)
|
def powtest(type): if type != float: print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if (pow(type(i),0)!=1): raise ValueError, 'pow('+str(i)+',0) != 1' if (pow(type(i),1)!=type(i)): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if (pow(type(0),1)!=type(0)): raise ValueError, 'pow(0,'+str(i)+') != 0' if (pow(type(1),1)!=type(1)): raise ValueError, 'pow(1,'+str(i)+') != 1' for i in range(-100, 100): if (pow(type(i),3)!=i*i*i): raise ValueError, 'pow('+str(i)+',3) != '+str(i*i*i) pow2=1 for i in range(0,31): if (pow(2,i)!=pow2): raise ValueError, 'pow(2,'+str(i)+') != '+str(pow2) if (i!=30): pow2=pow2*2 print " Testing 3-argument pow() function..." il, ih = -20, 20 jl, jh = -5, 5 kl, kh = -10, 10 compare = cmp if (type==float): il=1 compare = test_support.fcmp elif (type==int): jl=0 elif (type==long): jl,jh = 0, 15 for i in range(il, ih+1): for j in range(jl,jh+1): for k in range(kl, kh+1): if (k!=0): if compare(pow(type(i),j,k), pow(type(i),j)% type(k)): raise ValueError, "pow(" +str(i)+ "," +str(j)+ \ "," +str(k)+ ") != pow(" +str(i)+ "," + \ str(j)+ ") % " +str(k)
| 13,944
|
def powtest(type): if (type!=float): print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if (pow(type(i),0)!=1): raise ValueError, 'pow('+str(i)+',0) != 1' if (pow(type(i),1)!=type(i)): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if (pow(type(0),1)!=type(0)): raise ValueError, 'pow(0,'+str(i)+') != 0' if (pow(type(1),1)!=type(1)): raise ValueError, 'pow(1,'+str(i)+') != 1' for i in range(-100, 100): if (pow(type(i),3)!=i*i*i): raise ValueError, 'pow('+str(i)+',3) != '+str(i*i*i) pow2=1 for i in range(0,31): if (pow(2,i)!=pow2): raise ValueError, 'pow(2,'+str(i)+') != '+str(pow2) if (i!=30): pow2=pow2*2 print " Testing 3-argument pow() function..." il, ih = -20, 20 jl, jh = -5, 5 kl, kh = -10, 10 compare = cmp if (type==float): il=1 compare = test_support.fcmp elif (type==int): jl=0 elif (type==long): jl,jh = 0, 15 for i in range(il, ih+1): for j in range(jl,jh+1): for k in range(kl, kh+1): if (k!=0): if compare(pow(type(i),j,k), pow(type(i),j)% type(k)): raise ValueError, "pow(" +str(i)+ "," +str(j)+ \ "," +str(k)+ ") != pow(" +str(i)+ "," + \ str(j)+ ") % " +str(k)
|
def powtest(type): if (type!=float): print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if pow(type(i), 0) != 1: raise ValueError, 'pow('+str(i)+',0) != 1' if (pow(type(i),1)!=type(i)): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if (pow(type(0),1)!=type(0)): raise ValueError, 'pow(0,'+str(i)+') != 0' if (pow(type(1),1)!=type(1)): raise ValueError, 'pow(1,'+str(i)+') != 1' for i in range(-100, 100): if (pow(type(i),3)!=i*i*i): raise ValueError, 'pow('+str(i)+',3) != '+str(i*i*i) pow2=1 for i in range(0,31): if (pow(2,i)!=pow2): raise ValueError, 'pow(2,'+str(i)+') != '+str(pow2) if (i!=30): pow2=pow2*2 print " Testing 3-argument pow() function..." il, ih = -20, 20 jl, jh = -5, 5 kl, kh = -10, 10 compare = cmp if (type==float): il=1 compare = test_support.fcmp elif (type==int): jl=0 elif (type==long): jl,jh = 0, 15 for i in range(il, ih+1): for j in range(jl,jh+1): for k in range(kl, kh+1): if (k!=0): if compare(pow(type(i),j,k), pow(type(i),j)% type(k)): raise ValueError, "pow(" +str(i)+ "," +str(j)+ \ "," +str(k)+ ") != pow(" +str(i)+ "," + \ str(j)+ ") % " +str(k)
| 13,945
|
def powtest(type): if (type!=float): print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if (pow(type(i),0)!=1): raise ValueError, 'pow('+str(i)+',0) != 1' if (pow(type(i),1)!=type(i)): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if (pow(type(0),1)!=type(0)): raise ValueError, 'pow(0,'+str(i)+') != 0' if (pow(type(1),1)!=type(1)): raise ValueError, 'pow(1,'+str(i)+') != 1' for i in range(-100, 100): if (pow(type(i),3)!=i*i*i): raise ValueError, 'pow('+str(i)+',3) != '+str(i*i*i) pow2=1 for i in range(0,31): if (pow(2,i)!=pow2): raise ValueError, 'pow(2,'+str(i)+') != '+str(pow2) if (i!=30): pow2=pow2*2 print " Testing 3-argument pow() function..." il, ih = -20, 20 jl, jh = -5, 5 kl, kh = -10, 10 compare = cmp if (type==float): il=1 compare = test_support.fcmp elif (type==int): jl=0 elif (type==long): jl,jh = 0, 15 for i in range(il, ih+1): for j in range(jl,jh+1): for k in range(kl, kh+1): if (k!=0): if compare(pow(type(i),j,k), pow(type(i),j)% type(k)): raise ValueError, "pow(" +str(i)+ "," +str(j)+ \ "," +str(k)+ ") != pow(" +str(i)+ "," + \ str(j)+ ") % " +str(k)
|
def powtest(type): if (type!=float): print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if (pow(type(i),0)!=1): raise ValueError, 'pow('+str(i)+',0) != 1' if pow(type(i), 1) != type(i): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if (pow(type(0),1)!=type(0)): raise ValueError, 'pow(0,'+str(i)+') != 0' if (pow(type(1),1)!=type(1)): raise ValueError, 'pow(1,'+str(i)+') != 1' for i in range(-100, 100): if (pow(type(i),3)!=i*i*i): raise ValueError, 'pow('+str(i)+',3) != '+str(i*i*i) pow2=1 for i in range(0,31): if (pow(2,i)!=pow2): raise ValueError, 'pow(2,'+str(i)+') != '+str(pow2) if (i!=30): pow2=pow2*2 print " Testing 3-argument pow() function..." il, ih = -20, 20 jl, jh = -5, 5 kl, kh = -10, 10 compare = cmp if (type==float): il=1 compare = test_support.fcmp elif (type==int): jl=0 elif (type==long): jl,jh = 0, 15 for i in range(il, ih+1): for j in range(jl,jh+1): for k in range(kl, kh+1): if (k!=0): if compare(pow(type(i),j,k), pow(type(i),j)% type(k)): raise ValueError, "pow(" +str(i)+ "," +str(j)+ \ "," +str(k)+ ") != pow(" +str(i)+ "," + \ str(j)+ ") % " +str(k)
| 13,946
|
def powtest(type): if (type!=float): print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if (pow(type(i),0)!=1): raise ValueError, 'pow('+str(i)+',0) != 1' if (pow(type(i),1)!=type(i)): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if (pow(type(0),1)!=type(0)): raise ValueError, 'pow(0,'+str(i)+') != 0' if (pow(type(1),1)!=type(1)): raise ValueError, 'pow(1,'+str(i)+') != 1' for i in range(-100, 100): if (pow(type(i),3)!=i*i*i): raise ValueError, 'pow('+str(i)+',3) != '+str(i*i*i) pow2=1 for i in range(0,31): if (pow(2,i)!=pow2): raise ValueError, 'pow(2,'+str(i)+') != '+str(pow2) if (i!=30): pow2=pow2*2 print " Testing 3-argument pow() function..." il, ih = -20, 20 jl, jh = -5, 5 kl, kh = -10, 10 compare = cmp if (type==float): il=1 compare = test_support.fcmp elif (type==int): jl=0 elif (type==long): jl,jh = 0, 15 for i in range(il, ih+1): for j in range(jl,jh+1): for k in range(kl, kh+1): if (k!=0): if compare(pow(type(i),j,k), pow(type(i),j)% type(k)): raise ValueError, "pow(" +str(i)+ "," +str(j)+ \ "," +str(k)+ ") != pow(" +str(i)+ "," + \ str(j)+ ") % " +str(k)
|
def powtest(type): if (type!=float): print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if (pow(type(i),0)!=1): raise ValueError, 'pow('+str(i)+',0) != 1' if (pow(type(i),1)!=type(i)): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if pow(type(0), 1) != type(0): raise ValueError, 'pow(0,'+str(i)+') != 0' if (pow(type(1),1)!=type(1)): raise ValueError, 'pow(1,'+str(i)+') != 1' for i in range(-100, 100): if (pow(type(i),3)!=i*i*i): raise ValueError, 'pow('+str(i)+',3) != '+str(i*i*i) pow2=1 for i in range(0,31): if (pow(2,i)!=pow2): raise ValueError, 'pow(2,'+str(i)+') != '+str(pow2) if (i!=30): pow2=pow2*2 print " Testing 3-argument pow() function..." il, ih = -20, 20 jl, jh = -5, 5 kl, kh = -10, 10 compare = cmp if (type==float): il=1 compare = test_support.fcmp elif (type==int): jl=0 elif (type==long): jl,jh = 0, 15 for i in range(il, ih+1): for j in range(jl,jh+1): for k in range(kl, kh+1): if (k!=0): if compare(pow(type(i),j,k), pow(type(i),j)% type(k)): raise ValueError, "pow(" +str(i)+ "," +str(j)+ \ "," +str(k)+ ") != pow(" +str(i)+ "," + \ str(j)+ ") % " +str(k)
| 13,947
|
def powtest(type): if (type!=float): print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if (pow(type(i),0)!=1): raise ValueError, 'pow('+str(i)+',0) != 1' if (pow(type(i),1)!=type(i)): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if (pow(type(0),1)!=type(0)): raise ValueError, 'pow(0,'+str(i)+') != 0' if (pow(type(1),1)!=type(1)): raise ValueError, 'pow(1,'+str(i)+') != 1' for i in range(-100, 100): if (pow(type(i),3)!=i*i*i): raise ValueError, 'pow('+str(i)+',3) != '+str(i*i*i) pow2=1 for i in range(0,31): if (pow(2,i)!=pow2): raise ValueError, 'pow(2,'+str(i)+') != '+str(pow2) if (i!=30): pow2=pow2*2 print " Testing 3-argument pow() function..." il, ih = -20, 20 jl, jh = -5, 5 kl, kh = -10, 10 compare = cmp if (type==float): il=1 compare = test_support.fcmp elif (type==int): jl=0 elif (type==long): jl,jh = 0, 15 for i in range(il, ih+1): for j in range(jl,jh+1): for k in range(kl, kh+1): if (k!=0): if compare(pow(type(i),j,k), pow(type(i),j)% type(k)): raise ValueError, "pow(" +str(i)+ "," +str(j)+ \ "," +str(k)+ ") != pow(" +str(i)+ "," + \ str(j)+ ") % " +str(k)
|
def powtest(type): if (type!=float): print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if (pow(type(i),0)!=1): raise ValueError, 'pow('+str(i)+',0) != 1' if (pow(type(i),1)!=type(i)): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if (pow(type(0),1)!=type(0)): raise ValueError, 'pow(0,'+str(i)+') != 0' if pow(type(1), 1) != type(1): raise ValueError, 'pow(1,'+str(i)+') != 1' for i in range(-100, 100): if (pow(type(i),3)!=i*i*i): raise ValueError, 'pow('+str(i)+',3) != '+str(i*i*i) pow2=1 for i in range(0,31): if (pow(2,i)!=pow2): raise ValueError, 'pow(2,'+str(i)+') != '+str(pow2) if (i!=30): pow2=pow2*2 print " Testing 3-argument pow() function..." il, ih = -20, 20 jl, jh = -5, 5 kl, kh = -10, 10 compare = cmp if (type==float): il=1 compare = test_support.fcmp elif (type==int): jl=0 elif (type==long): jl,jh = 0, 15 for i in range(il, ih+1): for j in range(jl,jh+1): for k in range(kl, kh+1): if (k!=0): if compare(pow(type(i),j,k), pow(type(i),j)% type(k)): raise ValueError, "pow(" +str(i)+ "," +str(j)+ \ "," +str(k)+ ") != pow(" +str(i)+ "," + \ str(j)+ ") % " +str(k)
| 13,948
|
def powtest(type): if (type!=float): print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if (pow(type(i),0)!=1): raise ValueError, 'pow('+str(i)+',0) != 1' if (pow(type(i),1)!=type(i)): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if (pow(type(0),1)!=type(0)): raise ValueError, 'pow(0,'+str(i)+') != 0' if (pow(type(1),1)!=type(1)): raise ValueError, 'pow(1,'+str(i)+') != 1' for i in range(-100, 100): if (pow(type(i),3)!=i*i*i): raise ValueError, 'pow('+str(i)+',3) != '+str(i*i*i) pow2=1 for i in range(0,31): if (pow(2,i)!=pow2): raise ValueError, 'pow(2,'+str(i)+') != '+str(pow2) if (i!=30): pow2=pow2*2 print " Testing 3-argument pow() function..." il, ih = -20, 20 jl, jh = -5, 5 kl, kh = -10, 10 compare = cmp if (type==float): il=1 compare = test_support.fcmp elif (type==int): jl=0 elif (type==long): jl,jh = 0, 15 for i in range(il, ih+1): for j in range(jl,jh+1): for k in range(kl, kh+1): if (k!=0): if compare(pow(type(i),j,k), pow(type(i),j)% type(k)): raise ValueError, "pow(" +str(i)+ "," +str(j)+ \ "," +str(k)+ ") != pow(" +str(i)+ "," + \ str(j)+ ") % " +str(k)
|
def powtest(type): if (type!=float): print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if (pow(type(i),0)!=1): raise ValueError, 'pow('+str(i)+',0) != 1' if (pow(type(i),1)!=type(i)): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if (pow(type(0),1)!=type(0)): raise ValueError, 'pow(0,'+str(i)+') != 0' if (pow(type(1),1)!=type(1)): raise ValueError, 'pow(1,'+str(i)+') != 1' for i in range(-100, 100): if (pow(type(i),3)!=i*i*i): raise ValueError, 'pow('+str(i)+',3) != '+str(i*i*i) pow2=1 for i in range(0,31): if (pow(2,i)!=pow2): raise ValueError, 'pow(2,'+str(i)+') != '+str(pow2) if (i!=30): pow2=pow2*2 print " Testing 3-argument pow() function..." il, ih = -20, 20 jl, jh = -5, 5 kl, kh = -10, 10 compare = cmp if (type==float): il=1 compare = test_support.fcmp elif (type==int): jl=0 elif (type==long): jl,jh = 0, 15 for i in range(il, ih+1): for j in range(jl,jh+1): for k in range(kl, kh+1): if (k!=0): if compare(pow(type(i),j,k), pow(type(i),j)% type(k)): raise ValueError, "pow(" +str(i)+ "," +str(j)+ \ "," +str(k)+ ") != pow(" +str(i)+ "," + \ str(j)+ ") % " +str(k)
| 13,949
|
def powtest(type): if (type!=float): print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if (pow(type(i),0)!=1): raise ValueError, 'pow('+str(i)+',0) != 1' if (pow(type(i),1)!=type(i)): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if (pow(type(0),1)!=type(0)): raise ValueError, 'pow(0,'+str(i)+') != 0' if (pow(type(1),1)!=type(1)): raise ValueError, 'pow(1,'+str(i)+') != 1' for i in range(-100, 100): if (pow(type(i),3)!=i*i*i): raise ValueError, 'pow('+str(i)+',3) != '+str(i*i*i) pow2=1 for i in range(0,31): if (pow(2,i)!=pow2): raise ValueError, 'pow(2,'+str(i)+') != '+str(pow2) if (i!=30): pow2=pow2*2 print " Testing 3-argument pow() function..." il, ih = -20, 20 jl, jh = -5, 5 kl, kh = -10, 10 compare = cmp if (type==float): il=1 compare = test_support.fcmp elif (type==int): jl=0 elif (type==long): jl,jh = 0, 15 for i in range(il, ih+1): for j in range(jl,jh+1): for k in range(kl, kh+1): if (k!=0): if compare(pow(type(i),j,k), pow(type(i),j)% type(k)): raise ValueError, "pow(" +str(i)+ "," +str(j)+ \ "," +str(k)+ ") != pow(" +str(i)+ "," + \ str(j)+ ") % " +str(k)
|
def powtest(type): if (type!=float): print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if (pow(type(i),0)!=1): raise ValueError, 'pow('+str(i)+',0) != 1' if (pow(type(i),1)!=type(i)): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if (pow(type(0),1)!=type(0)): raise ValueError, 'pow(0,'+str(i)+') != 0' if (pow(type(1),1)!=type(1)): raise ValueError, 'pow(1,'+str(i)+') != 1' for i in range(-100, 100): if pow(type(i), 3) != i*i*i: raise ValueError, 'pow('+str(i)+',3) != '+str(i*i*i) pow2=1 for i in range(0,31): if (pow(2,i)!=pow2): raise ValueError, 'pow(2,'+str(i)+') != '+str(pow2) if (i!=30): pow2=pow2*2 print " Testing 3-argument pow() function..." il, ih = -20, 20 jl, jh = -5, 5 kl, kh = -10, 10 compare = cmp if (type==float): il=1 compare = test_support.fcmp elif (type==int): jl=0 elif (type==long): jl,jh = 0, 15 for i in range(il, ih+1): for j in range(jl,jh+1): for k in range(kl, kh+1): if (k!=0): if compare(pow(type(i),j,k), pow(type(i),j)% type(k)): raise ValueError, "pow(" +str(i)+ "," +str(j)+ \ "," +str(k)+ ") != pow(" +str(i)+ "," + \ str(j)+ ") % " +str(k)
| 13,950
|
def powtest(type): if (type!=float): print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if (pow(type(i),0)!=1): raise ValueError, 'pow('+str(i)+',0) != 1' if (pow(type(i),1)!=type(i)): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if (pow(type(0),1)!=type(0)): raise ValueError, 'pow(0,'+str(i)+') != 0' if (pow(type(1),1)!=type(1)): raise ValueError, 'pow(1,'+str(i)+') != 1' for i in range(-100, 100): if (pow(type(i),3)!=i*i*i): raise ValueError, 'pow('+str(i)+',3) != '+str(i*i*i) pow2=1 for i in range(0,31): if (pow(2,i)!=pow2): raise ValueError, 'pow(2,'+str(i)+') != '+str(pow2) if (i!=30): pow2=pow2*2 print " Testing 3-argument pow() function..." il, ih = -20, 20 jl, jh = -5, 5 kl, kh = -10, 10 compare = cmp if (type==float): il=1 compare = test_support.fcmp elif (type==int): jl=0 elif (type==long): jl,jh = 0, 15 for i in range(il, ih+1): for j in range(jl,jh+1): for k in range(kl, kh+1): if (k!=0): if compare(pow(type(i),j,k), pow(type(i),j)% type(k)): raise ValueError, "pow(" +str(i)+ "," +str(j)+ \ "," +str(k)+ ") != pow(" +str(i)+ "," + \ str(j)+ ") % " +str(k)
|
def powtest(type): if (type!=float): print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if (pow(type(i),0)!=1): raise ValueError, 'pow('+str(i)+',0) != 1' if (pow(type(i),1)!=type(i)): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if (pow(type(0),1)!=type(0)): raise ValueError, 'pow(0,'+str(i)+') != 0' if (pow(type(1),1)!=type(1)): raise ValueError, 'pow(1,'+str(i)+') != 1' for i in range(-100, 100): if (pow(type(i),3)!=i*i*i): raise ValueError, 'pow('+str(i)+',3) != '+str(i*i*i) pow2 = 1 for i in range(0,31): if (pow(2,i)!=pow2): raise ValueError, 'pow(2,'+str(i)+') != '+str(pow2) if (i!=30): pow2=pow2*2 print " Testing 3-argument pow() function..." il, ih = -20, 20 jl, jh = -5, 5 kl, kh = -10, 10 compare = cmp if (type==float): il=1 compare = test_support.fcmp elif (type==int): jl=0 elif (type==long): jl,jh = 0, 15 for i in range(il, ih+1): for j in range(jl,jh+1): for k in range(kl, kh+1): if (k!=0): if compare(pow(type(i),j,k), pow(type(i),j)% type(k)): raise ValueError, "pow(" +str(i)+ "," +str(j)+ \ "," +str(k)+ ") != pow(" +str(i)+ "," + \ str(j)+ ") % " +str(k)
| 13,951
|
def powtest(type): if (type!=float): print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if (pow(type(i),0)!=1): raise ValueError, 'pow('+str(i)+',0) != 1' if (pow(type(i),1)!=type(i)): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if (pow(type(0),1)!=type(0)): raise ValueError, 'pow(0,'+str(i)+') != 0' if (pow(type(1),1)!=type(1)): raise ValueError, 'pow(1,'+str(i)+') != 1' for i in range(-100, 100): if (pow(type(i),3)!=i*i*i): raise ValueError, 'pow('+str(i)+',3) != '+str(i*i*i) pow2=1 for i in range(0,31): if (pow(2,i)!=pow2): raise ValueError, 'pow(2,'+str(i)+') != '+str(pow2) if (i!=30): pow2=pow2*2 print " Testing 3-argument pow() function..." il, ih = -20, 20 jl, jh = -5, 5 kl, kh = -10, 10 compare = cmp if (type==float): il=1 compare = test_support.fcmp elif (type==int): jl=0 elif (type==long): jl,jh = 0, 15 for i in range(il, ih+1): for j in range(jl,jh+1): for k in range(kl, kh+1): if (k!=0): if compare(pow(type(i),j,k), pow(type(i),j)% type(k)): raise ValueError, "pow(" +str(i)+ "," +str(j)+ \ "," +str(k)+ ") != pow(" +str(i)+ "," + \ str(j)+ ") % " +str(k)
|
def powtest(type): if (type!=float): print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if (pow(type(i),0)!=1): raise ValueError, 'pow('+str(i)+',0) != 1' if (pow(type(i),1)!=type(i)): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if (pow(type(0),1)!=type(0)): raise ValueError, 'pow(0,'+str(i)+') != 0' if (pow(type(1),1)!=type(1)): raise ValueError, 'pow(1,'+str(i)+') != 1' for i in range(-100, 100): if (pow(type(i),3)!=i*i*i): raise ValueError, 'pow('+str(i)+',3) != '+str(i*i*i) pow2=1 for i in range(0,31): if pow(2, i) != pow2: raise ValueError, 'pow(2,'+str(i)+') != '+str(pow2) if (i!=30): pow2=pow2*2 print " Testing 3-argument pow() function..." il, ih = -20, 20 jl, jh = -5, 5 kl, kh = -10, 10 compare = cmp if (type==float): il=1 compare = test_support.fcmp elif (type==int): jl=0 elif (type==long): jl,jh = 0, 15 for i in range(il, ih+1): for j in range(jl,jh+1): for k in range(kl, kh+1): if (k!=0): if compare(pow(type(i),j,k), pow(type(i),j)% type(k)): raise ValueError, "pow(" +str(i)+ "," +str(j)+ \ "," +str(k)+ ") != pow(" +str(i)+ "," + \ str(j)+ ") % " +str(k)
| 13,952
|
def powtest(type): if (type!=float): print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if (pow(type(i),0)!=1): raise ValueError, 'pow('+str(i)+',0) != 1' if (pow(type(i),1)!=type(i)): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if (pow(type(0),1)!=type(0)): raise ValueError, 'pow(0,'+str(i)+') != 0' if (pow(type(1),1)!=type(1)): raise ValueError, 'pow(1,'+str(i)+') != 1' for i in range(-100, 100): if (pow(type(i),3)!=i*i*i): raise ValueError, 'pow('+str(i)+',3) != '+str(i*i*i) pow2=1 for i in range(0,31): if (pow(2,i)!=pow2): raise ValueError, 'pow(2,'+str(i)+') != '+str(pow2) if (i!=30): pow2=pow2*2 print " Testing 3-argument pow() function..." il, ih = -20, 20 jl, jh = -5, 5 kl, kh = -10, 10 compare = cmp if (type==float): il=1 compare = test_support.fcmp elif (type==int): jl=0 elif (type==long): jl,jh = 0, 15 for i in range(il, ih+1): for j in range(jl,jh+1): for k in range(kl, kh+1): if (k!=0): if compare(pow(type(i),j,k), pow(type(i),j)% type(k)): raise ValueError, "pow(" +str(i)+ "," +str(j)+ \ "," +str(k)+ ") != pow(" +str(i)+ "," + \ str(j)+ ") % " +str(k)
|
def powtest(type): if (type!=float): print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if (pow(type(i),0)!=1): raise ValueError, 'pow('+str(i)+',0) != 1' if (pow(type(i),1)!=type(i)): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if (pow(type(0),1)!=type(0)): raise ValueError, 'pow(0,'+str(i)+') != 0' if (pow(type(1),1)!=type(1)): raise ValueError, 'pow(1,'+str(i)+') != 1' for i in range(-100, 100): if (pow(type(i),3)!=i*i*i): raise ValueError, 'pow('+str(i)+',3) != '+str(i*i*i) pow2=1 for i in range(0,31): if (pow(2,i)!=pow2): raise ValueError, 'pow(2,'+str(i)+') != '+str(pow2) if i != 30 : pow2 = pow2*2 for othertype in int, long: for i in range(-10, 0) + range(1, 10): ii = type(i) for j in range(1, 11): jj = -othertype(j) try: pow(ii, jj) except ValueError: pass else: raise ValueError, "pow(%s, %s) did not fail" % (ii, jj) for othertype in int, long, float: for i in range(1, 100): zero = type(0) exp = -othertype(i/10.0) if exp == 0: continue try: pow(zero, exp) except ZeroDivisionError: pass else: raise ValueError, "pow(%s, %s) did not fail" % (zero, exp) print " Testing 3-argument pow() function..." il, ih = -20, 20 jl, jh = -5, 5 kl, kh = -10, 10 compare = cmp if (type==float): il=1 compare = test_support.fcmp elif (type==int): jl=0 elif (type==long): jl,jh = 0, 15 for i in range(il, ih+1): for j in range(jl,jh+1): for k in range(kl, kh+1): if (k!=0): if compare(pow(type(i),j,k), pow(type(i),j)% type(k)): raise ValueError, "pow(" +str(i)+ "," +str(j)+ \ "," +str(k)+ ") != pow(" +str(i)+ "," + \ str(j)+ ") % " +str(k)
| 13,953
|
def powtest(type): if (type!=float): print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if (pow(type(i),0)!=1): raise ValueError, 'pow('+str(i)+',0) != 1' if (pow(type(i),1)!=type(i)): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if (pow(type(0),1)!=type(0)): raise ValueError, 'pow(0,'+str(i)+') != 0' if (pow(type(1),1)!=type(1)): raise ValueError, 'pow(1,'+str(i)+') != 1' for i in range(-100, 100): if (pow(type(i),3)!=i*i*i): raise ValueError, 'pow('+str(i)+',3) != '+str(i*i*i) pow2=1 for i in range(0,31): if (pow(2,i)!=pow2): raise ValueError, 'pow(2,'+str(i)+') != '+str(pow2) if (i!=30): pow2=pow2*2 print " Testing 3-argument pow() function..." il, ih = -20, 20 jl, jh = -5, 5 kl, kh = -10, 10 compare = cmp if (type==float): il=1 compare = test_support.fcmp elif (type==int): jl=0 elif (type==long): jl,jh = 0, 15 for i in range(il, ih+1): for j in range(jl,jh+1): for k in range(kl, kh+1): if (k!=0): if compare(pow(type(i),j,k), pow(type(i),j)% type(k)): raise ValueError, "pow(" +str(i)+ "," +str(j)+ \ "," +str(k)+ ") != pow(" +str(i)+ "," + \ str(j)+ ") % " +str(k)
|
def powtest(type): if (type!=float): print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if (pow(type(i),0)!=1): raise ValueError, 'pow('+str(i)+',0) != 1' if (pow(type(i),1)!=type(i)): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if (pow(type(0),1)!=type(0)): raise ValueError, 'pow(0,'+str(i)+') != 0' if (pow(type(1),1)!=type(1)): raise ValueError, 'pow(1,'+str(i)+') != 1' for i in range(-100, 100): if (pow(type(i),3)!=i*i*i): raise ValueError, 'pow('+str(i)+',3) != '+str(i*i*i) pow2=1 for i in range(0,31): if (pow(2,i)!=pow2): raise ValueError, 'pow(2,'+str(i)+') != '+str(pow2) if (i!=30): pow2=pow2*2 print " Testing 3-argument pow() function..." il, ih = -20, 20 jl, jh = -5, 5 kl, kh = -10, 10 compare = cmp if type == float: il = 1 compare = test_support.fcmp elif (type==int): jl=0 elif (type==long): jl,jh = 0, 15 for i in range(il, ih+1): for j in range(jl,jh+1): for k in range(kl, kh+1): if (k!=0): if compare(pow(type(i),j,k), pow(type(i),j)% type(k)): raise ValueError, "pow(" +str(i)+ "," +str(j)+ \ "," +str(k)+ ") != pow(" +str(i)+ "," + \ str(j)+ ") % " +str(k)
| 13,954
|
def powtest(type): if (type!=float): print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if (pow(type(i),0)!=1): raise ValueError, 'pow('+str(i)+',0) != 1' if (pow(type(i),1)!=type(i)): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if (pow(type(0),1)!=type(0)): raise ValueError, 'pow(0,'+str(i)+') != 0' if (pow(type(1),1)!=type(1)): raise ValueError, 'pow(1,'+str(i)+') != 1' for i in range(-100, 100): if (pow(type(i),3)!=i*i*i): raise ValueError, 'pow('+str(i)+',3) != '+str(i*i*i) pow2=1 for i in range(0,31): if (pow(2,i)!=pow2): raise ValueError, 'pow(2,'+str(i)+') != '+str(pow2) if (i!=30): pow2=pow2*2 print " Testing 3-argument pow() function..." il, ih = -20, 20 jl, jh = -5, 5 kl, kh = -10, 10 compare = cmp if (type==float): il=1 compare = test_support.fcmp elif (type==int): jl=0 elif (type==long): jl,jh = 0, 15 for i in range(il, ih+1): for j in range(jl,jh+1): for k in range(kl, kh+1): if (k!=0): if compare(pow(type(i),j,k), pow(type(i),j)% type(k)): raise ValueError, "pow(" +str(i)+ "," +str(j)+ \ "," +str(k)+ ") != pow(" +str(i)+ "," + \ str(j)+ ") % " +str(k)
|
def powtest(type): if (type!=float): print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if (pow(type(i),0)!=1): raise ValueError, 'pow('+str(i)+',0) != 1' if (pow(type(i),1)!=type(i)): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if (pow(type(0),1)!=type(0)): raise ValueError, 'pow(0,'+str(i)+') != 0' if (pow(type(1),1)!=type(1)): raise ValueError, 'pow(1,'+str(i)+') != 1' for i in range(-100, 100): if (pow(type(i),3)!=i*i*i): raise ValueError, 'pow('+str(i)+',3) != '+str(i*i*i) pow2=1 for i in range(0,31): if (pow(2,i)!=pow2): raise ValueError, 'pow(2,'+str(i)+') != '+str(pow2) if (i!=30): pow2=pow2*2 print " Testing 3-argument pow() function..." il, ih = -20, 20 jl, jh = -5, 5 kl, kh = -10, 10 compare = cmp if (type==float): il=1 compare = test_support.fcmp elif type == int: jl = 0 elif type == long: jl, jh = 0, 15 for i in range(il, ih+1): for j in range(jl,jh+1): for k in range(kl, kh+1): if (k!=0): if compare(pow(type(i),j,k), pow(type(i),j)% type(k)): raise ValueError, "pow(" +str(i)+ "," +str(j)+ \ "," +str(k)+ ") != pow(" +str(i)+ "," + \ str(j)+ ") % " +str(k)
| 13,955
|
def powtest(type): if (type!=float): print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if (pow(type(i),0)!=1): raise ValueError, 'pow('+str(i)+',0) != 1' if (pow(type(i),1)!=type(i)): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if (pow(type(0),1)!=type(0)): raise ValueError, 'pow(0,'+str(i)+') != 0' if (pow(type(1),1)!=type(1)): raise ValueError, 'pow(1,'+str(i)+') != 1' for i in range(-100, 100): if (pow(type(i),3)!=i*i*i): raise ValueError, 'pow('+str(i)+',3) != '+str(i*i*i) pow2=1 for i in range(0,31): if (pow(2,i)!=pow2): raise ValueError, 'pow(2,'+str(i)+') != '+str(pow2) if (i!=30): pow2=pow2*2 print " Testing 3-argument pow() function..." il, ih = -20, 20 jl, jh = -5, 5 kl, kh = -10, 10 compare = cmp if (type==float): il=1 compare = test_support.fcmp elif (type==int): jl=0 elif (type==long): jl,jh = 0, 15 for i in range(il, ih+1): for j in range(jl,jh+1): for k in range(kl, kh+1): if (k!=0): if compare(pow(type(i),j,k), pow(type(i),j)% type(k)): raise ValueError, "pow(" +str(i)+ "," +str(j)+ \ "," +str(k)+ ") != pow(" +str(i)+ "," + \ str(j)+ ") % " +str(k)
|
def powtest(type): if (type!=float): print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if (pow(type(i),0)!=1): raise ValueError, 'pow('+str(i)+',0) != 1' if (pow(type(i),1)!=type(i)): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if (pow(type(0),1)!=type(0)): raise ValueError, 'pow(0,'+str(i)+') != 0' if (pow(type(1),1)!=type(1)): raise ValueError, 'pow(1,'+str(i)+') != 1' for i in range(-100, 100): if (pow(type(i),3)!=i*i*i): raise ValueError, 'pow('+str(i)+',3) != '+str(i*i*i) pow2=1 for i in range(0,31): if (pow(2,i)!=pow2): raise ValueError, 'pow(2,'+str(i)+') != '+str(pow2) if (i!=30): pow2=pow2*2 print " Testing 3-argument pow() function..." il, ih = -20, 20 jl, jh = -5, 5 kl, kh = -10, 10 compare = cmp if (type==float): il=1 compare = test_support.fcmp elif (type==int): jl=0 elif (type==long): jl,jh = 0, 15 for i in range(il, ih+1): for j in range(jl, jh+1): for k in range(kl, kh+1): if (k!=0): if compare(pow(type(i),j,k), pow(type(i),j)% type(k)): raise ValueError, "pow(" +str(i)+ "," +str(j)+ \ "," +str(k)+ ") != pow(" +str(i)+ "," + \ str(j)+ ") % " +str(k)
| 13,956
|
def powtest(type): if (type!=float): print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if (pow(type(i),0)!=1): raise ValueError, 'pow('+str(i)+',0) != 1' if (pow(type(i),1)!=type(i)): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if (pow(type(0),1)!=type(0)): raise ValueError, 'pow(0,'+str(i)+') != 0' if (pow(type(1),1)!=type(1)): raise ValueError, 'pow(1,'+str(i)+') != 1' for i in range(-100, 100): if (pow(type(i),3)!=i*i*i): raise ValueError, 'pow('+str(i)+',3) != '+str(i*i*i) pow2=1 for i in range(0,31): if (pow(2,i)!=pow2): raise ValueError, 'pow(2,'+str(i)+') != '+str(pow2) if (i!=30): pow2=pow2*2 print " Testing 3-argument pow() function..." il, ih = -20, 20 jl, jh = -5, 5 kl, kh = -10, 10 compare = cmp if (type==float): il=1 compare = test_support.fcmp elif (type==int): jl=0 elif (type==long): jl,jh = 0, 15 for i in range(il, ih+1): for j in range(jl,jh+1): for k in range(kl, kh+1): if (k!=0): if compare(pow(type(i),j,k), pow(type(i),j)% type(k)): raise ValueError, "pow(" +str(i)+ "," +str(j)+ \ "," +str(k)+ ") != pow(" +str(i)+ "," + \ str(j)+ ") % " +str(k)
|
def powtest(type): if (type!=float): print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if (pow(type(i),0)!=1): raise ValueError, 'pow('+str(i)+',0) != 1' if (pow(type(i),1)!=type(i)): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if (pow(type(0),1)!=type(0)): raise ValueError, 'pow(0,'+str(i)+') != 0' if (pow(type(1),1)!=type(1)): raise ValueError, 'pow(1,'+str(i)+') != 1' for i in range(-100, 100): if (pow(type(i),3)!=i*i*i): raise ValueError, 'pow('+str(i)+',3) != '+str(i*i*i) pow2=1 for i in range(0,31): if (pow(2,i)!=pow2): raise ValueError, 'pow(2,'+str(i)+') != '+str(pow2) if (i!=30): pow2=pow2*2 print " Testing 3-argument pow() function..." il, ih = -20, 20 jl, jh = -5, 5 kl, kh = -10, 10 compare = cmp if (type==float): il=1 compare = test_support.fcmp elif (type==int): jl=0 elif (type==long): jl,jh = 0, 15 for i in range(il, ih+1): for j in range(jl,jh+1): for k in range(kl, kh+1): if k != 0: if compare(pow(type(i),j,k), pow(type(i),j)% type(k)): raise ValueError, "pow(" +str(i)+ "," +str(j)+ \ "," +str(k)+ ") != pow(" +str(i)+ "," + \ str(j)+ ") % " +str(k)
| 13,957
|
def powtest(type): if (type!=float): print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if (pow(type(i),0)!=1): raise ValueError, 'pow('+str(i)+',0) != 1' if (pow(type(i),1)!=type(i)): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if (pow(type(0),1)!=type(0)): raise ValueError, 'pow(0,'+str(i)+') != 0' if (pow(type(1),1)!=type(1)): raise ValueError, 'pow(1,'+str(i)+') != 1' for i in range(-100, 100): if (pow(type(i),3)!=i*i*i): raise ValueError, 'pow('+str(i)+',3) != '+str(i*i*i) pow2=1 for i in range(0,31): if (pow(2,i)!=pow2): raise ValueError, 'pow(2,'+str(i)+') != '+str(pow2) if (i!=30): pow2=pow2*2 print " Testing 3-argument pow() function..." il, ih = -20, 20 jl, jh = -5, 5 kl, kh = -10, 10 compare = cmp if (type==float): il=1 compare = test_support.fcmp elif (type==int): jl=0 elif (type==long): jl,jh = 0, 15 for i in range(il, ih+1): for j in range(jl,jh+1): for k in range(kl, kh+1): if (k!=0): if compare(pow(type(i),j,k), pow(type(i),j)% type(k)): raise ValueError, "pow(" +str(i)+ "," +str(j)+ \ "," +str(k)+ ") != pow(" +str(i)+ "," + \ str(j)+ ") % " +str(k)
|
def powtest(type): if (type!=float): print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if (pow(type(i),0)!=1): raise ValueError, 'pow('+str(i)+',0) != 1' if (pow(type(i),1)!=type(i)): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if (pow(type(0),1)!=type(0)): raise ValueError, 'pow(0,'+str(i)+') != 0' if (pow(type(1),1)!=type(1)): raise ValueError, 'pow(1,'+str(i)+') != 1' for i in range(-100, 100): if (pow(type(i),3)!=i*i*i): raise ValueError, 'pow('+str(i)+',3) != '+str(i*i*i) pow2=1 for i in range(0,31): if (pow(2,i)!=pow2): raise ValueError, 'pow(2,'+str(i)+') != '+str(pow2) if (i!=30): pow2=pow2*2 print " Testing 3-argument pow() function..." il, ih = -20, 20 jl, jh = -5, 5 kl, kh = -10, 10 compare = cmp if (type==float): il=1 compare = test_support.fcmp elif (type==int): jl=0 elif (type==long): jl,jh = 0, 15 for i in range(il, ih+1): for j in range(jl,jh+1): for k in range(kl, kh+1): if (k!=0): if compare(pow(type(i),j,k), pow(type(i),j)% type(k)): raise ValueError, "pow(" +str(i)+ "," +str(j)+ \ "," +str(k)+ ") != pow(" +str(i)+ "," + \ str(j)+ ") % " +str(k)
| 13,958
|
def getreply(self): """Get a reply from the server. Returns a tuple consisting of:
|
def getreply(self): """Get a reply from the server. Returns a tuple consisting of:
| 13,959
|
def getreply(self): """Get a reply from the server. Returns a tuple consisting of:
|
def try: errcode = string.atoi(code) except ValueError: errcode = -1 break getreply(self): try: errcode = string.atoi(code) except ValueError: errcode = -1 break """Get try: errcode = string.atoi(code) except ValueError: errcode = -1 break a try: errcode = string.atoi(code) except ValueError: errcode = -1 break reply try: errcode = string.atoi(code) except ValueError: errcode = -1 break from try: errcode = string.atoi(code) except ValueError: errcode = -1 break the try: errcode = string.atoi(code) except ValueError: errcode = -1 break server. try: errcode = string.atoi(code) except ValueError: errcode = -1 break try: errcode = string.atoi(code) except ValueError: errcode = -1 break Returns try: errcode = string.atoi(code) except ValueError: errcode = -1 break a try: errcode = string.atoi(code) except ValueError: errcode = -1 break tuple try: errcode = string.atoi(code) except ValueError: errcode = -1 break consisting try: errcode = string.atoi(code) except ValueError: errcode = -1 break of:
| 13,960
|
def getreply(self): """Get a reply from the server. Returns a tuple consisting of:
|
def getreply(self): """Get a reply from the server. Returns a tuple consisting of:
| 13,961
|
def find_config_files (self): """Find as many configuration files as should be processed for this platform, and return a list of filenames in the order in which they should be parsed. The filenames returned are guaranteed to exist (modulo nasty race conditions).
|
def find_config_files (self): """Find as many configuration files as should be processed for this platform, and return a list of filenames in the order in which they should be parsed. The filenames returned are guaranteed to exist (modulo nasty race conditions).
| 13,962
|
def test_mondo_message(self): eq = self.assertEqual neq = self.ndiffAssertEqual msg = self._msgobj('crispin-torture.txt') payload = msg.get_payload() eq(type(payload), ListType) eq(len(payload), 12) eq(msg.preamble, None) eq(msg.epilogue, '\n\n') # Probably the best way to verify the message is parsed correctly is to # dump its structure and compare it against the known structure. fp = StringIO() _structure(msg, fp=fp) neq(fp.getvalue(), """\
|
def test_mondo_message(self): eq = self.assertEqual neq = self.ndiffAssertEqual msg = self._msgobj('crispin-torture.txt') payload = msg.get_payload() eq(type(payload), ListType) eq(len(payload), 12) eq(msg.preamble, None) eq(msg.epilogue, '\n') # Probably the best way to verify the message is parsed correctly is to # dump its structure and compare it against the known structure. fp = StringIO() _structure(msg, fp=fp) neq(fp.getvalue(), """\
| 13,963
|
def remove_option(self, section, option): """Remove an option.""" if not section or section == "DEFAULT": sectdict = self.__defaults else: try: sectdict = self.__sections[section] except KeyError: raise NoSectionError(section) existed = sectdict.has_key(key) if existed: del sectdict[key] return existed
|
def remove_option(self, section, option): """Remove an option.""" if not section or section == "DEFAULT": sectdict = self.__defaults else: try: sectdict = self.__sections[section] except KeyError: raise NoSectionError(section) existed = sectdict.has_key(option) if existed: del sectdict[key] return existed
| 13,964
|
def remove_option(self, section, option): """Remove an option.""" if not section or section == "DEFAULT": sectdict = self.__defaults else: try: sectdict = self.__sections[section] except KeyError: raise NoSectionError(section) existed = sectdict.has_key(key) if existed: del sectdict[key] return existed
|
def remove_option(self, section, option): """Remove an option.""" if not section or section == "DEFAULT": sectdict = self.__defaults else: try: sectdict = self.__sections[section] except KeyError: raise NoSectionError(section) existed = sectdict.has_key(key) if existed: del sectdict[option] return existed
| 13,965
|
def subconvert(line, ofp, table, discards, autoclosing, endchar=None): stack = [] while line: if line[0] == endchar and not stack: return line[1:] m = _comment_rx.match(line) if m: text = m.group(1) if text: ofp.write("(COMMENT\n") ofp.write("- %s \n" % encode(text)) ofp.write(")COMMENT\n") ofp.write("-\\n\n")
|
def subconvert(line, ofp, table, discards, autoclosing, endchar=None): stack = [] while line: if line[0] == endchar and not stack: return line[1:] m = _comment_rx.match(line) if m: text = m.group(1) if text: ofp.write("(COMMENT\n") ofp.write("- %s \n" % encode(text)) ofp.write(")COMMENT\n") ofp.write("-\\n\n")
| 13,966
|
def convert(ifp, ofp, table={}, discards=(), autoclosing=()): try: subconvert(ifp.read(), ofp, table, discards, autoclosing) except IOError, (err, msg): if err != errno.EPIPE: raise
|
def convert(ifp, ofp, table={}, discards=(), autoclosing=()): try: subconvert(data, ofp, table, discards, autoclosing) except IOError, (err, msg): if err != errno.EPIPE: raise
| 13,967
|
def loadTestsFromName(self, name, module=None): """Return a suite of all tests cases given a string specifier.
|
def loadTestsFromName(self, name, module=None): """Return a suite of all tests cases given a string specifier.
| 13,968
|
... def g():
|
... def g():
| 13,969
|
... def f(self):
|
... def f(self):
| 13,970
|
def read_manifest (self):
|
def read_manifest (self):
| 13,971
|
def read_manifest (self):
|
def read_manifest (self):
| 13,972
|
def read_manifest (self):
|
def read_manifest (self):
| 13,973
|
def send(self, str): """Send `str' to the server.""" if self.debuglevel > 0: print 'send:', `str` self.sock.send(str)
|
def send(self, str): """Send `str' to the server.""" if self.debuglevel > 0: print 'send:', `str` self.sock.send(str)
| 13,974
|
def getreply(self): """Get a reply from the server. Returns a tuple consisting of: - server response code (e.g. '250', or such, if all goes well) Note: returns -1 if it can't read responce code. - server response string corresponding to response code
|
def getreply(self): """Get a reply from the server. Returns a tuple consisting of: - server response code (e.g. '250', or such, if all goes well) Note: returns -1 if it can't read responce code. - server response string corresponding to response code
| 13,975
|
def getreply(self): """Get a reply from the server. Returns a tuple consisting of: - server response code (e.g. '250', or such, if all goes well) Note: returns -1 if it can't read responce code. - server response string corresponding to response code
|
def getreply(self): """Get a reply from the server. Returns a tuple consisting of: - server response code (e.g. '250', or such, if all goes well) Note: returns -1 if it can't read responce code. - server response string corresponding to response code
| 13,976
|
def help(self): """ SMTP 'help' command. Returns help text from server """
|
def help(self): """ SMTP 'help' command. Returns help text from server """
| 13,977
|
def data(self,msg): """ SMTP 'DATA' command. Sends message data to server. Automatically quotes lines beginning with a period per rfc821 """
|
def data(self,msg): """ SMTP 'DATA' command. Sends message data to server. Automatically quotes lines beginning with a period per rfc821 """
| 13,978
|
def data(self,msg): """ SMTP 'DATA' command. Sends message data to server. Automatically quotes lines beginning with a period per rfc821 """
|
def data(self,msg): """ SMTP 'DATA' command. Sends message data to server. Automatically quotes lines beginning with a period per rfc821 """
| 13,979
|
def sendmail(self,from_addr,to_addrs,msg): """ This command performs an entire mail transaction. The arguments are: - from_addr : The address sending this mail. - to_addrs : a list of addresses to send this mail to - msg : the message to send.
|
def sendmail(self,from_addr,to_addrs,msg): """ This command performs an entire mail transaction. The arguments are: - from_addr : The address sending this mail. - to_addrs : a list of addresses to send this mail to - msg : the message to send.
| 13,980
|
def sendmail(self,from_addr,to_addrs,msg): """ This command performs an entire mail transaction. The arguments are: - from_addr : The address sending this mail. - to_addrs : a list of addresses to send this mail to - msg : the message to send.
|
def sendmail(self,from_addr,to_addrs,msg): """ This command performs an entire mail transaction. The arguments are: - from_addr : The address sending this mail. - to_addrs : a list of addresses to send this mail to - msg : the message to send.
| 13,981
|
def sendmail(self,from_addr,to_addrs,msg): """ This command performs an entire mail transaction. The arguments are: - from_addr : The address sending this mail. - to_addrs : a list of addresses to send this mail to - msg : the message to send.
|
def sendmail(self,from_addr,to_addrs,msg): """ This command performs an entire mail transaction. The arguments are: - from_addr : The address sending this mail. - to_addrs : a list of addresses to send this mail to - msg : the message to send.
| 13,982
|
def sendmail(self,from_addr,to_addrs,msg): """ This command performs an entire mail transaction. The arguments are: - from_addr : The address sending this mail. - to_addrs : a list of addresses to send this mail to - msg : the message to send.
|
def sendmail(self,from_addr,to_addrs,msg): """ This command performs an entire mail transaction. The arguments are: - from_addr : The address sending this mail. - to_addrs : a list of addresses to send this mail to - msg : the message to send.
| 13,983
|
def sendmail(self,from_addr,to_addrs,msg): """ This command performs an entire mail transaction. The arguments are: - from_addr : The address sending this mail. - to_addrs : a list of addresses to send this mail to - msg : the message to send.
|
def sendmail(self,from_addr,to_addrs,msg): """ This command performs an entire mail transaction. The arguments are: - from_addr : The address sending this mail. - to_addrs : a list of addresses to send this mail to - msg : the message to send.
| 13,984
|
def __init__(self): self.reset() if self.elements is XMLParser.elements: self.__fixelements()
|
def __init__(self): self.reset() if self.elements is XMLParser.elements: self.__fixelements()
| 13,985
|
def translate_references(self, data, all = 1): i = 0 while 1: res = amp.search(data, i) if res is None: return data res = ref.match(data, res.start(0)) if res is None: self.syntax_error("bogus `&'") i =i+1 continue i = res.end(0) if data[i - 1] != ';': self.syntax_error("`;' missing after entity/char reference") i = i-1 str = res.group(1) pre = data[:res.start(0)] post = data[i:] if str[0] == '#': if str[1] == 'x': str = chr(string.atoi(str[2:], 16)) else: str = chr(string.atoi(str[1:])) data = pre + str + post i = res.start(0)+len(str) elif all: if self.entitydefs.has_key(str): data = pre + self.entitydefs[str] + post i = res.start(0) # rescan substituted text else: self.syntax_error('reference to unknown entity') # can't do it, so keep the entity ref in data = pre + '&' + str + ';' + post i = res.start(0) + len(str) + 2 else: # just translating character references pass # i is already postioned correctly
|
def translate_references(self, data, all = 1): i = 0 while 1: res = amp.search(data, i) if res is None: return data res = ref.match(data, res.start(0)) if res is None: self.syntax_error("bogus `&'") i =i+1 continue i = res.end(0) if data[i - 1] != ';': self.syntax_error("`;' missing after entity/char reference") i = i-1 str = res.group(1) pre = data[:res.start(0)] post = data[i:] if str[0] == '#': if str[1] == 'x': str = chr(string.atoi(str[2:], 16)) else: str = chr(string.atoi(str[1:])) data = pre + str + post i = res.start(0)+len(str) elif all: if self.entitydefs.has_key(str): data = pre + self.entitydefs[str] + post i = res.start(0) # rescan substituted text else: self.syntax_error("reference to unknown entity `&%s;'" % str) # can't do it, so keep the entity ref in data = pre + '&' + str + ';' + post i = res.start(0) + len(str) + 2 else: # just translating character references pass # i is already postioned correctly
| 13,986
|
def goahead(self, end): rawdata = self.rawdata i = 0 n = len(rawdata) while i < n: if i > 0: self.__at_start = 0 if self.nomoretags: data = rawdata[i:n] self.handle_data(data) self.lineno = self.lineno + string.count(data, '\n') i = n break res = interesting.search(rawdata, i) if res: j = res.start(0) else: j = n if i < j: data = rawdata[i:j] if self.__at_start and space.match(data) is None: self.syntax_error('illegal data at start of file') self.__at_start = 0 if not self.stack and space.match(data) is None: self.syntax_error('data not in content') if illegal.search(data): self.syntax_error('illegal character in content') self.handle_data(data) self.lineno = self.lineno + string.count(data, '\n') i = j if i == n: break if rawdata[i] == '<': if starttagopen.match(rawdata, i): if self.literal: data = rawdata[i] self.handle_data(data) self.lineno = self.lineno + string.count(data, '\n') i = i+1 continue k = self.parse_starttag(i) if k < 0: break self.__seen_starttag = 1 self.lineno = self.lineno + string.count(rawdata[i:k], '\n') i = k continue if endtagopen.match(rawdata, i): k = self.parse_endtag(i) if k < 0: break self.lineno = self.lineno + string.count(rawdata[i:k], '\n') i = k continue if commentopen.match(rawdata, i): if self.literal: data = rawdata[i] self.handle_data(data) self.lineno = self.lineno + string.count(data, '\n') i = i+1 continue k = self.parse_comment(i) if k < 0: break self.lineno = self.lineno + string.count(rawdata[i:k], '\n') i = k continue if cdataopen.match(rawdata, i): k = self.parse_cdata(i) if k < 0: break self.lineno = self.lineno + string.count(rawdata[i:i], '\n') i = k continue res = xmldecl.match(rawdata, i) if res: if not self.__at_start: self.syntax_error("<?xml?> declaration not at start of document") version, encoding, standalone = res.group('version', 'encoding', 'standalone') if version[1:-1] != '1.0': raise RuntimeError, 'only XML version 1.0 supported' if encoding: encoding = encoding[1:-1] if standalone: standalone = standalone[1:-1] self.handle_xml(encoding, standalone) i = res.end(0) continue res = procopen.match(rawdata, i) if res: k = self.parse_proc(i) if k < 0: break self.lineno = self.lineno + string.count(rawdata[i:k], '\n') i = k continue res = doctype.match(rawdata, i) if res: if self.literal: data = rawdata[i] self.handle_data(data) self.lineno = self.lineno + string.count(data, '\n') i = i+1 continue if self.__seen_doctype: self.syntax_error('multiple DOCTYPE elements') if self.__seen_starttag: self.syntax_error('DOCTYPE not at beginning of document') k = self.parse_doctype(res) if k < 0: break self.__seen_doctype = res.group('name') self.lineno = self.lineno + string.count(rawdata[i:k], '\n') i = k continue elif rawdata[i] == '&': if self.literal: data = rawdata[i] self.handle_data(data) i = i+1 continue res = charref.match(rawdata, i) if res is not None: i = res.end(0) if rawdata[i-1] != ';': self.syntax_error("`;' missing in charref") i = i-1 if not self.stack: self.syntax_error('data not in content') self.handle_charref(res.group('char')[:-1]) self.lineno = self.lineno + string.count(res.group(0), '\n') continue res = entityref.match(rawdata, i) if res is not None: i = res.end(0) if rawdata[i-1] != ';': self.syntax_error("`;' missing in entityref") i = i-1 name = res.group('name') if self.entitydefs.has_key(name): self.rawdata = rawdata = rawdata[:res.start(0)] + self.entitydefs[name] + rawdata[i:] n = len(rawdata) i = res.start(0) else: self.syntax_error('reference to unknown entity') self.unknown_entityref(name) self.lineno = self.lineno + string.count(res.group(0), '\n') continue elif rawdata[i] == ']': if self.literal: data = rawdata[i] self.handle_data(data) i = i+1 continue if n-i < 3: break if cdataclose.match(rawdata, i): self.syntax_error("bogus `]]>'") self.handle_data(rawdata[i]) i = i+1 continue else: raise RuntimeError, 'neither < nor & ??' # We get here only if incomplete matches but # nothing else break # end while if i > 0: self.__at_start = 0 if end and i < n: data = rawdata[i] self.syntax_error("bogus `%s'" % data) if illegal.search(data): self.syntax_error('illegal character in content') self.handle_data(data) self.lineno = self.lineno + string.count(data, '\n') self.rawdata = rawdata[i+1:] return self.goahead(end) self.rawdata = rawdata[i:] if end: if not self.__seen_starttag: self.syntax_error('no elements in file') if self.stack: self.syntax_error('missing end tags') while self.stack: self.finish_endtag(self.stack[-1][0])
|
def goahead(self, end): rawdata = self.rawdata i = 0 n = len(rawdata) while i < n: if i > 0: self.__at_start = 0 if self.nomoretags: data = rawdata[i:n] self.handle_data(data) self.lineno = self.lineno + string.count(data, '\n') i = n break res = interesting.search(rawdata, i) if res: j = res.start(0) else: j = n if i < j: data = rawdata[i:j] if self.__at_start and space.match(data) is None: self.syntax_error('illegal data at start of file') self.__at_start = 0 if not self.stack and space.match(data) is None: self.syntax_error('data not in content') if illegal.search(data): self.syntax_error('illegal character in content') self.handle_data(data) self.lineno = self.lineno + string.count(data, '\n') i = j if i == n: break if rawdata[i] == '<': if starttagopen.match(rawdata, i): if self.literal: data = rawdata[i] self.handle_data(data) self.lineno = self.lineno + string.count(data, '\n') i = i+1 continue k = self.parse_starttag(i) if k < 0: break self.__seen_starttag = 1 self.lineno = self.lineno + string.count(rawdata[i:k], '\n') i = k continue if endtagopen.match(rawdata, i): k = self.parse_endtag(i) if k < 0: break self.lineno = self.lineno + string.count(rawdata[i:k], '\n') i = k continue if commentopen.match(rawdata, i): if self.literal: data = rawdata[i] self.handle_data(data) self.lineno = self.lineno + string.count(data, '\n') i = i+1 continue k = self.parse_comment(i) if k < 0: break self.lineno = self.lineno + string.count(rawdata[i:k], '\n') i = k continue if cdataopen.match(rawdata, i): k = self.parse_cdata(i) if k < 0: break self.lineno = self.lineno + string.count(rawdata[i:i], '\n') i = k continue res = xmldecl.match(rawdata, i) if res: if not self.__at_start: self.syntax_error("<?xml?> declaration not at start of document") version, encoding, standalone = res.group('version', 'encoding', 'standalone') if version[1:-1] != '1.0': raise RuntimeError, 'only XML version 1.0 supported' if encoding: encoding = encoding[1:-1] if standalone: standalone = standalone[1:-1] self.handle_xml(encoding, standalone) i = res.end(0) continue res = procopen.match(rawdata, i) if res: k = self.parse_proc(i) if k < 0: break self.lineno = self.lineno + string.count(rawdata[i:k], '\n') i = k continue res = doctype.match(rawdata, i) if res: if self.literal: data = rawdata[i] self.handle_data(data) self.lineno = self.lineno + string.count(data, '\n') i = i+1 continue if self.__seen_doctype: self.syntax_error('multiple DOCTYPE elements') if self.__seen_starttag: self.syntax_error('DOCTYPE not at beginning of document') k = self.parse_doctype(res) if k < 0: break self.__seen_doctype = res.group('name') self.lineno = self.lineno + string.count(rawdata[i:k], '\n') i = k continue elif rawdata[i] == '&': if self.literal: data = rawdata[i] self.handle_data(data) i = i+1 continue res = charref.match(rawdata, i) if res is not None: i = res.end(0) if rawdata[i-1] != ';': self.syntax_error("`;' missing in charref") i = i-1 if not self.stack: self.syntax_error('data not in content') self.handle_charref(res.group('char')[:-1]) self.lineno = self.lineno + string.count(res.group(0), '\n') continue res = entityref.match(rawdata, i) if res is not None: i = res.end(0) if rawdata[i-1] != ';': self.syntax_error("`;' missing in entityref") i = i-1 name = res.group('name') if self.entitydefs.has_key(name): self.rawdata = rawdata = rawdata[:res.start(0)] + self.entitydefs[name] + rawdata[i:] n = len(rawdata) i = res.start(0) else: self.syntax_error("reference to unknown entity `&%s;'" % name) self.unknown_entityref(name) self.lineno = self.lineno + string.count(res.group(0), '\n') continue elif rawdata[i] == ']': if self.literal: data = rawdata[i] self.handle_data(data) i = i+1 continue if n-i < 3: break if cdataclose.match(rawdata, i): self.syntax_error("bogus `]]>'") self.handle_data(rawdata[i]) i = i+1 continue else: raise RuntimeError, 'neither < nor & ??' # We get here only if incomplete matches but # nothing else break # end while if i > 0: self.__at_start = 0 if end and i < n: data = rawdata[i] self.syntax_error("bogus `%s'" % data) if illegal.search(data): self.syntax_error('illegal character in content') self.handle_data(data) self.lineno = self.lineno + string.count(data, '\n') self.rawdata = rawdata[i+1:] return self.goahead(end) self.rawdata = rawdata[i:] if end: if not self.__seen_starttag: self.syntax_error('no elements in file') if self.stack: self.syntax_error('missing end tags') while self.stack: self.finish_endtag(self.stack[-1][0])
| 13,987
|
def _getElementsByTagNameNSHelper(parent, nsURI, localName, rc): for node in parent.childNodes: if node.nodeType == Node.ELEMENT_NODE: if ((localName == "*" or node.tagName == localName) and (nsURI == "*" or node.namespaceURI == nsURI)): rc.append(node) _getElementsByTagNameNSHelper(node, nsURI, localName, rc) return rc
|
defchildNodeTypes = (Node.TEXT_NODE, Node.ENTITY_REFERENCE_NODE) _getElementsByTagNameNSHelper(parent,childNodeTypes = (Node.TEXT_NODE, Node.ENTITY_REFERENCE_NODE) nsURI,childNodeTypes = (Node.TEXT_NODE, Node.ENTITY_REFERENCE_NODE) localName,childNodeTypes = (Node.TEXT_NODE, Node.ENTITY_REFERENCE_NODE) rc):childNodeTypes = (Node.TEXT_NODE, Node.ENTITY_REFERENCE_NODE) forchildNodeTypes = (Node.TEXT_NODE, Node.ENTITY_REFERENCE_NODE) nodechildNodeTypes = (Node.TEXT_NODE, Node.ENTITY_REFERENCE_NODE) inchildNodeTypes = (Node.TEXT_NODE, Node.ENTITY_REFERENCE_NODE) parent.childNodes:childNodeTypes = (Node.TEXT_NODE, Node.ENTITY_REFERENCE_NODE) ifchildNodeTypes = (Node.TEXT_NODE, Node.ENTITY_REFERENCE_NODE) node.nodeTypechildNodeTypes = (Node.TEXT_NODE, Node.ENTITY_REFERENCE_NODE) ==childNodeTypes = (Node.TEXT_NODE, Node.ENTITY_REFERENCE_NODE) Node.ELEMENT_NODE:childNodeTypes = (Node.TEXT_NODE, Node.ENTITY_REFERENCE_NODE) ifchildNodeTypes = (Node.TEXT_NODE, Node.ENTITY_REFERENCE_NODE) ((localNamechildNodeTypes = (Node.TEXT_NODE, Node.ENTITY_REFERENCE_NODE) ==childNodeTypes = (Node.TEXT_NODE, Node.ENTITY_REFERENCE_NODE) "*"childNodeTypes = (Node.TEXT_NODE, Node.ENTITY_REFERENCE_NODE) orchildNodeTypes = (Node.TEXT_NODE, Node.ENTITY_REFERENCE_NODE) node.tagNamechildNodeTypes = (Node.TEXT_NODE, Node.ENTITY_REFERENCE_NODE) ==childNodeTypes = (Node.TEXT_NODE, Node.ENTITY_REFERENCE_NODE) localName)childNodeTypes = (Node.TEXT_NODE, Node.ENTITY_REFERENCE_NODE) andchildNodeTypes = (Node.TEXT_NODE, Node.ENTITY_REFERENCE_NODE) (nsURIchildNodeTypes = (Node.TEXT_NODE, Node.ENTITY_REFERENCE_NODE) ==childNodeTypes = (Node.TEXT_NODE, Node.ENTITY_REFERENCE_NODE) "*"childNodeTypes = (Node.TEXT_NODE, Node.ENTITY_REFERENCE_NODE) orchildNodeTypes = (Node.TEXT_NODE, Node.ENTITY_REFERENCE_NODE) node.namespaceURIchildNodeTypes = (Node.TEXT_NODE, Node.ENTITY_REFERENCE_NODE) ==childNodeTypes = (Node.TEXT_NODE, Node.ENTITY_REFERENCE_NODE) nsURI)):childNodeTypes = (Node.TEXT_NODE, Node.ENTITY_REFERENCE_NODE) rc.append(node)childNodeTypes = (Node.TEXT_NODE, Node.ENTITY_REFERENCE_NODE) _getElementsByTagNameNSHelper(node,childNodeTypes = (Node.TEXT_NODE, Node.ENTITY_REFERENCE_NODE) nsURI,childNodeTypes = (Node.TEXT_NODE, Node.ENTITY_REFERENCE_NODE) localName,childNodeTypes = (Node.TEXT_NODE, Node.ENTITY_REFERENCE_NODE) rc)childNodeTypes = (Node.TEXT_NODE, Node.ENTITY_REFERENCE_NODE) returnchildNodeTypes = (Node.TEXT_NODE, Node.ENTITY_REFERENCE_NODE) rcchildNodeTypes = (Node.TEXT_NODE, Node.ENTITY_REFERENCE_NODE)
| 13,988
|
def __delitem__(self, attname_or_tuple): node = self[attname_or_tuple] node.unlink() del self._attrs[node.name] del self._attrsNS[(node.namespaceURI, node.localName)] self.length = len(self._attrs)
|
defchildNodeTypes = (Node.ELEMENT_NODE, Node.PROCESSING_INSTRUCTION_NODE, Node.COMMENT_NODE, Node.TEXT_NODE, Node.CDATA_SECTION_NODE, Node.ENTITY_REFERENCE_NODE) __delitem__(self,childNodeTypes = (Node.ELEMENT_NODE, Node.PROCESSING_INSTRUCTION_NODE, Node.COMMENT_NODE, Node.TEXT_NODE, Node.CDATA_SECTION_NODE, Node.ENTITY_REFERENCE_NODE) attname_or_tuple):childNodeTypes = (Node.ELEMENT_NODE, Node.PROCESSING_INSTRUCTION_NODE, Node.COMMENT_NODE, Node.TEXT_NODE, Node.CDATA_SECTION_NODE, Node.ENTITY_REFERENCE_NODE) nodechildNodeTypes = (Node.ELEMENT_NODE, Node.PROCESSING_INSTRUCTION_NODE, Node.COMMENT_NODE, Node.TEXT_NODE, Node.CDATA_SECTION_NODE, Node.ENTITY_REFERENCE_NODE) =childNodeTypes = (Node.ELEMENT_NODE, Node.PROCESSING_INSTRUCTION_NODE, Node.COMMENT_NODE, Node.TEXT_NODE, Node.CDATA_SECTION_NODE, Node.ENTITY_REFERENCE_NODE) self[attname_or_tuple]childNodeTypes = (Node.ELEMENT_NODE, Node.PROCESSING_INSTRUCTION_NODE, Node.COMMENT_NODE, Node.TEXT_NODE, Node.CDATA_SECTION_NODE, Node.ENTITY_REFERENCE_NODE) node.unlink()childNodeTypes = (Node.ELEMENT_NODE, Node.PROCESSING_INSTRUCTION_NODE, Node.COMMENT_NODE, Node.TEXT_NODE, Node.CDATA_SECTION_NODE, Node.ENTITY_REFERENCE_NODE) delchildNodeTypes = (Node.ELEMENT_NODE, Node.PROCESSING_INSTRUCTION_NODE, Node.COMMENT_NODE, Node.TEXT_NODE, Node.CDATA_SECTION_NODE, Node.ENTITY_REFERENCE_NODE) self._attrs[node.name]childNodeTypes = (Node.ELEMENT_NODE, Node.PROCESSING_INSTRUCTION_NODE, Node.COMMENT_NODE, Node.TEXT_NODE, Node.CDATA_SECTION_NODE, Node.ENTITY_REFERENCE_NODE) delchildNodeTypes = (Node.ELEMENT_NODE, Node.PROCESSING_INSTRUCTION_NODE, Node.COMMENT_NODE, Node.TEXT_NODE, Node.CDATA_SECTION_NODE, Node.ENTITY_REFERENCE_NODE) self._attrsNS[(node.namespaceURI,childNodeTypes = (Node.ELEMENT_NODE, Node.PROCESSING_INSTRUCTION_NODE, Node.COMMENT_NODE, Node.TEXT_NODE, Node.CDATA_SECTION_NODE, Node.ENTITY_REFERENCE_NODE) node.localName)]childNodeTypes = (Node.ELEMENT_NODE, Node.PROCESSING_INSTRUCTION_NODE, Node.COMMENT_NODE, Node.TEXT_NODE, Node.CDATA_SECTION_NODE, Node.ENTITY_REFERENCE_NODE) self.lengthchildNodeTypes = (Node.ELEMENT_NODE, Node.PROCESSING_INSTRUCTION_NODE, Node.COMMENT_NODE, Node.TEXT_NODE, Node.CDATA_SECTION_NODE, Node.ENTITY_REFERENCE_NODE) =childNodeTypes = (Node.ELEMENT_NODE, Node.PROCESSING_INSTRUCTION_NODE, Node.COMMENT_NODE, Node.TEXT_NODE, Node.CDATA_SECTION_NODE, Node.ENTITY_REFERENCE_NODE) len(self._attrs)
| 13,989
|
def _get_attributes(self): return AttributeList(self._attrs, self._attrsNS)
|
defchildNodeTypes = () _get_attributes(self):childNodeTypes = () returnchildNodeTypes = () AttributeList(self._attrs,childNodeTypes = () self._attrsNS)
| 13,990
|
def writexml(self, writer): writer.write("<!--%s-->" % self.data)
|
defchildNodeTypes = () writexml(self,childNodeTypes = () writer):childNodeTypes = () writer.write("<!--%s-->"childNodeTypes = () %childNodeTypes = () self.data)
| 13,991
|
def writexml(self, writer): writer.write("<?%s %s?>" % (self.target, self.data))
|
defchildNodeTypes = () writexml(self,childNodeTypes = () writer):childNodeTypes = () writer.write("<?%schildNodeTypes = () %s?>"childNodeTypes = () %childNodeTypes = () (self.target,childNodeTypes = () self.data))
| 13,992
|
def _parse(self, fp): """Override this method to support alternative .mo formats.""" unpack = struct.unpack filename = getattr(fp, 'name', '') # Parse the .mo file header, which consists of 5 little endian 32 # bit words. self._catalog = catalog = {} buf = fp.read() # Are we big endian or little endian? magic = unpack('<i', buf[:4])[0] if magic == self.LE_MAGIC: version, msgcount, masteridx, transidx = unpack('<4i', buf[4:20]) ii = '<ii' elif magic == self.BE_MAGIC: version, msgcount, masteridx, transidx = unpack('>4i', buf[4:20]) ii = '>ii' else: raise IOError(0, 'Bad magic number', filename) # # Now put all messages from the .mo file buffer into the catalog # dictionary. for i in xrange(0, msgcount): mlen, moff = unpack(ii, buf[masteridx:masteridx+8]) mend = moff + mlen tlen, toff = unpack(ii, buf[transidx:transidx+8]) tend = toff + tlen if mend < len(buf) and tend < len(buf): tmsg = buf[toff:tend] catalog[buf[moff:mend]] = tmsg else: raise IOError(0, 'File is corrupt', filename) # See if we're looking at GNU .mo conventions for metadata if mlen == 0 and tmsg.lower().startswith('project-id-version:'): # Catalog description for item in tmsg.split('\n'): item = item.strip() if not item: continue k, v = item.split(':', 1) k = k.strip().lower() v = v.strip() self._info[k] = v if k == 'content-type': self._charset = v.split('charset=')[1] # advance to next entry in the seek tables masteridx += 8 transidx += 8
|
def _parse(self, fp): """Override this method to support alternative .mo formats.""" unpack = struct.unpack filename = getattr(fp, 'name', '') # Parse the .mo file header, which consists of 5 little endian 32 # bit words. self._catalog = catalog = {} buf = fp.read() # Are we big endian or little endian? magic = unpack('<i', buf[:4])[0] & MASK if magic == self.LE_MAGIC: version, msgcount, masteridx, transidx = unpack('<4i', buf[4:20]) ii = '<ii' elif magic == self.BE_MAGIC: version, msgcount, masteridx, transidx = unpack('>4i', buf[4:20]) ii = '>ii' else: raise IOError(0, 'Bad magic number', filename) # # Now put all messages from the .mo file buffer into the catalog # dictionary. for i in xrange(0, msgcount): mlen, moff = unpack(ii, buf[masteridx:masteridx+8]) mend = moff + mlen tlen, toff = unpack(ii, buf[transidx:transidx+8]) tend = toff + tlen if mend < len(buf) and tend < len(buf): tmsg = buf[toff:tend] catalog[buf[moff:mend]] = tmsg else: raise IOError(0, 'File is corrupt', filename) # See if we're looking at GNU .mo conventions for metadata if mlen == 0 and tmsg.lower().startswith('project-id-version:'): # Catalog description for item in tmsg.split('\n'): item = item.strip() if not item: continue k, v = item.split(':', 1) k = k.strip().lower() v = v.strip() self._info[k] = v if k == 'content-type': self._charset = v.split('charset=')[1] # advance to next entry in the seek tables masteridx += 8 transidx += 8
| 13,993
|
def _parse(self, fp): """Override this method to support alternative .mo formats.""" unpack = struct.unpack filename = getattr(fp, 'name', '') # Parse the .mo file header, which consists of 5 little endian 32 # bit words. self._catalog = catalog = {} buf = fp.read() # Are we big endian or little endian? magic = unpack('<i', buf[:4])[0] if magic == self.LE_MAGIC: version, msgcount, masteridx, transidx = unpack('<4i', buf[4:20]) ii = '<ii' elif magic == self.BE_MAGIC: version, msgcount, masteridx, transidx = unpack('>4i', buf[4:20]) ii = '>ii' else: raise IOError(0, 'Bad magic number', filename) # # Now put all messages from the .mo file buffer into the catalog # dictionary. for i in xrange(0, msgcount): mlen, moff = unpack(ii, buf[masteridx:masteridx+8]) mend = moff + mlen tlen, toff = unpack(ii, buf[transidx:transidx+8]) tend = toff + tlen if mend < len(buf) and tend < len(buf): tmsg = buf[toff:tend] catalog[buf[moff:mend]] = tmsg else: raise IOError(0, 'File is corrupt', filename) # See if we're looking at GNU .mo conventions for metadata if mlen == 0 and tmsg.lower().startswith('project-id-version:'): # Catalog description for item in tmsg.split('\n'): item = item.strip() if not item: continue k, v = item.split(':', 1) k = k.strip().lower() v = v.strip() self._info[k] = v if k == 'content-type': self._charset = v.split('charset=')[1] # advance to next entry in the seek tables masteridx += 8 transidx += 8
|
def msgcount &= MASK masteridx &= MASK transidx &= MASK _parse(self, msgcount &= MASK masteridx &= MASK transidx &= MASK fp): msgcount &= MASK masteridx &= MASK transidx &= MASK """Override msgcount &= MASK masteridx &= MASK transidx &= MASK this msgcount &= MASK masteridx &= MASK transidx &= MASK method msgcount &= MASK masteridx &= MASK transidx &= MASK to msgcount &= MASK masteridx &= MASK transidx &= MASK support msgcount &= MASK masteridx &= MASK transidx &= MASK alternative msgcount &= MASK masteridx &= MASK transidx &= MASK .mo msgcount &= MASK masteridx &= MASK transidx &= MASK formats.""" msgcount &= MASK masteridx &= MASK transidx &= MASK unpack msgcount &= MASK masteridx &= MASK transidx &= MASK = msgcount &= MASK masteridx &= MASK transidx &= MASK struct.unpack msgcount &= MASK masteridx &= MASK transidx &= MASK filename msgcount &= MASK masteridx &= MASK transidx &= MASK = msgcount &= MASK masteridx &= MASK transidx &= MASK getattr(fp, msgcount &= MASK masteridx &= MASK transidx &= MASK 'name', msgcount &= MASK masteridx &= MASK transidx &= MASK '') msgcount &= MASK masteridx &= MASK transidx &= MASK # msgcount &= MASK masteridx &= MASK transidx &= MASK Parse msgcount &= MASK masteridx &= MASK transidx &= MASK the msgcount &= MASK masteridx &= MASK transidx &= MASK .mo msgcount &= MASK masteridx &= MASK transidx &= MASK file msgcount &= MASK masteridx &= MASK transidx &= MASK header, msgcount &= MASK masteridx &= MASK transidx &= MASK which msgcount &= MASK masteridx &= MASK transidx &= MASK consists msgcount &= MASK masteridx &= MASK transidx &= MASK of msgcount &= MASK masteridx &= MASK transidx &= MASK 5 msgcount &= MASK masteridx &= MASK transidx &= MASK little msgcount &= MASK masteridx &= MASK transidx &= MASK endian msgcount &= MASK masteridx &= MASK transidx &= MASK 32 msgcount &= MASK masteridx &= MASK transidx &= MASK # msgcount &= MASK masteridx &= MASK transidx &= MASK bit msgcount &= MASK masteridx &= MASK transidx &= MASK words. msgcount &= MASK masteridx &= MASK transidx &= MASK self._catalog msgcount &= MASK masteridx &= MASK transidx &= MASK = msgcount &= MASK masteridx &= MASK transidx &= MASK catalog msgcount &= MASK masteridx &= MASK transidx &= MASK = msgcount &= MASK masteridx &= MASK transidx &= MASK {} msgcount &= MASK masteridx &= MASK transidx &= MASK buf msgcount &= MASK masteridx &= MASK transidx &= MASK = msgcount &= MASK masteridx &= MASK transidx &= MASK fp.read() msgcount &= MASK masteridx &= MASK transidx &= MASK # msgcount &= MASK masteridx &= MASK transidx &= MASK Are msgcount &= MASK masteridx &= MASK transidx &= MASK we msgcount &= MASK masteridx &= MASK transidx &= MASK big msgcount &= MASK masteridx &= MASK transidx &= MASK endian msgcount &= MASK masteridx &= MASK transidx &= MASK or msgcount &= MASK masteridx &= MASK transidx &= MASK little msgcount &= MASK masteridx &= MASK transidx &= MASK endian? msgcount &= MASK masteridx &= MASK transidx &= MASK magic msgcount &= MASK masteridx &= MASK transidx &= MASK = msgcount &= MASK masteridx &= MASK transidx &= MASK unpack('<i', msgcount &= MASK masteridx &= MASK transidx &= MASK buf[:4])[0] msgcount &= MASK masteridx &= MASK transidx &= MASK if msgcount &= MASK masteridx &= MASK transidx &= MASK magic msgcount &= MASK masteridx &= MASK transidx &= MASK == msgcount &= MASK masteridx &= MASK transidx &= MASK self.LE_MAGIC: msgcount &= MASK masteridx &= MASK transidx &= MASK version, msgcount &= MASK masteridx &= MASK transidx &= MASK msgcount, msgcount &= MASK masteridx &= MASK transidx &= MASK masteridx, msgcount &= MASK masteridx &= MASK transidx &= MASK transidx msgcount &= MASK masteridx &= MASK transidx &= MASK = msgcount &= MASK masteridx &= MASK transidx &= MASK unpack('<4i', msgcount &= MASK masteridx &= MASK transidx &= MASK buf[4:20]) msgcount &= MASK masteridx &= MASK transidx &= MASK ii msgcount &= MASK masteridx &= MASK transidx &= MASK = msgcount &= MASK masteridx &= MASK transidx &= MASK '<ii' msgcount &= MASK masteridx &= MASK transidx &= MASK elif msgcount &= MASK masteridx &= MASK transidx &= MASK magic msgcount &= MASK masteridx &= MASK transidx &= MASK == msgcount &= MASK masteridx &= MASK transidx &= MASK self.BE_MAGIC: msgcount &= MASK masteridx &= MASK transidx &= MASK version, msgcount &= MASK masteridx &= MASK transidx &= MASK msgcount, msgcount &= MASK masteridx &= MASK transidx &= MASK masteridx, msgcount &= MASK masteridx &= MASK transidx &= MASK transidx msgcount &= MASK masteridx &= MASK transidx &= MASK = msgcount &= MASK masteridx &= MASK transidx &= MASK unpack('>4i', msgcount &= MASK masteridx &= MASK transidx &= MASK buf[4:20]) msgcount &= MASK masteridx &= MASK transidx &= MASK ii msgcount &= MASK masteridx &= MASK transidx &= MASK = msgcount &= MASK masteridx &= MASK transidx &= MASK '>ii' msgcount &= MASK masteridx &= MASK transidx &= MASK else: msgcount &= MASK masteridx &= MASK transidx &= MASK raise msgcount &= MASK masteridx &= MASK transidx &= MASK IOError(0, msgcount &= MASK masteridx &= MASK transidx &= MASK 'Bad msgcount &= MASK masteridx &= MASK transidx &= MASK magic msgcount &= MASK masteridx &= MASK transidx &= MASK number', msgcount &= MASK masteridx &= MASK transidx &= MASK filename) msgcount &= MASK masteridx &= MASK transidx &= MASK # msgcount &= MASK masteridx &= MASK transidx &= MASK # msgcount &= MASK masteridx &= MASK transidx &= MASK Now msgcount &= MASK masteridx &= MASK transidx &= MASK put msgcount &= MASK masteridx &= MASK transidx &= MASK all msgcount &= MASK masteridx &= MASK transidx &= MASK messages msgcount &= MASK masteridx &= MASK transidx &= MASK from msgcount &= MASK masteridx &= MASK transidx &= MASK the msgcount &= MASK masteridx &= MASK transidx &= MASK .mo msgcount &= MASK masteridx &= MASK transidx &= MASK file msgcount &= MASK masteridx &= MASK transidx &= MASK buffer msgcount &= MASK masteridx &= MASK transidx &= MASK into msgcount &= MASK masteridx &= MASK transidx &= MASK the msgcount &= MASK masteridx &= MASK transidx &= MASK catalog msgcount &= MASK masteridx &= MASK transidx &= MASK # msgcount &= MASK masteridx &= MASK transidx &= MASK dictionary. msgcount &= MASK masteridx &= MASK transidx &= MASK for msgcount &= MASK masteridx &= MASK transidx &= MASK i msgcount &= MASK masteridx &= MASK transidx &= MASK in msgcount &= MASK masteridx &= MASK transidx &= MASK xrange(0, msgcount &= MASK masteridx &= MASK transidx &= MASK msgcount): msgcount &= MASK masteridx &= MASK transidx &= MASK mlen, msgcount &= MASK masteridx &= MASK transidx &= MASK moff msgcount &= MASK masteridx &= MASK transidx &= MASK = msgcount &= MASK masteridx &= MASK transidx &= MASK unpack(ii, msgcount &= MASK masteridx &= MASK transidx &= MASK buf[masteridx:masteridx+8]) msgcount &= MASK masteridx &= MASK transidx &= MASK mend msgcount &= MASK masteridx &= MASK transidx &= MASK = msgcount &= MASK masteridx &= MASK transidx &= MASK moff msgcount &= MASK masteridx &= MASK transidx &= MASK + msgcount &= MASK masteridx &= MASK transidx &= MASK mlen msgcount &= MASK masteridx &= MASK transidx &= MASK tlen, msgcount &= MASK masteridx &= MASK transidx &= MASK toff msgcount &= MASK masteridx &= MASK transidx &= MASK = msgcount &= MASK masteridx &= MASK transidx &= MASK unpack(ii, msgcount &= MASK masteridx &= MASK transidx &= MASK buf[transidx:transidx+8]) msgcount &= MASK masteridx &= MASK transidx &= MASK tend msgcount &= MASK masteridx &= MASK transidx &= MASK = msgcount &= MASK masteridx &= MASK transidx &= MASK toff msgcount &= MASK masteridx &= MASK transidx &= MASK + msgcount &= MASK masteridx &= MASK transidx &= MASK tlen msgcount &= MASK masteridx &= MASK transidx &= MASK if msgcount &= MASK masteridx &= MASK transidx &= MASK mend msgcount &= MASK masteridx &= MASK transidx &= MASK < msgcount &= MASK masteridx &= MASK transidx &= MASK len(buf) msgcount &= MASK masteridx &= MASK transidx &= MASK and msgcount &= MASK masteridx &= MASK transidx &= MASK tend msgcount &= MASK masteridx &= MASK transidx &= MASK < msgcount &= MASK masteridx &= MASK transidx &= MASK len(buf): msgcount &= MASK masteridx &= MASK transidx &= MASK tmsg msgcount &= MASK masteridx &= MASK transidx &= MASK = msgcount &= MASK masteridx &= MASK transidx &= MASK buf[toff:tend] msgcount &= MASK masteridx &= MASK transidx &= MASK catalog[buf[moff:mend]] msgcount &= MASK masteridx &= MASK transidx &= MASK = msgcount &= MASK masteridx &= MASK transidx &= MASK tmsg msgcount &= MASK masteridx &= MASK transidx &= MASK else: msgcount &= MASK masteridx &= MASK transidx &= MASK raise msgcount &= MASK masteridx &= MASK transidx &= MASK IOError(0, msgcount &= MASK masteridx &= MASK transidx &= MASK 'File msgcount &= MASK masteridx &= MASK transidx &= MASK is msgcount &= MASK masteridx &= MASK transidx &= MASK corrupt', msgcount &= MASK masteridx &= MASK transidx &= MASK filename) msgcount &= MASK masteridx &= MASK transidx &= MASK # msgcount &= MASK masteridx &= MASK transidx &= MASK See msgcount &= MASK masteridx &= MASK transidx &= MASK if msgcount &= MASK masteridx &= MASK transidx &= MASK we're msgcount &= MASK masteridx &= MASK transidx &= MASK looking msgcount &= MASK masteridx &= MASK transidx &= MASK at msgcount &= MASK masteridx &= MASK transidx &= MASK GNU msgcount &= MASK masteridx &= MASK transidx &= MASK .mo msgcount &= MASK masteridx &= MASK transidx &= MASK conventions msgcount &= MASK masteridx &= MASK transidx &= MASK for msgcount &= MASK masteridx &= MASK transidx &= MASK metadata msgcount &= MASK masteridx &= MASK transidx &= MASK if msgcount &= MASK masteridx &= MASK transidx &= MASK mlen msgcount &= MASK masteridx &= MASK transidx &= MASK == msgcount &= MASK masteridx &= MASK transidx &= MASK 0 msgcount &= MASK masteridx &= MASK transidx &= MASK and msgcount &= MASK masteridx &= MASK transidx &= MASK tmsg.lower().startswith('project-id-version:'): msgcount &= MASK masteridx &= MASK transidx &= MASK # msgcount &= MASK masteridx &= MASK transidx &= MASK Catalog msgcount &= MASK masteridx &= MASK transidx &= MASK description msgcount &= MASK masteridx &= MASK transidx &= MASK for msgcount &= MASK masteridx &= MASK transidx &= MASK item msgcount &= MASK masteridx &= MASK transidx &= MASK in msgcount &= MASK masteridx &= MASK transidx &= MASK tmsg.split('\n'): msgcount &= MASK masteridx &= MASK transidx &= MASK item msgcount &= MASK masteridx &= MASK transidx &= MASK = msgcount &= MASK masteridx &= MASK transidx &= MASK item.strip() msgcount &= MASK masteridx &= MASK transidx &= MASK if msgcount &= MASK masteridx &= MASK transidx &= MASK not msgcount &= MASK masteridx &= MASK transidx &= MASK item: msgcount &= MASK masteridx &= MASK transidx &= MASK continue msgcount &= MASK masteridx &= MASK transidx &= MASK k, msgcount &= MASK masteridx &= MASK transidx &= MASK v msgcount &= MASK masteridx &= MASK transidx &= MASK = msgcount &= MASK masteridx &= MASK transidx &= MASK item.split(':', msgcount &= MASK masteridx &= MASK transidx &= MASK 1) msgcount &= MASK masteridx &= MASK transidx &= MASK k msgcount &= MASK masteridx &= MASK transidx &= MASK = msgcount &= MASK masteridx &= MASK transidx &= MASK k.strip().lower() msgcount &= MASK masteridx &= MASK transidx &= MASK v msgcount &= MASK masteridx &= MASK transidx &= MASK = msgcount &= MASK masteridx &= MASK transidx &= MASK v.strip() msgcount &= MASK masteridx &= MASK transidx &= MASK self._info[k] msgcount &= MASK masteridx &= MASK transidx &= MASK = msgcount &= MASK masteridx &= MASK transidx &= MASK v msgcount &= MASK masteridx &= MASK transidx &= MASK if msgcount &= MASK masteridx &= MASK transidx &= MASK k msgcount &= MASK masteridx &= MASK transidx &= MASK == msgcount &= MASK masteridx &= MASK transidx &= MASK 'content-type': msgcount &= MASK masteridx &= MASK transidx &= MASK self._charset msgcount &= MASK masteridx &= MASK transidx &= MASK = msgcount &= MASK masteridx &= MASK transidx &= MASK v.split('charset=')[1] msgcount &= MASK masteridx &= MASK transidx &= MASK # msgcount &= MASK masteridx &= MASK transidx &= MASK advance msgcount &= MASK masteridx &= MASK transidx &= MASK to msgcount &= MASK masteridx &= MASK transidx &= MASK next msgcount &= MASK masteridx &= MASK transidx &= MASK entry msgcount &= MASK masteridx &= MASK transidx &= MASK in msgcount &= MASK masteridx &= MASK transidx &= MASK the msgcount &= MASK masteridx &= MASK transidx &= MASK seek msgcount &= MASK masteridx &= MASK transidx &= MASK tables msgcount &= MASK masteridx &= MASK transidx &= MASK masteridx msgcount &= MASK masteridx &= MASK transidx &= MASK += msgcount &= MASK masteridx &= MASK transidx &= MASK 8 msgcount &= MASK masteridx &= MASK transidx &= MASK transidx msgcount &= MASK masteridx &= MASK transidx &= MASK += msgcount &= MASK masteridx &= MASK transidx &= MASK 8
| 13,994
|
def _parse(self, fp): """Override this method to support alternative .mo formats.""" unpack = struct.unpack filename = getattr(fp, 'name', '') # Parse the .mo file header, which consists of 5 little endian 32 # bit words. self._catalog = catalog = {} buf = fp.read() # Are we big endian or little endian? magic = unpack('<i', buf[:4])[0] if magic == self.LE_MAGIC: version, msgcount, masteridx, transidx = unpack('<4i', buf[4:20]) ii = '<ii' elif magic == self.BE_MAGIC: version, msgcount, masteridx, transidx = unpack('>4i', buf[4:20]) ii = '>ii' else: raise IOError(0, 'Bad magic number', filename) # # Now put all messages from the .mo file buffer into the catalog # dictionary. for i in xrange(0, msgcount): mlen, moff = unpack(ii, buf[masteridx:masteridx+8]) mend = moff + mlen tlen, toff = unpack(ii, buf[transidx:transidx+8]) tend = toff + tlen if mend < len(buf) and tend < len(buf): tmsg = buf[toff:tend] catalog[buf[moff:mend]] = tmsg else: raise IOError(0, 'File is corrupt', filename) # See if we're looking at GNU .mo conventions for metadata if mlen == 0 and tmsg.lower().startswith('project-id-version:'): # Catalog description for item in tmsg.split('\n'): item = item.strip() if not item: continue k, v = item.split(':', 1) k = k.strip().lower() v = v.strip() self._info[k] = v if k == 'content-type': self._charset = v.split('charset=')[1] # advance to next entry in the seek tables masteridx += 8 transidx += 8
|
def _parse(self, fp): """Override this method to support alternative .mo formats.""" unpack = struct.unpack filename = getattr(fp, 'name', '') # Parse the .mo file header, which consists of 5 little endian 32 # bit words. self._catalog = catalog = {} buf = fp.read() # Are we big endian or little endian? magic = unpack('<i', buf[:4])[0] if magic == self.LE_MAGIC: version, msgcount, masteridx, transidx = unpack('<4i', buf[4:20]) ii = '<ii' elif magic == self.BE_MAGIC: version, msgcount, masteridx, transidx = unpack('>4i', buf[4:20]) ii = '>ii' else: raise IOError(0, 'Bad magic number', filename) # # Now put all messages from the .mo file buffer into the catalog # dictionary. for i in xrange(0, msgcount): mlen, moff = unpack(ii, buf[masteridx:masteridx+8]) moff &= MASK mend = moff + (mlen & MASK) tlen, toff = unpack(ii, buf[transidx:transidx+8]) tend = toff + tlen if mend < len(buf) and tend < len(buf): tmsg = buf[toff:tend] catalog[buf[moff:mend]] = tmsg else: raise IOError(0, 'File is corrupt', filename) # See if we're looking at GNU .mo conventions for metadata if mlen == 0 and tmsg.lower().startswith('project-id-version:'): # Catalog description for item in tmsg.split('\n'): item = item.strip() if not item: continue k, v = item.split(':', 1) k = k.strip().lower() v = v.strip() self._info[k] = v if k == 'content-type': self._charset = v.split('charset=')[1] # advance to next entry in the seek tables masteridx += 8 transidx += 8
| 13,995
|
def _parse(self, fp): """Override this method to support alternative .mo formats.""" unpack = struct.unpack filename = getattr(fp, 'name', '') # Parse the .mo file header, which consists of 5 little endian 32 # bit words. self._catalog = catalog = {} buf = fp.read() # Are we big endian or little endian? magic = unpack('<i', buf[:4])[0] if magic == self.LE_MAGIC: version, msgcount, masteridx, transidx = unpack('<4i', buf[4:20]) ii = '<ii' elif magic == self.BE_MAGIC: version, msgcount, masteridx, transidx = unpack('>4i', buf[4:20]) ii = '>ii' else: raise IOError(0, 'Bad magic number', filename) # # Now put all messages from the .mo file buffer into the catalog # dictionary. for i in xrange(0, msgcount): mlen, moff = unpack(ii, buf[masteridx:masteridx+8]) mend = moff + mlen tlen, toff = unpack(ii, buf[transidx:transidx+8]) tend = toff + tlen if mend < len(buf) and tend < len(buf): tmsg = buf[toff:tend] catalog[buf[moff:mend]] = tmsg else: raise IOError(0, 'File is corrupt', filename) # See if we're looking at GNU .mo conventions for metadata if mlen == 0 and tmsg.lower().startswith('project-id-version:'): # Catalog description for item in tmsg.split('\n'): item = item.strip() if not item: continue k, v = item.split(':', 1) k = k.strip().lower() v = v.strip() self._info[k] = v if k == 'content-type': self._charset = v.split('charset=')[1] # advance to next entry in the seek tables masteridx += 8 transidx += 8
|
def _parse(self, fp): """Override this method to support alternative .mo formats.""" unpack = struct.unpack filename = getattr(fp, 'name', '') # Parse the .mo file header, which consists of 5 little endian 32 # bit words. self._catalog = catalog = {} buf = fp.read() # Are we big endian or little endian? magic = unpack('<i', buf[:4])[0] if magic == self.LE_MAGIC: version, msgcount, masteridx, transidx = unpack('<4i', buf[4:20]) ii = '<ii' elif magic == self.BE_MAGIC: version, msgcount, masteridx, transidx = unpack('>4i', buf[4:20]) ii = '>ii' else: raise IOError(0, 'Bad magic number', filename) # # Now put all messages from the .mo file buffer into the catalog # dictionary. for i in xrange(0, msgcount): mlen, moff = unpack(ii, buf[masteridx:masteridx+8]) mend = moff + mlen tlen, toff = unpack(ii, buf[transidx:transidx+8]) toff &= MASK tend = toff + (tlen & MASK) if mend < buflen and tend < buflen: tmsg = buf[toff:tend] catalog[buf[moff:mend]] = tmsg else: raise IOError(0, 'File is corrupt', filename) # See if we're looking at GNU .mo conventions for metadata if mlen == 0 and tmsg.lower().startswith('project-id-version:'): # Catalog description for item in tmsg.split('\n'): item = item.strip() if not item: continue k, v = item.split(':', 1) k = k.strip().lower() v = v.strip() self._info[k] = v if k == 'content-type': self._charset = v.split('charset=')[1] # advance to next entry in the seek tables masteridx += 8 transidx += 8
| 13,996
|
def _getElementsByTagNameNSHelper(parent, nsURI, localName, rc): for node in parent.childNodes: if node.nodeType == Node.ELEMENT_NODE: if ((localName == "*" or node.tagName == localName) and (nsURI == "*" or node.namespaceURI == nsURI)): rc.append(node) _getElementsByTagNameNSHelper(node, nsURI, localName, rc) return rc
|
def _getElementsByTagNameNSHelper(parent, nsURI, localName, rc): for node in parent.childNodes: if node.nodeType == Node.ELEMENT_NODE: if ((localName == "*" or node.localName == localName) and (nsURI == "*" or node.namespaceURI == nsURI)): rc.append(node) _getElementsByTagNameNSHelper(node, nsURI, localName, rc) return rc
| 13,997
|
def getElementsByTagNameNS(self, namespaceURI, localName): _getElementsByTagNameNSHelper(self, namespaceURI, localName, [])
|
def getElementsByTagNameNS(self, namespaceURI, localName): _getElementsByTagNameNSHelper(self, namespaceURI, localName, [])
| 13,998
|
def getElementsByTagNameNS(self, namespaceURI, localName): _getElementsByTagNameNSHelper(self, namespaceURI, localName)
|
def getElementsByTagNameNS(self, namespaceURI, localName): _getElementsByTagNameNSHelper(self, namespaceURI, localName)
| 13,999
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.