bugged
stringlengths 4
228k
| fixed
stringlengths 0
96.3M
| __index_level_0__
int64 0
481k
|
|---|---|---|
def _compile(pathname, timestamp): """Compile (and cache) a Python source file. The file specified by <pathname> is compiled to a code object and returned. Presuming the appropriate privileges exist, the bytecodes will be saved back to the filesystem for future imports. The source file's modification timestamp must be provided as a Long value. """ codestring = open(pathname, 'r').read() if codestring and codestring[-1] != '\n': codestring = codestring + '\n' code = __builtin__.compile(codestring, pathname, 'exec') # try to cache the compiled code try: f = open(pathname + _suffix_char, 'wb') except IOError: pass else: f.write('\0\0\0\0') f.write(struct.pack('<I', timestamp)) marshal.dump(code, f) f.flush() f.seek(0, 0) f.write(imp.get_magic()) f.close() return code
|
def _compile(pathname, timestamp): """Compile (and cache) a Python source file. The file specified by <pathname> is compiled to a code object and returned. Presuming the appropriate privileges exist, the bytecodes will be saved back to the filesystem for future imports. The source file's modification timestamp must be provided as a Long value. """ codestring = open(pathname, 'rU').read() if codestring and codestring[-1] != '\n': codestring = codestring + '\n' code = __builtin__.compile(codestring, pathname, 'exec') # try to cache the compiled code try: f = open(pathname + _suffix_char, 'wb') except IOError: pass else: f.write('\0\0\0\0') f.write(struct.pack('<I', timestamp)) marshal.dump(code, f) f.flush() f.seek(0, 0) f.write(imp.get_magic()) f.close() return code
| 11,800
|
def send(self, buffer): self.unfinished = self.unfinished + buffer i = 0 n = len(self.unfinished) while i < n: c = self.unfinished[i] i = i+1 if c != ESC: self.add_char(c) continue if i >= n: i = i-1 break c = self.unfinished[i] i = i+1 if c == 'c': self.reset() continue if c <> '[': self.msg('unrecognized: ESC %s', `c`) continue argstr = '' while i < n: c = self.unfinished[i] i = i+1 if c not in '0123456789;': break argstr = argstr + c else: i = i - len(argstr) break
|
def send(self, buffer): self.unfinished = self.unfinished + buffer i = 0 n = len(self.unfinished) while i < n: c = self.unfinished[i] i = i+1 if c != ESC: self.add_char(c) continue if i >= n: i = i-1 break c = self.unfinished[i] i = i+1 if c == 'c': self.reset() continue if c <> '[': self.msg('unrecognized: ESC %s', `c`) continue argstr = '' while i < n: c = self.unfinished[i] i = i+1 if c not in '0123456789;': break argstr = argstr + c else: i = i - len(argstr) - 2 break
| 11,801
|
def __trackarrow(self, chip, rgbtuple): # invert the last chip if self.__lastchip is not None: color = self.__canvas.itemcget(self.__lastchip, 'fill') self.__canvas.itemconfigure(self.__lastchip, outline=color) self.__lastchip = chip
|
def __trackarrow(self, chip, rgbtuple): # invert the last chip if self.__lastchip is not None: color = self.__canvas.itemcget(self.__lastchip, 'fill') self.__canvas.itemconfigure(self.__lastchip, outline=color) self.__lastchip = chip
| 11,802
|
def execvpe(file, args, env): """execv(file, args, env) Execute the executable file (which is searched for along $PATH) with argument list args and environment env , replacing the current process. args may be a list or tuple of strings. """ _execvpe(file, args, env)
|
def execvpe(file, args, env): """execv(file, args, env) Execute the executable file (which is searched for along $PATH) with argument list args and environment env , replacing the current process. args may be a list or tuple of strings. """ _execvpe(file, args, env)
| 11,803
|
def _execvpe(file, args, env=None): if env is not None: func = execve argrest = (args, env) else: func = execv argrest = (args,) env = environ global _notfound head, tail = path.split(file) if head: apply(func, (file,) + argrest) return if 'PATH' in env: envpath = env['PATH'] else: envpath = defpath PATH = envpath.split(pathsep) if not _notfound: if sys.platform[:4] == 'beos': # Process handling (fork, wait) under BeOS (up to 5.0) # doesn't interoperate reliably with the thread interlocking # that happens during an import. The actual error we need # is the same on BeOS for posix.open() et al., ENOENT. try: unlink('/_#.# ## #.#') except error, _notfound: pass else: import tempfile t = tempfile.mktemp() # Exec a file that is guaranteed not to exist try: execv(t, ('blah',)) except error, _notfound: pass exc, arg = error, _notfound for dir in PATH: fullname = path.join(dir, file) try: apply(func, (fullname,) + argrest) except error, (errno, msg): if errno != arg[0]: exc, arg = error, (errno, msg) raise exc, arg
|
def _execvpe(file, args, env=None): if env is not None: func = execve argrest = (args, env) else: func = execv argrest = (args,) env = environ head, tail = path.split(file) if head: apply(func, (file,) + argrest) return if 'PATH' in env: envpath = env['PATH'] else: envpath = defpath PATH = envpath.split(pathsep) if not _notfound: if sys.platform[:4] == 'beos': # Process handling (fork, wait) under BeOS (up to 5.0) # doesn't interoperate reliably with the thread interlocking # that happens during an import. The actual error we need # is the same on BeOS for posix.open() et al., ENOENT. try: unlink('/_#.# ## #.#') except error, _notfound: pass else: import tempfile t = tempfile.mktemp() # Exec a file that is guaranteed not to exist try: execv(t, ('blah',)) except error, _notfound: pass exc, arg = error, _notfound for dir in PATH: fullname = path.join(dir, file) try: apply(func, (fullname,) + argrest) except error, (errno, msg): if errno != arg[0]: exc, arg = error, (errno, msg) raise exc, arg
| 11,804
|
def _execvpe(file, args, env=None): if env is not None: func = execve argrest = (args, env) else: func = execv argrest = (args,) env = environ global _notfound head, tail = path.split(file) if head: apply(func, (file,) + argrest) return if 'PATH' in env: envpath = env['PATH'] else: envpath = defpath PATH = envpath.split(pathsep) if not _notfound: if sys.platform[:4] == 'beos': # Process handling (fork, wait) under BeOS (up to 5.0) # doesn't interoperate reliably with the thread interlocking # that happens during an import. The actual error we need # is the same on BeOS for posix.open() et al., ENOENT. try: unlink('/_#.# ## #.#') except error, _notfound: pass else: import tempfile t = tempfile.mktemp() # Exec a file that is guaranteed not to exist try: execv(t, ('blah',)) except error, _notfound: pass exc, arg = error, _notfound for dir in PATH: fullname = path.join(dir, file) try: apply(func, (fullname,) + argrest) except error, (errno, msg): if errno != arg[0]: exc, arg = error, (errno, msg) raise exc, arg
|
def _execvpe(file, args, env=None): if env is not None: func = execve argrest = (args, env) else: func = execv argrest = (args,) env = environ global _notfound head, tail = path.split(file) if head: apply(func, (file,) + argrest) return if 'PATH' in env: envpath = env['PATH'] else: envpath = defpath PATH = envpath.split(pathsep) if not _notfound: if sys.platform[:4] == 'beos': # Process handling (fork, wait) under BeOS (up to 5.0) # doesn't interoperate reliably with the thread interlocking # that happens during an import. The actual error we need # is the same on BeOS for posix.open() et al., ENOENT. try: unlink('/_#.# ## #.#') except error, _notfound: pass else: import tempfile t = tempfile.mktemp() # Exec a file that is guaranteed not to exist try: execv(t, ('blah',)) except error, _notfound: pass exc, arg = error, _notfound for dir in PATH: fullname = path.join(dir, file) try: apply(func, (fullname,) + argrest) except error, (errno, msg): if errno != arg[0]: exc, arg = error, (errno, msg) raise exc, arg
| 11,805
|
def _execvpe(file, args, env=None): if env is not None: func = execve argrest = (args, env) else: func = execv argrest = (args,) env = environ global _notfound head, tail = path.split(file) if head: apply(func, (file,) + argrest) return if 'PATH' in env: envpath = env['PATH'] else: envpath = defpath PATH = envpath.split(pathsep) if not _notfound: if sys.platform[:4] == 'beos': # Process handling (fork, wait) under BeOS (up to 5.0) # doesn't interoperate reliably with the thread interlocking # that happens during an import. The actual error we need # is the same on BeOS for posix.open() et al., ENOENT. try: unlink('/_#.# ## #.#') except error, _notfound: pass else: import tempfile t = tempfile.mktemp() # Exec a file that is guaranteed not to exist try: execv(t, ('blah',)) except error, _notfound: pass exc, arg = error, _notfound for dir in PATH: fullname = path.join(dir, file) try: apply(func, (fullname,) + argrest) except error, (errno, msg): if errno != arg[0]: exc, arg = error, (errno, msg) raise exc, arg
|
def _execvpe(file, args, env=None): if env is not None: func = execve argrest = (args, env) else: func = execv argrest = (args,) env = environ global _notfound head, tail = path.split(file) if head: apply(func, (file,) + argrest) return if 'PATH' in env: envpath = env['PATH'] else: envpath = defpath PATH = envpath.split(pathsep) if not _notfound: if sys.platform[:4] == 'beos': # Process handling (fork, wait) under BeOS (up to 5.0) # doesn't interoperate reliably with the thread interlocking # that happens during an import. The actual error we need # is the same on BeOS for posix.open() et al., ENOENT. try: unlink('/_#.# ## #.#') except error, _notfound: pass else: import tempfile t = tempfile.mktemp() # Exec a file that is guaranteed not to exist try: execv(t, ('blah',)) except error, _notfound: pass exc, arg = error, _notfound for dir in PATH: fullname = path.join(dir, file) try: apply(func, (fullname,) + argrest) except error, (errno, msg): if errno != ENOENT and errno != ENOTDIR: raise raise error, (errno, msg)
| 11,806
|
def create_inifile (self): # Create an inifile containing data describing the installation. # This could be done without creating a real file, but # a file is (at least) useful for debugging bdist_wininst.
|
def create_inifile (self): # Create an inifile containing data describing the installation. # This could be done without creating a real file, but # a file is (at least) useful for debugging bdist_wininst.
| 11,807
|
def find_executable_linenos(filename): """Return dict where keys are line numbers in the line number table.""" assert filename.endswith('.py') try: prog = open(filename).read() except IOError, err: print >> sys.stderr, ("Not printing coverage data for %r: %s" % (filename, err)) return {} code = compile(prog, filename, "exec") strs = find_strings(filename) return find_lines(code, strs)
|
def find_executable_linenos(filename): """Return dict where keys are line numbers in the line number table.""" assert filename.endswith('.py') try: prog = open(filename, "rU").read() except IOError, err: print >> sys.stderr, ("Not printing coverage data for %r: %s" % (filename, err)) return {} code = compile(prog, filename, "exec") strs = find_strings(filename) return find_lines(code, strs)
| 11,808
|
def __init__(self, indent=1, width=80, depth=None, stream=None): """Handle pretty printing operations onto a stream using a set of configured parameters.
|
def __init__(self, indent=1, width=80, depth=None, stream=None): """Handle pretty printing operations onto a stream using a set of configured parameters.
| 11,809
|
def _safe_repr(object, context, maxlevels=None, level=0): level += 1 typ = type(object) if not (typ in (DictType, ListType, TupleType) and object): rep = `object` return rep, (rep and (rep[0] != '<')), 0 if context.has_key(id(object)): return `_Recursion(object)`, 0, 1 objid = id(object) context[objid] = 1 readable = 1 recursive = 0 startchar, endchar = {ListType: "[]", TupleType: "()", DictType: "{}"}[typ] if maxlevels and level > maxlevels: with_commas = "..." readable = 0 elif typ is DictType: components = [] for k, v in object.iteritems(): krepr, kreadable, krecur = _safe_repr(k, context, maxlevels, level) vrepr, vreadable, vrecur = _safe_repr(v, context, maxlevels, level) components.append("%s: %s" % (krepr, vrepr)) readable = readable and kreadable and vreadable recursive = recursive or krecur or vrecur with_commas = ", ".join(components) else: # list or tuple assert typ in (ListType, TupleType) components = [] for element in object: subrepr, subreadable, subrecur = _safe_repr( element, context, maxlevels, level) components.append(subrepr) readable = readable and subreadable recursive = recursive or subrecur if len(components) == 1 and typ is TupleType: components[0] += "," with_commas = ", ".join(components) s = "%s%s%s" % (startchar, with_commas, endchar) del context[objid] return s, readable and not recursive, recursive
|
def _safe_repr(object, context, maxlevels=None, level=0): level += 1 typ = type(object) if not (typ in (DictType, ListType, TupleType, StringType) and object): rep = `object` return rep, (rep and (rep[0] != '<')), 0 if context.has_key(id(object)): return `_Recursion(object)`, 0, 1 objid = id(object) context[objid] = 1 readable = 1 recursive = 0 startchar, endchar = {ListType: "[]", TupleType: "()", DictType: "{}"}[typ] if maxlevels and level > maxlevels: with_commas = "..." readable = 0 elif typ is DictType: components = [] for k, v in object.iteritems(): krepr, kreadable, krecur = _safe_repr(k, context, maxlevels, level) vrepr, vreadable, vrecur = _safe_repr(v, context, maxlevels, level) components.append("%s: %s" % (krepr, vrepr)) readable = readable and kreadable and vreadable recursive = recursive or krecur or vrecur with_commas = ", ".join(components) else: # list or tuple assert typ in (ListType, TupleType) components = [] for element in object: subrepr, subreadable, subrecur = _safe_repr( element, context, maxlevels, level) components.append(subrepr) readable = readable and subreadable recursive = recursive or subrecur if len(components) == 1 and typ is TupleType: components[0] += "," with_commas = ", ".join(components) s = "%s%s%s" % (startchar, with_commas, endchar) del context[objid] return s, readable and not recursive, recursive
| 11,810
|
def test_varsized_array(self): array = (c_int * 20)(20, 21, 22, 23, 24, 25, 26, 27, 28, 29)
|
def test_varsized_array(self): array = (c_int * 20)(20, 21, 22, 23, 24, 25, 26, 27, 28, 29)
| 11,811
|
def end_fill(): _getpen.end_fill()
|
def end_fill(): _getpen.end_fill()
| 11,812
|
def _fancy_replace(self, a, alo, ahi, b, blo, bhi): r""" When replacing one block of lines with another, search the blocks for *similar* lines; the best-matching pair (if any) is used as a synch point, and intraline difference marking is done on the similar pair. Lots of work, but often worth it.
|
def _fancy_replace(self, a, alo, ahi, b, blo, bhi): r""" When replacing one block of lines with another, search the blocks for *similar* lines; the best-matching pair (if any) is used as a synch point, and intraline difference marking is done on the similar pair. Lots of work, but often worth it.
| 11,813
|
def _qformat(self, aline, bline, atags, btags): r""" Format "?" output and deal with leading tabs.
|
def _qformat(self, aline, bline, atags, btags): r""" Format "?" output and deal with leading tabs.
| 11,814
|
def setUp(self): self.filename = self.__class__.__name__ + '.db' homeDir = os.path.join(os.path.dirname(sys.argv[0]), 'db_home') self.homeDir = homeDir try: os.mkdir(homeDir) except os.error: pass self.env = db.DBEnv() self.env.open(homeDir, db.DB_CREATE | db.DB_INIT_MPOOL)
|
def setUp(self): self.filename = self.__class__.__name__ + '.db' homeDir = os.path.join(os.path.dirname(sys.argv[0]), 'db_home') self.homeDir = homeDir try: os.mkdir(homeDir) except os.error: import glob files = glob.glob(os.path.join(self.homeDir, '*')) for file in files: os.remove(file) self.env = db.DBEnv() self.env.open(homeDir, db.DB_CREATE | db.DB_INIT_MPOOL)
| 11,815
|
def setUp(self): self.filename = self.__class__.__name__ + '.db' homeDir = os.path.join(os.path.dirname(sys.argv[0]), 'db_home') self.homeDir = homeDir try: os.mkdir(homeDir) except os.error: pass self.env = db.DBEnv() self.env.open(homeDir, db.DB_CREATE | db.DB_INIT_MPOOL | db.DB_INIT_LOCK | db.DB_THREAD | self.envFlags)
|
def setUp(self): self.filename = self.__class__.__name__ + '.db' homeDir = os.path.join(os.path.dirname(sys.argv[0]), 'db_home') self.homeDir = homeDir try: os.mkdir(homeDir) except os.error: import glob files = glob.glob(os.path.join(self.homeDir, '*')) for file in files: os.remove(file) self.env = db.DBEnv() self.env.open(homeDir, db.DB_CREATE | db.DB_INIT_MPOOL | db.DB_INIT_LOCK | db.DB_THREAD | self.envFlags)
| 11,816
|
def test01_associateWithDB(self): if verbose: print '\n', '-=' * 30 print "Running %s.test01_associateWithDB..." % \ self.__class__.__name__
|
def test01_associateWithDB(self): if verbose: print '\n', '-=' * 30 print "Running %s.test01_associateWithDB..." % \ self.__class__.__name__
| 11,817
|
def test01_associateWithDB(self): if verbose: print '\n', '-=' * 30 print "Running %s.test01_associateWithDB..." % \ self.__class__.__name__
|
def test01_associateWithDB(self): if verbose: print '\n', '-=' * 30 print "Running %s.test01_associateWithDB..." % \ self.__class__.__name__
| 11,818
|
def test01_associateWithDB(self): if verbose: print '\n', '-=' * 30 print "Running %s.test01_associateWithDB..." % \ self.__class__.__name__
|
def test01_associateWithDB(self): if verbose: print '\n', '-=' * 30 print "Running %s.test01_associateWithDB..." % \ self.__class__.__name__
| 11,819
|
def test02_associateAfterDB(self): if verbose: print '\n', '-=' * 30 print "Running %s.test02_associateAfterDB..." % \ self.__class__.__name__
|
def test02_associateAfterDB(self): if verbose: print '\n', '-=' * 30 print "Running %s.test02_associateAfterDB..." % \ self.__class__.__name__
| 11,820
|
def test02_associateAfterDB(self): if verbose: print '\n', '-=' * 30 print "Running %s.test02_associateAfterDB..." % \ self.__class__.__name__
|
def test02_associateAfterDB(self): if verbose: print '\n', '-=' * 30 print "Running %s.test02_associateAfterDB..." % \ self.__class__.__name__
| 11,821
|
def finish_test(self, secDB, txn=None): # 'Blues' should not be in the secondary database vals = secDB.pget('Blues', txn=txn) assert vals == None, vals
|
def finish_test(self, secDB, txn=None): # 'Blues' should not be in the secondary database vals = secDB.pget('Blues', txn=txn) assert vals == None, vals
| 11,822
|
def finish_test(self, secDB, txn=None): # 'Blues' should not be in the secondary database vals = secDB.pget('Blues', txn=txn) assert vals == None, vals
|
def finish_test(self, secDB, txn=None): # 'Blues' should not be in the secondary database vals = secDB.pget('Blues', txn=txn) assert vals == None, vals
| 11,823
|
def finish_test(self, secDB, txn=None): # 'Blues' should not be in the secondary database vals = secDB.pget('Blues', txn=txn) assert vals == None, vals
|
def finish_test(self, secDB, txn=None): # 'Blues' should not be in the secondary database vals = secDB.pget('Blues', txn=txn) assert vals == None, vals
| 11,824
|
def finish_test(self, secDB, txn=None): # 'Blues' should not be in the secondary database vals = secDB.pget('Blues', txn=txn) assert vals == None, vals
|
def finish_test(self, secDB, txn=None): # 'Blues' should not be in the secondary database vals = secDB.pget('Blues', txn=txn) assert vals == None, vals
| 11,825
|
def finish_test(self, secDB, txn=None): # 'Blues' should not be in the secondary database vals = secDB.pget('Blues', txn=txn) assert vals == None, vals
|
def finish_test(self, secDB, txn=None): # 'Blues' should not be in the secondary database vals = secDB.pget('Blues', txn=txn) assert vals == None, vals
| 11,826
|
def finish_test(self, secDB, txn=None): # 'Blues' should not be in the secondary database vals = secDB.pget('Blues', txn=txn) assert vals == None, vals
|
def finish_test(self, secDB, txn=None): # 'Blues' should not be in the secondary database vals = secDB.pget('Blues', txn=txn) assert vals == None, vals
| 11,827
|
def finish_test(self, secDB, txn=None): # 'Blues' should not be in the secondary database vals = secDB.pget('Blues', txn=txn) assert vals == None, vals
|
def finish_test(self, secDB, txn=None): # 'Blues' should not be in the secondary database vals = secDB.pget('Blues', txn=txn) assert vals == None, vals
| 11,828
|
def finish_test(self, secDB, txn=None): # 'Blues' should not be in the secondary database vals = secDB.pget('Blues', txn=txn) assert vals == None, vals
|
def finish_test(self, secDB, txn=None): # 'Blues' should not be in the secondary database vals = secDB.pget('Blues', txn=txn) assert vals == None, vals
| 11,829
|
def test13_associateAutoCommit(self): if verbose: print '\n', '-=' * 30 print "Running %s.test13_associateAutoCommit..." % \ self.__class__.__name__
|
def txn_finish_test(self, sDB, txn): try: self.finish_test(sDB, txn=txn) finally: if self.cur: self.cur.close() self.cur = None if txn: txn.commit() def test13_associate_in_transaction(self): if verbose: print '\n', '-=' * 30 print "Running %s.test13_associateAutoCommit..." % \ self.__class__.__name__
| 11,830
|
def test13_associateAutoCommit(self): if verbose: print '\n', '-=' * 30 print "Running %s.test13_associateAutoCommit..." % \ self.__class__.__name__
|
def test13_associateAutoCommit(self): if verbose: print '\n', '-=' * 30 print "Running %s.test13_associateAutoCommit..." % \ self.__class__.__name__
| 11,831
|
def test13_associateAutoCommit(self): if verbose: print '\n', '-=' * 30 print "Running %s.test13_associateAutoCommit..." % \ self.__class__.__name__
|
def test13_associateAutoCommit(self): if verbose: print '\n', '-=' * 30 print "Running %s.test13_associateAutoCommit..." % \ self.__class__.__name__
| 11,832
|
def test13_associateAutoCommit(self): if verbose: print '\n', '-=' * 30 print "Running %s.test13_associateAutoCommit..." % \ self.__class__.__name__
|
def test13_associateAutoCommit(self): if verbose: print '\n', '-=' * 30 print "Running %s.test13_associateAutoCommit..." % \ self.__class__.__name__
| 11,833
|
def finalize_options (self): self.set_undefined_options('bdist', ('bdist_base', 'bdist_base')) if self.rpm_base is None: if not self.rpm3_mode: raise DistutilsOptionError, \ "you must specify --rpm-base in RPM 2 mode" self.rpm_base = os.path.join(self.bdist_base, "rpm")
|
def finalize_options (self): self.set_undefined_options('bdist', ('bdist_base', 'bdist_base')) if self.rpm_base is None: if not self.rpm3_mode: raise DistutilsOptionError, \ "you must specify --rpm-base in RPM 2 mode" self.rpm_base = os.path.join(self.bdist_base, "rpm")
| 11,834
|
def test_b(self): from _testcapi import getargs_b # b returns 'unsigned char', and does range checking (0 ... UCHAR_MAX) self.failUnlessEqual(3, getargs_b(3.14)) self.failUnlessEqual(99, getargs_b(Long())) self.failUnlessEqual(99, getargs_b(Int()))
|
def test_b(self): from _testcapi import getargs_b # b returns 'unsigned char', and does range checking (0 ... UCHAR_MAX) self.assertRaises(TypeError, getargs_b, 3.14) self.failUnlessEqual(99, getargs_b(Long())) self.failUnlessEqual(99, getargs_b(Int()))
| 11,835
|
def test_B(self): from _testcapi import getargs_B # B returns 'unsigned char', no range checking self.failUnlessEqual(3, getargs_B(3.14)) self.failUnlessEqual(99, getargs_B(Long())) self.failUnlessEqual(99, getargs_B(Int()))
|
def test_B(self): from _testcapi import getargs_B # B returns 'unsigned char', no range checking self.assertRaises(TypeError, getargs_B, 3.14) self.failUnlessEqual(99, getargs_B(Long())) self.failUnlessEqual(99, getargs_B(Int()))
| 11,836
|
def test_H(self): from _testcapi import getargs_H # H returns 'unsigned short', no range checking self.failUnlessEqual(3, getargs_H(3.14)) self.failUnlessEqual(99, getargs_H(Long())) self.failUnlessEqual(99, getargs_H(Int()))
|
def test_H(self): from _testcapi import getargs_H # H returns 'unsigned short', no range checking self.assertRaises(TypeError, getargs_H, 3.14) self.failUnlessEqual(99, getargs_H(Long())) self.failUnlessEqual(99, getargs_H(Int()))
| 11,837
|
def test_I(self): from _testcapi import getargs_I # I returns 'unsigned int', no range checking self.failUnlessEqual(3, getargs_I(3.14)) self.failUnlessEqual(99, getargs_I(Long())) self.failUnlessEqual(99, getargs_I(Int()))
|
def test_I(self): from _testcapi import getargs_I # I returns 'unsigned int', no range checking self.assertRaises(TypeError, getargs_I, 3.14) self.failUnlessEqual(99, getargs_I(Long())) self.failUnlessEqual(99, getargs_I(Int()))
| 11,838
|
def test_i(self): from _testcapi import getargs_i # i returns 'int', and does range checking (INT_MIN ... INT_MAX) self.failUnlessEqual(3, getargs_i(3.14)) self.failUnlessEqual(99, getargs_i(Long())) self.failUnlessEqual(99, getargs_i(Int()))
|
def test_i(self): from _testcapi import getargs_i # i returns 'int', and does range checking (INT_MIN ... INT_MAX) self.assertRaises(TypeError, getargs_i, 3.14) self.failUnlessEqual(99, getargs_i(Long())) self.failUnlessEqual(99, getargs_i(Int()))
| 11,839
|
def test_l(self): from _testcapi import getargs_l # l returns 'long', and does range checking (LONG_MIN ... LONG_MAX) self.failUnlessEqual(3, getargs_l(3.14)) self.failUnlessEqual(99, getargs_l(Long())) self.failUnlessEqual(99, getargs_l(Int()))
|
def test_l(self): from _testcapi import getargs_l # l returns 'long', and does range checking (LONG_MIN ... LONG_MAX) self.assertRaises(TypeError, getargs_l, 3.14) self.failUnlessEqual(99, getargs_l(Long())) self.failUnlessEqual(99, getargs_l(Int()))
| 11,840
|
def setup(self):
|
def setup(self):
| 11,841
|
def rewrite_desc_entries(doc, argname_gi): argnodes = doc.getElementsByTagName(argname_gi) for node in argnodes: parent = node.parentNode nodes = [] for n in parent.childNodes: if n.nodeType != xml.dom.core.ELEMENT or n.tagName != argname_gi: nodes.append(n) desc = doc.createElement("description") for n in nodes: parent.removeChild(n) desc.appendChild(n) if node.childNodes: # keep the <args>...</args>, newline & indent parent.insertBefore(doc.createText("\n "), node) else: # no arguments, remove the <args/> node parent.removeChild(node) parent.appendChild(doc.createText("\n ")) parent.appendChild(desc) parent.appendChild(doc.createText("\n"))
|
def handle_args(doc): for node in find_all_elements(doc, "args"): parent = node.parentNode nodes = [] for n in parent.childNodes: if n.nodeType != xml.dom.core.ELEMENT or n.tagName != argname_gi: nodes.append(n) desc = doc.createElement("description") for n in nodes: parent.removeChild(n) desc.appendChild(n) if node.childNodes: # keep the <args>...</args>, newline & indent parent.insertBefore(doc.createText("\n "), node) else: # no arguments, remove the <args/> node parent.removeChild(node) parent.appendChild(doc.createText("\n ")) parent.appendChild(desc) parent.appendChild(doc.createText("\n"))
| 11,842
|
def rewrite_desc_entries(doc, argname_gi): argnodes = doc.getElementsByTagName(argname_gi) for node in argnodes: parent = node.parentNode nodes = [] for n in parent.childNodes: if n.nodeType != xml.dom.core.ELEMENT or n.tagName != argname_gi: nodes.append(n) desc = doc.createElement("description") for n in nodes: parent.removeChild(n) desc.appendChild(n) if node.childNodes: # keep the <args>...</args>, newline & indent parent.insertBefore(doc.createText("\n "), node) else: # no arguments, remove the <args/> node parent.removeChild(node) parent.appendChild(doc.createText("\n ")) parent.appendChild(desc) parent.appendChild(doc.createText("\n"))
|
def rewrite_desc_entries(doc, argname_gi): argnodes = doc.getElementsByTagName(argname_gi) for node in argnodes: parent = node.parentNode nodes = [] for n in parent.childNodes: if n.nodeType != xml.dom.core.ELEMENT or n.tagName != "args": nodes.append(n) desc = doc.createElement("description") for n in nodes: parent.removeChild(n) desc.appendChild(n) if node.childNodes: # keep the <args>...</args>, newline & indent parent.insertBefore(doc.createText("\n "), node) else: # no arguments, remove the <args/> node parent.removeChild(node) parent.appendChild(doc.createText("\n ")) parent.appendChild(desc) parent.appendChild(doc.createText("\n"))
| 11,843
|
def rewrite_desc_entries(doc, argname_gi): argnodes = doc.getElementsByTagName(argname_gi) for node in argnodes: parent = node.parentNode nodes = [] for n in parent.childNodes: if n.nodeType != xml.dom.core.ELEMENT or n.tagName != argname_gi: nodes.append(n) desc = doc.createElement("description") for n in nodes: parent.removeChild(n) desc.appendChild(n) if node.childNodes: # keep the <args>...</args>, newline & indent parent.insertBefore(doc.createText("\n "), node) else: # no arguments, remove the <args/> node parent.removeChild(node) parent.appendChild(doc.createText("\n ")) parent.appendChild(desc) parent.appendChild(doc.createText("\n"))
|
def rewrite_desc_entries(doc, argname_gi): argnodes = doc.getElementsByTagName(argname_gi) for node in argnodes: parent = node.parentNode nodes = [] for n in parent.childNodes: if n.nodeType != xml.dom.core.ELEMENT or n.tagName != argname_gi: nodes.append(n) desc = doc.createElement("description") for n in nodes: parent.removeChild(n) desc.appendChild(n) if node.childNodes: # keep the <args>...</args>, newline & indent parent.insertBefore(doc.createText("\n "), node) else: # no arguments, remove the <args/> node parent.removeChild(node) parent.appendChild(doc.createText("\n ")) parent.appendChild(desc) parent.appendChild(doc.createText("\n"))
| 11,844
|
def rewrite_desc_entries(doc, argname_gi): argnodes = doc.getElementsByTagName(argname_gi) for node in argnodes: parent = node.parentNode nodes = [] for n in parent.childNodes: if n.nodeType != xml.dom.core.ELEMENT or n.tagName != argname_gi: nodes.append(n) desc = doc.createElement("description") for n in nodes: parent.removeChild(n) desc.appendChild(n) if node.childNodes: # keep the <args>...</args>, newline & indent parent.insertBefore(doc.createText("\n "), node) else: # no arguments, remove the <args/> node parent.removeChild(node) parent.appendChild(doc.createText("\n ")) parent.appendChild(desc) parent.appendChild(doc.createText("\n"))
|
def rewrite_desc_entries(doc, argname_gi): argnodes = doc.getElementsByTagName(argname_gi) for node in argnodes: parent = node.parentNode nodes = [] for n in parent.childNodes: if n.nodeType != xml.dom.core.ELEMENT or n.tagName != argname_gi: nodes.append(n) desc = doc.createElement("description") for n in nodes: parent.removeChild(n) desc.appendChild(n) if node.childNodes: # keep the <args>...</args>, newline & indent parent.insertBefore(doc.createText("\n "), node) else: # no arguments, remove the <args/> node parent.removeChild(node) parent.appendChild(doc.createText("\n ")) parent.appendChild(desc) parent.appendChild(doc.createText("\n"))
| 11,845
|
def handle_labels(doc): for node in doc.childNodes: if node.nodeType == xml.dom.core.ELEMENT: labels = node.getElementsByTagName("label") for label in labels: id = label.getAttribute("id") if not id: continue parent = label.parentNode if parent.tagName == "title": parent.parentNode.setAttribute("id", id) else: parent.setAttribute("id", id) # now, remove <label id="..."/> from parent: parent.removeChild(label)
|
def handle_labels(doc): for node in doc.childNodes: if node.nodeType == xml.dom.core.ELEMENT: labels = node.getElementsByTagName("label") for label in labels: id = label.getAttribute("id") if not id: continue parent = label.parentNode if parent.tagName == "title": parent.parentNode.setAttribute("id", id) else: parent.setAttribute("id", id) # now, remove <label id="..."/> from parent: parent.removeChild(label)
| 11,846
|
def create_module_info(doc, section): # Heavy. node = extract_first_element(section, "modulesynopsis") if node is None: return node._node.name = "synopsis" lastchild = node.childNodes[-1] if lastchild.nodeType == xml.dom.core.TEXT \ and lastchild.data[-1:] == ".": lastchild.data = lastchild.data[:-1] modauthor = extract_first_element(section, "moduleauthor") if modauthor: modauthor._node.name = "author" modauthor.appendChild(doc.createTextNode( modauthor.getAttribute("name"))) modauthor.removeAttribute("name") if section.tagName == "section": modinfo_pos = 2 modinfo = doc.createElement("moduleinfo") moddecl = extract_first_element(section, "declaremodule") name = None if moddecl: modinfo.appendChild(doc.createTextNode("\n ")) name = moddecl.attributes["name"].value namenode = doc.createElement("name") namenode.appendChild(doc.createTextNode(name)) modinfo.appendChild(namenode) type = moddecl.attributes.get("type") if type: type = type.value modinfo.appendChild(doc.createTextNode("\n ")) typenode = doc.createElement("type") typenode.appendChild(doc.createTextNode(type)) modinfo.appendChild(typenode) title = get_first_element(section, "title") if title: children = title.childNodes if len(children) >= 2 \ and children[0].nodeType == xml.dom.core.ELEMENT \ and children[0].tagName == "module" \ and children[0].childNodes[0].data == name: # this is it; morph the <title> into <short-synopsis> first_data = children[1] if first_data.data[:4] == " ---": first_data.data = string.lstrip(first_data.data[4:]) title._node.name = "short-synopsis" if children[-1].data[-1:] == ".": children[-1].data = children[-1].data[:-1] section.removeChild(title) section.removeChild(section.childNodes[0]) title.removeChild(children[0]) modinfo_pos = 0 else: sys.stderr.write( "module name in title doesn't match" " <declaremodule>; no <short-synopsis>\n") else: sys.stderr.write( "Unexpected condition: <section> without <title>\n") modinfo.appendChild(doc.createTextNode("\n ")) modinfo.appendChild(node) if title and not contents_match(title, node): # The short synopsis is actually different, # and needs to be stored: modinfo.appendChild(doc.createTextNode("\n ")) modinfo.appendChild(title) if modauthor: modinfo.appendChild(doc.createTextNode("\n ")) modinfo.appendChild(modauthor) modinfo.appendChild(doc.createTextNode("\n ")) section.insertBefore(modinfo, section.childNodes[modinfo_pos]) section.insertBefore(doc.createTextNode("\n "), modinfo)
|
def create_module_info(doc, section): # Heavy. node = extract_first_element(section, "modulesynopsis") if node is None: return node._node.name = "synopsis" lastchild = node.childNodes[-1] if lastchild.nodeType == xml.dom.core.TEXT \ and lastchild.data[-1:] == ".": lastchild.data = lastchild.data[:-1] modauthor = extract_first_element(section, "moduleauthor") if modauthor: modauthor._node.name = "author" modauthor.appendChild(doc.createTextNode( modauthor.getAttribute("name"))) modauthor.removeAttribute("name") if section.tagName == "section": modinfo_pos = 2 modinfo = doc.createElement("moduleinfo") moddecl = extract_first_element(section, "declaremodule") name = None if moddecl: modinfo.appendChild(doc.createTextNode("\n ")) name = moddecl.attributes["name"].value namenode = doc.createElement("name") namenode.appendChild(doc.createTextNode(name)) modinfo.appendChild(namenode) type = moddecl.attributes.get("type") if type: type = type.value modinfo.appendChild(doc.createTextNode("\n ")) typenode = doc.createElement("type") typenode.appendChild(doc.createTextNode(type)) modinfo.appendChild(typenode) title = get_first_element(section, "title") if title: children = title.childNodes if len(children) >= 2 \ and children[0].nodeType == xml.dom.core.ELEMENT \ and children[0].tagName == "module" \ and children[0].childNodes[0].data == name: # this is it; morph the <title> into <short-synopsis> first_data = children[1] if first_data.data[:4] == " ---": first_data.data = string.lstrip(first_data.data[4:]) title._node.name = "short-synopsis" if children[-1].nodeType == xml.dom.core.TEXT \ and children[-1].data[-1:] == ".": children[-1].data = children[-1].data[:-1] section.removeChild(title) section.removeChild(section.childNodes[0]) title.removeChild(children[0]) modinfo_pos = 0 else: sys.stderr.write( "module name in title doesn't match" " <declaremodule>; no <short-synopsis>\n") else: sys.stderr.write( "Unexpected condition: <section> without <title>\n") modinfo.appendChild(doc.createTextNode("\n ")) modinfo.appendChild(node) if title and not contents_match(title, node): # The short synopsis is actually different, # and needs to be stored: modinfo.appendChild(doc.createTextNode("\n ")) modinfo.appendChild(title) if modauthor: modinfo.appendChild(doc.createTextNode("\n ")) modinfo.appendChild(modauthor) modinfo.appendChild(doc.createTextNode("\n ")) section.insertBefore(modinfo, section.childNodes[modinfo_pos]) section.insertBefore(doc.createTextNode("\n "), modinfo)
| 11,847
|
def cleanup_synopses(doc): for node in doc.childNodes: if node.nodeType == xml.dom.core.ELEMENT \ and node.tagName == "section": create_module_info(doc, node)
|
def cleanup_synopses(doc): for node in find_all_elements(doc, "section"): create_module_info(doc, node)
| 11,848
|
def fixup_table_structures(doc): # must be done after remap_element_names(), or the tables won't be found for child in doc.childNodes: if child.nodeType == xml.dom.core.ELEMENT: tables = child.getElementsByTagName("table") for table in tables: fixup_table(doc, table)
|
def fixup_table_structures(doc): # must be done after remap_element_names(), or the tables won't be found for table in find_all_elements(doc, "table"): fixup_table(doc, table)
| 11,849
|
def move_elements_by_name(doc, source, dest, name, sep=None): nodes = [] for child in source.childNodes: if child.nodeType == xml.dom.core.ELEMENT and child.tagName == name: nodes.append(child) for node in nodes: source.removeChild(node) dest.appendChild(node) if sep: dest.appendChild(doc.createTextNode(sep))
|
def move_elements_by_name(doc, source, dest, name, sep=None): nodes = [] for child in source.childNodes: if child.nodeType == xml.dom.core.ELEMENT and child.tagName == name: nodes.append(child) for node in nodes: source.removeChild(node) dest.appendChild(node) if sep: dest.appendChild(doc.createTextNode(sep))
| 11,850
|
def move_elements_by_name(doc, source, dest, name, sep=None): nodes = [] for child in source.childNodes: if child.nodeType == xml.dom.core.ELEMENT and child.tagName == name: nodes.append(child) for node in nodes: source.removeChild(node) dest.appendChild(node) if sep: dest.appendChild(doc.createTextNode(sep))
|
def move_elements_by_name(doc, source, dest, name, sep=None): nodes = [] for child in source.childNodes: if child.nodeType == xml.dom.core.ELEMENT and child.tagName == name: nodes.append(child) for node in nodes: source.removeChild(node) dest.appendChild(node) if sep: dest.appendChild(doc.createTextNode(sep))
| 11,851
|
def move_elements_by_name(doc, source, dest, name, sep=None): nodes = [] for child in source.childNodes: if child.nodeType == xml.dom.core.ELEMENT and child.tagName == name: nodes.append(child) for node in nodes: source.removeChild(node) dest.appendChild(node) if sep: dest.appendChild(doc.createTextNode(sep))
|
def move_elements_by_name(doc, source, dest, name, sep=None): nodes = [] for child in source.childNodes: if child.nodeType == xml.dom.core.ELEMENT and child.tagName == name: nodes.append(child) for node in nodes: source.removeChild(node) dest.appendChild(node) if sep: dest.appendChild(doc.createTextNode(sep))
| 11,852
|
def move_elements_by_name(doc, source, dest, name, sep=None): nodes = [] for child in source.childNodes: if child.nodeType == xml.dom.core.ELEMENT and child.tagName == name: nodes.append(child) for node in nodes: source.removeChild(node) dest.appendChild(node) if sep: dest.appendChild(doc.createTextNode(sep))
|
def move_elements_by_name(doc, source, dest, name, sep=None): nodes = [] for child in source.childNodes: if child.nodeType == xml.dom.core.ELEMENT and child.tagName == name: nodes.append(child) for node in nodes: source.removeChild(node) dest.appendChild(node) if sep: dest.appendChild(doc.createTextNode(sep))
| 11,853
|
def fixup_paras(doc): for child in doc.childNodes: if child.nodeType == xml.dom.core.ELEMENT \ and child.tagName in FIXUP_PARA_ELEMENTS: fixup_paras_helper(doc, child) descriptions = child.getElementsByTagName("description") for description in descriptions: if DEBUG_PARA_FIXER: sys.stderr.write("-- Fixing up <description> element...\n") fixup_paras_helper(doc, description)
|
def fixup_paras(doc): for child in doc.childNodes: if child.nodeType == xml.dom.core.ELEMENT \ and child.tagName in RECURSE_INTO_PARA_CONTAINERS: fixup_paras_helper(doc, child) descriptions = child.getElementsByTagName("description") for description in descriptions: if DEBUG_PARA_FIXER: sys.stderr.write("-- Fixing up <description> element...\n") fixup_paras_helper(doc, description)
| 11,854
|
def fixup_paras(doc): for child in doc.childNodes: if child.nodeType == xml.dom.core.ELEMENT \ and child.tagName in FIXUP_PARA_ELEMENTS: fixup_paras_helper(doc, child) descriptions = child.getElementsByTagName("description") for description in descriptions: if DEBUG_PARA_FIXER: sys.stderr.write("-- Fixing up <description> element...\n") fixup_paras_helper(doc, description)
|
def fixup_paras(doc): for child in doc.childNodes: if child.nodeType == xml.dom.core.ELEMENT \ and child.tagName in FIXUP_PARA_ELEMENTS: fixup_paras_helper(doc, child) descriptions = child.getElementsByTagName("description") for description in descriptions: fixup_paras_helper(doc, description)
| 11,855
|
def fixup_paras_helper(doc, container): # document is already normalized children = container.childNodes start = 0 start_fixed = 0 i = len(children) SKIP_ELEMENTS = PARA_LEVEL_ELEMENTS + PARA_LEVEL_PRECEEDERS if DEBUG_PARA_FIXER: sys.stderr.write("fixup_paras_helper() called on <%s>; %d, %d\n" % (container.tagName, start, i)) if i > start: # the first [start:i] children shoudl be rewritten as <para> elements # start by breaking text nodes that contain \n\n+ into multiple nodes nstart, i = skip_leading_nodes(container.childNodes, start, i) if i > nstart: build_para(doc, container, nstart, i) fixup_paras_helper(doc, container)
|
def fixup_paras_helper(doc, container, depth=0): # document is already normalized children = container.childNodes start = 0 start_fixed = 0 i = len(children) SKIP_ELEMENTS = PARA_LEVEL_ELEMENTS + PARA_LEVEL_PRECEEDERS if DEBUG_PARA_FIXER: sys.stderr.write("fixup_paras_helper() called on <%s>; %d, %d\n" % (container.tagName, start, i)) if i > start: # the first [start:i] children shoudl be rewritten as <para> elements # start by breaking text nodes that contain \n\n+ into multiple nodes nstart, i = skip_leading_nodes(container.childNodes, start, i) if i > nstart: build_para(doc, container, nstart, i) fixup_paras_helper(doc, container)
| 11,856
|
def fixup_paras_helper(doc, container): # document is already normalized children = container.childNodes start = 0 start_fixed = 0 i = len(children) SKIP_ELEMENTS = PARA_LEVEL_ELEMENTS + PARA_LEVEL_PRECEEDERS if DEBUG_PARA_FIXER: sys.stderr.write("fixup_paras_helper() called on <%s>; %d, %d\n" % (container.tagName, start, i)) if i > start: # the first [start:i] children shoudl be rewritten as <para> elements # start by breaking text nodes that contain \n\n+ into multiple nodes nstart, i = skip_leading_nodes(container.childNodes, start, i) if i > nstart: build_para(doc, container, nstart, i) fixup_paras_helper(doc, container)
|
def fixup_paras_helper(doc, container): # document is already normalized children = container.childNodes start = 0 start_fixed = 0 i = len(children) SKIP_ELEMENTS = PARA_LEVEL_ELEMENTS + PARA_LEVEL_PRECEEDERS if DEBUG_PARA_FIXER: sys.stderr.write("fixup_paras_helper() called on <%s>; %d, %d\n" % (container.tagName, start, i)) if i > start: # the first [start:i] children shoudl be rewritten as <para> elements # start by breaking text nodes that contain \n\n+ into multiple nodes nstart, i = skip_leading_nodes(container.childNodes, start, i) if i > nstart: build_para(doc, container, nstart, i) fixup_paras_helper(doc, container)
| 11,857
|
def build_para(doc, parent, start, i): children = parent.childNodes # collect all children until \n\n+ is found in a text node or a # PARA_LEVEL_ELEMENT is found. after = start + 1 have_last = 0 BREAK_ELEMENTS = PARA_LEVEL_ELEMENTS + FIXUP_PARA_ELEMENTS for j in range(start, i): after = j + 1 child = children[j] nodeType = child.nodeType if nodeType == xml.dom.core.ELEMENT: if child.tagName in BREAK_ELEMENTS: after = j break elif nodeType == xml.dom.core.TEXT: pos = string.find(child.data, "\n\n") if pos == 0: after = j break if pos >= 1: child.splitText(pos) break else: have_last = 1 if children[after - 1].nodeType == xml.dom.core.TEXT: # we may need to split off trailing white space: child = children[after - 1] data = child.data if string.rstrip(data) != data: have_last = 0 child.splitText(len(string.rstrip(data))) children = parent.childNodes para = doc.createElement("para") prev = None indexes = range(start, after) indexes.reverse() for j in indexes: node = children[j] parent.removeChild(node) para.insertBefore(node, prev) prev = node if have_last: parent.appendChild(para) else: parent.insertBefore(para, parent.childNodes[start])
|
def build_para(doc, parent, start, i): children = parent.childNodes # collect all children until \n\n+ is found in a text node or a # PARA_LEVEL_ELEMENT is found. after = start + 1 have_last = 0 BREAK_ELEMENTS = PARA_LEVEL_ELEMENTS + FIXUP_PARA_ELEMENTS for j in range(start, i): after = j + 1 child = children[j] nodeType = child.nodeType if nodeType == xml.dom.core.ELEMENT: if child.tagName in BREAK_ELEMENTS: after = j break elif nodeType == xml.dom.core.TEXT: pos = string.find(child.data, "\n\n") if pos == 0: after = j break if pos >= 1: child.splitText(pos) break else: have_last = 1 if children[after - 1].nodeType == xml.dom.core.TEXT: # we may need to split off trailing white space: child = children[after - 1] data = child.data if string.rstrip(data) != data: have_last = 0 child.splitText(len(string.rstrip(data))) children = parent.childNodes para = doc.createElement("para") prev = None indexes = range(start, after) indexes.reverse() for j in indexes: node = children[j] parent.removeChild(node) para.insertBefore(node, prev) prev = node if have_last: parent.appendChild(para) else: parent.insertBefore(para, parent.childNodes[start])
| 11,858
|
def build_para(doc, parent, start, i): children = parent.childNodes # collect all children until \n\n+ is found in a text node or a # PARA_LEVEL_ELEMENT is found. after = start + 1 have_last = 0 BREAK_ELEMENTS = PARA_LEVEL_ELEMENTS + FIXUP_PARA_ELEMENTS for j in range(start, i): after = j + 1 child = children[j] nodeType = child.nodeType if nodeType == xml.dom.core.ELEMENT: if child.tagName in BREAK_ELEMENTS: after = j break elif nodeType == xml.dom.core.TEXT: pos = string.find(child.data, "\n\n") if pos == 0: after = j break if pos >= 1: child.splitText(pos) break else: have_last = 1 if children[after - 1].nodeType == xml.dom.core.TEXT: # we may need to split off trailing white space: child = children[after - 1] data = child.data if string.rstrip(data) != data: have_last = 0 child.splitText(len(string.rstrip(data))) children = parent.childNodes para = doc.createElement("para") prev = None indexes = range(start, after) indexes.reverse() for j in indexes: node = children[j] parent.removeChild(node) para.insertBefore(node, prev) prev = node if have_last: parent.appendChild(para) else: parent.insertBefore(para, parent.childNodes[start])
|
def build_para(doc, parent, start, i): # collect all children until \n\n+ is found in a text node or a # PARA_LEVEL_ELEMENT is found. after = start + 1 have_last = 0 BREAK_ELEMENTS = PARA_LEVEL_ELEMENTS + FIXUP_PARA_ELEMENTS for j in range(start, i): after = j + 1 child = children[j] nodeType = child.nodeType if nodeType == xml.dom.core.ELEMENT: if child.tagName in BREAK_ELEMENTS: after = j break elif nodeType == xml.dom.core.TEXT: pos = string.find(child.data, "\n\n") if pos == 0: after = j break if pos >= 1: child.splitText(pos) break else: have_last = 1 if children[after - 1].nodeType == xml.dom.core.TEXT: # we may need to split off trailing white space: child = children[after - 1] data = child.data if string.rstrip(data) != data: have_last = 0 child.splitText(len(string.rstrip(data))) para = doc.createElement("para") prev = None indexes = range(start, after) indexes.reverse() for j in indexes: node = children[j] parent.removeChild(node) para.insertBefore(node, prev) prev = node if have_last: parent.appendChild(para) else: parent.insertBefore(para, parent.childNodes[start])
| 11,859
|
def build_para(doc, parent, start, i): children = parent.childNodes # collect all children until \n\n+ is found in a text node or a # PARA_LEVEL_ELEMENT is found. after = start + 1 have_last = 0 BREAK_ELEMENTS = PARA_LEVEL_ELEMENTS + FIXUP_PARA_ELEMENTS for j in range(start, i): after = j + 1 child = children[j] nodeType = child.nodeType if nodeType == xml.dom.core.ELEMENT: if child.tagName in BREAK_ELEMENTS: after = j break elif nodeType == xml.dom.core.TEXT: pos = string.find(child.data, "\n\n") if pos == 0: after = j break if pos >= 1: child.splitText(pos) break else: have_last = 1 if children[after - 1].nodeType == xml.dom.core.TEXT: # we may need to split off trailing white space: child = children[after - 1] data = child.data if string.rstrip(data) != data: have_last = 0 child.splitText(len(string.rstrip(data))) children = parent.childNodes para = doc.createElement("para") prev = None indexes = range(start, after) indexes.reverse() for j in indexes: node = children[j] parent.removeChild(node) para.insertBefore(node, prev) prev = node if have_last: parent.appendChild(para) else: parent.insertBefore(para, parent.childNodes[start])
|
def build_para(doc, parent, start, i): children = parent.childNodes # collect all children until \n\n+ is found in a text node or a # PARA_LEVEL_ELEMENT is found. after = start + 1 have_last = 0 BREAK_ELEMENTS = PARA_LEVEL_ELEMENTS + FIXUP_PARA_ELEMENTS for j in range(start, i): after = j + 1 child = children[j] nodeType = child.nodeType if nodeType == xml.dom.core.ELEMENT: if child.tagName in BREAK_ELEMENTS: after = j break elif nodeType == xml.dom.core.TEXT: pos = string.find(child.data, "\n\n") if pos == 0: after = j break if pos >= 1: child.splitText(pos) break else: have_last = 1 if children[after - 1].nodeType == xml.dom.core.TEXT: # we may need to split off trailing white space: child = children[after - 1] data = child.data if string.rstrip(data) != data: have_last = 0 child.splitText(len(string.rstrip(data))) children = parent.childNodes para = doc.createElement("para") prev = None indexes = range(start, after) indexes.reverse() for j in indexes: node = parent.childNodes[j] parent.removeChild(node) para.insertBefore(node, prev) prev = node if have_last: parent.appendChild(para) else: parent.insertBefore(para, parent.childNodes[start])
| 11,860
|
def build_para(doc, parent, start, i): children = parent.childNodes # collect all children until \n\n+ is found in a text node or a # PARA_LEVEL_ELEMENT is found. after = start + 1 have_last = 0 BREAK_ELEMENTS = PARA_LEVEL_ELEMENTS + FIXUP_PARA_ELEMENTS for j in range(start, i): after = j + 1 child = children[j] nodeType = child.nodeType if nodeType == xml.dom.core.ELEMENT: if child.tagName in BREAK_ELEMENTS: after = j break elif nodeType == xml.dom.core.TEXT: pos = string.find(child.data, "\n\n") if pos == 0: after = j break if pos >= 1: child.splitText(pos) break else: have_last = 1 if children[after - 1].nodeType == xml.dom.core.TEXT: # we may need to split off trailing white space: child = children[after - 1] data = child.data if string.rstrip(data) != data: have_last = 0 child.splitText(len(string.rstrip(data))) children = parent.childNodes para = doc.createElement("para") prev = None indexes = range(start, after) indexes.reverse() for j in indexes: node = children[j] parent.removeChild(node) para.insertBefore(node, prev) prev = node if have_last: parent.appendChild(para) else: parent.insertBefore(para, parent.childNodes[start])
|
def build_para(doc, parent, start, i): children = parent.childNodes # collect all children until \n\n+ is found in a text node or a # PARA_LEVEL_ELEMENT is found. after = start + 1 have_last = 0 BREAK_ELEMENTS = PARA_LEVEL_ELEMENTS + FIXUP_PARA_ELEMENTS for j in range(start, i): after = j + 1 child = children[j] nodeType = child.nodeType if nodeType == xml.dom.core.ELEMENT: if child.tagName in BREAK_ELEMENTS: after = j break elif nodeType == xml.dom.core.TEXT: pos = string.find(child.data, "\n\n") if pos == 0: after = j break if pos >= 1: child.splitText(pos) break else: have_last = 1 if children[after - 1].nodeType == xml.dom.core.TEXT: # we may need to split off trailing white space: child = children[after - 1] data = child.data if string.rstrip(data) != data: have_last = 0 child.splitText(len(string.rstrip(data))) children = parent.childNodes para = doc.createElement("para") prev = None indexes = range(start, after) indexes.reverse() for j in indexes: node = children[j] parent.removeChild(node) para.insertBefore(node, prev) prev = node if have_last: parent.appendChild(para) else: parent.insertBefore(para, parent.childNodes[start])
| 11,861
|
def skip_leading_nodes(children, start, i): i = min(i, len(children)) while i > start: # skip over leading comments and whitespace: try: child = children[start] except IndexError: sys.stderr.write( "skip_leading_nodes() failed at index %d\n" % start) raise nodeType = child.nodeType if nodeType == xml.dom.core.COMMENT: start = start + 1 elif nodeType == xml.dom.core.TEXT: data = child.data shortened = string.lstrip(data) if shortened: if data != shortened: # break into two nodes: whitespace and non-whitespace child.splitText(len(data) - len(shortened)) return start + 1, i + 1 break # all whitespace, just skip start = start + 1 elif nodeType == xml.dom.core.ELEMENT: if child.tagName in PARA_LEVEL_ELEMENTS + PARA_LEVEL_PRECEEDERS: start = start + 1 else: break else: break return start, i
|
def skip_leading_nodes(children, start, i): i = min(i, len(children)) while i > start: # skip over leading comments and whitespace: child = children[start] nodeType = child.nodeType if nodeType == xml.dom.core.COMMENT: start = start + 1 elif nodeType == xml.dom.core.TEXT: data = child.data shortened = string.lstrip(data) if shortened: if data != shortened: # break into two nodes: whitespace and non-whitespace child.splitText(len(data) - len(shortened)) return start + 1, i + 1 break # all whitespace, just skip start = start + 1 elif nodeType == xml.dom.core.ELEMENT: if child.tagName in PARA_LEVEL_ELEMENTS + PARA_LEVEL_PRECEEDERS: start = start + 1 else: break else: break return start, i
| 11,862
|
def skip_leading_nodes(children, start, i): i = min(i, len(children)) while i > start: # skip over leading comments and whitespace: try: child = children[start] except IndexError: sys.stderr.write( "skip_leading_nodes() failed at index %d\n" % start) raise nodeType = child.nodeType if nodeType == xml.dom.core.COMMENT: start = start + 1 elif nodeType == xml.dom.core.TEXT: data = child.data shortened = string.lstrip(data) if shortened: if data != shortened: # break into two nodes: whitespace and non-whitespace child.splitText(len(data) - len(shortened)) return start + 1, i + 1 break # all whitespace, just skip start = start + 1 elif nodeType == xml.dom.core.ELEMENT: if child.tagName in PARA_LEVEL_ELEMENTS + PARA_LEVEL_PRECEEDERS: start = start + 1 else: break else: break return start, i
|
def skip_leading_nodes(children, start, i): i = min(i, len(children)) while i > start: # skip over leading comments and whitespace: try: child = children[start] except IndexError: sys.stderr.write( "skip_leading_nodes() failed at index %d\n" % start) raise nodeType = child.nodeType if nodeType == xml.dom.core.TEXT: data = child.data shortened = string.lstrip(data) if shortened: if data != shortened: # break into two nodes: whitespace and non-whitespace child.splitText(len(data) - len(shortened)) return start + 1, i + 1 break # all whitespace, just skip start = start + 1 elif nodeType == xml.dom.core.ELEMENT: if child.tagName in PARA_LEVEL_ELEMENTS + PARA_LEVEL_PRECEEDERS: start = start + 1 else: break else: break return start, i
| 11,863
|
def skip_leading_nodes(children, start, i): i = min(i, len(children)) while i > start: # skip over leading comments and whitespace: try: child = children[start] except IndexError: sys.stderr.write( "skip_leading_nodes() failed at index %d\n" % start) raise nodeType = child.nodeType if nodeType == xml.dom.core.COMMENT: start = start + 1 elif nodeType == xml.dom.core.TEXT: data = child.data shortened = string.lstrip(data) if shortened: if data != shortened: # break into two nodes: whitespace and non-whitespace child.splitText(len(data) - len(shortened)) return start + 1, i + 1 break # all whitespace, just skip start = start + 1 elif nodeType == xml.dom.core.ELEMENT: if child.tagName in PARA_LEVEL_ELEMENTS + PARA_LEVEL_PRECEEDERS: start = start + 1 else: break else: break return start, i
|
def skip_leading_nodes(children, start, i): i = min(i, len(children)) while i > start: # skip over leading comments and whitespace: try: child = children[start] except IndexError: sys.stderr.write( "skip_leading_nodes() failed at index %d\n" % start) raise nodeType = child.nodeType if nodeType == xml.dom.core.COMMENT: start = start + 1 elif nodeType == xml.dom.core.TEXT: data = child.data shortened = string.lstrip(data) if shortened: if data != shortened: # break into two nodes: whitespace and non-whitespace child.splitText(len(data) - len(shortened)) return start + 1 return start # all whitespace, just skip start = start + 1 elif nodeType == xml.dom.core.ELEMENT: if child.tagName in PARA_LEVEL_ELEMENTS + PARA_LEVEL_PRECEEDERS: start = start + 1 else: break else: break return start, i
| 11,864
|
def skip_leading_nodes(children, start, i): i = min(i, len(children)) while i > start: # skip over leading comments and whitespace: try: child = children[start] except IndexError: sys.stderr.write( "skip_leading_nodes() failed at index %d\n" % start) raise nodeType = child.nodeType if nodeType == xml.dom.core.COMMENT: start = start + 1 elif nodeType == xml.dom.core.TEXT: data = child.data shortened = string.lstrip(data) if shortened: if data != shortened: # break into two nodes: whitespace and non-whitespace child.splitText(len(data) - len(shortened)) return start + 1, i + 1 break # all whitespace, just skip start = start + 1 elif nodeType == xml.dom.core.ELEMENT: if child.tagName in PARA_LEVEL_ELEMENTS + PARA_LEVEL_PRECEEDERS: start = start + 1 else: break else: break return start, i
|
def skip_leading_nodes(children, start, i): i = min(i, len(children)) while i > start: # skip over leading comments and whitespace: try: child = children[start] except IndexError: sys.stderr.write( "skip_leading_nodes() failed at index %d\n" % start) raise nodeType = child.nodeType if nodeType == xml.dom.core.COMMENT: elif nodeType == xml.dom.core.TEXT: data = child.data shortened = string.lstrip(data) if shortened: if data != shortened: # break into two nodes: whitespace and non-whitespace child.splitText(len(data) - len(shortened)) return start + 1, i + 1 break # all whitespace, just skip elif nodeType == xml.dom.core.ELEMENT: if child.tagName in PARA_LEVEL_ELEMENTS + PARA_LEVEL_PRECEEDERS: else: break else: break return start, i
| 11,865
|
def skip_leading_nodes(children, start, i): i = min(i, len(children)) while i > start: # skip over leading comments and whitespace: try: child = children[start] except IndexError: sys.stderr.write( "skip_leading_nodes() failed at index %d\n" % start) raise nodeType = child.nodeType if nodeType == xml.dom.core.COMMENT: start = start + 1 elif nodeType == xml.dom.core.TEXT: data = child.data shortened = string.lstrip(data) if shortened: if data != shortened: # break into two nodes: whitespace and non-whitespace child.splitText(len(data) - len(shortened)) return start + 1, i + 1 break # all whitespace, just skip start = start + 1 elif nodeType == xml.dom.core.ELEMENT: if child.tagName in PARA_LEVEL_ELEMENTS + PARA_LEVEL_PRECEEDERS: start = start + 1 else: break else: break return start, i
|
def skip_leading_nodes(children, start, i): i = min(i, len(children)) while i > start: # skip over leading comments and whitespace: try: child = children[start] except IndexError: sys.stderr.write( "skip_leading_nodes() failed at index %d\n" % start) raise nodeType = child.nodeType if nodeType == xml.dom.core.COMMENT: start = start + 1 elif nodeType == xml.dom.core.TEXT: data = child.data shortened = string.lstrip(data) if shortened: if data != shortened: # break into two nodes: whitespace and non-whitespace child.splitText(len(data) - len(shortened)) return start + 1, i + 1 break # all whitespace, just skip start = start + 1 elif nodeType == xml.dom.core.ELEMENT: tagName = child.tagName if tagName in RECURSE_INTO_PARA_CONTAINERS: return start if tagName not in PARA_LEVEL_ELEMENTS + PARA_LEVEL_PRECEEDERS: return start start = start + 1 return start
| 11,866
|
def fixup_rfc_references(doc): rfc_nodes = [] for child in doc.childNodes: if child.nodeType == xml.dom.core.ELEMENT: kids = child.getElementsByTagName("rfc") for k in kids: rfc_nodes.append(k) for rfc_node in rfc_nodes: rfc_node.appendChild(doc.createTextNode( "RFC " + rfc_node.getAttribute("num")))
|
def fixup_rfc_references(doc): for rfcnode in find_all_elements(doc, "rfc"): rfcnode.appendChild(doc.createTextNode( "RFC " + rfcnode.getAttribute("num")))
| 11,867
|
def pprint(object, stream=None, indent=1, width=80, depth=None): """Pretty-print a Python object to a stream [default is sys.sydout].""" printer = PrettyPrinter( stream=stream, indent=indent, width=width, depth=depth) printer.pprint(object)
|
def pprint(object, stream=None, indent=1, width=80, depth=None): """Pretty-print a Python object to a stream [default is sys.stdout].""" printer = PrettyPrinter( stream=stream, indent=indent, width=width, depth=depth) printer.pprint(object)
| 11,868
|
def UpdateRecentFilesList(self,newFile=None): "Load or update the recent files list, and menu if required" rfList=[] if os.path.exists(self.recentFilesPath): RFfile=open(self.recentFilesPath,'r') try: rfList=RFfile.readlines() finally: RFfile.close() if newFile: newFile=os.path.abspath(newFile)+'\n' if newFile in rfList: rfList.remove(newFile) rfList.insert(0,newFile) rfList=self.__CleanRecentFiles(rfList) #print self.flist.inversedict #print self.top.instanceDict #print self if rfList: for instance in self.top.instanceDict.keys(): instance.menuRecentFiles.delete(1,END) for file in rfList: fileName=file[0:-1] instance.menuRecentFiles.add_command(label=fileName, command=instance.__RecentFileCallback(fileName))
|
def UpdateRecentFilesList(self,newFile=None): "Load or update the recent files list, and menu if required" rfList=[] if os.path.exists(self.recentFilesPath): RFfile=open(self.recentFilesPath,'r') try: rfList=RFfile.readlines() finally: RFfile.close() if newFile: newFile=os.path.abspath(newFile)+'\n' if newFile in rfList: rfList.remove(newFile) rfList.insert(0,newFile) rfList=self.__CleanRecentFiles(rfList) #print self.flist.inversedict #print self.top.instanceDict #print self if rfList: for instance in self.top.instanceDict.keys(): menu = instance.menuRecentFiles menu.delete(1,END) i = 0 ; ul = 0; ullen = len(ullist) for file in rfList: fileName=file[0:-1] instance.menuRecentFiles.add_command(label=fileName, command=instance.__RecentFileCallback(fileName))
| 11,869
|
def UpdateRecentFilesList(self,newFile=None): "Load or update the recent files list, and menu if required" rfList=[] if os.path.exists(self.recentFilesPath): RFfile=open(self.recentFilesPath,'r') try: rfList=RFfile.readlines() finally: RFfile.close() if newFile: newFile=os.path.abspath(newFile)+'\n' if newFile in rfList: rfList.remove(newFile) rfList.insert(0,newFile) rfList=self.__CleanRecentFiles(rfList) #print self.flist.inversedict #print self.top.instanceDict #print self if rfList: for instance in self.top.instanceDict.keys(): instance.menuRecentFiles.delete(1,END) for file in rfList: fileName=file[0:-1] instance.menuRecentFiles.add_command(label=fileName, command=instance.__RecentFileCallback(fileName))
|
def UpdateRecentFilesList(self,newFile=None): "Load or update the recent files list, and menu if required" rfList=[] if os.path.exists(self.recentFilesPath): RFfile=open(self.recentFilesPath,'r') try: rfList=RFfile.readlines() finally: RFfile.close() if newFile: newFile=os.path.abspath(newFile)+'\n' if newFile in rfList: rfList.remove(newFile) rfList.insert(0,newFile) rfList=self.__CleanRecentFiles(rfList) #print self.flist.inversedict #print self.top.instanceDict #print self if rfList: for instance in self.top.instanceDict.keys(): instance.menuRecentFiles.delete(1,END) for file in rfList: fileName=file[0:-1] callback = instance.__RecentFileCallback(fileName) if i > ullen: ul=None menu.add_command(label=ullist[i] + " " + fileName, command=callback, underline=ul) i += 1
| 11,870
|
def _get_params_preserve(self, failobj, header): # Like get_params() but preserves the quoting of values. BAW: # should this be part of the public interface? missing = [] value = self.get(header, missing) if value is missing: return failobj params = [] for p in paramre.split(value): try: name, val = p.split('=', 1) name = name.strip() val = val.strip() except ValueError: # Must have been a bare attribute name = p.strip() val = '' params.append((name, val)) params = Utils.decode_params(params) return params
|
def _get_params_preserve(self, failobj, header): # Like get_params() but preserves the quoting of values. BAW: # should this be part of the public interface? missing = [] value = self.get(header, missing) if value is missing: return failobj params = [] for p in _parseparam(';' + value): try: name, val = p.split('=', 1) name = name.strip() val = val.strip() except ValueError: # Must have been a bare attribute name = p.strip() val = '' params.append((name, val)) params = Utils.decode_params(params) return params
| 11,871
|
def register_X_browsers(): # First, the Mozilla/Netscape browsers for browser in ("mozilla-firefox", "firefox", "mozilla-firebird", "firebird", "mozilla", "netscape"): if _iscommand(browser): register(browser, None, Mozilla(browser)) # The default Gnome browser if _iscommand("gconftool-2"): # get the web browser string from gconftool gc = 'gconftool-2 -g /desktop/gnome/url-handlers/http/command' out = os.popen(gc) commd = out.read().strip() retncode = out.close() # if successful, register it if retncode == None and len(commd) != 0: register("gnome", None, GenericBrowser( commd + " '%s' >/dev/null &")) # Konqueror/kfm, the KDE browser. if _iscommand("kfm") or _iscommand("konqueror"): register("kfm", Konqueror, Konqueror()) # Gnome's Galeon and Epiphany for browser in ("galeon", "epiphany"): if _iscommand(browser): register(browser, None, Galeon(browser)) # Skipstone, another Gtk/Mozilla based browser if _iscommand("skipstone"): register("skipstone", None, GenericBrowser("skipstone '%s' &")) # Opera, quite popular if _iscommand("opera"): register("opera", None, Opera("opera")) # Next, Mosaic -- old but still in use. if _iscommand("mosaic"): register("mosaic", None, GenericBrowser("mosaic '%s' &")) # Grail, the Python browser. Does anybody still use it? if _iscommand("grail"): register("grail", Grail, None)
|
def register_X_browsers(): # First, the Mozilla/Netscape browsers for browser in ("mozilla-firefox", "firefox", "mozilla-firebird", "firebird", "mozilla", "netscape"): if _iscommand(browser): register(browser, None, Mozilla(browser)) # The default Gnome browser if _iscommand("gconftool-2"): # get the web browser string from gconftool gc = 'gconftool-2 -g /desktop/gnome/url-handlers/http/command' out = os.popen(gc) commd = out.read().strip() retncode = out.close() # if successful, register it if retncode == None and len(commd) != 0: register("gnome", None, GenericBrowser( commd + " '%s' >/dev/null &")) # Konqueror/kfm, the KDE browser. if _iscommand("kfm"): register("kfm", Konqueror, Konqueror("kfm")) elif _iscommand("konqueror"): register("konqueror", Konqueror, Konqueror("konqueror")) # Gnome's Galeon and Epiphany for browser in ("galeon", "epiphany"): if _iscommand(browser): register(browser, None, Galeon(browser)) # Skipstone, another Gtk/Mozilla based browser if _iscommand("skipstone"): register("skipstone", None, GenericBrowser("skipstone '%s' &")) # Opera, quite popular if _iscommand("opera"): register("opera", None, Opera("opera")) # Next, Mosaic -- old but still in use. if _iscommand("mosaic"): register("mosaic", None, GenericBrowser("mosaic '%s' &")) # Grail, the Python browser. Does anybody still use it? if _iscommand("grail"): register("grail", Grail, None)
| 11,872
|
def detect_modules(self): # XXX this always gets an empty list -- hardwiring to # a fixed list lib_dirs = self.compiler.library_dirs[:] lib_dirs += ['/lib', '/usr/lib', '/usr/local/lib'] exts = []
|
def detect_modules(self): # XXX this always gets an empty list -- hardwiring to # a fixed list lib_dirs = self.compiler.library_dirs[:] lib_dirs += ['/lib', '/usr/lib', '/usr/local/lib'] exts = []
| 11,873
|
def detect_modules(self): # XXX this always gets an empty list -- hardwiring to # a fixed list lib_dirs = self.compiler.library_dirs[:] lib_dirs += ['/lib', '/usr/lib', '/usr/local/lib'] exts = []
|
def detect_modules(self): # XXX this always gets an empty list -- hardwiring to # a fixed list lib_dirs = self.compiler.library_dirs[:] lib_dirs += ['/lib', '/usr/lib', '/usr/local/lib'] exts = []
| 11,874
|
def normalize(p): # Strip unnecessary zero coefficients n = len(p) while p: if p[n-1]: return p[:n] n = n-1 return []
|
def normalize(p): # Strip unnecessary zero coefficients n = len(p) while n: if p[n-1]: return p[:n] n = n-1 return []
| 11,875
|
def dump_special(self, callable, args, state = None):
|
def dump_special(self, callable, args, state = None):
| 11,876
|
def save(self, object, pers_save = 0): memo = self.memo
|
def save(self, object, pers_save = 0): memo = self.memo
| 11,877
|
def load_reduce(self): stack = self.stack
|
def load_reduce(self): stack = self.stack
| 11,878
|
def load_reduce(self): stack = self.stack
|
def load_reduce(self): stack = self.stack
| 11,879
|
def run (self): if (sys.platform != "win32" and (self.distribution.has_ext_modules() or self.distribution.has_c_libraries())): raise DistutilsPlatformError \ ("distribution contains extensions and/or C libraries; " "must be compiled on a Windows 32 platform")
|
def run (self): if (sys.platform != "win32" and (self.distribution.has_ext_modules() or self.distribution.has_c_libraries())): raise DistutilsPlatformError \ ("distribution contains extensions and/or C libraries; " "must be compiled on a Windows 32 platform")
| 11,880
|
def run (self): if (sys.platform != "win32" and (self.distribution.has_ext_modules() or self.distribution.has_c_libraries())): raise DistutilsPlatformError \ ("distribution contains extensions and/or C libraries; " "must be compiled on a Windows 32 platform")
|
def run (self): if (sys.platform != "win32" and (self.distribution.has_ext_modules() or self.distribution.has_c_libraries())): raise DistutilsPlatformError \ ("distribution contains extensions and/or C libraries; " "must be compiled on a Windows 32 platform")
| 11,881
|
def get_inidata (self): # Return data describing the installation.
|
def get_inidata (self): # Return data describing the installation.
| 11,882
|
def get_exe_bytes (self): import base64 return base64.decodestring (EXEDATA)
|
def get_exe_bytes (self): import base64 return base64.decodestring (EXEDATA)
| 11,883
|
def get_exe_bytes (self): import base64 return base64.decodestring (EXEDATA)
|
def get_exe_bytes (self): import base64 return base64.decodestring (EXEDATA)
| 11,884
|
def get_exe_bytes (self): import base64 return base64.decodestring (EXEDATA)
|
def get_exe_bytes (self): import base64 return base64.decodestring (EXEDATA)
| 11,885
|
def get_exe_bytes (self): import base64 return base64.decodestring (EXEDATA)
|
def get_exe_bytes (self): import base64 return base64.decodestring (EXEDATA)
| 11,886
|
def get_exe_bytes (self): import base64 return base64.decodestring (EXEDATA)
|
def get_exe_bytes (self): import base64 return base64.decodestring (EXEDATA)
| 11,887
|
def get_exe_bytes (self): import base64 return base64.decodestring (EXEDATA)
|
def get_exe_bytes (self): import base64 return base64.decodestring (EXEDATA)
| 11,888
|
def newnews(self, group, date, time, file=None): """Process a NEWNEWS command. Arguments: - group: group name or '*' - date: string 'yymmdd' indicating the date - time: string 'hhmmss' indicating the time Return: - resp: server response if successful - list: list of article ids"""
|
def newnews(self, group, date, time, file=None): """Process a NEWNEWS command. Arguments: - group: group name or '*' - date: string 'yymmdd' indicating the date - time: string 'hhmmss' indicating the time Return: - resp: server response if successful - list: list of article ids"""
| 11,889
|
def stat(self, id): """Process a STAT command. Argument: - id: article number or message id Returns: - resp: server response if successful - nr: the article number - id: the article id"""
|
def stat(self, id): """Process a STAT command. Argument: - id: article number or message id Returns: - resp: server response if successful - nr: the article number - id: the article id"""
| 11,890
|
def makepath(*paths): dir = os.path.abspath(os.path.join(*paths)) return dir, os.path.normcase(dir)
|
def makepath(*paths): dir = os.path.abspath(os.path.join(*paths)) return dir, os.path.normcase(dir)
| 11,891
|
def preprocess (self, source, output_file=None, macros=None, include_dirs=None, extra_preargs=None, extra_postargs=None):
|
def preprocess (self, source, output_file=None, macros=None, include_dirs=None, extra_preargs=None, extra_postargs=None):
| 11,892
|
def run (self):
|
def run (self):
| 11,893
|
def run (self):
|
def run (self):
| 11,894
|
def run (self):
|
def run (self):
| 11,895
|
def setUp(self): self.case = "empty set" self.values = [] self.set = set(self.values) self.dup = set(self.values) self.length = 0 self.repr = "{}"
|
def setUp(self): self.case = "empty set" self.values = [] self.set = set(self.values) self.dup = set(self.values) self.length = 0 self.repr = "{}"
| 11,896
|
def open_local_file(self, url): import mimetypes, mimetools, StringIO mtype = mimetypes.guess_type(url)[0] headers = mimetools.Message(StringIO.StringIO( 'Content-Type: %s\n' % (mtype or 'text/plain'))) host, file = splithost(url) if not host: return addinfourl(open(url2pathname(file), 'rb'), headers, 'file:'+file) host, port = splitport(host) if not port \ and socket.gethostbyname(host) in (localhost(), thishost()): return addinfourl(open(url2pathname(file), 'rb'), headers, 'file:'+file) raise IOError, ('local file error', 'not on local host')
|
def open_local_file(self, url): import mimetypes, mimetools, StringIO mtype = mimetypes.guess_type(url)[0] headers = mimetools.Message(StringIO.StringIO( 'Content-Type: %s\n' % (mtype or 'text/plain'))) host, file = splithost(url) if not host: return addinfourl(open(url2pathname(file), 'rb'), headers, urlfile) host, port = splitport(host) if not port \ and socket.gethostbyname(host) in (localhost(), thishost()): return addinfourl(open(url2pathname(file), 'rb'), headers, urlfile) raise IOError, ('local file error', 'not on local host')
| 11,897
|
def open_local_file(self, url): import mimetypes, mimetools, StringIO mtype = mimetypes.guess_type(url)[0] headers = mimetools.Message(StringIO.StringIO( 'Content-Type: %s\n' % (mtype or 'text/plain'))) host, file = splithost(url) if not host: return addinfourl(open(url2pathname(file), 'rb'), headers, 'file:'+file) host, port = splitport(host) if not port \ and socket.gethostbyname(host) in (localhost(), thishost()): return addinfourl(open(url2pathname(file), 'rb'), headers, 'file:'+file) raise IOError, ('local file error', 'not on local host')
|
def open_local_file(self, url): import mimetypes, mimetools, StringIO mtype = mimetypes.guess_type(url)[0] headers = mimetools.Message(StringIO.StringIO( 'Content-Type: %s\n' % (mtype or 'text/plain'))) host, file = splithost(url) if not host: return addinfourl(open(url2pathname(file), 'rb'), headers, urlfile) host, port = splitport(host) if not port \ and socket.gethostbyname(host) in (localhost(), thishost()): return addinfourl(open(url2pathname(file), 'rb'), headers, urlfile) raise IOError, ('local file error', 'not on local host')
| 11,898
|
def parse(self, lines): """parse the input lines from a robot.txt file. We allow that a user-agent: line is not preceded by one or more blank lines.""" state = 0 linenumber = 0 entry = Entry()
|
def parse(self, lines): """parse the input lines from a robots.txt file. We allow that a user-agent: line is not preceded by one or more blank lines.""" state = 0 linenumber = 0 entry = Entry()
| 11,899
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.