diff --git a/tren.py b/tren.py index 576b31a..606e5bd 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.118 2010/01/29 00:17:13 tundra Exp $" +RCSID = "$Id: tren.py,v 1.119 2010/01/29 18:32:04 tundra Exp $" VERSION = RCSID.split()[2] # Copyright Information @@ -54,7 +54,7 @@ ##### MAXINCLUDES = 50 # Maximum number of includes allowed - +TGTSEQFLG = 9999 # Indicates non-stat() in SeqTypes table ##### # Message Formatting Constants @@ -102,12 +102,18 @@ dPAIR = "Option/Target Pair" dPROGENV = "$" + PROGENV dRESOLVEDOPTS = "Resolved Command Line" -dSEQCMD = "Command Line Sequence:" -dSEQSIZE = "Size Sequence:" dSEQATIME = "Access Time Sequence:" +dSEQCMD = "Command Line Sequence:" dSEQCTIME = "Creation Time Sequence:" +dSEQDEV = "Device Sequence:" +dSEQGID = "GID Sequence" +dSEQINO = "Inode Sequence:" +dSEQMODE = "Mode Sequence:" dSEQMTIME = "Modification Time Sequence:" -dTARGETS = "Rename Targets: %s" +dSEQNLINK = "Nlinks Sequence" +dSEQSIZE = "Size Sequence:" +dSEQTARGS = "Rename Targets:" +dSEQUID = "UID Seqeuence" ##### @@ -162,7 +168,6 @@ DEBUG = False # Debugging off CASESENSITIVE = True # Search is case-sensitive ERRORCONTINUE = False # Do not continue after error -EXTDELIM = EXTDELIM # Extension Delimiter FORCERENAM = False # Do not rename if target already exists GLOBAL = False # Only rename first instance of old string QUIET = False # Display progress @@ -195,13 +200,27 @@ fully-qualified name : [ basename, stat information for the entry, - order of appearance on command line (0-based), - ascending order of appearance by-atime (0-based), - descending order of appearance by-atime (0-based), - ascending order of appearance by-ctime (0-based), - descending order of appearance by-ctime (0-based), - ascending order of appearance by-mtime (0-based), - descending order of appearance by-mtime (0-based), + position in command line args list (0-based) + ascending alpha order of rename targets (O-based) + descending alpha order of rename targets (0-based) + ascending order of appearance by-mode (O-based) + descending order of appearance by-mode (0-based) + ascending order of appearance by-inode (O-based) + descending order of appearance by-inode (0-based) + ascending order of appearance by-devno (O-based) + descending order of appearance by-devno (0-based) + ascending order of appearance by-nlinks (O-based) + descending order of appearance by-nlinks (0-based) + ascending order of appearance by-uid (O-based) + descending order of appearance by-uid (0-based) + ascending order of appearance by-gid (O-based) + descending order of appearance by-gid (0-based) + ascending order of appearance by-atime (0-based) + descending order of appearance by-atime (0-based) + ascending order of appearance by-ctime (0-based) + descending order of appearance by-ctime (0-based) + ascending order of appearance by-mtime (0-based) + descending order of appearance by-mtime (0-based) ascending order of appearance by-size (0-based) descending order of appearance by-size (0-based) ] @@ -215,6 +234,13 @@ # Ordered lists used by sequence renaming tokens + args = {} # Keys = 0, Values = Rename targets from command line + modes = {} # Keys = modes, Values = List of corresponding files + inodes = {} # Keys = inodes, Values = List of corresponding files + devs = {} # Keys = devs, Values = List of corresponding files + nlinks = {} # Keys = nlinks, Values = List of corresponding files + uids = {} # Keys = uids, Values = List of corresponding files + gids = {} # Keys = gids, Values = List of corresponding files atimes = {} # Keys = atimes, Values = List of corresponding files ctimes = {} # Keys = ctimes, Values = List of corresponding files mtimes = {} # Keys = mtimes, Values = List of corresponding files @@ -233,10 +259,17 @@ # we need to build the sequence renaming token support. # This makes it easy to add more types later on. - SeqTypes = [ [ST_ATIME, atimes, dSEQATIME], - [ST_CTIME, ctimes, dSEQCTIME], - [ST_CTIME, mtimes, dSEQMTIME], - [ST_SIZE, sizes, dSEQSIZE], + SeqTypes = [ [TGTSEQFLG, args, dSEQTARGS], + [ST_MODE, modes, dSEQMODE], + [ST_INO, inodes, dSEQINO], + [ST_DEV, devs, dSEQDEV], + [ST_NLINK, nlinks, dSEQNLINK], + [ST_UID, uids, dSEQUID], + [ST_GID, gids, dSEQGID], + [ST_ATIME, atimes, dSEQATIME], + [ST_CTIME, ctimes, dSEQCTIME], + [ST_CTIME, mtimes, dSEQMTIME], + [ST_SIZE, sizes, dSEQSIZE], ] # Incrementally build lists of keys that will later be @@ -244,8 +277,17 @@ for seqtype in SeqTypes: - statval = stats[seqtype[0]] - vals = seqtype[1] + # Handle os.stat() values + + if seqtype[0] != TGTSEQFLG: + statval = stats[seqtype[0]] + + # Handle non os.stat() stuff + else: + statval = TGTSEQFLG + + # Where to put the results + vals = seqtype[1] if statval in vals: vals[statval].append(fullname) @@ -255,9 +297,9 @@ self.RenNames[fullname] = [basename, stats, cmdorder] cmdorder += 1 + # Create the various sorted views we may need + # for sequence renaming tokens - # Create the various sorted views we may need for sequence tokens - for seqtype in SeqTypes: view = seqtype[1]