diff --git a/tren.py b/tren.py index c066330..4f2f053 100755 --- a/tren.py +++ b/tren.py @@ -8,7 +8,7 @@ PROGNAME = "tren.py" BASENAME = PROGNAME.split(".py")[0] PROGENV = BASENAME.upper() -RCSID = "$Id: tren.py,v 1.130 2010/01/30 20:04:58 tundra Exp $" +RCSID = "$Id: tren.py,v 1.131 2010/01/30 22:10:13 tundra Exp $" VERSION = RCSID.split()[2] # Copyright Information @@ -69,7 +69,7 @@ # Make sure these make sense: MAXLINELEN > PADWIDTH + WRAPINDENT # because of the way line conditioning/wrap works. -MAXLINELEN = 75 # Maximum length of printed line +MAXLINELEN = 75 # Default max printed line length PADCHAR = " " # Padding character PADWIDTH = 30 # Column width LSTPAD = 13 # Padding to use when dumping lists @@ -84,11 +84,12 @@ ALL = "All" # Rename target is whole filename ARROW = "--->" # Text pointer COMMENT = "#" # Comment character in include files +ESC = "\\" # Escape character EXT = "Ext" # Rename target is extension EXTDELIM = "." # Extension delimeter INCL = "-I" # Include file command line option NAM = "Nam" # Rename target is name -SEPCHAR = "-" # Character used for debug separator lines +RENSEP = "=" # Rename command separator: oldRENSEPnew #----------------------------------------------------------# @@ -109,6 +110,7 @@ dPROGENV = "$" + PROGENV dRENREQ = "Renaming Requests:" dRESOLVEDOPTS = "Resolved Command Line" +dSEPCHAR = "-" # Used for debug separator lines dSEQATIME = "Access Time Sequence:" dSEQCMD = "Command Line Sequence:" dSEQCTIME = "Creation Time Sequence:" @@ -162,7 +164,8 @@ " -I file Include command line arguments from file", " -l string File extension delimiter string. (Default: .)", " -q Quiet mode, do not show progress.", - " -r Replace old with new in file or directory names.", + " -R rensep Separator string for -r rename arguments. (Default: =)", + " -r old=new Replace old with new in file or directory names.", " -t Test mode, don't rename, just show what the program *would* do", " -v Print detailed program version information and exit.", " -w Line length of diagnostic and error output (Default: 75)", @@ -434,7 +437,7 @@ def DumpRenameObj(obj): - SEPARATOR = SEPCHAR * MAXLINELEN + SEPARATOR = dSEPCHAR * MAXLINELEN DebugMsg(SEPARATOR) DebugMsg(dDUMPOBJ % str(obj)) DebugMsg(SEPARATOR) @@ -457,7 +460,7 @@ def DumpState(): - SEPARATOR = SEPCHAR * MAXLINELEN + SEPARATOR = dSEPCHAR * MAXLINELEN DebugMsg(SEPARATOR) DebugMsg(dCURSTATE) DebugMsg(SEPARATOR) @@ -473,6 +476,7 @@ "GLOBAL", "MAXLINELEN", "QUIET", + "RENSEP", "REGEX", "TARGET", "TESTMODE", @@ -668,7 +672,7 @@ RenRequests = [] try: - opts, args = getopt.getopt(OPTIONS, '1abbCcdEefghl:qr:tvw:Xx]') + opts, args = getopt.getopt(OPTIONS, '1abbCcdEefghl:qR:r:tvw:Xx]') except getopt.GetoptError as e: ErrorMsg(eBADARG % e.args[0]) sys.exit(1) @@ -704,8 +708,10 @@ EXTDELIM = val if opt == "-q": QUIET = True + if opt == '-R': + RENSEP = val if opt == "-r": - RenRequests.append(val) + RenRequests.append(val.split(RENSEP)) if opt == "-t": TESTMODE = True if opt == "-v": @@ -753,3 +759,4 @@ if targs: del targs +