| |
---|
| | PROGNAME = "tren.py" |
---|
| | BASENAME = PROGNAME.split(".py")[0] |
---|
| | PROGENV = BASENAME.upper() |
---|
| | INCLENV = PROGENV + "INCL" |
---|
| | RCSID = "$Id: tren.py,v 1.221 2010/08/12 02:58:08 tundra Exp $" |
---|
| | RCSID = "$Id: tren.py,v 1.222 2010/08/19 19:22:04 tundra Exp $" |
---|
| | VERSION = RCSID.split()[2] |
---|
| | |
---|
| | # Copyright Information |
---|
| | |
---|
| |
---|
| | |
---|
| | # List all legal command line options that will be processed by getopt() later. |
---|
| | # We exclude -I here because it is parsed manually before the getopt() call. |
---|
| | |
---|
| | OPTIONSLIST = "A:abCcdfhi:P:qR:r:S:tvw:Xx" # All legal command line options in getopt() format |
---|
| | OPTIONSLIST = "A:abCcde:fhi:P:qR:r:S:tvw:Xx" # All legal command line options in getopt() format |
---|
| | |
---|
| | |
---|
| | ##### |
---|
| | # Literals |
---|
| |
---|
| | |
---|
| | ASK = "ASK" |
---|
| | BACKUPS = "BACKUPS" |
---|
| | DEBUG = "DEBUG" |
---|
| | CASECONV = "CASECONV" |
---|
| | CASESENSITIVE = "CASESENSITIVE" |
---|
| | ESCAPE = "ESCAPE" |
---|
| | EXISTSUFFIX = "EXISTSUFFIX" |
---|
| | FORCERENAME = "FORCERENAME" |
---|
| |
---|
| | " -b Turn off backups during forced renaming (Default: Do Backups)", |
---|
| | " -C Do case-sensitive renaming (Default)", |
---|
| | " -c Collapse case when doing string substitution (Default: False)", |
---|
| | " -d Dump debugging information (Default: False)", |
---|
| | " -e type Force case conversion (Default: None)", |
---|
| | " -f Force renaming even if target file or directory name already exists (Default: False)", |
---|
| | " -h Print help information (Default: False)", |
---|
| | " -I file Include command line arguments from file", |
---|
| | " -i num|range Specify which instance(s) to replace (Default: %s)" % DEFINST, |
---|
| |
---|
| | |
---|
| | #----------------------------------------------------------# |
---|
| | # Lookup Tables # |
---|
| | #----------------------------------------------------------# |
---|
| | |
---|
| | |
---|
| | # Day And Month Conversion Tables |
---|
| | |
---|
| | |
---|
| |
---|
| | ProgramOptions = { |
---|
| | ASK : False, # Interactively ask user before renaming each file |
---|
| | BACKUPS : True, # Do backups during forced renaming |
---|
| | DEBUG : False, # Debugging off |
---|
| | CASECONV : None, # Forced case conversions |
---|
| | CASESENSITIVE : True, # Search is case-sensitive |
---|
| | ESCAPE : DEFESC, # Escape string |
---|
| | EXISTSUFFIX : DEFSUFFIX, # What to tack on when renaming existing targets |
---|
| | FORCERENAME : False, # Do not rename if target already exists |
---|
| |
---|
| | BACKUPS : do backups during forced renaming flag, |
---|
| | OLD : old rename string, |
---|
| | NEW : new rename string, |
---|
| | DEBUG : debug flag, |
---|
| | CASECONV : type of case conversion, |
---|
| | CASESENSITIVE : case sensitivity flag, |
---|
| | FORCERENAME : force renaming flag, |
---|
| | INSTANCESTART : DReplace first, leftmost instance by default |
---|
| | INSTANCEEND : |
---|
| |
---|
| | if opt == "-d": |
---|
| | ProgramOptions[DEBUG] = True |
---|
| | DumpState() |
---|
| | |
---|
| | # Force case conversion |
---|
| | |
---|
| | if opt == "-e": |
---|
| | pass # Stick validation and storage logic here |
---|
| | |
---|
| | # Force renaming of existing targets |
---|
| | |
---|
| | if opt == "-f": |
---|
| | ProgramOptions[FORCERENAME] = True |
---|
| |
---|
| | |