diff --git a/tren.py b/tren.py index 4bbac02..b9c9f33 100755 --- a/tren.py +++ b/tren.py @@ -9,7 +9,7 @@ BASENAME = PROGNAME.split(".py")[0] PROGENV = BASENAME.upper() INCLENV = PROGENV + "INCL" -RCSID = "$Id: tren.py,v 1.222 2010/08/19 19:22:04 tundra Exp $" +RCSID = "$Id: tren.py,v 1.223 2010/08/20 01:18:23 tundra Exp $" VERSION = RCSID.split()[2] # Copyright Information @@ -352,6 +352,7 @@ eALPHACMDLEN = "Alphabet '%s' too short! Must contain at least 2 symbols." eARGLENGTH = "%s must contain exactly %s character(s)!" eBADARG = "Invalid command line: %s!" +eBADCASECONV = "Invalid case conversion argument: %s! Must be one of: %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 :" eBADLEN = "Bad line length '%s'!" @@ -421,6 +422,21 @@ #----------------------------------------------------------# +# Case Conversion + + +# Notice use of *unbound* string function methods from the class definition + +CASETBL = {'c' : str.capitalize, + 'l' : str.lower, + 's' : str.swapcase, + 't' : str.title, + 'u' : str.upper + } + +CASEOPS = CASETBL.keys() + + # Day And Month Conversion Tables @@ -2066,7 +2082,15 @@ # Force case conversion if opt == "-e": - pass # Stick validation and storage logic here + + # Make sure we support the requested case conversion + if val in CASEOPS: + ProgramOptions[CASECONV] = val + + # Error out if we don't recognize it + else: + ErrorMsg(eBADCASECONV % (val, ", ".join(CASEOPS))) + # Force renaming of existing targets