Next / Previous / Contents / Shipman's homepage

8. Source code for

This script is generally quite similar to The only important difference is how the files are sorted: in this case, they are sorted in descending order by modification time, that is, in reverse chronological order.

As with the script, we create a class that inherits from PathInfo, and define a different .__cmp__() method to change the sorting behavior. Like, we also redefine the .__str__() method to change the format used to display each file's information.

We'll call the derived class OldInfo.

So, here's the overall flow for processing each directory tree named on the command line.

  1. Instantiate a class called OldReport that holds all the information needed to generate our report. The class constructor takes the name of the director as an argument. It walks the directory tree, makes each thing it finds into an OldInfo object, and then sorts them.

  2. Use the .genFiles() method of the BigReport object to generate the OldInfo objects in reverse chronological order, printing each one as it is generated.