diff --git a/tren.py b/tren.py index dc51b4f..ab95136 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.192 2010/03/13 20:57:13 tundra Exp $" +RCSID = "$Id: tren.py,v 1.193 2010/03/15 16:47:42 tundra Exp $" VERSION = RCSID.split()[2] # Copyright Information @@ -275,8 +275,8 @@ # Error Messages ##### -eALPHABETEXIST = "Alphabet '%s' requested in '%s' does not exist!" -eALPHABETMISSING = "'%s' has a missing or incorrect alphabet specification!" +eALPHABETEXIST = "Renaming token '%s' specifies a non-existent alphabet!" +eALPHABETMISSING = "Renaming token '%s' has a missing or incorrect alphabet specification!" eARGLENGTH = "%s must contain exactly %s character(s)!" eBADARG = "Invalid command line: %s!" eBADINCL = "option -%s requires argument" % INCL @@ -285,7 +285,7 @@ eBADNEWOLD = "Bad -r argument '%s'! Requires exactly one new, old string separator (Default: " + DEFSEP + ")" eBADREGEX = "Invalid Regular Expression: %s" eERROR = "ERROR" -eEXECFAIL = "Command: '%s' Failed To Execute!" +eEXECFAIL = "Renaming token: '%s', command '%s' Failed To Execute!" eFILEOPEN = "Cannot open file '%s': %s!" eLINELEN = "Specified line length too short! Must be at least %s" % MINLEN eNAMELONG = "Renaming '%s' to new name '%s' too long! (Maximum length is %s.)" @@ -295,7 +295,7 @@ eRENAMEFAIL = "Attempt to rename '%s' to '%s' failed : %s!" eTOKBADSEQ = "Unknown sequence renaming token, '%s'!" eTOKDELIM = "Renaming token '%s' missing delimiter!" -eTOKRANDIG = "Invalid random precision, '%s'! Must be integer > 0." +eTOKRANDIG = "Renaming token: '%s' has invalid random precision! Must be integer > 0." eTOKUNKNOWN = "Renaming token '%s' is unknown type!" eTOOMANYINC = "Too many includes! (Max is %d) Possible circular reference?" % MAXINCLUDES @@ -951,6 +951,8 @@ for r in rentokens: + fullrentoken = "%s%s%s" % (TOKDELIM, r[2], TOKDELIM) # Need this for error messages. + ### # File Attribute Renaming Tokens ### @@ -1040,7 +1042,7 @@ # Nonzero status means error attempting to execute the command if status: - ErrorMsg(eEXECFAIL % command) + ErrorMsg(eEXECFAIL % (fullrentoken, command)) # Otherwise swap the command with its results, stripping newlines @@ -1061,10 +1063,10 @@ precision = int(precision) except: - ErrorMsg(eTOKRANDIG % str(precision)) + ErrorMsg(eTOKRANDIG % fullrentoken) if precision < 1: - ErrorMsg(eTOKRANDIG % str(precision)) + ErrorMsg(eTOKRANDIG % fullrentoken) fmt = '"%0' + str(precision) + 'd" % random.randint(0, pow(10, precision)-1)' r[2] = eval(fmt) @@ -1090,19 +1092,19 @@ break if not found: - ErrorMsg(eTOKBADSEQ % r[2]) + ErrorMsg(eTOKBADSEQ % fullrentoken) # Now derive the name of the alphabet to use - if field[0] != ALPHADELIM: - ErrorMsg(eALPHABETMISSING % r[2]) + if not field.startswith(ALPHADELIM): + ErrorMsg(eALPHABETMISSING % fullrentoken) field = field[1:] alphabet, alphadelim, field = field.partition(ALPHADELIM) if not alphadelim: - ErrorMsg(eALPHABETMISSING % r[2]) + ErrorMsg(eALPHABETMISSING % fullrentoken) # Empty alphabet string means default to decimal counting @@ -1110,7 +1112,7 @@ alphabet = DECIMAL if alphabet not in ALPHABETS: - ErrorMsg(eALPHABETEXIST % (alphabet, r[2])) + ErrorMsg(eALPHABETEXIST % fullrentoken) # Retrieve the ordered list of the requested type, @@ -1131,7 +1133,7 @@ ### else: - ErrorMsg(eTOKUNKNOWN % (TOKDELIM + r[2] + TOKDELIM)) + ErrorMsg(eTOKUNKNOWN % fullrentoken) ### # Successful Lookup, Do the actual replacement