Next / Previous / Contents / Shipman's homepage

8.3. report(): Generate one directory tree's report

This function generates the report for one directory subtree. The pathname of the directory is the argument.

oldfiles.py
# - - -   r e p o r t   - - -

def report ( dirName ):
    """Generate the report for one directory subtree.

      [ dirName is a string ->
            sys.stdout  +:=  a report listing the files below
                directory (dirName), with files in reverse
                chronological order by modification time ]
    """

    #-- 1 -
    # [ basePath  :=  dirName's absolute path name
    #   sys.stdout  +:=  report heading showing dirName's real
    #                    absolute path ]
    basePath  =  os.path.abspath ( dirName )
    print "\n   === %s ===" % os.path.realpath ( dirName )

    #-- 2 --
    # [ oldReport  :=  an OldReport object describing all the
    #       accessible files in directory tree (dirName) ]
    oldReport  =  OldReport ( basePath )

    #-- 3 --
    # [ oldReport is an OldReport object ->
    #     sys.stdout  +:=  lines describing files in oldReport
    #         in chronological order by modification time ]
    for  oldInfo in oldReport.genFiles():
        print oldInfo