def TryFindClosestFileInRoot(log: Log, toolConfig: ToolConfig, startDirectory: str, findFilename: str) -> Optional[str]: foundPath = IOUtil.TryFindFileInCurrentOrParentDir( startDirectory, findFilename) if foundPath is None: return None foundDir = IOUtil.GetDirectoryName(foundPath) rootDir = toolConfig.TryFindRootDirectory(foundDir) return foundDir if rootDir is not None else None
def __GetProjectRootConfigPath(localConfig: LowLevelToolConfig, currentDir: str, projectRootFileName: str) -> str: try: res = IOUtil.TryFindFileInCurrentOrParentDir(currentDir, projectRootFileName) if res is not None: return res except (Exception) as ex: if localConfig.VerbosityLevel > 0: print("ERROR: {0}".format(ex)) if localConfig.DebugEnabled: raise raise Exception("Project configuration file '{0}' could not be located in current or parent folder".format(projectRootFileName))
def LocateFileInParentTree(log: Log, startDirectory: str, findFilename: str) -> str: try: res = IOUtil.TryFindFileInCurrentOrParentDir( startDirectory, findFilename) if res is not None: return res except (Exception) as ex: log.DoPrintError(str(ex)) raise Exception( "Could not find a '{0}' file in the parent tree of '{1}'".format( findFilename, startDirectory))