Next / Previous / Contents / Shipman's homepage

8.8. class OldReport: The application class

This class is a container for a list of OldInfo objects. Because of the behavior of the OldInfo.__cmp__(), sorting this list puts the entries into reverse chronological order.

The constructor takes the pathname of the directory subtree as an argument, builds the list of OldInfo objects, and sorts them. You can call the .genFiles() method and it will generate the contained OldInfo objects in reverse chronological order.

Again, this class is just about identical to the corresponding class in the bigfiles.py script; see Section 7.8, “class BigReport: The class for the whole application”.

oldfiles.py
# - - - - -   c l a s s   O l d R e p o r t   - - - - -

class OldReport:
    """Holds the old-files report.

      Exports:
        OldReport ( dir ):
          [ dir is a string ->
              if dir names a directory to which we have access ->
                return an OldReport object describing all the
                accessible files in that directory's subtree
              else -> raise OSError ]
        .genFiles():
          [ generate a sequence of OldInfo objects representing
            the files in self, in reverse chronological order
            by modification timestamp ]

      Class invariants:
        .__oldList:
          [ a list of information on all the files in self
            as OldInfo objects, sorted ]
    """