| |
---|
| | # Program Information |
---|
| | |
---|
| | 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 |
---|
| | |
---|
| |
---|
| | |
---|
| | |
---|
| | |
---|
| | ##### |
---|
| | # 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 |
---|
| | ##### |
---|
| |
---|
| | eTOOMANYINC = "Too Many Includes! (Max Is %d) Possible Circular Reference?" % MAXINCLUDES |
---|
| | |
---|
| | |
---|
| | ##### |
---|
| | # Informational Messages |
---|
| | # Warning Messages |
---|
| | ##### |
---|
| | |
---|
| | |
---|
| | ##### |
---|
| |
---|
| | ##### |
---|
| | # 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: |
---|
| | l = str(l) |
---|
| |
---|
| | # End of 'ColumnPad()' |
---|
| | |
---|
| | |
---|
| | ##### |
---|
| | # 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()' |
---|
| | |
---|
| | |
---|
| |
---|
| | # Print An Error Message |
---|
| | ##### |
---|
| | |
---|
| | def ErrorMsg(emsg): |
---|
| | PrintStderr(PROGNAME + " " + VERSION + " " + eERROR + ": " + emsg) |
---|
| | l = ConditionLine(emsg) |
---|
| | for emsg in l: |
---|
| | PrintStderr(PROGNAME + " " + VERSION + " " + eERROR + ": " + emsg) |
---|
| | |
---|
| | # End of 'ErrorMsg()' |
---|
| | |
---|
| | |
---|
| |
---|
| | |