| |
---|
| | |
---|
| | PROGNAME = "tren.py" |
---|
| | BASENAME = PROGNAME.split(".py")[0] |
---|
| | PROGENV = BASENAME.upper() |
---|
| | RCSID = "$Id: tren.py,v 1.193 2010/03/15 16:47:42 tundra Exp $" |
---|
| | RCSID = "$Id: tren.py,v 1.194 2010/03/16 20:43: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 = "aCcdfhi:P:qR:r:S:tvw:Xx" # All legal command line options in getopt() format |
---|
| | OPTIONSLIST = "A:aCcdfhi:P:qR:r:S:tvw:Xx" # All legal command line options in getopt() format |
---|
| | |
---|
| | |
---|
| | ##### |
---|
| | # Literals |
---|
| |
---|
| | ##### |
---|
| | |
---|
| | eALPHABETEXIST = "Renaming token '%s' specifies a non-existent alphabet!" |
---|
| | eALPHABETMISSING = "Renaming token '%s' has a missing or incorrect alphabet specification!" |
---|
| | eALPHACMDBAD = "Alphabet specificaton '%s' malformed! Try \"Name:Alphabet\"" |
---|
| | eALPHACMDLEN = "Alphabet '%s' too short! Must contain at least 2 symbols." |
---|
| | eARGLENGTH = "%s must contain exactly %s character(s)!" |
---|
| | eBADARG = "Invalid command line: %s!" |
---|
| | eBADINCL = "option -%s requires argument" % INCL |
---|
| | eBADINSTANCE = "%s is an invalid replacement instance! Must be integer values in the form: n, n:n, :n, n:, or :" |
---|
| |
---|
| | uTable = [PROGVER, |
---|
| | HOMEPAGE, |
---|
| | "usage: " + PROGNAME + " [[-aCcdfhqtvwXx] [-I file] [-i instance] [-P escape] [ -R separator] [-S suffix] [-r old=new]] ... file|dir file|dir ...", |
---|
| | " where,", |
---|
| | " -A alphabet Install \"alphabet\" for use by sequence renaming tokens", |
---|
| | " -a Turn on interactive asking before each rename (Default: Off)", |
---|
| | " -C Do case-sensitive renaming (Default)", |
---|
| | " -c Collapse case when doing string substitution (Default: False)", |
---|
| | " -d Dump debugging information (Default: False)", |
---|
| |
---|
| | # Now process the options |
---|
| | |
---|
| | for opt, val in opts: |
---|
| | |
---|
| | # Turn on interactive "ask" mode |
---|
| | # Install new alphabet |
---|
| | |
---|
| | if opt == "-A": |
---|
| | |
---|
| | alphaname, delim, alpha = val.partition(ALPHADELIM) |
---|
| | |
---|
| | if not delim: |
---|
| | ErrorMsg(eALPHACMDBAD % val) |
---|
| | |
---|
| | if not alphaname: |
---|
| | ErrorMsg(eALPHACMDBAD % val) |
---|
| | |
---|
| | if len(alpha) < 2: |
---|
| | ErrorMsg(eALPHACMDLEN % val) |
---|
| | |
---|
| | a = [] |
---|
| | for c in alpha: |
---|
| | a.append(c) |
---|
| | |
---|
| | ALPHABETS[alphaname] = a |
---|
| | |
---|
| | if opt == "-a": |
---|
| | ProgramOptions[ASK] = True |
---|
| | |
---|
| |
---|
| | |