Factored out a common routine, DumpList(), for dumping any list, using any output handler.
Setup the basic structure for parsing renaming requests.
1 parent c01e3ab commit 7dda24a26d7c2aafd1aae231430501dcf227d7e1
@tundra tundra authored on 29 Jan 2010
Showing 1 changed file
View
58
tren.py
# Program Information
 
PROGNAME = "tren.py"
PROGENV = PROGNAME.split(".py")[0].upper()
RCSID = "$Id: tren.py,v 1.120 2010/01/29 18:52:29 tundra Exp $"
RCSID = "$Id: tren.py,v 1.121 2010/01/29 21:07:17 tundra Exp $"
VERSION = RCSID.split()[2]
 
# Copyright Information
 
 
MAXLINELEN = 75 # Maximum length of printed line
PADCHAR = " " # Padding character
PADWIDTH = 30 # Column width
SEQPAD = 13 # Padding to use when dumping sequence tables
LSTPAD = 13 # Padding to use when dumping lists
WRAPINDENT = 8 # Extra indent on wrapped lines
 
 
#####
dDUMPOBJ = "Dumping Object %s"
dINCLUDING = "Including file '%s'"
dPAIR = "Option/Target Pair"
dPROGENV = "$" + PROGENV
dRENREQ = "Renaming Requests:"
dRESOLVEDOPTS = "Resolved Command Line"
dSEQATIME = "Access Time Sequence:"
dSEQCMD = "Command Line Sequence:"
dSEQCTIME = "Creation Time Sequence:"
dSEQDEV = "Device Sequence:"
dSEQGID = "GID Sequence"
dSEQGID = "GID Sequence:"
dSEQINO = "Inode Sequence:"
dSEQMODE = "Mode Sequence:"
dSEQMTIME = "Modification Time Sequence:"
dSEQNLINK = "Nlinks Sequence"
dSEQSIZE = "Size Sequence:"
dSEQTARGS = "Rename Targets:"
dSEQUID = "UID Seqeuence"
dSEQUID = "UID Sequence:"
 
 
#####
# Error Messages
self.RenNames[name].append(tblz - t.index(name) - 1) # Descending Index
 
if DEBUG:
 
DebugMsg(debugmsg)
l=[]
for item in vieworder:
itemarrow = ColumnPad([item, ARROW], padwidth=SEQPAD)
DebugMsg(ColumnPad([" ", " %s %s" % (itemarrow, view[item])]))
DumpList(DebugMsg, debugmsg, item, view[item])
 
if DEBUG:
DumpRenameObj(self)
 
for msg in l:
PrintStderr(PROGNAME + " " + VERSION + " " + dDEBUG + ": " + msg)
 
# End of 'DebugMsg()'
 
 
#####
# Debug Dump Of A List
#####
 
def DumpList(handler, msg, listname, content):
 
handler(msg)
itemarrow = ColumnPad([listname, ARROW], padwidth=LSTPAD)
handler(ColumnPad([" ", " %s %s" % (itemarrow, content)]))
 
# End of 'DumpList()'
 
 
#####
# Dump The Contents Of A Rename Object
 
return commandlines
# End of 'ProcessOptTgtPair()'
 
 
#####
# Process Command Line Renaming Requests
#####
 
def ProcessRenReq(val):
 
return val.split("=")
 
# End of 'ProcessRenReq()'
 
 
#####
# Print Usage Information
# Now process the command line in "opts... targets" pairs
 
for commandline in pairs:
RenRequests = []
 
if DEBUG:
DebugMsg(ColumnPad([dPAIR, " ".join(commandline)]))
 
try:
except getopt.GetoptError as e:
ErrorMsg(eBADARG % e.args[0])
sys.exit(1)
 
# Create and populate an object with rename targets.
# We have to do this here so that subsequent
# renaming tokens references can be resolved.
# Create and populate an object with rename targets. We have to
# do *before* we process any renaming requests because they may make
# reference to renaming tokens that only can be resolved with the
# contents of the 'targs' data structure.
 
targs = None
if args:
targs = RenameTargets(args)
EXTDELIM = val
if opt == "-q":
QUIET = True
if opt == "-r":
pass
RenRequests.append(ProcessRenReq(val))
if opt == "-t":
TESTMODE = True
if opt == "-v":
PrintStdout(RCSID)
if opt == "-x":
REGEX = True
 
 
# Display outstanding renaming requests if we're debugging
 
if DEBUG:
DumpList(DebugMsg, dRENREQ , "", RenRequests)
 
# Release the target container if we created one
if targs:
del targs