Next / Previous / Contents / Shipman's homepage

7.2. bigfiles.py: The main program

The first step is to put together a list of the desired directories. If none are given on the command line, we create a list containing just "." for the current directory.

bigfiles.py
# - - - - -   m a i n   - - - - -

def main():
    """Main program."""

    print "=== %s %s ===" % (SCRIPT_NAME, EXTERNAL_VERSION)

    #-- 1 --
    # [ if sys.argv[1:] is empty ->
    #     dirList  :=  [ "." ]
    #   else ->
    #     dirList  :=  sys.argv[1:] ]
    dirList  =  sys.argv[1:]
    if  len(dirList) == 0:
        dirList  =  [ "." ]

Next we go through the elements of dirList, generating a report for each one.

bigfiles.py
    #-- 2 --
    # [ sys.stdout  +:=  reports listing files below each
    #       directory named in dirList, with files in descending
    #       order by size ]
    for  dirName in dirList:
        #-- 2 body --
        # [ dirName is a string ->
        #     sys.stdout  +:=  a report listing the files below
        #         directory (dirName), with files in descending
        #         order by size ]
        report ( dirName )