Пример #1
0
def DoGetFiles(config: Config,
               toolMiniConfig: ToolMinimalConfig,
               currentDir: str,
               allowRecursiveScan: bool = False) -> List[str]:
    """
    :param currentDir: currentDir must be part of a package root
    :param allowRecursiveScan: if True and not a sdk build all subdirectories will be scanned
    """
    if allowRecursiveScan and config.IsSDKBuild:
        config.DoPrintWarning("recursive is ignored for sdk builds")

    if ToolConfigPackageRootUtil.TryFindRootDirectory(
            toolMiniConfig.RootDirectories, currentDir) is None:
        raise UsageErrorException(
            "the folder '{0}' does not reside inside one of the root dirs".
            format(currentDir))

    theFiles = []  # type: List[str]
    if not config.IsSDKBuild:
        if allowRecursiveScan:
            theFiles += IOUtil.FindFileByName(currentDir, config.GenFileName,
                                              toolMiniConfig.IgnoreDirectories)
        else:
            theFile = IOUtil.Join(currentDir, config.GenFileName)
            if not os.path.isfile(theFile):
                raise Exception("File not found: '{0}'".format(theFile))
            theFiles.append(theFile)
    return theFiles
Пример #2
0
 def ToPath(self, path: str) -> str:
     return ToolConfigPackageRootUtil.ToPath(self.RootDirectories, path)
Пример #3
0
 def TryFindRootDirectory(
         self, path: Optional[str]) -> Optional[ToolConfigRootDirectory]:
     return ToolConfigPackageRootUtil.TryFindRootDirectory(
         self.RootDirectories, path)
Пример #4
0
 def TryToPath(self, path: Optional[str]) -> Optional[str]:
     if path is None:
         return None
     return ToolConfigPackageRootUtil.TryToPath(self.RootDirectories, path)