Next / Previous / Contents / Shipman's homepage

21.3. Heading.__getPaths(): Set up the directory path and file name

listext2
# - - -   H e a d i n g . _ _ g e t P a t h s

    def __getPaths(self):
        '''Set up the .__pathPart and .__filePart attributes.
        '''
        #-- 1
        # [ absPath  :=  the absolute path name to Args().inFileName ]
        absPath = os.path.abspath(Args().inFileName)

        #-- 2
        # [ dirPath  :=  directory part of absPath
        #   self.__filePart  :=  filename part of absPath ]
        dirPath, self.__filePart = os.path.split(absPath)

So that the reader understands that the directory path is a directory path, we append a slash to it. However, if the directory is/”, don't double it.

listext2
        #-- 3
        self.__pathPart =(dirPath
                          if dirPath.endswith('/')
                          else dirPath+'/')