bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
def get_config_h_filename(): """Return full pathname of installed pyconfig.h file.""" if python_build: inc_dir = os.curdir else: inc_dir = get_python_inc(plat_specific=1) if get_python_version() < '2.2': config_h = 'config.h' else: # The name of the config.h file changed in 2.2 config_h = 'pyconfig.h' return os.path.join(inc_dir, config_h)
def get_config_h_filename(): """Return full pathname of installed pyconfig.h file.""" if python_build: inc_dir = argv0_path else: inc_dir = get_python_inc(plat_specific=1) if get_python_version() < '2.2': config_h = 'config.h' else: # The name of the config.h file changed in 2.2 config_h = 'pyconfig.h' return os.path.join(inc_dir, config_h)
8,700
def askopenfilenames(**options): """Ask for multiple filenames to open Returns a list of filenames or empty list if cancel button selected """ options["multiple"]=1 files=Open(**options).show() return files.split()
def askopenfilenames(**options): """Ask for multiple filenames to open Returns a list of filenames or empty list if cancel button selected """ options["multiple"]=1 return Open(**options).show()
8,701
def report_callback_exception(self, exc, val, tb): import traceback print "Exception in Tkinter callback" traceback.print_exception(exc, val, tb)
def report_callback_exception(self, exc, val, tb): import traceback, sys sys.stderr.write("Exception in Tkinter callback\n") traceback.print_exception(exc, val, tb)
8,702
def _setup(self, master, cnf): if _support_default_root: global _default_root if not master: if not _default_root: _default_root = Tk() master = _default_root if not _default_root: _default_root = master self.master = master self.tk = master.tk name = None if cnf.has_key('name'): name = cnf['name'] del cnf['name'] if not name: name = `id(self)` self._name = name if master._w=='.': self._w = '.' + name else: self._w = master._w + '.' + name self.children = {} if self.master.children.has_key(self._name): self.master.children[self._name].destroy() self.master.children[self._name] = self
def _setup(self, master, cnf): if _support_default_root: global _default_root if not master: if not _default_root: _default_root = Tk() master = _default_root self.master = master self.tk = master.tk name = None if cnf.has_key('name'): name = cnf['name'] del cnf['name'] if not name: name = `id(self)` self._name = name if master._w=='.': self._w = '.' + name else: self._w = master._w + '.' + name self.children = {} if self.master.children.has_key(self._name): self.master.children[self._name].destroy() self.master.children[self._name] = self
8,703
def __setitem__(self, key, val): if not type(key) == type('') == type(val): raise TypeError, "keys and values must be strings" if not self._index.has_key(key): (pos, siz) = self._addval(val) self._addkey(key, (pos, siz)) else: pos, siz = self._index[key] oldblocks = (siz + _BLOCKSIZE - 1) / _BLOCKSIZE newblocks = (len(val) + _BLOCKSIZE - 1) / _BLOCKSIZE if newblocks <= oldblocks: pos, siz = self._setval(pos, val) self._index[key] = pos, siz else: pos, siz = self._addval(val) self._index[key] = pos, siz self._addkey(key, (pos, siz))
def __setitem__(self, key, val): if not type(key) == type('') == type(val): raise TypeError, "keys and values must be strings" if not self._index.has_key(key): (pos, siz) = self._addval(val) else: pos, siz = self._index[key] oldblocks = (siz + _BLOCKSIZE - 1) / _BLOCKSIZE newblocks = (len(val) + _BLOCKSIZE - 1) / _BLOCKSIZE if newblocks <= oldblocks: pos, siz = self._setval(pos, val) self._index[key] = pos, siz else: pos, siz = self._addval(val) self._index[key] = pos, siz
8,704
def save_int(self, object, pack=struct.pack): if self.bin: # If the int is small enough to fit in a signed 4-byte 2's-comp # format, we can store it more efficiently than the general # case. # First one- and two-byte unsigned ints: if object >= 0: if object < 0xff: self.write(BININT1 + chr(object)) return if object < 0xffff: self.write(BININT2 + chr(object&0xff) + chr(object>>8)) return # Next check for 4-byte signed ints: high_bits = object >> 31 # note that Python shift sign-extends if high_bits == 0 or high_bits == -1: # All high bits are copies of bit 2**31, so the value # fits in a 4-byte signed int. self.write(BININT + pack("<i", object)) return # Text pickle, or int too big to fit in signed 4-byte format. self.write(INT + `object` + '\n')
def save_int(self, object, pack=struct.pack): if self.bin: # If the int is small enough to fit in a signed 4-byte 2's-comp # format, we can store it more efficiently than the general # case. # First one- and two-byte unsigned ints: if object >= 0: if object <= 0xff: self.write(BININT1 + chr(object)) return if object < 0xffff: self.write(BININT2 + chr(object&0xff) + chr(object>>8)) return # Next check for 4-byte signed ints: high_bits = object >> 31 # note that Python shift sign-extends if high_bits == 0 or high_bits == -1: # All high bits are copies of bit 2**31, so the value # fits in a 4-byte signed int. self.write(BININT + pack("<i", object)) return # Text pickle, or int too big to fit in signed 4-byte format. self.write(INT + `object` + '\n')
8,705
def save_int(self, object, pack=struct.pack): if self.bin: # If the int is small enough to fit in a signed 4-byte 2's-comp # format, we can store it more efficiently than the general # case. # First one- and two-byte unsigned ints: if object >= 0: if object < 0xff: self.write(BININT1 + chr(object)) return if object < 0xffff: self.write(BININT2 + chr(object&0xff) + chr(object>>8)) return # Next check for 4-byte signed ints: high_bits = object >> 31 # note that Python shift sign-extends if high_bits == 0 or high_bits == -1: # All high bits are copies of bit 2**31, so the value # fits in a 4-byte signed int. self.write(BININT + pack("<i", object)) return # Text pickle, or int too big to fit in signed 4-byte format. self.write(INT + `object` + '\n')
def save_int(self, object, pack=struct.pack): if self.bin: # If the int is small enough to fit in a signed 4-byte 2's-comp # format, we can store it more efficiently than the general # case. # First one- and two-byte unsigned ints: if object >= 0: if object < 0xff: self.write(BININT1 + chr(object)) return if object <= 0xffff: self.write(BININT2 + chr(object&0xff) + chr(object>>8)) return # Next check for 4-byte signed ints: high_bits = object >> 31 # note that Python shift sign-extends if high_bits == 0 or high_bits == -1: # All high bits are copies of bit 2**31, so the value # fits in a 4-byte signed int. self.write(BININT + pack("<i", object)) return # Text pickle, or int too big to fit in signed 4-byte format. self.write(INT + `object` + '\n')
8,706
def search(pattern, string, flags=0): assert flags == 0 return compile(pattern, _fixflags(flags)).search(string)
def search(pattern, string, flags=0): return compile(pattern, _fixflags(flags)).search(string)
8,707
def join(a, *p): """Join two or more pathname components, inserting "\\" as needed""" path = a for b in p: if isabs(b): path = b elif path == '' or path[-1:] in '/\\:': path = path + b else: path = path + "\\" + b return path
def join(a, *p): """Join two or more pathname components, inserting "\\" as needed""" path = a for b in p: if len(path) == 2 and path[-1] == ":" and splitdrive(b)[0] == "": pass elif isabs(b) or path == "": path = "" elif path[-1:] not in "/\\": b = "\\" + b path += b return path
8,708
def triplet_to_pmwrgb(rgbtuple): return map(operator.__div__, rgbtuple, _maxtuple)
def triplet_to_fractional_rgb(rgbtuple): return map(operator.__div__, rgbtuple, _maxtuple)
8,709
def triplet_to_pmwrgb(rgbtuple): return map(operator.__div__, rgbtuple, _maxtuple)
def triplet_to_pmwrgb(rgbtuple): return map(operator.__div__, rgbtuple, _maxtuple)
8,710
def triplet_to_pmwrgb(rgbtuple): return map(operator.__div__, rgbtuple, _maxtuple)
def triplet_to_pmwrgb(rgbtuple): return map(operator.__div__, rgbtuple, _maxtuple)
8,711
def repr1(self, x, level): methodname = 'repr_' + join(split(type(x).__name__), '_') if hasattr(self, methodname): return getattr(self, methodname)(x, level) else: return self.escape(cram(stripid(repr(x)), self.maxother))
def repr1(self, x, level): methodname = 'repr_' + join(split(type(x).__name__), '_') if hasattr(self, methodname): return getattr(self, methodname)(x, level) else: return self.escape(cram(stripid(repr(x)), self.maxother))
8,712
def repr1(self, x, level): methodname = 'repr_' + join(split(type(x).__name__), '_') if hasattr(self, methodname): return getattr(self, methodname)(x, level) else: return cram(stripid(repr(x)), self.maxother)
def repr1(self, x, level): methodname = 'repr_' + join(split(type(x).__name__), '_') if hasattr(self, methodname): return getattr(self, methodname)(x, level) else: return cram(stripid(repr(x)), self.maxother)
8,713
def copytree(src, dst, symlinks=False): """Recursively copy a directory tree using copy2(). The destination directory must not already exist. If exception(s) occur, an Error is raised with a list of reasons. If the optional symlinks flag is true, symbolic links in the source tree result in symbolic links in the destination tree; if it is false, the contents of the files pointed to by symbolic links are copied. XXX Consider this example code rather than the ultimate tool. """ names = os.listdir(src) os.makedirs(dst) errors = [] for name in names: srcname = os.path.join(src, name) dstname = os.path.join(dst, name) try: if symlinks and os.path.islink(srcname): linkto = os.readlink(srcname) os.symlink(linkto, dstname) elif os.path.isdir(srcname): copytree(srcname, dstname, symlinks) else: copy2(srcname, dstname) # XXX What about devices, sockets etc.? except (IOError, os.error), why: errors.append((srcname, dstname, why)) # catch the Error from the recursive copytree so that we can # continue with other files except Error, err: errors.extend(err.args[0]) copystat(src, dst) if errors: raise Error, errors
def copytree(src, dst, symlinks=False): """Recursively copy a directory tree using copy2(). The destination directory must not already exist. If exception(s) occur, an Error is raised with a list of reasons. If the optional symlinks flag is true, symbolic links in the source tree result in symbolic links in the destination tree; if it is false, the contents of the files pointed to by symbolic links are copied. XXX Consider this example code rather than the ultimate tool. """ names = os.listdir(src) os.makedirs(dst) errors = [] for name in names: srcname = os.path.join(src, name) dstname = os.path.join(dst, name) try: if symlinks and os.path.islink(srcname): linkto = os.readlink(srcname) os.symlink(linkto, dstname) elif os.path.isdir(srcname): copytree(srcname, dstname, symlinks) else: copy2(srcname, dstname) # XXX What about devices, sockets etc.? except (IOError, os.error), why: errors.append((srcname, dstname, str(why))) # catch the Error from the recursive copytree so that we can # continue with other files except Error, err: errors.extend(err.args[0]) copystat(src, dst) if errors: raise Error, errors
8,714
def testMultiply(self): self.assertEquals((0 * 10), 0) self.assertEquals((5 * 8), 40)
def testMultiply(self): self.assertEquals((0 * 10), 0) self.assertEquals((5 * 8), 40)
8,715
def __repr__(self): return "<%s run=%i errors=%i failures=%i>" % \ (self.__class__, self.testsRun, len(self.errors), len(self.failures))
def __repr__(self): return "<%s run=%i errors=%i failures=%i>" % \ (_strclass(self.__class__), self.testsRun, len(self.errors), len(self.failures))
8,716
def id(self): return "%s.%s" % (self.__class__, self.__testMethodName)
def id(self): return "%s.%s" % (self.__class__, self.__testMethodName)
8,717
def __repr__(self): return "<%s testMethod=%s>" % \ (self.__class__, self.__testMethodName)
def __repr__(self): return "<%s testMethod=%s>" % \ (self.__class__, self.__testMethodName)
8,718
def __repr__(self): return "<%s tests=%s>" % (self.__class__, self._tests)
def __repr__(self): return "<%s tests=%s>" % (self.__class__, self._tests)
8,719
def __str__(self): return "%s (%s)" % (self.__class__, self.__testFunc.__name__)
def __str__(self): return "%s (%s)" % (self.__class__, self.__testFunc.__name__)
8,720
def __repr__(self): return "<%s testFunc=%s>" % (self.__class__, self.__testFunc)
def __repr__(self): return "<%s testFunc=%s>" % (self.__class__, self.__testFunc)
8,721
def find_module(self, fullname, path=None): self.imports.append(fullname) return None
def find_module(self, fullname, path=None): self.imports.append(fullname) return None
8,722
def _cleanup(): for inst in _active[:]: inst.poll()
def _cleanup(): for inst in _active[:]: if inst.poll(_deadstate=sys.maxint) >= 0: try: _active.remove(inst) except ValueError: pass
8,723
def __init__(self, args, bufsize=0, executable=None, stdin=None, stdout=None, stderr=None, preexec_fn=None, close_fds=False, shell=False, cwd=None, env=None, universal_newlines=False, startupinfo=None, creationflags=0): """Create new Popen instance.""" _cleanup()
def __init__(self, args, bufsize=0, executable=None, stdin=None, stdout=None, stderr=None, preexec_fn=None, close_fds=False, shell=False, cwd=None, env=None, universal_newlines=False, startupinfo=None, creationflags=0): """Create new Popen instance.""" _cleanup()
8,724
def poll(self): """Check if child process has terminated. Returns returncode attribute.""" if self.returncode is None: if WaitForSingleObject(self._handle, 0) == WAIT_OBJECT_0: self.returncode = GetExitCodeProcess(self._handle) _active.remove(self) return self.returncode
def poll(self, _deadstate=None): """Check if child process has terminated. Returns returncode attribute.""" if self.returncode is None: if WaitForSingleObject(self._handle, 0) == WAIT_OBJECT_0: self.returncode = GetExitCodeProcess(self._handle) _active.remove(self) return self.returncode
8,725
def poll(self): """Check if child process has terminated. Returns returncode attribute.""" if self.returncode is None: if WaitForSingleObject(self._handle, 0) == WAIT_OBJECT_0: self.returncode = GetExitCodeProcess(self._handle) _active.remove(self) return self.returncode
def poll(self): """Check if child process has terminated. Returns returncode attribute.""" if self.returncode is None: if WaitForSingleObject(self._handle, 0) == WAIT_OBJECT_0: self.returncode = GetExitCodeProcess(self._handle) return self.returncode
8,726
def wait(self): """Wait for child process to terminate. Returns returncode attribute.""" if self.returncode is None: obj = WaitForSingleObject(self._handle, INFINITE) self.returncode = GetExitCodeProcess(self._handle) _active.remove(self) return self.returncode
def wait(self): """Wait for child process to terminate. Returns returncode attribute.""" if self.returncode is None: obj = WaitForSingleObject(self._handle, INFINITE) self.returncode = GetExitCodeProcess(self._handle) return self.returncode
8,727
def _handle_exitstatus(self, sts): if os.WIFSIGNALED(sts): self.returncode = -os.WTERMSIG(sts) elif os.WIFEXITED(sts): self.returncode = os.WEXITSTATUS(sts) else: # Should never happen raise RuntimeError("Unknown child exit status!")
def _handle_exitstatus(self, sts): if os.WIFSIGNALED(sts): self.returncode = -os.WTERMSIG(sts) elif os.WIFEXITED(sts): self.returncode = os.WEXITSTATUS(sts) else: # Should never happen raise RuntimeError("Unknown child exit status!")
8,728
def poll(self): """Check if child process has terminated. Returns returncode attribute.""" if self.returncode is None: try: pid, sts = os.waitpid(self.pid, os.WNOHANG) if pid == self.pid: self._handle_exitstatus(sts) except os.error: pass return self.returncode
def poll(self): """Check if child process has terminated. Returns returncode attribute.""" if self.returncode is None: try: pid, sts = os.waitpid(self.pid, os.WNOHANG) if pid == self.pid: self._handle_exitstatus(sts) except os.error: if _deadstate is not None: self.returncode = _deadstate return self.returncode
8,729
def run_cgi(self): """Execute a CGI script.""" dir, rest = self.cgi_info i = rest.rfind('?') if i >= 0: rest, query = rest[:i], rest[i+1:] else: query = '' i = rest.find('/') if i >= 0: script, rest = rest[:i], rest[i:] else: script, rest = rest, '' scriptname = dir + '/' + script scriptfile = self.translate_path(scriptname) if not os.path.exists(scriptfile): self.send_error(404, "No such CGI script (%s)" % `scriptname`) return if not os.path.isfile(scriptfile): self.send_error(403, "CGI script is not a plain file (%s)" % `scriptname`) return ispy = self.is_python(scriptname) if not ispy: if not (self.have_fork or self.have_popen2): self.send_error(403, "CGI script is not a Python script (%s)" % `scriptname`) return if not self.is_executable(scriptfile): self.send_error(403, "CGI script is not executable (%s)" % `scriptname`) return
def run_cgi(self): """Execute a CGI script.""" dir, rest = self.cgi_info i = rest.rfind('?') if i >= 0: rest, query = rest[:i], rest[i+1:] else: query = '' i = rest.find('/') if i >= 0: script, rest = rest[:i], rest[i:] else: script, rest = rest, '' scriptname = dir + '/' + script scriptfile = self.translate_path(scriptname) if not os.path.exists(scriptfile): self.send_error(404, "No such CGI script (%s)" % `scriptname`) return if not os.path.isfile(scriptfile): self.send_error(403, "CGI script is not a plain file (%s)" % `scriptname`) return ispy = self.is_python(scriptname) if not ispy: if not (self.have_fork or self.have_popen2): self.send_error(403, "CGI script is not a Python script (%s)" % `scriptname`) return if not self.is_executable(scriptfile): self.send_error(403, "CGI script is not executable (%s)" % `scriptname`) return
8,730
def makeusermenus(self): m = Wapplication.Menu(self.menubar, "File") newitem = FrameWork.MenuItem(m, "New", "N", 'new') openitem = FrameWork.MenuItem(m, "Open", "O", 'open') FrameWork.Separator(m) closeitem = FrameWork.MenuItem(m, "Close", "W", 'close') saveitem = FrameWork.MenuItem(m, "Save", "S", 'save') saveasitem = FrameWork.MenuItem(m, "Save as", None, 'save_as') FrameWork.Separator(m) saveasappletitem = FrameWork.MenuItem(m, "Save as Applet", None, 'save_as_applet') FrameWork.Separator(m) quititem = FrameWork.MenuItem(m, "Quit", "Q", 'quit') m = Wapplication.Menu(self.menubar, "Edit") undoitem = FrameWork.MenuItem(m, "Undo", 'Z', "undo") FrameWork.Separator(m) cutitem = FrameWork.MenuItem(m, "Cut", 'X', "cut") copyitem = FrameWork.MenuItem(m, "Copy", "C", "copy") pasteitem = FrameWork.MenuItem(m, "Paste", "V", "paste") FrameWork.MenuItem(m, "Clear", None, "clear") FrameWork.Separator(m) selallitem = FrameWork.MenuItem(m, "Select all", "A", "selectall") sellineitem = FrameWork.MenuItem(m, "Select line", "L", "selectline") FrameWork.Separator(m) finditem = FrameWork.MenuItem(m, "Find", "F", "find") findagainitem = FrameWork.MenuItem(m, "Find again", 'G', "findnext") enterselitem = FrameWork.MenuItem(m, "Enter search string", "E", "entersearchstring") replaceitem = FrameWork.MenuItem(m, "Replace", None, "replace") replacefinditem = FrameWork.MenuItem(m, "Replace & find again", 'T', "replacefind") FrameWork.Separator(m) shiftleftitem = FrameWork.MenuItem(m, "Shift left", "[", "shiftleft") shiftrightitem = FrameWork.MenuItem(m, "Shift right", "]", "shiftright") m = Wapplication.Menu(self.menubar, "Python") runitem = FrameWork.MenuItem(m, "Run window", "R", 'run') runselitem = FrameWork.MenuItem(m, "Run selection", None, 'runselection') FrameWork.Separator(m) moditem = FrameWork.MenuItem(m, "Module browser", "M", self.domenu_modulebrowser) FrameWork.Separator(m) mm = FrameWork.SubMenu(m, "Preferences") FrameWork.MenuItem(mm, "Set Scripts folder", None, self.do_setscriptsfolder) FrameWork.MenuItem(mm, "Editor default settings", None, self.do_editorprefs) self.openwindowsmenu = Wapplication.Menu(self.menubar, 'Windows') self.makeopenwindowsmenu() self._menustocheck = [closeitem, saveitem, saveasitem, saveasappletitem, undoitem, cutitem, copyitem, pasteitem, selallitem, sellineitem, finditem, findagainitem, enterselitem, replaceitem, replacefinditem, shiftleftitem, shiftrightitem, runitem, runselitem] prefs = self.getprefs() try: fss, fss_changed = macfs.RawAlias(prefs.scriptsfolder).Resolve() except: path = os.path.join(os.getcwd(), 'Scripts') if not os.path.exists(path): os.mkdir(path) fss = macfs.FSSpec(path) self.scriptsfolder = fss.NewAlias() self.scriptsfoldermodtime = fss.GetDates()[1] else: self.scriptsfolder = fss.NewAlias() self.scriptsfoldermodtime = fss.GetDates()[1] prefs.scriptsfolder = self.scriptsfolder.data self._scripts = {} self.scriptsmenu = None self.makescriptsmenu()
def makeusermenus(self): m = Wapplication.Menu(self.menubar, "File") newitem = FrameWork.MenuItem(m, "New", "N", 'new') openitem = FrameWork.MenuItem(m, "Open", "O", 'open') FrameWork.Separator(m) closeitem = FrameWork.MenuItem(m, "Close", "W", 'close') saveitem = FrameWork.MenuItem(m, "Save", "S", 'save') saveasitem = FrameWork.MenuItem(m, "Save as", None, 'save_as') FrameWork.Separator(m) saveasappletitem = FrameWork.MenuItem(m, "Save as Applet", None, 'save_as_applet') FrameWork.Separator(m) quititem = FrameWork.MenuItem(m, "Quit", "Q", 'quit') m = Wapplication.Menu(self.menubar, "Edit") undoitem = FrameWork.MenuItem(m, "Undo", 'Z', "undo") FrameWork.Separator(m) cutitem = FrameWork.MenuItem(m, "Cut", 'X', "cut") copyitem = FrameWork.MenuItem(m, "Copy", "C", "copy") pasteitem = FrameWork.MenuItem(m, "Paste", "V", "paste") FrameWork.MenuItem(m, "Clear", None, "clear") FrameWork.Separator(m) selallitem = FrameWork.MenuItem(m, "Select all", "A", "selectall") sellineitem = FrameWork.MenuItem(m, "Select line", "L", "selectline") FrameWork.Separator(m) finditem = FrameWork.MenuItem(m, "Find", "F", "find") findagainitem = FrameWork.MenuItem(m, "Find again", 'G', "findnext") enterselitem = FrameWork.MenuItem(m, "Enter search string", "E", "entersearchstring") replaceitem = FrameWork.MenuItem(m, "Replace", None, "replace") replacefinditem = FrameWork.MenuItem(m, "Replace & find again", 'T', "replacefind") FrameWork.Separator(m) shiftleftitem = FrameWork.MenuItem(m, "Shift left", "[", "shiftleft") shiftrightitem = FrameWork.MenuItem(m, "Shift right", "]", "shiftright") m = Wapplication.Menu(self.menubar, "Python") runitem = FrameWork.MenuItem(m, "Run window", "R", 'run') runselitem = FrameWork.MenuItem(m, "Run selection", None, 'runselection') FrameWork.Separator(m) moditem = FrameWork.MenuItem(m, "Module browser", "M", self.domenu_modulebrowser) FrameWork.Separator(m) mm = FrameWork.SubMenu(m, "Preferences") FrameWork.MenuItem(mm, "Set Scripts folder", None, self.do_setscriptsfolder) FrameWork.MenuItem(mm, "Editor default settings", None, self.do_editorprefs) self.openwindowsmenu = Wapplication.Menu(self.menubar, 'Windows') self.makeopenwindowsmenu() self._menustocheck = [closeitem, saveitem, saveasitem, saveasappletitem, undoitem, cutitem, copyitem, pasteitem, selallitem, sellineitem, finditem, findagainitem, enterselitem, replaceitem, replacefinditem, shiftleftitem, shiftrightitem, runitem, runselitem] prefs = self.getprefs() try: fss, fss_changed = macfs.RawAlias(prefs.scriptsfolder).Resolve() except: path = os.path.join(os.getcwd(), 'Scripts') if not os.path.exists(path): os.mkdir(path) fss = macfs.FSSpec(path) self.scriptsfoldermodtime = fss.GetDates()[1] else: self.scriptsfoldermodtime = fss.GetDates()[1] prefs.scriptsfolder = self.scriptsfolder.data self._scripts = {} self.scriptsmenu = None self.makescriptsmenu()
8,731
def testformat(formatstr, args, output=None): if verbose: if output: print "%s %% %s =? %s ..." %\ (repr(formatstr), repr(args), repr(output)), else: print "%s %% %s works? ..." % (repr(formatstr), repr(args)), try: result = formatstr % args except OverflowError: if verbose: print 'overflow (this is fine)' else: if output and result != output: if verbose: print 'no' print "%s %% %s == %s != %s" %\ (repr(formatstr), repr(args), repr(result), repr(output)) else: if verbose: print 'yes'
def testformat(formatstr, args, output=None): if verbose: if output: print "%s %% %s =? %s ..." %\ (repr(formatstr), repr(args), repr(output)), else: print "%s %% %s works? ..." % (repr(formatstr), repr(args)), try: result = formatstr % args except OverflowError: if not overflowok: raise if verbose: print 'overflow (this is fine)' else: if output and result != output: if verbose: print 'no' print "%s %% %s == %s != %s" %\ (repr(formatstr), repr(args), repr(result), repr(output)) else: if verbose: print 'yes'
8,732
def testboth(formatstr, *args): testformat(formatstr, *args) testformat(unicode(formatstr), *args)
def testboth(formatstr, *args): testformat(formatstr, *args) testformat(unicode(formatstr), *args)
8,733
def emparse_cts(fp): while 1: line = fp.readline() if not line: raise Unparseable line = line[:-1] # Check that we're not in the returned message yet if string.lower(line)[:5] == 'from:': raise Unparseable line = string.split(line) if len(line) > 3 and line[0][:2] == '|-' and line[1] == 'Failed' \ and line[2] == 'addresses': # Yes, found it! break errors = [] while 1: line = fp.readline() if not line: break line = line[:-1] if not line: continue errors.append(line) if line[:2] == '|-': break return errors
def emparse_cts(fp): while 1: line = fp.readline() if not line: raise Unparseable line = line[:-1] # Check that we're not in the returned message yet if string.lower(line)[:5] == 'from:': raise Unparseable line = string.split(line) if len(line) > 3 and line[0][:2] == '|-' and line[1] == 'Failed' \ and line[2] == 'addresses': # Yes, found it! break errors = [] while 1: line = fp.readline() if not line: break line = line[:-1] if not line: continue errors.append(line) return errors
8,734
def _synthesize(browser): """Attempt to synthesize a controller base on existing controllers. This is useful to create a controller when a user specifies a path to an entry in the BROWSER environment variable -- we can copy a general controller to operate using a specific installation of the desired browser in this way. If we can't create a controller in this way, or if there is no executable for the requested browser, return [None, None]. """ if not os.path.exists(browser): return [None, None] name = os.path.basename(browser) try: command = _browsers[name.lower()] except KeyError: return [None, None] # now attempt to clone to fit the new name: controller = command[1] if controller and name.lower() == controller.basename: import copy controller = copy.copy(controller) controller.name = browser controller.basename = os.path.basename(browser) register(browser, None, controller) return [None, controller] ret
def _synthesize(browser): """Attempt to synthesize a controller base on existing controllers. This is useful to create a controller when a user specifies a path to an entry in the BROWSER environment variable -- we can copy a general controller to operate using a specific installation of the desired browser in this way. If we can't create a controller in this way, or if there is no executable for the requested browser, return [None, None]. """ if not os.path.exists(browser): return [None, None] name = os.path.basename(browser) try: command = _browsers[name.lower()] except KeyError: return [None, None] # now attempt to clone to fit the new name: controller = command[1] if controller and name.lower() == controller.basename: import copy controller = copy.copy(controller) controller.name = browser controller.basename = os.path.basename(browser) register(browser, None, controller) return [None, controller] return [None, None]
8,735
def finalize_options (self):
def finalize_options (self):
8,736
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 = {} self.plural = lambda n: int(n != 1) # germanic plural by default buf = fp.read() buflen = len(buf) # 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 < buflen and tend < buflen: msg = buf[moff:mend] tmsg = buf[toff:tend] else: raise IOError(0, 'File is corrupt', filename) # See if we're looking at GNU .mo conventions for metadata if mlen == 0: # Catalog description for item in tmsg.splitlines(): 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] elif k == 'plural-forms': v = v.split(';') plural = v[1].split('plural=')[1] self.plural = c2py(plural) # Note: we unconditionally convert both msgids and msgstrs to # Unicode using the character encoding specified in the charset # parameter of the Content-Type header. The gettext documentation # strongly encourages msgids to be us-ascii, but some appliations # require alternative encodings (e.g. Zope's ZCML and ZPT). For # traditional gettext applications, the msgid conversion will # cause no problems since us-ascii should always be a subset of # the charset encoding. We may want to fall back to 8-bit msgids # if the Unicode conversion fails. if msg.find('\x00') >= 0: # Plural forms msgid1, msgid2 = msg.split('\x00') tmsg = tmsg.split('\x00') if self._charset: msgid1 = unicode(msgid1, self._charset) tmsg = [unicode(x, self._charset) for x in tmsg] for i in range(len(tmsg)): catalog[(msgid1, i)] = tmsg[i] else: if self._charset: msg = unicode(msg, self._charset) tmsg = unicode(tmsg, self._charset) catalog[msg] = tmsg # 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 = {} self.plural = lambda n: int(n != 1) # germanic plural by default buf = fp.read() buflen = len(buf) # 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 < buflen and tend < buflen: msg = buf[moff:mend] tmsg = buf[toff:tend] else: raise IOError(0, 'File is corrupt', filename) # See if we're looking at GNU .mo conventions for metadata if mlen == 0: # Catalog description for item in tmsg.splitlines(): item = item.strip() if not item: continue if ':' in item: k, v = item.split(':', 1) k = k.strip().lower() v = v.strip() self._info[k] = v lastk = k elif lastk: self._info[lastk] += '\n' + item if k == 'content-type': self._charset = v.split('charset=')[1] elif k == 'plural-forms': v = v.split(';') plural = v[1].split('plural=')[1] self.plural = c2py(plural) # Note: we unconditionally convert both msgids and msgstrs to # Unicode using the character encoding specified in the charset # parameter of the Content-Type header. The gettext documentation # strongly encourages msgids to be us-ascii, but some appliations # require alternative encodings (e.g. Zope's ZCML and ZPT). For # traditional gettext applications, the msgid conversion will # cause no problems since us-ascii should always be a subset of # the charset encoding. We may want to fall back to 8-bit msgids # if the Unicode conversion fails. if msg.find('\x00') >= 0: # Plural forms msgid1, msgid2 = msg.split('\x00') tmsg = tmsg.split('\x00') if self._charset: msgid1 = unicode(msgid1, self._charset) tmsg = [unicode(x, self._charset) for x in tmsg] for i in range(len(tmsg)): catalog[(msgid1, i)] = tmsg[i] else: if self._charset: msg = unicode(msg, self._charset) tmsg = unicode(tmsg, self._charset) catalog[msg] = tmsg # advance to next entry in the seek tables masteridx += 8 transidx += 8
8,737
def mkpath (self, name, mode=0777): util.mkpath (name, mode, self.verbose, self.dry_run)
def mkpath (self, name, mode=0777): util.mkpath (name, mode, self.verbose, self.dry_run)
8,738
def copy_file (self, infile, outfile, preserve_mode=1, preserve_times=1, link=None, level=1): """Copy a file respecting verbose, dry-run and force flags. (The former two default to whatever is in the Distribution object, and the latter defaults to false for commands that don't define it.)"""
def copy_file (self, infile, outfile, preserve_mode=1, preserve_times=1, link=None, level=1): """Copy a file respecting verbose, dry-run and force flags. (The former two default to whatever is in the Distribution object, and the latter defaults to false for commands that don't define it.)"""
8,739
def copy_tree (self, infile, outfile, preserve_mode=1, preserve_times=1, preserve_symlinks=0, level=1): """Copy an entire directory tree respecting verbose, dry-run, and force flags. """ return util.copy_tree (infile, outfile, preserve_mode,preserve_times,preserve_symlinks, not self.force, self.verbose >= level, self.dry_run)
def copy_tree (self, infile, outfile, preserve_mode=1, preserve_times=1, preserve_symlinks=0, level=1): """Copy an entire directory tree respecting verbose, dry-run, and force flags. """ return util.copy_tree (infile, outfile, preserve_mode,preserve_times,preserve_symlinks, not self.force, self.verbose >= level, self.dry_run)
8,740
def move_file (self, src, dst, level=1): """Move a file respecting verbose and dry-run flags.""" return util.move_file (src, dst, self.verbose >= level, self.dry_run)
def move_file (self, src, dst, level=1): """Move a file respecting verbose and dry-run flags.""" return util.move_file (src, dst, self.verbose >= level, self.dry_run)
8,741
def make_archive (self, base_name, format, root_dir=None, base_dir=None): return util.make_archive (base_name, format, root_dir, base_dir, self.verbose, self.dry_run)
def make_archive (self, base_name, format, root_dir=None, base_dir=None): return util.make_archive (base_name, format, root_dir, base_dir, self.verbose, self.dry_run)
8,742
def make_file (self, infiles, outfile, func, args, exec_msg=None, skip_msg=None, level=1): """Special case of 'execute()' for operations that process one or more input files and generate one output file. Works just like 'execute()', except the operation is skipped and a different message printed if 'outfile' already exists and is newer than all files listed in 'infiles'. If the command defined 'self.force', and it is true, then the command is unconditionally run -- does no timestamp checks. """ if exec_msg is None: exec_msg = "generating %s from %s" % \ (outfile, string.join (infiles, ', ')) if skip_msg is None: skip_msg = "skipping %s (inputs unchanged)" % outfile
def make_file (self, infiles, outfile, func, args, exec_msg=None, skip_msg=None, level=1): """Special case of 'execute()' for operations that process one or more input files and generate one output file. Works just like 'execute()', except the operation is skipped and a different message printed if 'outfile' already exists and is newer than all files listed in 'infiles'. If the command defined 'self.force', and it is true, then the command is unconditionally run -- does no timestamp checks. """ if exec_msg is None: exec_msg = "generating %s from %s" % \ (outfile, string.join (infiles, ', ')) if skip_msg is None: skip_msg = "skipping %s (inputs unchanged)" % outfile
8,743
def set_final_options (self):
def set_final_options (self):
8,744
def set_final_options (self):
def set_final_options (self):
8,745
def replace_sys_prefix (self, config_attr, fallback_postfix, use_exec=0): """Attempts to glean a simple pattern from an installation directory available as a 'sysconfig' attribute: if the directory name starts with the "system prefix" (the one hard-coded in the Makefile and compiled into Python), then replace it with the current installation prefix and return the "relocated" installation directory."""
def replace_sys_prefix (self, config_attr, fallback_postfix, use_exec=0): """Attempts to glean a simple pattern from an installation directory available as a 'sysconfig' attribute: if the directory name starts with the "system prefix" (the one hard-coded in the Makefile and compiled into Python), then replace it with the current installation prefix and return the "relocated" installation directory."""
8,746
def replace_sys_prefix (self, config_attr, fallback_postfix, use_exec=0): """Attempts to glean a simple pattern from an installation directory available as a 'sysconfig' attribute: if the directory name starts with the "system prefix" (the one hard-coded in the Makefile and compiled into Python), then replace it with the current installation prefix and return the "relocated" installation directory."""
def replace_sys_prefix (self, config_attr, fallback_postfix, use_exec=0): """Attempts to glean a simple pattern from an installation directory available as a 'sysconfig' attribute: if the directory name starts with the "system prefix" (the one hard-coded in the Makefile and compiled into Python), then replace it with the current installation prefix and return the "relocated" installation directory."""
8,747
def classlink(self, object, modname, *dicts): """Make a link for a class.""" name = classname(object, modname) for dict in dicts: if dict.has_key(object): return '<a href="%s">%s</a>' % (dict[object], name) return name
def classlink(self, object, modname): """Make a link for a class.""" name = classname(object, modname) for dict in dicts: if dict.has_key(object): return '<a href="%s">%s</a>' % (dict[object], name) return name
8,748
def classlink(self, object, modname, *dicts): """Make a link for a class.""" name = classname(object, modname) for dict in dicts: if dict.has_key(object): return '<a href="%s">%s</a>' % (dict[object], name) return name
def classlink(self, object, modname, *dicts): """Make a link for a class.""" name = classname(object, modname) if sys.modules.has_key(object.__module__) and \ getattr(sys.modules[object.__module__], object.__name__) is object: return '<a href="%s.html object.__module__, object.__name__, name) return name
8,749
def formattree(self, tree, modname, classes={}, parent=None): """Produce HTML for a class tree as given by inspect.getclasstree().""" result = '' for entry in tree: if type(entry) is type(()): c, bases = entry result = result + '<dt><font face="helvetica, arial"><small>' result = result + self.classlink(c, modname, classes) if bases and bases != (parent,): parents = [] for base in bases: parents.append(self.classlink(base, modname, classes)) result = result + '(' + join(parents, ', ') + ')' result = result + '\n</small></font></dt>' elif type(entry) is type([]): result = result + '<dd>\n%s</dd>\n' % self.formattree( entry, modname, classes, c) return '<dl>\n%s</dl>\n' % result
def formattree(self, tree, modname, parent=None): """Produce HTML for a class tree as given by inspect.getclasstree().""" result = '' for entry in tree: if type(entry) is type(()): c, bases = entry result = result + '<dt><font face="helvetica, arial"><small>' result = result + self.classlink(c, modname, classes) if bases and bases != (parent,): parents = [] for base in bases: parents.append(self.classlink(base, modname, classes)) result = result + '(' + join(parents, ', ') + ')' result = result + '\n</small></font></dt>' elif type(entry) is type([]): result = result + '<dd>\n%s</dd>\n' % self.formattree( entry, modname, classes, c) return '<dl>\n%s</dl>\n' % result
8,750
def formattree(self, tree, modname, classes={}, parent=None): """Produce HTML for a class tree as given by inspect.getclasstree().""" result = '' for entry in tree: if type(entry) is type(()): c, bases = entry result = result + '<dt><font face="helvetica, arial"><small>' result = result + self.classlink(c, modname, classes) if bases and bases != (parent,): parents = [] for base in bases: parents.append(self.classlink(base, modname, classes)) result = result + '(' + join(parents, ', ') + ')' result = result + '\n</small></font></dt>' elif type(entry) is type([]): result = result + '<dd>\n%s</dd>\n' % self.formattree( entry, modname, classes, c) return '<dl>\n%s</dl>\n' % result
def formattree(self, tree, modname, classes={}, parent=None): """Produce HTML for a class tree as given by inspect.getclasstree().""" result = '' for entry in tree: if type(entry) is type(()): c, bases = entry result = result + '<dt><font face="helvetica, arial"><small>' result = result + self.classlink(c, modname) if bases and bases != (parent,): parents = [] for base in bases: parents.append(self.classlink(base, modname, classes)) result = result + '(' + join(parents, ', ') + ')' result = result + '\n</small></font></dt>' elif type(entry) is type([]): result = result + '<dd>\n%s</dd>\n' % self.formattree( entry, modname, classes, c) return '<dl>\n%s</dl>\n' % result
8,751
def formattree(self, tree, modname, classes={}, parent=None): """Produce HTML for a class tree as given by inspect.getclasstree().""" result = '' for entry in tree: if type(entry) is type(()): c, bases = entry result = result + '<dt><font face="helvetica, arial"><small>' result = result + self.classlink(c, modname, classes) if bases and bases != (parent,): parents = [] for base in bases: parents.append(self.classlink(base, modname, classes)) result = result + '(' + join(parents, ', ') + ')' result = result + '\n</small></font></dt>' elif type(entry) is type([]): result = result + '<dd>\n%s</dd>\n' % self.formattree( entry, modname, classes, c) return '<dl>\n%s</dl>\n' % result
def formattree(self, tree, modname, classes={}, parent=None): """Produce HTML for a class tree as given by inspect.getclasstree().""" result = '' for entry in tree: if type(entry) is type(()): c, bases = entry result = result + '<dt><font face="helvetica, arial"><small>' result = result + self.classlink(c, modname, classes) if bases and bases != (parent,): parents = [] for base in bases: parents.append(self.classlink(base, modname)) result = result + '(' + join(parents, ', ') + ')' result = result + '\n</small></font></dt>' elif type(entry) is type([]): result = result + '<dd>\n%s</dd>\n' % self.formattree( entry, modname, classes, c) return '<dl>\n%s</dl>\n' % result
8,752
def formattree(self, tree, modname, classes={}, parent=None): """Produce HTML for a class tree as given by inspect.getclasstree().""" result = '' for entry in tree: if type(entry) is type(()): c, bases = entry result = result + '<dt><font face="helvetica, arial"><small>' result = result + self.classlink(c, modname, classes) if bases and bases != (parent,): parents = [] for base in bases: parents.append(self.classlink(base, modname, classes)) result = result + '(' + join(parents, ', ') + ')' result = result + '\n</small></font></dt>' elif type(entry) is type([]): result = result + '<dd>\n%s</dd>\n' % self.formattree( entry, modname, classes, c) return '<dl>\n%s</dl>\n' % result
def formattree(self, tree, modname, classes={}, parent=None): """Produce HTML for a class tree as given by inspect.getclasstree().""" result = '' for entry in tree: if type(entry) is type(()): c, bases = entry result = result + '<dt><font face="helvetica, arial"><small>' result = result + self.classlink(c, modname, classes) if bases and bases != (parent,): parents = [] for base in bases: parents.append(self.classlink(base, modname, classes)) result = result + '(' + join(parents, ', ') + ')' result = result + '\n</small></font></dt>' elif type(entry) is type([]): result = result + '<dd>\n%s</dd>\n' % self.formattree( entry, modname, c) return '<dl>\n%s</dl>\n' % result
8,753
def docmodule(self, object, name=None, mod=None): """Produce HTML documentation for a module object.""" name = object.__name__ # ignore the passed-in name parts = split(name, '.') links = [] for i in range(len(parts)-1): links.append( '<a href="%s.html"><font color="#ffffff">%s</font></a>' % (join(parts[:i+1], '.'), parts[i])) linkedname = join(links + parts[-1:], '.') head = '<big><big><strong>%s</strong></big></big>' % linkedname try: path = inspect.getabsfile(object) filelink = '<a href="file:%s">%s</a>' % (path, path) except TypeError: filelink = '(built-in)' info = [] if hasattr(object, '__version__'): version = str(object.__version__) if version[:11] == '$' + 'Revision: ' and version[-1:] == '$': version = strip(version[11:-1]) info.append('version %s' % self.escape(version)) if hasattr(object, '__date__'): info.append(self.escape(str(object.__date__))) if info: head = head + ' (%s)' % join(info, ', ') result = self.heading( head, '#ffffff', '#7799ee', '<a href=".">index</a><br>' + filelink)
def docmodule(self, object, name=None, mod=None): """Produce HTML documentation for a module object.""" name = object.__name__ # ignore the passed-in name parts = split(name, '.') links = [] for i in range(len(parts)-1): links.append( '<a href="%s.html"><font color="#ffffff">%s</font></a>' % (join(parts[:i+1], '.'), parts[i])) linkedname = join(links + parts[-1:], '.') head = '<big><big><strong>%s</strong></big></big>' % linkedname try: path = inspect.getabsfile(object) filelink = '<a href="file:%s">%s</a>' % (path, path) except TypeError: filelink = '(built-in)' info = [] if hasattr(object, '__version__'): version = str(object.__version__) if version[:11] == '$' + 'Revision: ' and version[-1:] == '$': version = strip(version[11:-1]) info.append('version %s' % self.escape(version)) if hasattr(object, '__date__'): info.append(self.escape(str(object.__date__))) if info: head = head + ' (%s)' % join(info, ', ') result = self.heading( head, '#ffffff', '#7799ee', '<a href=".">index</a><br>' + filelink)
8,754
def docclass(self, object, name=None, mod=None, funcs={}, classes={}): """Produce HTML documentation for a class object.""" realname = object.__name__ name = name or realname bases = object.__bases__ contents = ''
def docclass(self, object, name=None, mod=None, funcs={}, classes={}): """Produce HTML documentation for a class object.""" realname = object.__name__ name = name or realname bases = object.__bases__ contents = ''
8,755
def docroutine(self, object, name=None, mod=None, funcs={}, classes={}, methods={}, cl=None): """Produce HTML documentation for a function or method object.""" realname = object.__name__ name = name or realname anchor = (cl and cl.__name__ or '') + '-' + name note = '' skipdocs = 0 if inspect.ismethod(object): imclass = object.im_class if cl: if imclass is not cl: url = '%s.html#%s-%s' % ( imclass.__module__, imclass.__name__, name) note = ' from <a href="%s">%s</a>' % ( url, classname(imclass, mod)) skipdocs = 1 else: inst = object.im_self note = (inst and ' method of %s instance' % classname(inst.__class__, mod) or ' unbound %s method' % classname(imclass, mod)) object = object.im_func
def docroutine(self, object, name=None, mod=None, funcs={}, classes={}, methods={}, cl=None): """Produce HTML documentation for a function or method object.""" realname = object.__name__ name = name or realname anchor = (cl and cl.__name__ or '') + '-' + name note = '' skipdocs = 0 if inspect.ismethod(object): imclass = object.im_class if cl: if imclass is not cl: url = '%s.html#%s-%s' % ( imclass.__module__, imclass.__name__, name) note = ' from <a href="%s">%s</a>' % ( url, classname(imclass, mod)) skipdocs = 1 else: inst = object.im_self note = (inst and ' method of %s instance' % classname(inst.__class__, mod) or ' unbound %s method' % classname(imclass, mod)) object = object.im_func
8,756
def docroutine(self, object, name=None, mod=None, funcs={}, classes={}, methods={}, cl=None): """Produce HTML documentation for a function or method object.""" realname = object.__name__ name = name or realname anchor = (cl and cl.__name__ or '') + '-' + name note = '' skipdocs = 0 if inspect.ismethod(object): imclass = object.im_class if cl: if imclass is not cl: url = '%s.html#%s-%s' % ( imclass.__module__, imclass.__name__, name) note = ' from <a href="%s">%s</a>' % ( url, classname(imclass, mod)) skipdocs = 1 else: inst = object.im_self note = (inst and ' method of %s instance' % classname(inst.__class__, mod) or ' unbound %s method' % classname(imclass, mod)) object = object.im_func
def docroutine(self, object, name=None, mod=None, funcs={}, classes={}, methods={}, cl=None): """Produce HTML documentation for a function or method object.""" realname = object.__name__ name = name or realname anchor = (cl and cl.__name__ or '') + '-' + name note = '' skipdocs = 0 if inspect.ismethod(object): imclass = object.im_class if cl: if imclass is not cl: url = '%s.html#%s-%s' % ( imclass.__module__, imclass.__name__, name) note = ' from <a href="%s">%s</a>' % ( url, classname(imclass, mod)) skipdocs = 1 else: if object.im_self: note = ' method of %s instance' % self.classlink( object.im_self.__class__, mod) else: note = ' unbound %s method' % self.classlink(imclass,mod) object = object.im_func
8,757
def docroutine(self, object, name=None, mod=None, cl=None): """Produce text documentation for a function or method object.""" realname = object.__name__ name = name or realname note = '' skipdocs = 0 if inspect.ismethod(object): imclass = object.im_class if cl: if imclass is not cl: note = ' from ' + classname(imclass, mod) skipdocs = 1 else: inst = object.im_self note = (inst and ' method of %s instance' % classname(inst.__class__, mod) or ' unbound %s method' % classname(imclass, mod)) object = object.im_func
def docroutine(self, object, name=None, mod=None, cl=None): """Produce text documentation for a function or method object.""" realname = object.__name__ name = name or realname note = '' skipdocs = 0 if inspect.ismethod(object): imclass = object.im_class if cl: if imclass is not cl: note = ' from ' + classname(imclass, mod) skipdocs = 1 else: if object.im_self: note = ' method of %s instance' % classname( object.im_self.__class__, mod) else: note = ' unbound %s method' % classname(imclass,mod) object = object.im_func
8,758
def break_yolks(self): self.yolks = self.yolks - 2
def break_yolks(self): self.yolks = self.yolks - 2
8,759
def _call_chain(self, chain, kind, meth_name, *args): # XXX raise an exception if no one else should try to handle # this url. return None if you can't but someone else could. handlers = chain.get(kind, ()) for handler in handlers: func = getattr(handler, meth_name)
def _call_chain(self, chain, kind, meth_name, *args): # XXX raise an exception if no one else should try to handle # this url. return None if you can't but someone else could. handlers = chain.get(kind, ()) for handler in handlers: func = getattr(handler, meth_name)
8,760
def proxy_open(self, req, proxy, type): orig_type = req.get_type() proxy_type, user, password, hostport = _parse_proxy(proxy) if proxy_type is None: proxy_type = orig_type if user and password: user_pass = '%s:%s' % (unquote(user), unquote(password)) creds = base64.encodestring(user_pass).strip() req.add_header('Proxy-authorization', 'Basic ' + creds) hostport = unquote(hostport) req.set_proxy(hostport, proxy_type) if orig_type == proxy_type: # let other handlers take care of it return None else: # need to start over, because the other handlers don't # grok the proxy's URL type # e.g. if we have a constructor arg proxies like so: # {'http': 'ftp://proxy.example.com'}, we may end up turning # a request for http://acme.example.com/a into one for # ftp://proxy.example.com/a return self.parent.open(req)
def proxy_open(self, req, proxy, type): orig_type = req.get_type() proxy_type, user, password, hostport = _parse_proxy(proxy) if proxy_type is None: proxy_type = orig_type if user and password: user_pass = '%s:%s' % (unquote(user), unquote(password)) creds = base64.encodestring(user_pass).strip() req.add_header('Proxy-authorization', 'Basic ' + creds) hostport = unquote(hostport) req.set_proxy(hostport, proxy_type) if orig_type == proxy_type: # let other handlers take care of it return None else: # need to start over, because the other handlers don't # grok the proxy's URL type # e.g. if we have a constructor arg proxies like so: # {'http': 'ftp://proxy.example.com'}, we may end up turning # a request for http://acme.example.com/a into one for # ftp://proxy.example.com/a return self.parent.open(req)
8,761
def gopher_open(self, req): import gopherlib # this raises DeprecationWarning in 2.5 host = req.get_host() if not host: raise GopherError('no host given') host = unquote(host) selector = req.get_selector() type, selector = splitgophertype(selector) selector, query = splitquery(selector) selector = unquote(selector) if query: query = unquote(query) fp = gopherlib.send_query(selector, query, host) else: fp = gopherlib.send_selector(selector, host) return addinfourl(fp, noheaders(), req.get_full_url())
def gopher_open(self, req): import gopherlib # this raises DeprecationWarning in 2.5 host = req.get_host() if not host: raise GopherError('no host given') host = unquote(host) selector = req.get_selector() type, selector = splitgophertype(selector) selector, query = splitquery(selector) selector = unquote(selector) if query: query = unquote(query) fp = gopherlib.send_query(selector, query, host) else: fp = gopherlib.send_selector(selector, host) return addinfourl(fp, noheaders(), req.get_full_url())
8,762
def open_new(self, url): # Deprecated. May be removed in 2.1. self.open(url)
def open_new(self, url): # Deprecated. May be removed in 2.1. self.open(url)
8,763
def getregentry(): return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
def getregentry(): return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
8,764
def process(self, accu): if self.debugging > 1: print self.skip, self.stack, if accu: print accu[0][:30], if accu[0][30:] or accu[1:]: print '...', print if self.stack and self.stack[-1] == 'menu': # XXX should be done differently for line in accu: mo = miprog.match(line) if not mo: line = string.strip(line) + '\n' self.expand(line) continue bgn, end = mo.span(0) a, b = mo.span(1) c, d = mo.span(2) e, f = mo.span(3) g, h = mo.span(4) label = line[a:b] nodename = line[c:d] if nodename[0] == ':': nodename = label else: nodename = line[e:f] punct = line[g:h] self.write(' <LI><A HREF="', makefile(nodename), '">', nodename, '</A>', punct, '\n') self.expand(line[end:]) else: text = string.joinfields(accu, '') self.expand(text)
def process(self, accu): if self.debugging > 1: print '!'*self.debugging, 'process:', self.skip, self.stack, if accu: print accu[0][:30], if accu[0][30:] or accu[1:]: print '...', print if self.stack and self.stack[-1] == 'menu': # XXX should be done differently for line in accu: mo = miprog.match(line) if not mo: line = string.strip(line) + '\n' self.expand(line) continue bgn, end = mo.span(0) a, b = mo.span(1) c, d = mo.span(2) e, f = mo.span(3) g, h = mo.span(4) label = line[a:b] nodename = line[c:d] if nodename[0] == ':': nodename = label else: nodename = line[e:f] punct = line[g:h] self.write(' <LI><A HREF="', makefile(nodename), '">', nodename, '</A>', punct, '\n') self.expand(line[end:]) else: text = string.joinfields(accu, '') self.expand(text)
8,765
def process(self, accu): if self.debugging > 1: print self.skip, self.stack, if accu: print accu[0][:30], if accu[0][30:] or accu[1:]: print '...', print if self.stack and self.stack[-1] == 'menu': # XXX should be done differently for line in accu: mo = miprog.match(line) if not mo: line = string.strip(line) + '\n' self.expand(line) continue bgn, end = mo.span(0) a, b = mo.span(1) c, d = mo.span(2) e, f = mo.span(3) g, h = mo.span(4) label = line[a:b] nodename = line[c:d] if nodename[0] == ':': nodename = label else: nodename = line[e:f] punct = line[g:h] self.write(' <LI><A HREF="', makefile(nodename), '">', nodename, '</A>', punct, '\n') self.expand(line[end:]) else: text = string.joinfields(accu, '') self.expand(text)
def process(self, accu): if self.debugging > 1: print self.skip, self.stack, if accu: print accu[0][:30], if accu[0][30:] or accu[1:]: print '...', print if self.inmenu(): # XXX should be done differently for line in accu: mo = miprog.match(line) if not mo: line = string.strip(line) + '\n' self.expand(line) continue bgn, end = mo.span(0) a, b = mo.span(1) c, d = mo.span(2) e, f = mo.span(3) g, h = mo.span(4) label = line[a:b] nodename = line[c:d] if nodename[0] == ':': nodename = label else: nodename = line[e:f] punct = line[g:h] self.write(' <LI><A HREF="', makefile(nodename), '">', nodename, '</A>', punct, '\n') self.expand(line[end:]) else: text = string.joinfields(accu, '') self.expand(text)
8,766
def do_include(self, args): file = args file = os.path.join(self.includedir, file) try: fp = open(file, 'r') except IOError, msg: print '*** Can\'t open include file', `file` return if self.debugging: print '--> file', `file` save_done = self.done save_skip = self.skip save_stack = self.stack self.includedepth = self.includedepth + 1 self.parserest(fp, 0) self.includedepth = self.includedepth - 1 fp.close() self.done = save_done self.skip = save_skip self.stack = save_stack if self.debugging: print '<-- file', `file`
def do_include(self, args): file = args file = os.path.join(self.includedir, file) try: fp = open(file, 'r') except IOError, msg: print '*** Can\'t open include file', `file` return print '!'*self.debugging, '--> file', `file` save_done = self.done save_skip = self.skip save_stack = self.stack self.includedepth = self.includedepth + 1 self.parserest(fp, 0) self.includedepth = self.includedepth - 1 fp.close() self.done = save_done self.skip = save_skip self.stack = save_stack if self.debugging: print '<-- file', `file`
8,767
def do_include(self, args): file = args file = os.path.join(self.includedir, file) try: fp = open(file, 'r') except IOError, msg: print '*** Can\'t open include file', `file` return if self.debugging: print '--> file', `file` save_done = self.done save_skip = self.skip save_stack = self.stack self.includedepth = self.includedepth + 1 self.parserest(fp, 0) self.includedepth = self.includedepth - 1 fp.close() self.done = save_done self.skip = save_skip self.stack = save_stack if self.debugging: print '<-- file', `file`
def do_include(self, args): file = args file = os.path.join(self.includedir, file) try: fp = open(file, 'r') except IOError, msg: print '*** Can\'t open include file', `file` return if self.debugging: print '--> file', `file` save_done = self.done save_skip = self.skip save_stack = self.stack self.includedepth = self.includedepth + 1 self.parserest(fp, 0) self.includedepth = self.includedepth - 1 fp.close() self.done = save_done self.skip = save_skip self.stack = save_stack if self.debugging: print '<-- file', `file`
8,768
def command(self, line, mo): a, b = mo.span(1) cmd = line[a:b] args = string.strip(line[b:]) if self.debugging > 1: print self.skip, self.stack, '@' + cmd, args try: func = getattr(self, 'do_' + cmd) except AttributeError: try: func = getattr(self, 'bgn_' + cmd) except AttributeError: # don't complain if we are skipping anyway if not self.skip: self.unknown_cmd(cmd, args) return self.stack.append(cmd) func(args) return if not self.skip or cmd == 'end': func(args)
def command(self, line, mo): a, b = mo.span(1) cmd = line[a:b] args = string.strip(line[b:]) if self.debugging > 1: print '!'*self.debugging, 'command:', self.skip, self.stack, \ '@' + cmd, args try: func = getattr(self, 'do_' + cmd) except AttributeError: try: func = getattr(self, 'bgn_' + cmd) except AttributeError: # don't complain if we are skipping anyway if not self.skip: self.unknown_cmd(cmd, args) return self.stack.append(cmd) func(args) return if not self.skip or cmd == 'end': func(args)
8,769
def do_set(self, args): fields = string.splitfields(args, ' ') key = fields[0] if len(fields) == 1: value = 1 else: value = string.joinfields(fields[1:], ' ') self.values[key] = value print self.values
def do_set(self, args): fields = string.splitfields(args, ' ') key = fields[0] if len(fields) == 1: value = 1 else: value = string.joinfields(fields[1:], ' ') self.values[key] = value print self.values
8,770
def end_ifset(self): print self.stack print self.stackinfo if self.stackinfo[len(self.stack) + 1]: self.skip = self.skip - 1 del self.stackinfo[len(self.stack) + 1]
def end_ifset(self): print self.stack print self.stackinfo if self.stackinfo[len(self.stack) + 1]: self.skip = self.skip - 1 del self.stackinfo[len(self.stack) + 1]
8,771
def bgn_ifclear(self, args): if args in self.values.keys() \ and self.values[args] is not None: self.skip = self.skip + 1 self.stackinfo[len(self.stack)] = 1 else: self.stackinfo[len(self.stack)] = 0
def bgn_ifclear(self, args): if args in self.values.keys() \ and self.values[args] is not None: self.skip = self.skip + 1 self.stackinfo[len(self.stack)] = 1 else: self.stackinfo[len(self.stack)] = 0
8,772
def do_settitle(self, args): print args self.startsaving() self.expand(args) self.title = self.collectsavings() print self.title
def do_settitle(self, args): self.startsaving() self.expand(args) self.title = self.collectsavings() print self.title
8,773
def do_settitle(self, args): print args self.startsaving() self.expand(args) self.title = self.collectsavings() print self.title
def do_settitle(self, args): print args self.startsaving() self.expand(args) self.title = self.collectsavings() print self.title
8,774
def do_node(self, args): self.endnode() self.nodelineno = 0 parts = string.splitfields(args, ',') while len(parts) < 4: parts.append('') for i in range(4): parts[i] = string.strip(parts[i]) self.nodelinks = parts [name, next, prev, up] = parts[:4] file = self.dirname + '/' + makefile(name) if self.filenames.has_key(file): print '*** Filename already in use: ', file else: if self.debugging: print '--- writing', file self.filenames[file] = 1 # self.nodefp = open(file, 'w') self.nodename = name if self.cont and self.nodestack: self.nodestack[-1].cont = self.nodename if not self.topname: self.topname = name title = name if self.title: title = title + ' -- ' + self.title self.node = self.Node(self.dirname, self.nodename, self.topname, title, next, prev, up)
def do_node(self, args): self.endnode() self.nodelineno = 0 parts = string.splitfields(args, ',') while len(parts) < 4: parts.append('') for i in range(4): parts[i] = string.strip(parts[i]) self.nodelinks = parts [name, next, prev, up] = parts[:4] file = self.dirname + '/' + makefile(name) if self.filenames.has_key(file): print '*** Filename already in use: ', file else: if self.debugging: print '!'*self.debugging, '--- writing', file self.filenames[file] = 1 # self.nodefp = open(file, 'w') self.nodename = name if self.cont and self.nodestack: self.nodestack[-1].cont = self.nodename if not self.topname: self.topname = name title = name if self.title: title = title + ' -- ' + self.title self.node = self.Node(self.dirname, self.nodename, self.topname, title, next, prev, up)
8,775
def do_item(self, args): if self.itemindex: self.index(self.itemindex, args) if self.itemarg: if self.itemarg[0] == '@' and self.itemarg[1:2] and \ self.itemarg[1] in string.ascii_letters: args = self.itemarg + '{' + args + '}' else: # some other character, e.g. '-' args = self.itemarg + ' ' + args if self.itemnumber <> None: args = self.itemnumber + '. ' + args self.itemnumber = increment(self.itemnumber) if self.stack and self.stack[-1] == 'table': self.write('<DT>') self.expand(args) self.write('\n<DD>') else: self.write('<LI>') self.expand(args) self.write(' ')
def do_item(self, args): if self.itemindex: self.index(self.itemindex, args) if self.itemarg: if self.itemarg[0] == '@' and self.itemarg[1] and \ self.itemarg[1] in string.ascii_letters: args = self.itemarg + '{' + args + '}' else: # some other character, e.g. '-' args = self.itemarg + ' ' + args if self.itemnumber <> None: args = self.itemnumber + '. ' + args self.itemnumber = increment(self.itemnumber) if self.stack and self.stack[-1] == 'table': self.write('<DT>') self.expand(args) self.write('\n<DD>') else: self.write('<LI>') self.expand(args) self.write(' ')
8,776
def prindex(self, name): iscodeindex = (name not in self.noncodeindices) index = self.whichindex[name] if not index: return if self.debugging: print '--- Generating', self.indextitle[name], 'index' # The node already provides a title index1 = [] junkprog = re.compile('^(@[a-z]+)?{') for key, node in index: sortkey = string.lower(key) # Remove leading `@cmd{' from sort key # -- don't bother about the matching `}' oldsortkey = sortkey while 1: mo = junkprog.match(sortkey) if not mo: break i = mo.end() sortkey = sortkey[i:] index1.append((sortkey, key, node)) del index[:] index1.sort() self.write('<DL COMPACT>\n') prevkey = prevnode = None for sortkey, key, node in index1: if (key, node) == (prevkey, prevnode): continue if self.debugging > 1: print key, ':', node self.write('<DT>') if iscodeindex: key = '@code{' + key + '}' if key != prevkey: self.expand(key) self.write('\n<DD><A HREF="%s">%s</A>\n' % (makefile(node), node)) prevkey, prevnode = key, node self.write('</DL>\n')
def prindex(self, name): iscodeindex = (name not in self.noncodeindices) index = self.whichindex[name] if not index: return if self.debugging: print '!'*self.debugging, '--- Generating', \ self.indextitle[name], 'index' # The node already provides a title index1 = [] junkprog = re.compile('^(@[a-z]+)?{') for key, node in index: sortkey = string.lower(key) # Remove leading `@cmd{' from sort key # -- don't bother about the matching `}' oldsortkey = sortkey while 1: mo = junkprog.match(sortkey) if not mo: break i = mo.end() sortkey = sortkey[i:] index1.append((sortkey, key, node)) del index[:] index1.sort() self.write('<DL COMPACT>\n') prevkey = prevnode = None for sortkey, key, node in index1: if (key, node) == (prevkey, prevnode): continue if self.debugging > 1: print key, ':', node self.write('<DT>') if iscodeindex: key = '@code{' + key + '}' if key != prevkey: self.expand(key) self.write('\n<DD><A HREF="%s">%s</A>\n' % (makefile(node), node)) prevkey, prevnode = key, node self.write('</DL>\n')
8,777
def prindex(self, name): iscodeindex = (name not in self.noncodeindices) index = self.whichindex[name] if not index: return if self.debugging: print '--- Generating', self.indextitle[name], 'index' # The node already provides a title index1 = [] junkprog = re.compile('^(@[a-z]+)?{') for key, node in index: sortkey = string.lower(key) # Remove leading `@cmd{' from sort key # -- don't bother about the matching `}' oldsortkey = sortkey while 1: mo = junkprog.match(sortkey) if not mo: break i = mo.end() sortkey = sortkey[i:] index1.append((sortkey, key, node)) del index[:] index1.sort() self.write('<DL COMPACT>\n') prevkey = prevnode = None for sortkey, key, node in index1: if (key, node) == (prevkey, prevnode): continue if self.debugging > 1: print key, ':', node self.write('<DT>') if iscodeindex: key = '@code{' + key + '}' if key != prevkey: self.expand(key) self.write('\n<DD><A HREF="%s">%s</A>\n' % (makefile(node), node)) prevkey, prevnode = key, node self.write('</DL>\n')
def prindex(self, name): iscodeindex = (name not in self.noncodeindices) index = self.whichindex[name] if not index: return if self.debugging: print '--- Generating', self.indextitle[name], 'index' # The node already provides a title index1 = [] junkprog = re.compile('^(@[a-z]+)?{') for key, node in index: sortkey = string.lower(key) # Remove leading `@cmd{' from sort key # -- don't bother about the matching `}' oldsortkey = sortkey while 1: mo = junkprog.match(sortkey) if not mo: break i = mo.end() sortkey = sortkey[i:] index1.append((sortkey, key, node)) del index[:] index1.sort() self.write('<DL COMPACT>\n') prevkey = prevnode = None for sortkey, key, node in index1: if (key, node) == (prevkey, prevnode): continue if self.debugging > 1: print '!'*self.debugging, key, ':', node self.write('<DT>') if iscodeindex: key = '@code{' + key + '}' if key != prevkey: self.expand(key) self.write('\n<DD><A HREF="%s">%s</A>\n' % (makefile(node), node)) prevkey, prevnode = key, node self.write('</DL>\n')
8,778
def test(): import sys debugging = 0 print_headers = 0 cont = 0 html3 = 0 while sys.argv[1:2] == ['-d']: debugging = debugging + 1 del sys.argv[1:2] if sys.argv[1] == '-p': print_headers = 1 del sys.argv[1] if sys.argv[1] == '-c': cont = 1 del sys.argv[1] if sys.argv[1] == '-3': html3 = 1 del sys.argv[1] if len(sys.argv) <> 3: print 'usage: texi2html [-d [-d]] [-p] [-c] inputfile outputdirectory' sys.exit(2) if html3: parser = TexinfoParserHTML3() else: parser = TexinfoParser() parser.cont = cont parser.debugging = debugging parser.print_headers = print_headers file = sys.argv[1] parser.setdirname(sys.argv[2]) if file == '-': fp = sys.stdin else: parser.setincludedir(os.path.dirname(file)) try: fp = open(file, 'r') except IOError, msg: print file, ':', msg sys.exit(1) parser.parse(fp) fp.close() parser.report()
def test(): import sys debugging = 0 print_headers = 0 cont = 0 html3 = 0 htmlhelp = '' while sys.argv[1] == ['-d']: debugging = debugging + 1 del sys.argv[1:2] if sys.argv[1] == '-p': print_headers = 1 del sys.argv[1] if sys.argv[1] == '-c': cont = 1 del sys.argv[1] if sys.argv[1] == '-3': html3 = 1 del sys.argv[1] if len(sys.argv) <> 3: print 'usage: texi2html [-d [-d]] [-p] [-c] inputfile outputdirectory' sys.exit(2) if html3: parser = TexinfoParserHTML3() else: parser = TexinfoParser() parser.cont = cont parser.debugging = debugging parser.print_headers = print_headers file = sys.argv[1] parser.setdirname(sys.argv[2]) if file == '-': fp = sys.stdin else: parser.setincludedir(os.path.dirname(file)) try: fp = open(file, 'r') except IOError, msg: print file, ':', msg sys.exit(1) parser.parse(fp) fp.close() parser.report()
8,779
def test(): import sys debugging = 0 print_headers = 0 cont = 0 html3 = 0 while sys.argv[1:2] == ['-d']: debugging = debugging + 1 del sys.argv[1:2] if sys.argv[1] == '-p': print_headers = 1 del sys.argv[1] if sys.argv[1] == '-c': cont = 1 del sys.argv[1] if sys.argv[1] == '-3': html3 = 1 del sys.argv[1] if len(sys.argv) <> 3: print 'usage: texi2html [-d [-d]] [-p] [-c] inputfile outputdirectory' sys.exit(2) if html3: parser = TexinfoParserHTML3() else: parser = TexinfoParser() parser.cont = cont parser.debugging = debugging parser.print_headers = print_headers file = sys.argv[1] parser.setdirname(sys.argv[2]) if file == '-': fp = sys.stdin else: parser.setincludedir(os.path.dirname(file)) try: fp = open(file, 'r') except IOError, msg: print file, ':', msg sys.exit(1) parser.parse(fp) fp.close() parser.report()
def test(): import sys debugging = 0 print_headers = 0 cont = 0 html3 = 0 while sys.argv[1:2] == ['-d']: debugging = debugging + 1 del sys.argv[1] if sys.argv[1] == '-p': print_headers = 1 del sys.argv[1] if sys.argv[1] == '-c': cont = 1 del sys.argv[1] if sys.argv[1] == '-3': html3 = 1 del sys.argv[1] if len(sys.argv) <> 3: print 'usage: texi2html [-d [-d]] [-p] [-c] inputfile outputdirectory' sys.exit(2) if html3: parser = TexinfoParserHTML3() else: parser = TexinfoParser() parser.cont = cont parser.debugging = debugging parser.print_headers = print_headers file = sys.argv[1] parser.setdirname(sys.argv[2]) if file == '-': fp = sys.stdin else: parser.setincludedir(os.path.dirname(file)) try: fp = open(file, 'r') except IOError, msg: print file, ':', msg sys.exit(1) parser.parse(fp) fp.close() parser.report()
8,780
def test(): import sys debugging = 0 print_headers = 0 cont = 0 html3 = 0 while sys.argv[1:2] == ['-d']: debugging = debugging + 1 del sys.argv[1:2] if sys.argv[1] == '-p': print_headers = 1 del sys.argv[1] if sys.argv[1] == '-c': cont = 1 del sys.argv[1] if sys.argv[1] == '-3': html3 = 1 del sys.argv[1] if len(sys.argv) <> 3: print 'usage: texi2html [-d [-d]] [-p] [-c] inputfile outputdirectory' sys.exit(2) if html3: parser = TexinfoParserHTML3() else: parser = TexinfoParser() parser.cont = cont parser.debugging = debugging parser.print_headers = print_headers file = sys.argv[1] parser.setdirname(sys.argv[2]) if file == '-': fp = sys.stdin else: parser.setincludedir(os.path.dirname(file)) try: fp = open(file, 'r') except IOError, msg: print file, ':', msg sys.exit(1) parser.parse(fp) fp.close() parser.report()
def test(): import sys debugging = 0 print_headers = 0 cont = 0 html3 = 0 while sys.argv[1:2] == ['-d']: debugging = debugging + 1 del sys.argv[1:2] if sys.argv[1] == '-p': print_headers = 1 del sys.argv[1] if sys.argv[1] == '-c': cont = 1 del sys.argv[1] if sys.argv[1] == '-3': html3 = 1 del sys.argv[1] if len(sys.argv) <> 3: print 'usage: texi2hh [-d [-d]] [-p] [-c] [-3] [-H htmlhelp]', \ 'inputfile outputdirectory' sys.exit(2) if html3: parser = TexinfoParserHTML3() else: parser = TexinfoParser() parser.cont = cont parser.debugging = debugging parser.print_headers = print_headers file = sys.argv[1] parser.setdirname(sys.argv[2]) if file == '-': fp = sys.stdin else: parser.setincludedir(os.path.dirname(file)) try: fp = open(file, 'r') except IOError, msg: print file, ':', msg sys.exit(1) parser.parse(fp) fp.close() parser.report()
8,781
def test(): import sys debugging = 0 print_headers = 0 cont = 0 html3 = 0 while sys.argv[1:2] == ['-d']: debugging = debugging + 1 del sys.argv[1:2] if sys.argv[1] == '-p': print_headers = 1 del sys.argv[1] if sys.argv[1] == '-c': cont = 1 del sys.argv[1] if sys.argv[1] == '-3': html3 = 1 del sys.argv[1] if len(sys.argv) <> 3: print 'usage: texi2html [-d [-d]] [-p] [-c] inputfile outputdirectory' sys.exit(2) if html3: parser = TexinfoParserHTML3() else: parser = TexinfoParser() parser.cont = cont parser.debugging = debugging parser.print_headers = print_headers file = sys.argv[1] parser.setdirname(sys.argv[2]) if file == '-': fp = sys.stdin else: parser.setincludedir(os.path.dirname(file)) try: fp = open(file, 'r') except IOError, msg: print file, ':', msg sys.exit(1) parser.parse(fp) fp.close() parser.report()
def test(): import sys debugging = 0 print_headers = 0 cont = 0 html3 = 0 while sys.argv[1:2] == ['-d']: debugging = debugging + 1 del sys.argv[1:2] if sys.argv[1] == '-p': print_headers = 1 del sys.argv[1] if sys.argv[1] == '-c': cont = 1 del sys.argv[1] if sys.argv[1] == '-3': html3 = 1 del sys.argv[1] if len(sys.argv) <> 3: print 'usage: texi2html [-d [-d]] [-p] [-c] inputfile outputdirectory' sys.exit(2) if html3: parser = TexinfoParserHTML3() else: parser = TexinfoParser() parser.cont = cont parser.debugging = debugging parser.print_headers = print_headers file = sys.argv[1] dirname = sys.argv[2] parser.setdirname(dirname) parser.setincludedir(os.path.dirname(file)) try: fp = open(file, 'r') except IOError, msg: print file, ':', msg sys.exit(1) parser.parse(fp) fp.close() parser.report()
8,782
def dump_address_pair(pair): """Dump a (name, address) pair in a canonicalized form.""" if pair[0]: return '"' + pair[0] + '" <' + pair[1] + '>' else: return pair[1]
def dump_address_pair(pair): """Dump a (name, address) pair in a canonicalized form.""" if pair[0]: return '"' + pair[0] + '" <' + pair[1] + '>' else: return pair[1]
8,783
def parsedate_tz(data): """Convert a date string to a time tuple. Accounts for military timezones. """ data = string.split(data) if data[0][-1] == ',' or data[0] in _daynames: # There's a dayname here. Skip it del data[0] if len(data) == 3: # RFC 850 date, deprecated stuff = string.split(data[0], '-') if len(stuff) == 3: data = stuff + data[1:] if len(data) == 4: s = data[3] i = string.find(s, '+') if i > 0: data[3:] = [s[:i], s[i+1:]] else: data.append('') # Dummy tz if len(data) < 5: return None data = data[:5] [dd, mm, yy, tm, tz] = data if not mm in _monthnames: dd, mm, yy, tm, tz = mm, dd, tm, yy, tz if not mm in _monthnames: return None mm = _monthnames.index(mm)+1 tm = string.splitfields(tm, ':') if len(tm) == 2: [thh, tmm] = tm tss = '0' elif len(tm) == 3: [thh, tmm, tss] = tm else: return None try: yy = string.atoi(yy) dd = string.atoi(dd) thh = string.atoi(thh) tmm = string.atoi(tmm) tss = string.atoi(tss) except string.atoi_error: return None tzoffset=None tz=string.upper(tz) if _timezones.has_key(tz): tzoffset=_timezones[tz] else: try: tzoffset=string.atoi(tz) except string.atoi_error: pass # Convert a timezone offset into seconds ; -0500 -> -18000 if tzoffset: if tzoffset < 0: tzsign = -1 tzoffset = -tzoffset else: tzsign = 1 tzoffset = tzsign * ( (tzoffset/100)*3600 + (tzoffset % 100)*60) tuple = (yy, mm, dd, thh, tmm, tss, 0, 0, 0, tzoffset) return tuple
def parsedate_tz(data): """Convert a date string to a time tuple. Accounts for military timezones. """ data = string.split(data) if data[0][-1] in (',', '.') or string.lower(data[0]) in _daynames: # There's a dayname here. Skip it del data[0] if len(data) == 3: # RFC 850 date, deprecated stuff = string.split(data[0], '-') if len(stuff) == 3: data = stuff + data[1:] if len(data) == 4: s = data[3] i = string.find(s, '+') if i > 0: data[3:] = [s[:i], s[i+1:]] else: data.append('') # Dummy tz if len(data) < 5: return None data = data[:5] [dd, mm, yy, tm, tz] = data if not mm in _monthnames: dd, mm, yy, tm, tz = mm, dd, tm, yy, tz if not mm in _monthnames: return None mm = _monthnames.index(mm)+1 tm = string.splitfields(tm, ':') if len(tm) == 2: [thh, tmm] = tm tss = '0' elif len(tm) == 3: [thh, tmm, tss] = tm else: return None try: yy = string.atoi(yy) dd = string.atoi(dd) thh = string.atoi(thh) tmm = string.atoi(tmm) tss = string.atoi(tss) except string.atoi_error: return None tzoffset=None tz=string.upper(tz) if _timezones.has_key(tz): tzoffset=_timezones[tz] else: try: tzoffset=string.atoi(tz) except string.atoi_error: pass # Convert a timezone offset into seconds ; -0500 -> -18000 if tzoffset: if tzoffset < 0: tzsign = -1 tzoffset = -tzoffset else: tzsign = 1 tzoffset = tzsign * ( (tzoffset/100)*3600 + (tzoffset % 100)*60) tuple = (yy, mm, dd, thh, tmm, tss, 0, 0, 0, tzoffset) return tuple
8,784
def parsedate_tz(data): """Convert a date string to a time tuple. Accounts for military timezones. """ data = string.split(data) if data[0][-1] == ',' or data[0] in _daynames: # There's a dayname here. Skip it del data[0] if len(data) == 3: # RFC 850 date, deprecated stuff = string.split(data[0], '-') if len(stuff) == 3: data = stuff + data[1:] if len(data) == 4: s = data[3] i = string.find(s, '+') if i > 0: data[3:] = [s[:i], s[i+1:]] else: data.append('') # Dummy tz if len(data) < 5: return None data = data[:5] [dd, mm, yy, tm, tz] = data if not mm in _monthnames: dd, mm, yy, tm, tz = mm, dd, tm, yy, tz if not mm in _monthnames: return None mm = _monthnames.index(mm)+1 tm = string.splitfields(tm, ':') if len(tm) == 2: [thh, tmm] = tm tss = '0' elif len(tm) == 3: [thh, tmm, tss] = tm else: return None try: yy = string.atoi(yy) dd = string.atoi(dd) thh = string.atoi(thh) tmm = string.atoi(tmm) tss = string.atoi(tss) except string.atoi_error: return None tzoffset=None tz=string.upper(tz) if _timezones.has_key(tz): tzoffset=_timezones[tz] else: try: tzoffset=string.atoi(tz) except string.atoi_error: pass # Convert a timezone offset into seconds ; -0500 -> -18000 if tzoffset: if tzoffset < 0: tzsign = -1 tzoffset = -tzoffset else: tzsign = 1 tzoffset = tzsign * ( (tzoffset/100)*3600 + (tzoffset % 100)*60) tuple = (yy, mm, dd, thh, tmm, tss, 0, 0, 0, tzoffset) return tuple
def parsedate_tz(data): """Convert a date string to a time tuple. Accounts for military timezones. """ data = string.split(data) if data[0][-1] == ',' or data[0] in _daynames: # There's a dayname here. Skip it del data[0] if len(data) == 3: # RFC 850 date, deprecated stuff = string.split(data[0], '-') if len(stuff) == 3: data = stuff + data[1:] if len(data) == 4: s = data[3] i = string.find(s, '+') if i > 0: data[3:] = [s[:i], s[i+1:]] else: data.append('') # Dummy tz if len(data) < 5: return None data = data[:5] [dd, mm, yy, tm, tz] = data if not mm in _monthnames: dd, mm = mm, string.lower(dd) if not mm in _monthnames: return None mm = _monthnames.index(mm)+1 tm = string.splitfields(tm, ':') if len(tm) == 2: [thh, tmm] = tm tss = '0' elif len(tm) == 3: [thh, tmm, tss] = tm else: return None try: yy = string.atoi(yy) dd = string.atoi(dd) thh = string.atoi(thh) tmm = string.atoi(tmm) tss = string.atoi(tss) except string.atoi_error: return None tzoffset=None tz=string.upper(tz) if _timezones.has_key(tz): tzoffset=_timezones[tz] else: try: tzoffset=string.atoi(tz) except string.atoi_error: pass # Convert a timezone offset into seconds ; -0500 -> -18000 if tzoffset: if tzoffset < 0: tzsign = -1 tzoffset = -tzoffset else: tzsign = 1 tzoffset = tzsign * ( (tzoffset/100)*3600 + (tzoffset % 100)*60) tuple = (yy, mm, dd, thh, tmm, tss, 0, 0, 0, tzoffset) return tuple
8,785
def __init__(self, file=None): if not file: file = os.path.join(os.environ['HOME'], ".netrc") try: fp = open(file) except: return None self.hosts = {} self.macros = {} lexer = shlex.shlex(fp) lexer.wordchars = lexer.wordchars + '.' while 1: # Look for a machine, default, or macdef top-level keyword toplevel = tt = lexer.get_token() if tt == '' or tt == None: break elif tt == 'machine': entryname = lexer.get_token() elif tt == 'default': entryname = 'default' elif tt == 'macdef': # Just skip to end of macdefs entryname = lexer.get_token() self.macros[entryname] = [] lexer.whitepace = ' \t' while 1: line = lexer.instream.readline() if not line or line == '\012' and tt == '\012': lexer.whitepace = ' \t\r\n' break tt = line self.macros[entryname].append(line) else: raise SyntaxError, "bad toplevel token %s, file %s, line %d" \ % (tt, file, lexer.lineno)
def __init__(self, file=None): if not file: file = os.path.join(os.environ['HOME'], ".netrc") try: fp = open(file) except: return None self.hosts = {} self.macros = {} lexer = shlex.shlex(fp) lexer.wordchars = lexer.wordchars + '.-@' while 1: # Look for a machine, default, or macdef top-level keyword toplevel = tt = lexer.get_token() if tt == '' or tt == None: break elif tt == 'machine': entryname = lexer.get_token() elif tt == 'default': entryname = 'default' elif tt == 'macdef': # Just skip to end of macdefs entryname = lexer.get_token() self.macros[entryname] = [] lexer.whitepace = ' \t' while 1: line = lexer.instream.readline() if not line or line == '\012' and tt == '\012': lexer.whitepace = ' \t\r\n' break tt = line self.macros[entryname].append(line) else: raise SyntaxError, "bad toplevel token %s, file %s, line %d" \ % (tt, file, lexer.lineno)
8,786
def pickline(file, key, casefold = 1): try: f = open(file, 'r') except IOError: return None pat = key + ':' if casefold: prog = regex.compile(pat, regex.casefold) else: prog = regex.compile(pat) while 1: line = f.readline() if not line: break if prog.match(line) == len(line): text = line[len(key)+1:] while 1: line = f.readline() if not line or \ line[0] not in string.whitespace: break text = text + line return string.strip(text) return None
def pickline(file, key, casefold = 1): try: f = open(file, 'r') except IOError: return None pat = key + ':' if casefold: prog = regex.compile(pat, regex.casefold) else: prog = regex.compile(pat) while 1: line = f.readline() if not line: break if prog.match(line) >= 0: text = line[len(key)+1:] while 1: line = f.readline() if not line or \ line[0] not in string.whitespace: break text = text + line return string.strip(text) return None
8,787
def go(self, event=None): if not self.msgq: self.msgq = Queue.Queue(0) self.check_msgq() if not self.sucker: self.sucker = SuckerThread(self.msgq) if self.sucker.stopit: return self.url_entry.selection_range(0, END) url = self.url_entry.get() url = url.strip() if not url: self.top.bell() self.message("[Error: No URL entered]") return self.rooturl = url dir = self.dir_entry.get().strip() if not dir: self.sucker.savedir = None else: self.sucker.savedir = dir self.sucker.rootdir = os.path.dirname( websucker.Sucker.savefilename(self, url)) self.go_button.configure(state=DISABLED) self.auto_button.configure(state=DISABLED) self.cancel_button.configure(state=NORMAL) self.message( '[running...]') self.sucker.stopit = 0 t = threading.Thread(target=self.sucker.run1, args=(url,)) t.start()
def go(self, event=None): if not self.msgq: self.msgq = Queue.Queue(0) self.check_msgq() if not self.sucker: self.sucker = SuckerThread(self.msgq) if self.sucker.stopit: return self.url_entry.selection_range(0, END) url = self.url_entry.get() url = url.strip() if not url: self.top.bell() self.message("[Error: No URL entered]") return self.rooturl = url dir = self.dir_entry.get().strip() if not dir: self.sucker.savedir = None else: self.sucker.savedir = dir self.sucker.rootdir = os.path.dirname( websucker.Sucker.savefilename(self.sucker, url)) self.go_button.configure(state=DISABLED) self.auto_button.configure(state=DISABLED) self.cancel_button.configure(state=NORMAL) self.message( '[running...]') self.sucker.stopit = 0 t = threading.Thread(target=self.sucker.run1, args=(url,)) t.start()
8,788
def make_pat(): kw = r"\b" + any("KEYWORD", keyword.kwlist) + r"\b" builtinlist = [str(name) for name in dir(__builtin__) if not name.startswith('_')] builtin = r"([^\\.]\b|^)" + any("BUILTIN", builtinlist) + r"\b" comment = any("COMMENT", [r"#[^\n]*"]) sqstring = r"(\b[rR])?'[^'\\\n]*(\\.[^'\\\n]*)*'?" dqstring = r'(\b[rR])?"[^"\\\n]*(\\.[^"\\\n]*)*"?' sq3string = r"(\b[rR])?'''[^'\\]*((\\.|'(?!''))[^'\\]*)*(''')?" dq3string = r'(\b[rR])?"""[^"\\]*((\\.|"(?!""))[^"\\]*)*(""")?' string = any("STRING", [sq3string, dq3string, sqstring, dqstring]) return kw + "|" + builtin + "|" + comment + "|" + string + "|" + any("SYNC", [r"\n"])
def make_pat(): kw = r"\b" + any("KEYWORD", keyword.kwlist) + r"\b" builtinlist = [str(name) for name in dir(__builtin__) if not name.startswith('_')] builtin = r"([^.'\"\\]\b|^)" + any("BUILTIN", builtinlist) + r"\b" comment = any("COMMENT", [r"#[^\n]*"]) sqstring = r"(\b[rR])?'[^'\\\n]*(\\.[^'\\\n]*)*'?" dqstring = r'(\b[rR])?"[^"\\\n]*(\\.[^"\\\n]*)*"?' sq3string = r"(\b[rR])?'''[^'\\]*((\\.|'(?!''))[^'\\]*)*(''')?" dq3string = r'(\b[rR])?"""[^"\\]*((\\.|"(?!""))[^"\\]*)*(""")?' string = any("STRING", [sq3string, dq3string, sqstring, dqstring]) return kw + "|" + builtin + "|" + comment + "|" + string + "|" + any("SYNC", [r"\n"])
8,789
def make_pat(): kw = r"\b" + any("KEYWORD", keyword.kwlist) + r"\b" builtinlist = [str(name) for name in dir(__builtin__) if not name.startswith('_')] builtin = r"([^\\.]\b|^)" + any("BUILTIN", builtinlist) + r"\b" comment = any("COMMENT", [r"#[^\n]*"]) sqstring = r"(\b[rR])?'[^'\\\n]*(\\.[^'\\\n]*)*'?" dqstring = r'(\b[rR])?"[^"\\\n]*(\\.[^"\\\n]*)*"?' sq3string = r"(\b[rR])?'''[^'\\]*((\\.|'(?!''))[^'\\]*)*(''')?" dq3string = r'(\b[rR])?"""[^"\\]*((\\.|"(?!""))[^"\\]*)*(""")?' string = any("STRING", [sq3string, dq3string, sqstring, dqstring]) return kw + "|" + builtin + "|" + comment + "|" + string + "|" + any("SYNC", [r"\n"])
def make_pat(): kw = r"\b" + any("KEYWORD", keyword.kwlist) + r"\b" builtinlist = [str(name) for name in dir(__builtin__) if not name.startswith('_')] builtin = r"([^\\.]\b|^)" + any("BUILTIN", builtinlist) + r"\b" comment = any("COMMENT", [r"#[^\n]*"]) sqstring = r"(\b[rR])?'[^'\\\n]*(\\.[^'\\\n]*)*'?" dqstring = r'(\b[rR])?"[^"\\\n]*(\\.[^"\\\n]*)*"?' sq3string = r"(\b[rR])?'''[^'\\]*((\\.|'(?!''))[^'\\]*)*(''')?" dq3string = r'(\b[rR])?"""[^"\\]*((\\.|"(?!""))[^"\\]*)*(""")?' string = any("STRING", [sq3string, dq3string, sqstring, dqstring]) return kw + "|" + builtin + "|" + comment + "|" + string +\ "|" + any("SYNC", [r"\n"])
8,790
def delete(self, index1, index2=None): index1 = self.index(index1) self.delegate.delete(index1, index2) self.notify_range(index1)
def delete(self, index1, index2=None): index1 = self.index(index1) self.delegate.delete(index1, index2) self.notify_range(index1)
8,791
def notify_range(self, index1, index2=None): self.tag_add("TODO", index1, index2) if self.after_id: if DEBUG: print "colorizing already scheduled" return if self.colorizing: self.stop_colorizing = 1 if DEBUG: print "stop colorizing" if self.allow_colorizing: if DEBUG: print "schedule colorizing" self.after_id = self.after(1, self.recolorize)
def notify_range(self, index1, index2=None): self.tag_add("TODO", index1, index2) if self.after_id: if DEBUG: print "colorizing already scheduled" return if self.colorizing: self.stop_colorizing = True if DEBUG: print "stop colorizing" if self.allow_colorizing: if DEBUG: print "schedule colorizing" self.after_id = self.after(1, self.recolorize)
8,792
def close(self, close_when_done=None): if self.after_id: after_id = self.after_id self.after_id = None if DEBUG: print "cancel scheduled recolorizer" self.after_cancel(after_id) self.allow_colorizing = 0 self.stop_colorizing = 1 if close_when_done: if not self.colorizing: close_when_done.destroy() else: self.close_when_done = close_when_done
def close(self, close_when_done=None): if self.after_id: after_id = self.after_id self.after_id = None if DEBUG: print "cancel scheduled recolorizer" self.after_cancel(after_id) self.allow_colorizing = False self.stop_colorizing = True if close_when_done: if not self.colorizing: close_when_done.destroy() else: self.close_when_done = close_when_done
8,793
def toggle_colorize_event(self, event): if self.after_id: after_id = self.after_id self.after_id = None if DEBUG: print "cancel scheduled recolorizer" self.after_cancel(after_id) if self.allow_colorizing and self.colorizing: if DEBUG: print "stop colorizing" self.stop_colorizing = 1 self.allow_colorizing = not self.allow_colorizing if self.allow_colorizing and not self.colorizing: self.after_id = self.after(1, self.recolorize) if DEBUG: print "auto colorizing turned", self.allow_colorizing and "on" or "off" return "break"
def toggle_colorize_event(self, event): if self.after_id: after_id = self.after_id self.after_id = None if DEBUG: print "cancel scheduled recolorizer" self.after_cancel(after_id) if self.allow_colorizing and self.colorizing: if DEBUG: print "stop colorizing" self.stop_colorizing = True self.allow_colorizing = not self.allow_colorizing if self.allow_colorizing and not self.colorizing: self.after_id = self.after(1, self.recolorize) if DEBUG: print "auto colorizing turned", self.allow_colorizing and "on" or "off" return "break"
8,794
def toggle_colorize_event(self, event): if self.after_id: after_id = self.after_id self.after_id = None if DEBUG: print "cancel scheduled recolorizer" self.after_cancel(after_id) if self.allow_colorizing and self.colorizing: if DEBUG: print "stop colorizing" self.stop_colorizing = 1 self.allow_colorizing = not self.allow_colorizing if self.allow_colorizing and not self.colorizing: self.after_id = self.after(1, self.recolorize) if DEBUG: print "auto colorizing turned", self.allow_colorizing and "on" or "off" return "break"
def toggle_colorize_event(self, event): if self.after_id: after_id = self.after_id self.after_id = None if DEBUG: print "cancel scheduled recolorizer" self.after_cancel(after_id) if self.allow_colorizing and self.colorizing: if DEBUG: print "stop colorizing" self.stop_colorizing = 1 self.allow_colorizing = not self.allow_colorizing if self.allow_colorizing and not self.colorizing: self.after_id = self.after(1, self.recolorize) if DEBUG: print "auto colorizing turned",\ self.allow_colorizing and "on" or "off" return "break"
8,795
def recolorize(self): self.after_id = None if not self.delegate: if DEBUG: print "no delegate" return if not self.allow_colorizing: if DEBUG: print "auto colorizing is off" return if self.colorizing: if DEBUG: print "already colorizing" return try: self.stop_colorizing = 0 self.colorizing = 1 if DEBUG: print "colorizing..." t0 = time.clock() self.recolorize_main() t1 = time.clock() if DEBUG: print "%.3f seconds" % (t1-t0) finally: self.colorizing = 0 if self.allow_colorizing and self.tag_nextrange("TODO", "1.0"): if DEBUG: print "reschedule colorizing" self.after_id = self.after(1, self.recolorize) if self.close_when_done: top = self.close_when_done self.close_when_done = None top.destroy()
def recolorize(self): self.after_id = None if not self.delegate: if DEBUG: print "no delegate" return if not self.allow_colorizing: if DEBUG: print "auto colorizing is off" return if self.colorizing: if DEBUG: print "already colorizing" return try: self.stop_colorizing = False self.colorizing = True if DEBUG: print "colorizing..." t0 = time.clock() self.recolorize_main() t1 = time.clock() if DEBUG: print "%.3f seconds" % (t1-t0) finally: self.colorizing = 0 if self.allow_colorizing and self.tag_nextrange("TODO", "1.0"): if DEBUG: print "reschedule colorizing" self.after_id = self.after(1, self.recolorize) if self.close_when_done: top = self.close_when_done self.close_when_done = None top.destroy()
8,796
def recolorize(self): self.after_id = None if not self.delegate: if DEBUG: print "no delegate" return if not self.allow_colorizing: if DEBUG: print "auto colorizing is off" return if self.colorizing: if DEBUG: print "already colorizing" return try: self.stop_colorizing = 0 self.colorizing = 1 if DEBUG: print "colorizing..." t0 = time.clock() self.recolorize_main() t1 = time.clock() if DEBUG: print "%.3f seconds" % (t1-t0) finally: self.colorizing = 0 if self.allow_colorizing and self.tag_nextrange("TODO", "1.0"): if DEBUG: print "reschedule colorizing" self.after_id = self.after(1, self.recolorize) if self.close_when_done: top = self.close_when_done self.close_when_done = None top.destroy()
def recolorize(self): self.after_id = None if not self.delegate: if DEBUG: print "no delegate" return if not self.allow_colorizing: if DEBUG: print "auto colorizing is off" return if self.colorizing: if DEBUG: print "already colorizing" return try: self.stop_colorizing = 0 self.colorizing = 1 if DEBUG: print "colorizing..." t0 = time.clock() self.recolorize_main() t1 = time.clock() if DEBUG: print "%.3f seconds" % (t1-t0) finally: self.colorizing = False if self.allow_colorizing and self.tag_nextrange("TODO", "1.0"): if DEBUG: print "reschedule colorizing" self.after_id = self.after(1, self.recolorize) if self.close_when_done: top = self.close_when_done self.close_when_done = None top.destroy()
8,797
def recolorize_main(self): next = "1.0" while 1: item = self.tag_nextrange("TODO", next) if not item: break head, tail = item self.tag_remove("SYNC", head, tail) item = self.tag_prevrange("SYNC", head) if item: head = item[1] else: head = "1.0"
def recolorize_main(self): next = "1.0" while True: item = self.tag_nextrange("TODO", next) if not item: break head, tail = item self.tag_remove("SYNC", head, tail) item = self.tag_prevrange("SYNC", head) if item: head = item[1] else: head = "1.0"
8,798
def recolorize_main(self): next = "1.0" while 1: item = self.tag_nextrange("TODO", next) if not item: break head, tail = item self.tag_remove("SYNC", head, tail) item = self.tag_prevrange("SYNC", head) if item: head = item[1] else: head = "1.0"
def recolorize_main(self): next = "1.0" while 1: item = self.tag_nextrange("TODO", next) if not item: break head, tail = item self.tag_remove("SYNC", head, tail) item = self.tag_prevrange("SYNC", head) if item: head = item[1] else: head = "1.0"
8,799