| |
---|
| | |
---|
| | 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 |
---|
| | |
---|
| |
---|
| | |
---|
| | # 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 |
---|
| | WRAPINDENT = 8 # Extra indent on wrapped lines |
---|
| |
---|
| | |
---|
| | 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 |
---|
| | |
---|
| | |
---|
| | #----------------------------------------------------------# |
---|
| | # Prompts, & Application Strings # |
---|
| |
---|
| | dINCLUDING = "Including file '%s'" |
---|
| | 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:" |
---|
| | dSEQDEV = "Device Sequence:" |
---|
| |
---|
| | " -h Print help information.", |
---|
| | " -I file Include command line arguments from file", |
---|
| | " -l string File extension delimiter string. (Default: .)", |
---|
| | " -q Quiet mode, do not show progress.", |
---|
| | " -r <old=new> 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)", |
---|
| | " -X Treat the renaming strings literally (Default)", |
---|
| |
---|
| | ##### |
---|
| | |
---|
| | def DumpRenameObj(obj): |
---|
| | |
---|
| | SEPARATOR = SEPCHAR * MAXLINELEN |
---|
| | SEPARATOR = dSEPCHAR * MAXLINELEN |
---|
| | DebugMsg(SEPARATOR) |
---|
| | DebugMsg(dDUMPOBJ % str(obj)) |
---|
| | DebugMsg(SEPARATOR) |
---|
| | |
---|
| |
---|
| | ##### |
---|
| | |
---|
| | def DumpState(): |
---|
| | |
---|
| | SEPARATOR = SEPCHAR * MAXLINELEN |
---|
| | SEPARATOR = dSEPCHAR * MAXLINELEN |
---|
| | DebugMsg(SEPARATOR) |
---|
| | DebugMsg(dCURSTATE) |
---|
| | DebugMsg(SEPARATOR) |
---|
| | |
---|
| |
---|
| | "FORCERENAM", |
---|
| | "GLOBAL", |
---|
| | "MAXLINELEN", |
---|
| | "QUIET", |
---|
| | "RENSEP", |
---|
| | "REGEX", |
---|
| | "TARGET", |
---|
| | "TESTMODE", |
---|
| | ] |
---|
| |
---|
| | |
---|
| | 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) |
---|
| | |
---|
| |
---|
| | if opt == "-l": |
---|
| | 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": |
---|
| | PrintStdout(RCSID) |
---|
| |
---|
| | |
---|
| | if targs: |
---|
| | del targs |
---|
| | |
---|
| | |
---|
| | |