diff --git a/tren.py b/tren.py index 72ca857..6554430 100755 --- a/tren.py +++ b/tren.py @@ -7,7 +7,7 @@ PROGNAME = "tren.py" PROGENV = PROGNAME.split(".py")[0].upper() -RCSID = "$Id: tren.py,v 1.112 2010/01/26 23:02:40 tundra Exp $" +RCSID = "$Id: tren.py,v 1.113 2010/01/27 17:34:57 tundra Exp $" VERSION = RCSID.split()[2] # Copyright Information @@ -50,11 +50,24 @@ ##### -# Constants +# General Program Constants ##### MAXINCLUDES = 50 # Maximum number of includes allowed + + +##### +# Message Formatting Constants +##### + +# Make sure these make sense: MAXLINELEN > PADWIDTH + WRAPINDENT +# because of the way line conditioning/wrap works. + +MAXLINELEN = 75 # Maximum length of printed line +PADCHAR = " " # Padding character PADWIDTH = 30 # Column width +WRAPINDENT = 8 # Extra indent on wrapped lines + ##### # Literals @@ -103,7 +116,7 @@ ##### -# Informational Messages +# Warning Messages ##### @@ -218,7 +231,7 @@ # Turn A List Into Columns With Space Padding ##### -def ColumnPad(list, padchar=" ", padwidth=PADWIDTH): +def ColumnPad(list, padchar=PADCHAR, padwidth=PADWIDTH): retval = "" for l in list: @@ -231,11 +244,38 @@ ##### +# Condition Line Length With Fancy Wrap And Formatting +##### + +def ConditionLine(msg, + padchar=PADCHAR, \ + padwidth=PADWIDTH, \ + wrapindent=WRAPINDENT, \ + maxlinelen=MAXLINELEN): + + retval = [] + + retval.append(msg[:maxlinelen]) + msg = msg[maxlinelen:] + + while msg: + msg = padchar * (padwidth + wrapindent) + msg + retval.append(msg[:maxlinelen]) + msg = msg[maxlinelen:] + + return retval + +# End of 'ConditionLine()' + + +##### # Print A Debug Message ##### def DebugMsg(msg): - PrintStderr(PROGNAME + " " + VERSION + " " + dDEBUG + ": " + msg) + l = ConditionLine(msg) + for msg in l: + PrintStderr(PROGNAME + " " + VERSION + " " + dDEBUG + ": " + msg) # End of 'DebugMsg()' @@ -300,7 +340,9 @@ ##### def ErrorMsg(emsg): - PrintStderr(PROGNAME + " " + VERSION + " " + eERROR + ": " + emsg) + l = ConditionLine(emsg) + for emsg in l: + PrintStderr(PROGNAME + " " + VERSION + " " + eERROR + ": " + emsg) # End of 'ErrorMsg()'