diff --git a/tren.py b/tren.py index c30a4c1..576b31a 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.117 2010/01/28 23:50:25 tundra Exp $" +RCSID = "$Id: tren.py,v 1.118 2010/01/29 00:17:13 tundra Exp $" VERSION = RCSID.split()[2] # Copyright Information @@ -104,7 +104,9 @@ dRESOLVEDOPTS = "Resolved Command Line" dSEQCMD = "Command Line Sequence:" dSEQSIZE = "Size Sequence:" +dSEQATIME = "Access Time Sequence:" dSEQCTIME = "Creation Time Sequence:" +dSEQMTIME = "Modification Time Sequence:" dTARGETS = "Rename Targets: %s" @@ -194,8 +196,12 @@ 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), ascending order of appearance by-size (0-based) descending order of appearance by-size (0-based) ] @@ -209,7 +215,9 @@ # Ordered lists used by sequence renaming tokens + atimes = {} # Keys = atimes, Values = List of corresponding files ctimes = {} # Keys = ctimes, Values = List of corresponding files + mtimes = {} # Keys = mtimes, Values = List of corresponding files sizes = {} # Keys = sizes, Values = List of corresponding files # Populate the data structures @@ -221,10 +229,23 @@ basename = os.path.basename(t) stats = os.stat(fullname) + # This data structure is used to keep track of everything + # 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], + ] + # Incrementally build lists of keys that will later be # used to create sequence renaming tokens - for statval, vals in ((stats[ST_CTIME], ctimes), (stats[ST_SIZE], sizes)): + for seqtype in SeqTypes: + + statval = stats[seqtype[0]] + vals = seqtype[1] if statval in vals: vals[statval].append(fullname) @@ -237,8 +258,10 @@ # Create the various sorted views we may need for sequence tokens - for view, debugmsg in ((ctimes, dSEQCTIME), (sizes, dSEQSIZE)): + for seqtype in SeqTypes: + view = seqtype[1] + debugmsg = seqtype[2] vieworder = view.keys() vieworder.sort()