| |
---|
| | |
---|
| | # Program Information |
---|
| | |
---|
| | PROGNAME = "tren.py" |
---|
| | RCSID = "$Id: tren.py,v 1.104 2010/01/22 20:33:06 tundra Exp $" |
---|
| | RCSID = "$Id: tren.py,v 1.105 2010/01/23 00:38:55 tundra Exp $" |
---|
| | VERSION = RCSID.split()[2] |
---|
| | |
---|
| | # Copyright Information |
---|
| | |
---|
| |
---|
| | |
---|
| | ##### |
---|
| | # Constants |
---|
| | ##### |
---|
| | |
---|
| | MAXINCLUDES = 50 # Maximum number of includes allowed |
---|
| | |
---|
| | |
---|
| | ##### |
---|
| | # Literals |
---|
| |
---|
| | |
---|
| | eBADARG = "Invalid or malformed command line argument!" |
---|
| | eBADINCL = "%s Option Missing Filename Specification!" % INCL |
---|
| | eERROR = "ERROR" |
---|
| | eFILEOPEN = "Cannot Open File '%s' Because: %s" |
---|
| | eFILEOPEN = "Cannot Open File '%s': %s!" |
---|
| | eTOOMANYINC = "Too Many Includes! (Max Is %d) Possible Circular Reference?" % MAXINCLUDES |
---|
| | |
---|
| | |
---|
| | ##### |
---|
| | # Informational Messages |
---|
| |
---|
| | # Resolve include file references allowing for nested includes. |
---|
| | # This has to be done here separate from the command line options so |
---|
| | # that getopt() processing below will "see" the included statements. |
---|
| | |
---|
| | NUMINCLUDES = 0 |
---|
| | while " ". join(OPTIONS).find(INCL) > -1: |
---|
| | |
---|
| | # Get the index of the next include to process. |
---|
| | # It cannot be the last item because this means the filename |
---|
| |
---|
| | ErrorMsg(eBADINCL) |
---|
| | sys.exit(1) |
---|
| | |
---|
| | file = OPTIONS[i+1] ; lhs = OPTIONS[:i] ; rhs = OPTIONS[i+2:] |
---|
| | |
---|
| | # Keep track of- and limit the number of includes allowed |
---|
| | |
---|
| | NUMINCLUDES += 1 |
---|
| | if NUMINCLUDES >= MAXINCLUDES: |
---|
| | ErrorMsg(eTOOMANYINC) |
---|
| | sys.exit(1) |
---|
| | |
---|
| | # Replace insert option on the command line with that file's contents |
---|
| | |
---|
| | try: |
---|
| |
---|
| | |
---|
| | except IOError as e: |
---|
| | ErrorMsg(eFILEOPEN % (file, e.args[1])) |
---|
| | sys.exit(1) |
---|
| | |
---|
| | |
---|
| | # Now process the command line options |
---|
| | |
---|
| | try: |
---|
| |
---|
| | |