def adjustPath(currentFileName, referencedFileName): currentFileName = normalizeFileName(currentFileName) referencedFileName = normalizeFileName(referencedFileName) adjustedPath="" shouldLeaveAsAbsolute = referencedFileName.startswith("/") shouldLeaveAsAbsolute = referencedFileName.startswith("/") or (("/" in referencedFileName) and not(referencedFileName.startswith("../"))) if ( shouldLeaveAsAbsolute ): adjustedPath=referencedFileName else: currentPath=currentFileName.split("/") currentPath=currentPath[0:len(currentPath)-1] referencedFilePath=referencedFileName.split("/") mereReferencedFileName=referencedFilePath[len(referencedFilePath)-1] referencedFilePath=referencedFilePath[0:len(referencedFilePath)-1] for pathElement in referencedFilePath: if ( pathElement == ".." ): # if we can still peal of one directory from the currentPath if ( not(not currentPath) ): currentPath=currentPath[0:len(currentPath)-1] else: currentPath.append("..") else: currentPath.append(pathElement) for pathElement in currentPath: adjustedPath+=pathElement+"/" adjustedPath+=mereReferencedFileName return adjustedPath
def add(self, absoluteFilePath): normalizedFilePath = normalizeFileName(absoluteFilePath) if not normalizedFilePath in self.list: self.list.append(normalizedFilePath) return True return False
def getIncludedFiles(self, includingFile): includedFiles = [] normalizedIncludingFile=normalizeFileName(includingFile) if ( normalizedIncludingFile in self.dict ): includedFiles = self.dict[normalizedIncludingFile] return includedFiles
def getIncludedFiles(self, includingFile): includedFiles = [] normalizedIncludingFile = normalizeFileName(includingFile) if (normalizedIncludingFile in self.dict): includedFiles = self.dict[normalizedIncludingFile] return includedFiles
def getTransitiveIncludedFiles(self, includingFile): includedFiles = [] normalizedIncludingFile = normalizeFileName(includingFile) if (normalizedIncludingFile in self.dict): includedFiles = self.dict[normalizedIncludingFile] if not (includingFile in includedFiles): includedFiles.append(normalizedIncludingFile) return includedFiles
def getTransitiveIncludedFiles(self, includingFile): includedFiles = [] normalizedIncludingFile=normalizeFileName(includingFile) if ( normalizedIncludingFile in self.dict ): includedFiles = self.dict[normalizedIncludingFile] if not( includingFile in includedFiles ): includedFiles.append(normalizedIncludingFile) return includedFiles
def adjustPath(currentFileName, referencedFileName): currentFileName = normalizeFileName(currentFileName) referencedFileName = normalizeFileName(referencedFileName) adjustedPath = "" shouldLeaveAsAbsolute = referencedFileName.startswith("/") shouldLeaveAsAbsolute = referencedFileName.startswith("/") or ( ("/" in referencedFileName) and not (referencedFileName.startswith("../"))) if (shouldLeaveAsAbsolute): adjustedPath = referencedFileName else: currentPath = currentFileName.split("/") currentPath = currentPath[0:len(currentPath) - 1] referencedFilePath = referencedFileName.split("/") mereReferencedFileName = referencedFilePath[len(referencedFilePath) - 1] referencedFilePath = referencedFilePath[0:len(referencedFilePath) - 1] for pathElement in referencedFilePath: if (pathElement == ".."): # if we can still peal of one directory from the currentPath if (not (not currentPath)): currentPath = currentPath[0:len(currentPath) - 1] else: currentPath.append("..") else: currentPath.append(pathElement) for pathElement in currentPath: adjustedPath += pathElement + "/" adjustedPath += mereReferencedFileName return adjustedPath
def add(self, includingFile, includedFile): if ( includingFile == None ) or ( includedFile == None ): self.log.error("Preconditions violated: ",[includingFile,includedFile]) return False added = False normalizedIncludingFile=normalizeFileName(includingFile) adjustedIncludedFile=adjustPath(normalizedIncludingFile,includedFile) if not(normalizedIncludingFile in self.dict) : self.dict[normalizedIncludingFile]=[] if not (adjustedIncludedFile in self.dict[normalizedIncludingFile]): self.dict[normalizedIncludingFile].append(adjustedIncludedFile) added = True return added
def add(self, includingFile, includedFile): if (includingFile == None) or (includedFile == None): self.log.error("Preconditions violated: ", [includingFile, includedFile]) return False added = False normalizedIncludingFile = normalizeFileName(includingFile) adjustedIncludedFile = adjustPath(normalizedIncludingFile, includedFile) if not (normalizedIncludingFile in self.dict): self.dict[normalizedIncludingFile] = [] if not (adjustedIncludedFile in self.dict[normalizedIncludingFile]): self.dict[normalizedIncludingFile].append(adjustedIncludedFile) added = True return added
def hasKey(self, fileName): normalizedFileName=normalizeFileName(fileName) return (normalizedFileName in self.dict )
def getTransitiveIncludedFiles(self, includingFile): includedFiles = [] normalizedIncludingFile=normalizeFileName(includingFile) self.getTransitiveIncludedFilesInternal(normalizedIncludingFile, includedFiles) return includedFiles
def hasKey(self, fileName): normalizedFileName = normalizeFileName(fileName) return (normalizedFileName in self.dict)
def getTransitiveIncludedFiles(self, includingFile): includedFiles = [] normalizedIncludingFile = normalizeFileName(includingFile) self.getTransitiveIncludedFilesInternal(normalizedIncludingFile, includedFiles) return includedFiles