| |
---|
| | |
---|
| | PROGNAME = "tren.py" |
---|
| | BASENAME = PROGNAME.split(".py")[0] |
---|
| | PROGENV = BASENAME.upper() |
---|
| | RCSID = "$Id: tren.py,v 1.217 2010/04/07 18:36:55 tundra Exp $" |
---|
| | INCLENV = PROGENV + "INCL" |
---|
| | RCSID = "$Id: tren.py,v 1.218 2010/06/25 22:39:46 tundra Exp $" |
---|
| | VERSION = RCSID.split()[2] |
---|
| | |
---|
| | # Copyright Information |
---|
| | |
---|
| |
---|
| | |
---|
| | elif OSNAME == 'posix': |
---|
| | POSIX = True |
---|
| | |
---|
| | # If we're on Win32, try to load win32all stuff if it's available |
---|
| | |
---|
| | # Set up Windows-specific stuff |
---|
| | |
---|
| | if WINDOWS: |
---|
| | |
---|
| | # Try to load win32all stuff if it's available |
---|
| | |
---|
| | try: |
---|
| | from win32api import GetFileAttributes, GetComputerName |
---|
| | import win32con |
---|
| | from win32file import GetDriveType |
---|
| |
---|
| | |
---|
| | except: |
---|
| | WIN32ALL = False |
---|
| | |
---|
| | |
---|
| | # Get Unix password and group features |
---|
| | # Set up Unix-specific stuff |
---|
| | |
---|
| | elif POSIX: |
---|
| | |
---|
| | # Get Unix password and group features |
---|
| | |
---|
| | import grp |
---|
| | import pwd |
---|
| | |
---|
| | |
---|
| | # Uh oh, this is not an OS we know about |
---|
| | |
---|
| | else: |
---|
| | sys.stderr.write("Unsupported Operating System! Aborting ...\n") |
---|
| | sys.exit(1) |
---|
| |
---|
| | |
---|
| | #----------------------------------------------------------# |
---|
| | # Constants & Literals # |
---|
| | #----------------------------------------------------------# |
---|
| | |
---|
| | |
---|
| | |
---|
| | ##### |
---|
| | # General Program Constants |
---|
| |
---|
| | NULLESC = "Escape string" # Cannot be null |
---|
| | NULLRENSEP = "Old/New separator string" # Cannot be null |
---|
| | NULLSUFFIX = "Forced renaming suffix string" # Cannot be null |
---|
| | OPTINTRO = "-" # Option introducer |
---|
| | PATHDELUNIX = ":" # Separates include path elements on Unix systems |
---|
| | PATHDELWIN = ";" # Separates include path elements on Windows systems |
---|
| | PATHSEP = os.path.sep # File path separator character |
---|
| | RANGESEP = ":" # Separator for instance ranges |
---|
| | SINGLEINST = "SINGLEINST" # Indicates a single, not range, replacement instance |
---|
| | WINDOWSGROUP = "WindowsGroup" # Returned on Windows w/o win32all |
---|
| | WINDOWSUSER = "WindowsUser" # Reutrned on Windows w/o win32all |
---|
| |
---|
| | if NUMINCLUDES > MAXINCLUDES: |
---|
| | ErrorMsg(eTOOMANYINC) |
---|
| | |
---|
| | # Read the included file, stripping out comments |
---|
| | |
---|
| | # Use include path if one was provided |
---|
| | |
---|
| | inclpath = os.getenv(INCLENV) |
---|
| | if inclpath: |
---|
| | |
---|
| | found = searchpath(inclfile, inclpath, PATHDEL) |
---|
| | if found: |
---|
| | inclfile = found[0] |
---|
| | |
---|
| | try: |
---|
| | n = [] |
---|
| | f = open(inclfile) |
---|
| |
---|
| | # End of 'ProcessIncludes()' |
---|
| | |
---|
| | |
---|
| | ##### |
---|
| | # Search Path Looking For Include File |
---|
| | ##### |
---|
| | |
---|
| | def searchpath(filename, pathlist, pathdelim): |
---|
| | |
---|
| | # What we'll return if we find nothing |
---|
| | |
---|
| | retval = [] |
---|
| | |
---|
| | # Find all instances of filename in specified paths |
---|
| | |
---|
| | paths = pathlist.split(pathdelim) |
---|
| | |
---|
| | for path in paths: |
---|
| | |
---|
| | if path and path[-1] != PATHSEP: |
---|
| | path += PATHSEP |
---|
| | |
---|
| | path += filename |
---|
| | |
---|
| | if os.path.exists(path): |
---|
| | retval.append(os.path.realpath(path)) |
---|
| | |
---|
| | return retval |
---|
| | |
---|
| | # End of 'searchpath()' |
---|
| | |
---|
| | |
---|
| | ##### |
---|
| | # Print Usage Information |
---|
| | ##### |
---|
| | |
---|
| | def Usage(): |
---|
| |
---|
| | |
---|
| | #----------------------------------------------------------# |
---|
| | # Program Entry Point # |
---|
| | #----------------------------------------------------------# |
---|
| | |
---|
| | # Set up proper include path separator |
---|
| | |
---|
| | |
---|
| | if WINDOWS: |
---|
| | PATHDEL = PATHDELWIN |
---|
| | |
---|
| | else: |
---|
| | PATHDEL = PATHDELUNIX |
---|
| | |
---|
| | |
---|
| | ##### |
---|
| | # Command Line Preprocessing |
---|
| | # |
---|
| |
---|
| | |