This function is called once for each directory in the subtree. The first argument is the base pathname for the subtree, so that we can generate path names relative to there. The second argument is the directory we are visiting. The third argument is a list of all the names in the directory.
# - - - L i n k R e p o r t . _ _ v i s i t o r - - -
def __visitor ( self, basePath, dirName, nameList ):
"""Visitor function for os.path.walk.
[ (basePath is the absolute path to a directory
at or above dirName) and
(dirName is the name of a directory) and
(nameList is a list of the names in that directory) ->
self.__linkList := self.__linkList with LinkInfo
instances added representing accessible links
in nameList ]
"""
The names in nameList are the files and
soft links in this directory. We iterate through that
list, adding more LinkInfo instances to
self.__linkList corresponding to
accessible soft links. The full path to each file is
reconstructed by using the os.path.join()
function to prepend dirName.
#-- 1 --
for fileName in nameList:
#-- 1 body --
# [ if fileName names an accessible soft link ->
# self.__linkList := self.__linkList + (a new
# LinkInfo instance describing fileName)
# else -> I ]
#-- 1.1 --
# [ filePath := dirName + fileName ]
filePath = os.path.join ( dirName, fileName )
#-- 1.2 --
# [ if filePath is an accessible soft link ->
# self.__linkList := self.__linkList + (a new
# LinkInfo instance describing filePath) ]
try:
linkInfo = LinkInfo ( filePath, basePath )
if linkInfo.isLink():
self.__linkList.append ( linkInfo )
except OSError, detail:
pass