diff --git a/twander.py b/twander.py index 87f5ff0..9607a3f 100755 --- a/twander.py +++ b/twander.py @@ -6,7 +6,7 @@ # Program Information PROGNAME = "twander" -RCSID = "$Id: twander.py,v 3.172 2005/01/25 20:01:32 tundra Exp $" +RCSID = "$Id: twander.py,v 3.173 2005/01/25 20:16:03 tundra Exp $" VERSION = RCSID.split()[2] # Copyright Information @@ -47,7 +47,7 @@ # If we're on Win32, try to load win32all stuff if possible -WIN32ALL = FALSE +WIN32ALL = False if OSNAME == 'nt': try: from win32api import GetLogicalDriveStrings as GetDrives @@ -57,9 +57,9 @@ import win32con from win32security import * WIN32HOST = GetComputerName() - WIN32ALL = TRUE + WIN32ALL = True except: - WIN32ALL = FALSE + WIN32ALL = False # Get unix password and group features @@ -260,7 +260,7 @@ # Booleans ##### -# Don't need to define TRUE & FALSE - they are defined in the Tkinter module +# Don't need to define True & False - they are defined in the Tkinter module ##### @@ -271,29 +271,29 @@ # Defaults ##### -ADAPTREFRESH = TRUE # Dynamically adjust refresh intervals -AFTERCLEAR = TRUE # Clear all selections following REFRESHAFTER +ADAPTREFRESH = True # Dynamically adjust refresh intervals +AFTERCLEAR = True # Clear all selections following REFRESHAFTER AFTERWAIT = 1 # Seconds to wait before REFRESHAFTER -AUTOREFRESH = TRUE # Automatically refresh the directory display? +AUTOREFRESH = True # Automatically refresh the directory display? CMDSHELL = "" # No CMDSHELL processing DEBUGLEVEL = 0 # No debug output DEFAULTSEP = "==>" # Default separator in PROMPT and YES definitions -FORCEUNIXPATH = FALSE # Force Unix path separators regardless of OS +FORCEUNIXPATH = False # Force Unix path separators regardless of OS MAXMENU = 32 # Maximum length of displayed menu MAXMENUBUF = 250 # Maximum size of internal menu buffer MAXNESTING = 32 # Maximum depth of nested variable definitions -NODETAILS = FALSE # TRUE means details can never be displayed -NONAVIGATE = FALSE # TRUE means that all directory navigation is prevented +NODETAILS = False # True means details can never be displayed +NONAVIGATE = False # True means that all directory navigation is prevented REFRESHINT = 5000 # Interval (ms) for automatic refresh QUOTECHAR = '\"' # Character to use when quoting Built-In Variables SORTBYFIELD = "Name" # Field to use as sort key -SORTREVERSE = FALSE # Reverse specified sort order? -SORTSEPARATE = TRUE # Separate Directories and Files in sorted displays? -SYMDIR = TRUE # Sort symlinks pointing to directories as directories -USETHREADS = FALSE # Use threads on Unix? -USEWIN32ALL = TRUE # Use win32all features if available? -WARN = TRUE # Warnings on? -WIN32ALLON = TRUE # Flag for toggling win32all features while running +SORTREVERSE = False # Reverse specified sort order? +SORTSEPARATE = True # Separate Directories and Files in sorted displays? +SYMDIR = True # Sort symlinks pointing to directories as directories +USETHREADS = False # Use threads on Unix? +USEWIN32ALL = True # Use win32all features if available? +WARN = True # Warnings on? +WIN32ALLON = True # Flag for toggling win32all features while running ##### @@ -662,7 +662,7 @@ # Convert Logical Values Into Yes/No String -YesOrNo = {TRUE:"YES", FALSE:"N0"} +YesOrNo = {True:"YES", False:"N0"} # Menu Button Titles @@ -783,7 +783,7 @@ dCMD = "COMMAND" dCMDTBL = hCOMMANDS dDIRSTK = "DIRECTORY STACK" -dFALSE = "False" +dFalse = "False" dFUNCKEYS = hDIRSC dHEADER = "twander Debug Dump Run On: %s\n" dHIST = "COMMAND HISTORY STACK" @@ -794,7 +794,7 @@ dNULL = "None" dOPTVAR = hOPTVBLS dSYMTBL = hUSERVBLS -dTRUE = "True" +dTrue = "True" dWILDSTK = "WILDCARD STACK" # Debug Formatting @@ -938,7 +938,7 @@ # a space. ##### -def PadString(string, width, Rjust=FALSE): +def PadString(string, width, Rjust=False): s = string[:(width-1)] if Rjust: @@ -958,7 +958,7 @@ # while the program is running. ##### -def ProcessConfiguration(event, DoOptionsProcessing=TRUE): +def ProcessConfiguration(event, DoOptionsProcessing=True): global CONF, UI, ConditionalStack # Cleanout any old configuration data @@ -972,7 +972,7 @@ # Initialize internal parsing data structures - ConditionalStack = [TRUE,] # This is a sentinel and guarantees there will + ConditionalStack = [True,] # This is a sentinel and guarantees there will # will always be something in this stack # Load Symbol Table with predefined symbols @@ -1335,7 +1335,7 @@ else: # Assume the conditional test fails - conditional = FALSE + conditional = False # Strip the reference syntax to get just the variable name var = args[0].strip()[1:-1] @@ -1361,21 +1361,21 @@ if condition == CONDEQUAL: if var == cmpstr: - conditional = TRUE + conditional = True elif condition == CONDNOTEQUAL: if var != cmpstr: - conditional = TRUE + conditional = True # Handle the existential conditional else: if var[0] == ENVVBL: if os.environ.has_key(var[1:]): - conditional = TRUE + conditional = True elif UI.SymTable.has_key(var): - conditional = TRUE + conditional = True # Even if the current conditional is True, we do not # process its contents if the *containing* scope is False. @@ -1485,7 +1485,7 @@ elif name == WILDCARD: if val and (val not in UI.WildHist): - UpdateMenu(UI.WildBtn, UI.WildHist, MAXMENU, MAXMENUBUF, KeySelWild, newentry=val, fakeevent=TRUE) + UpdateMenu(UI.WildBtn, UI.WildHist, MAXMENU, MAXMENUBUF, KeySelWild, newentry=val, fakeevent=True) # Process any option variables - blank RHS is OK and means to leave # option set to its default value. @@ -1493,7 +1493,7 @@ elif name in UI.OptionsBoolean.keys(): if val: val = val.upper() - if val == 'TRUE' or val == 'FALSE': + if val == 'True' or val == 'False': globals()[name] = eval(val) # !!! Cheater's way to get to global variables. else: WrnMsg(wBADRHS % (num, line), fn=file) @@ -1617,9 +1617,9 @@ # Make sure menus conform to max lengths (which may have changed). - UpdateMenu(UI.DirBtn, UI.AllDirs, MAXMENU, MAXMENUBUF, LoadDirList, sort=TRUE) - UpdateMenu(UI.HistBtn, UI.CmdHist, MAXMENU, MAXMENUBUF, KeyRunCommand, fakeevent=TRUE) - UpdateMenu(UI.WildBtn, UI.WildHist, MAXMENU, MAXMENUBUF, KeySelWild, fakeevent=TRUE) + UpdateMenu(UI.DirBtn, UI.AllDirs, MAXMENU, MAXMENUBUF, LoadDirList, sort=True) + UpdateMenu(UI.HistBtn, UI.CmdHist, MAXMENU, MAXMENUBUF, KeyRunCommand, fakeevent=True) + UpdateMenu(UI.WildBtn, UI.WildHist, MAXMENU, MAXMENUBUF, KeySelWild, fakeevent=True) # Initialize the Sorting Menu @@ -2098,19 +2098,19 @@ # Memory Keys - All Features Bound To A Common Handler ### - self.DirList.bind(self.KeyBindings["MEMCLR1"], lambda event : KeyMemHandler(mem=1, clear=TRUE)) - self.DirList.bind(self.KeyBindings["MEMCLR2"], lambda event : KeyMemHandler(mem=2, clear=TRUE)) - self.DirList.bind(self.KeyBindings["MEMCLR3"], lambda event : KeyMemHandler(mem=3, clear=TRUE)) - self.DirList.bind(self.KeyBindings["MEMCLR4"], lambda event : KeyMemHandler(mem=4, clear=TRUE)) - self.DirList.bind(self.KeyBindings["MEMCLR5"], lambda event : KeyMemHandler(mem=5, clear=TRUE)) - self.DirList.bind(self.KeyBindings["MEMCLR6"], lambda event : KeyMemHandler(mem=6, clear=TRUE)) - self.DirList.bind(self.KeyBindings["MEMCLR7"], lambda event : KeyMemHandler(mem=7, clear=TRUE)) - self.DirList.bind(self.KeyBindings["MEMCLR8"], lambda event : KeyMemHandler(mem=8, clear=TRUE)) - self.DirList.bind(self.KeyBindings["MEMCLR9"], lambda event : KeyMemHandler(mem=9, clear=TRUE)) - self.DirList.bind(self.KeyBindings["MEMCLR10"], lambda event : KeyMemHandler(mem=10, clear=TRUE)) - self.DirList.bind(self.KeyBindings["MEMCLR11"], lambda event : KeyMemHandler(mem=11, clear=TRUE)) - self.DirList.bind(self.KeyBindings["MEMCLR12"], lambda event : KeyMemHandler(mem=12, clear=TRUE)) - self.DirList.bind(self.KeyBindings["MEMCLRALL"], lambda event : KeyMemHandler(mem=13, clear=TRUE)) + self.DirList.bind(self.KeyBindings["MEMCLR1"], lambda event : KeyMemHandler(mem=1, clear=True)) + self.DirList.bind(self.KeyBindings["MEMCLR2"], lambda event : KeyMemHandler(mem=2, clear=True)) + self.DirList.bind(self.KeyBindings["MEMCLR3"], lambda event : KeyMemHandler(mem=3, clear=True)) + self.DirList.bind(self.KeyBindings["MEMCLR4"], lambda event : KeyMemHandler(mem=4, clear=True)) + self.DirList.bind(self.KeyBindings["MEMCLR5"], lambda event : KeyMemHandler(mem=5, clear=True)) + self.DirList.bind(self.KeyBindings["MEMCLR6"], lambda event : KeyMemHandler(mem=6, clear=True)) + self.DirList.bind(self.KeyBindings["MEMCLR7"], lambda event : KeyMemHandler(mem=7, clear=True)) + self.DirList.bind(self.KeyBindings["MEMCLR8"], lambda event : KeyMemHandler(mem=8, clear=True)) + self.DirList.bind(self.KeyBindings["MEMCLR9"], lambda event : KeyMemHandler(mem=9, clear=True)) + self.DirList.bind(self.KeyBindings["MEMCLR10"], lambda event : KeyMemHandler(mem=10, clear=True)) + self.DirList.bind(self.KeyBindings["MEMCLR11"], lambda event : KeyMemHandler(mem=11, clear=True)) + self.DirList.bind(self.KeyBindings["MEMCLR12"], lambda event : KeyMemHandler(mem=12, clear=True)) + self.DirList.bind(self.KeyBindings["MEMCLRALL"], lambda event : KeyMemHandler(mem=13, clear=True)) self.DirList.bind(self.KeyBindings["MEMSET1"], lambda event : KeyMemHandler(mem=1)) self.DirList.bind(self.KeyBindings["MEMSET2"], lambda event : KeyMemHandler(mem=2)) self.DirList.bind(self.KeyBindings["MEMSET3"], lambda event : KeyMemHandler(mem=3)) @@ -2191,7 +2191,7 @@ # If new dir entered via mouse, force correct activation if self.MouseNewDir: self.DirList.activate(0) - self.MouseNewDir = FALSE + self.MouseNewDir = False # Do autorefreshing as required @@ -2217,14 +2217,14 @@ ##### - # Set Detailed View -> FALSE == No Details, TRUE == Details + # Set Detailed View -> False == No Details, True == Details ##### def SetDetailedView(self, details): # See if we're forcing details to always be off if NODETAILS: - self.DetailsOn = FALSE + self.DetailsOn = False else: self.DetailsOn = details @@ -2648,7 +2648,7 @@ # Move to last directory visited, if any - inhibit this from # being placed on the directory traversal stack if UI.LastDir: - LoadDirList(UI.LastDir.pop(), save=FALSE) + LoadDirList(UI.LastDir.pop(), save=False) # No previous directory else: @@ -2916,7 +2916,7 @@ # Add this wildcard to the menu if its not there alread if uwc not in UI.WildHist: - UpdateMenu(UI.WildBtn, UI.WildHist, MAXMENU, MAXMENUBUF, KeySelWild, newentry=uwc, fakeevent=TRUE) + UpdateMenu(UI.WildBtn, UI.WildHist, MAXMENU, MAXMENUBUF, KeySelWild, newentry=uwc, fakeevent=True) # Dump wildcard stack if debug requested it if DEBUGLEVEL & DEBUGWILD: @@ -3021,9 +3021,9 @@ # Keep track of whether or not the user asked for a refresh after command completion # We have to strip it here of CMDSHELL processing will work. - do_refresh_after = FALSE + do_refresh_after = False if mycmd[0] == REFRESHAFTER: - do_refresh_after = TRUE + do_refresh_after = True mycmd = mycmd[1:] # Do CMDSHELL Processing if enabled and requested @@ -3039,7 +3039,7 @@ if do_refresh_after: mycmd = REFRESHAFTER + mycmd - ExecuteCommand(mycmd, pMANUALCMD, ResolveVars=TRUE, SaveUnresolved=TRUE) + ExecuteCommand(mycmd, pMANUALCMD, ResolveVars=True, SaveUnresolved=True) # Save the command only if Command History is enabled (MAXMENU > 0) # AND one of two conditions exist: @@ -3078,8 +3078,8 @@ if OSNAME=='nt' and \ os.path.abspath(UI.CurrentDir) == os.path.abspath(UI.CurrentDir + selected): - LoadDirList(SHOWDRIVES, save=TRUE) - UI.MouseNewDir = TRUE + LoadDirList(SHOWDRIVES, save=True) + UI.MouseNewDir = True # If selection is a directory, move there and list contents. @@ -3120,7 +3120,7 @@ selected += PSEP # Load UI with new directory - LoadDirList(selected, save=TRUE) + LoadDirList(selected, save=True) # Indicate that we entered a new directory this way. # This is a workaround for Tk madness. When this @@ -3134,7 +3134,7 @@ # we run things this way regardless since no harm # will be done in the latter case. - UI.MouseNewDir = TRUE + UI.MouseNewDir = True # No, a *file* was selected with a double-click @@ -3142,10 +3142,10 @@ # the selection elsewhere. elif OSNAME == 'nt': - ExecuteCommand(os.path.join(os.path.abspath(UI.CurrentDir), selected), '', ResolveBuiltIns=FALSE, UseStartDir=TRUE) + ExecuteCommand(os.path.join(os.path.abspath(UI.CurrentDir), selected), '', ResolveBuiltIns=False, UseStartDir=True) elif OSNAME == 'posix': - ExecuteCommand(os.path.join(os.path.abspath(UI.CurrentDir), selected), '') + ExecuteCommand(os.path.join(os.path.abspath(UI.CurrentDir), selected), '', ResolveBuiltIns=False) return 'break' @@ -3178,7 +3178,7 @@ # Event Handler: Menu-Related Features Handled By Single Handler ##### -def KeyMemHandler(mem, clear=FALSE): +def KeyMemHandler(mem, clear=False): global UI # Clearing Memory @@ -3223,11 +3223,11 @@ # Which entry in the Name2Key - refresh = FALSE + refresh = False if parm == fREVERSE: SORTREVERSE = not SORTREVERSE - refresh = TRUE + refresh = True # Separate Dirs/Files Means Nothing In Drive List View - Suppress # this there to avoid an unnecessary refresh @@ -3235,7 +3235,7 @@ elif (parm == fSEPARATE): if (UI.CurrentDir != SHOWDRIVES): SORTSEPARATE = not SORTSEPARATE - refresh = TRUE + refresh = True # Sort By Selected Parameter # In Drive List View only respond to those keys that have a @@ -3273,7 +3273,7 @@ # Go ahead and do the new sort else: SORTBYFIELD = parm - refresh = TRUE + refresh = True if refresh: LoadHelpMenu() @@ -3305,7 +3305,7 @@ # Execute A Command ##### -def ExecuteCommand(cmd, name, UseStartDir=FALSE, ResolveVars=FALSE, ResolveBuiltIns=TRUE, SaveUnresolved=FALSE): +def ExecuteCommand(cmd, name, UseStartDir=False, ResolveVars=False, ResolveBuiltIns=True, SaveUnresolved=False): global UI # Do nothing on blank commands @@ -3380,7 +3380,7 @@ else: savecmd = newcmd - UpdateMenu(UI.HistBtn, UI.CmdHist, MAXMENU, MAXMENUBUF, KeyRunCommand, newentry=savecmd, fakeevent=TRUE) + UpdateMenu(UI.HistBtn, UI.CmdHist, MAXMENU, MAXMENUBUF, KeyRunCommand, newentry=savecmd, fakeevent=True) # Dump Command History stack if requested @@ -3405,7 +3405,7 @@ # Load UI With Selected Directory ##### -def LoadDirList(newdir, save=TRUE, updtitle=True): +def LoadDirList(newdir, save=True, updtitle=True): # Make sure we're permitted to navigate - we have to allow initial entry into STARTDIR if NONAVIGATE and (newdir != STARTDIR): @@ -3468,7 +3468,7 @@ # We do NOT save this to the stack if: # - # 1) We've been told not to. - Passed when we're called (save=FALSE). + # 1) We've been told not to. - Passed when we're called (save=False). # 2) If we're trying to move into the current directory again. # This can happen either when the user does a manual directory # change or if they press ".." while in root. We don't @@ -3479,7 +3479,7 @@ # Are we trying to move back into same directory? if os.path.abspath(UI.CurrentDir) == os.path.abspath(newdir): - save = FALSE + save = False # Now save if we're supposed to. if save and UI.CurrentDir: @@ -3802,8 +3802,8 @@ freespace, totalspace = ('0', '0') - freespace = PadString(freespace, SZ_DRIVE_FREE, Rjust=TRUE) - totalspace = PadString(totalspace, SZ_DRIVE_TTL, Rjust=TRUE) + freespace = PadString(freespace, SZ_DRIVE_FREE, Rjust=True) + totalspace = PadString(totalspace, SZ_DRIVE_TTL, Rjust=True) entry += "%s%s%s%s" % (freespace, WIN32FREE, totalspace, WIN32TOTAL) fields.append(fspace) @@ -4175,8 +4175,8 @@ # Now take care of the prompting - for promptvar, handler, defaultarg, replace in ((YESNO, askyesno, "default", FALSE), - (PROMPT, askstring, "initialvalue", TRUE)): + for promptvar, handler, defaultarg, replace in ((YESNO, askyesno, "default", False), + (PROMPT, askstring, "initialvalue", True)): for x in range(cmd.count(promptvar)): b = cmd.find(promptvar) @@ -4238,7 +4238,7 @@ def ProcessVariables(cmd, num, line): - doeval = TRUE + doeval = True depth = 0 while doeval: @@ -4248,7 +4248,7 @@ depth += 1 if (depth > MAXNESTING): - doeval = FALSE + doeval = False # See if there are still unresolved variable references. # If so, let the user know @@ -4343,7 +4343,7 @@ # No substitutions left to do else: - doeval = FALSE + doeval = False return cmd @@ -4505,7 +4505,7 @@ # capitalization (if the user manually enteres it that way) # can appear twice in the Directory Menu - addentry = FALSE + addentry = False if OSNAME == 'nt': @@ -4518,15 +4518,15 @@ # Now see if our new entry is already there if newdir.lower() not in dlc: - addentry = TRUE + addentry = True elif newdir not in UI.AllDirs: - addentry = TRUE + addentry = True # Now add the entry if we decided it was necessary. observing MAXMENU value. if addentry: - UpdateMenu(UI.DirBtn, UI.AllDirs, MAXMENU, MAXMENUBUF, LoadDirList, sort=TRUE, newentry=newdir) + UpdateMenu(UI.DirBtn, UI.AllDirs, MAXMENU, MAXMENUBUF, LoadDirList, sort=True, newentry=newdir) # End of 'UpdateDirMenu()' @@ -4535,7 +4535,7 @@ # Generic Menu Update Routine ##### -def UpdateMenu(menubtn, datastore, max, maxbuf, func, sort=FALSE, newentry="", fakeevent=FALSE): +def UpdateMenu(menubtn, datastore, max, maxbuf, func, sort=False, newentry="", fakeevent=False): # First add the new data, if any, to the specified data storage stucture. @@ -4693,9 +4693,9 @@ # Translate Booleans into True/False strings if f: if value: - s = dTRUE + s = dTrue else: - s = dFALSE + s = dFalse # Translate all others into string representations else: @@ -4806,7 +4806,7 @@ UI.DirListMutex = mutex.mutex() # Intialize the "new dir via mouse" flag -UI.MouseNewDir = FALSE +UI.MouseNewDir = False # Initialize the refresh timers UI.LastRefresh = 0 @@ -4815,7 +4815,7 @@ UI.ConfigVisited = [] # Start in detailed mode -UI.SetDetailedView(TRUE) +UI.SetDetailedView(True) ##### @@ -4868,7 +4868,7 @@ # pickup any options changes from the environment # variable or command line. -ProcessConfiguration(None, DoOptionsProcessing=FALSE) +ProcessConfiguration(None, DoOptionsProcessing=False) # Process the rest of the options, if any @@ -4882,9 +4882,9 @@ print dHEADER % time.asctime() if opt == "-q": - WARN = FALSE + WARN = False if opt == "-r": - AUTOREFRESH = FALSE + AUTOREFRESH = False if opt == "-t": QUOTECHAR = "" if opt == "-x":