Next / Previous / Contents / Shipman's homepage

15. report(): Generate the report

The general report algorithm is discussed in Section 5, “Design”.

deduper
# - - -   r e p o r t

def report(fileData):
    '''Print the report.

      [ fileData is a FileData instance ->
          sys.stdout  +:=  report of sets of two or more rows in fileData
              that have the same hash, ordered by the lowest path in
              each such set ]
    '''
    #-- 1
    for mainPath in fileData.genPaths():
        #-- 1 body
        # [ let
        #     sameList == the PathHash instances in fileData whose
        #                 hash values equal mainPath.hash
        #   in ->
        #     if (len(sameList) > 1) and
        #     (mainPath.path == sameList[0].path) ->
        #       sys.stdout  +:=  separator + sameList
        #     else -> I ]

See Section 17.7, “FileData.genByHash().

deduper
        #-- 1.1
        # [ sameList  :=  list of PathHash instances in fileData
        #       whose hash values equal mainPath.hash ]
        sameList = [pathHash
                    for pathHash in fileData.genByHash(mainPath.hash)]

For the formatting of one group in the report, see Section 16, “showPath(): Write one report group”.

deduper
        #-- 1.2
        # [ if (len(sameList) > 1) and
        #   (mainPath.path == sameList[0].path) ->
        #       sys.stdout  +:=  separator + sameList
        #   else -> I ]
        if ((len(sameList) > 1) and
            (mainPath.path == sameList[0].path)):
            print("----")
            for pathHash in sameList:
                showPath(pathHash)