Next / Previous / Contents / Shipman's homepage

8.9. OldReport.__init__(): Constructor

The sole argument is the name of the directory. The constructor creates an empty list .__oldList, fills it with OldInfo objects made from the directories and files in the given subtree, and then sorts them.

For a more detailed description of the steps here, refer to the nearly identical method, Section 7.9, “BigReport.__init__(): Constructor”.

oldfiles.py
# - - -   O l d R e p o r t . _ _ i n i t _ _   - - -

    def __init__ ( self, dir ):
        """Constructor for the OldReport class."""

        #-- 1 --
        self.__oldList  =  []

        #-- 2 --
        # [ dir is a string ->
        #     self.__oldList  :=  self.__oldList with OldInfo
        #         objects added representing every accessible
        #         file in the subtree named by dir ]
        os.path.walk ( dir, self.__visitor, dir )

        #-- 3 --
        # [ self.__oldList  :=  self.__oldList, sorted ]
        self.__oldList.sort()