def getProjectRootDirectory(self, _strModuleName): """ This method returns the project root directory of a given module name. A directory is considered to be a project root if it contains the following directories: "conf", "src" and "plugins" @param _strModuleName: Name of the module @type _strModuleName: python string @return: The project root directory @type: python string """ strModuleLocation = self.getModuleLocation(_strModuleName) with self.locked(): strProjectRootDirectory = None if (strModuleLocation is not None): # Now start looking for "conf" and "plugins", max four iterations bFoundRootDirectory = False iMaxIterations = 4 strProjectRootDirectory = strModuleLocation while ((not bFoundRootDirectory) and (iMaxIterations > 0)): strProjectRootDirectory = os.path.abspath(os.path.join(strProjectRootDirectory, "..")) edListDirectoryContent = EDUtilsPath.getFileList(strProjectRootDirectory) if (("conf" in edListDirectoryContent) and \ ("src" in edListDirectoryContent) and \ ("plugins" in edListDirectoryContent)): bFoundRootDirectory = True iMaxIterations = iMaxIterations - 1 if (not bFoundRootDirectory): strProjectRootDirectory = None return strProjectRootDirectory
def getProjectRootDirectory(self, _strModuleName): """ This method returns the project root directory of a given module name. A directory is considered to be a project root if it contains the following directories: "conf", "src" and "plugins" @param _strModuleName: Name of the module @type _strModuleName: python string @return: The project root directory @type: python string """ strModuleLocation = self.getModuleLocation(_strModuleName) if strModuleLocation not in self.__class__.__dictProjectRootDir: with self.__class__.__semaphoreStatic: if strModuleLocation not in self.__class__.__dictProjectRootDir: strProjectRootDirectory = None if (strModuleLocation is not None): # Now start looking for "conf" and "plugins", max four iterations bFoundRootDirectory = False iMaxIterations = 4 strProjectRootDirectory = strModuleLocation while ((not bFoundRootDirectory) and (iMaxIterations > 0)): strProjectRootDirectory = os.path.abspath(os.path.join(strProjectRootDirectory, "..")) edListDirectoryContent = EDUtilsPath.getFileList(strProjectRootDirectory) if (("conf" in edListDirectoryContent) and \ ("src" in edListDirectoryContent) and \ ("plugins" in edListDirectoryContent)): bFoundRootDirectory = True iMaxIterations = iMaxIterations - 1 if (not bFoundRootDirectory): strProjectRootDirectory = None self.__class__.__dictProjectRootDir[strModuleLocation] = strProjectRootDirectory return self.__class__.__dictProjectRootDir[strModuleLocation]