Next / Previous / Contents / Shipman's homepage

9.2. main(): Main program

The main starts by building the list of directories from the command line, defaulting to [ "." ] if there are no command line arguments.

softlinks.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 generate a report for each member of dirList.

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