Next / Previous / Contents / Shipman's homepage

16. showPath(): Write one report group

deduper
# - - -   s h o w P a t h

def showPath(pathHash):
    '''Display one PathHash instance.

      [ pathHash is a FileData.PathHash instance ->
          sys.stdout  +:=  pathHash.size + pathHash.path ]
    '''

Because all SQLAlchemy strings are returned as Unicode, we must sanitize them for ASCII output.

deduper
    #-- 1
    # [ safePath  :=  pathHash.path with non-ASCII characters
    #                 replaced by XML character references ]
    safePath = pathHash.path.encode('ascii', 'xmlcharrefreplace')

    #-- 2
    # [ sys.stdout  +:=  pathHash.size + safePath ]
    print("{0:12d} {1}".format(pathHash.size, safePath))