List all files in ``templates`` directory, including all subdirectories.

    The resulting list contains UNIX-like relative paths starting with ``templates``.
550345
def get_templates(path: Path) -> List[str]:
    '''
    '''

    result = []

    for item in path.glob('**/*'):
        if item.is_file() and not item.name.startswith('_'):
            result.append(item.relative_to(path.parent).as_posix())

    return result
736859
def include_all_subfiles(*args):
    
    file_list = []
    for path_included in args:
        local_path = path.join(HERE, path_included)

        for file in listdir(local_path):
            file_abspath = path.join(local_path, file)
            if path.isdir(file_abspath):    #do not include sub folders
                continue
            file_list.append(path_included + '/' + file)

    return file_list
1316798
def files(self, *args, **kwargs):
        

        return [p for p in self.listdir(*args, **kwargs) if p.isfile()]
550760
def list_templates():
    """"""
    templates = [f for f in glob.glob(os.path.join(template_path, '*.yaml'))]
    return templates
739042
public function listTemplateFolders()
    {

        $this->setUpTemplate();
        $result = [];
        foreach ($this->templateNamespace as $ns => $paths) {
            foreach ($paths as $path) {
                $path = $this->getRootPath() . "/" . $path;
                if ($ns == "") {
                    $result[] = $path;
                } else {
                    $result[] = ['path' => $path, 'namespace' => $ns];
                }
            }
        }

        return $result;
    }
250343
def files_in_subdir(dir, subdir):
    """"""
    paths = []
    for (path, dirs, files) in os.walk(os.path.join(dir, subdir)):
        for file in files:
            paths.append(os.path.relpath(os.path.join(path, file), dir))
    return paths
1167926
def set_templates_dir
        input = gets.chomp.strip
        root_path = input.sub(/\/\w*\/*$/, '')
        case
        when input.downcase == "b"
          jumpstart_menu
        when input.downcase == "x"
          exit_normal
        when File.directory?(input)
          puts "\n  A directory of that name already exists, would you like to set it as your template directory anyway? (Nothing will be copied or removed.)".yellow
          puts "  Yes (" + "y".yellow + ") or No (" + "n".yellow + ")?"
          set_templates_dir_to_existing_dir(input)
        when File.directory?(root_path)
          begin
            Dir.chdir(root_path)
            Dir.mkdir(input)
            files_and_dirs = FileUtils.sort_contained_files_and_dirs(JumpStart.templates_path)
            puts "\nCopying existing templates to #{input}"
            files_and_dirs[:dirs].each {|x| FileUtils.mkdir_p(FileUtils.join_paths(input, x))}
            files_and_dirs[:files].each {|x| FileUtils.cp(FileUtils.join_paths(JumpStart.templates_path, x), FileUtils.join_paths(input, x)) }
            JumpStart.templates_path = input.to_s
            JumpStart.dump_jumpstart_setup_yaml
            puts "\n  Transfer complete!".green
            puts "\n  The directory " + input.green + " has been set as the JumpStart templates directory."
            jumpstart_menu
          rescue
            puts "  It looks like you do not have the correct permissions to create a directory in #{root_path.red}"
          end
        else
          puts "  Couldn't find a directory of that name. Try again.".red
          set_templates_dir
        end
      end
278942
def ls_dir(path, include_hidden=False):
    
    lst = []
    for file in os.listdir(path):
        hidden_file = FileSystem(file).is_hidden()
        if (hidden_file and include_hidden) or (not hidden_file):
            lst.append(os.path.join(path, file))
    return list(set(lst))
1216414
def obtain_all_templates_from_a_catalog(catalog_path)
      template_names = []
      catalog_path.children.select { |child|
        File.directory?(child) && child.split.last.to_s[0] != '.'
      }.map { |template_path|
        template_path.split.last.to_s
      }.each { |template_name|
        template_names.push(template_name)
      }
      return template_names
    end
53616
def list_templates(self) -> List[str]:
        
        result = set()
        for loader in self._loaders():
            for template in loader.list_templates():
                result.add(str(template))
        return list(result)
540249
def find_template_companion(template, extension='', check=True):
    

    if check and not os.path.isfile(template):
        yield ''
        return # May be '<stdin>' (click)

    template = os.path.abspath(template)
    template_dirname = os.path.dirname(template)
    template_basename = os.path.basename(template).split('.')

    current_path = template_dirname
    stop_path = os.path.commonprefix((os.getcwd(), current_path))
    stop_path = os.path.dirname(stop_path)

    token = template_basename[0] + '.'

    while True:

        for file in sorted(os.listdir(current_path)):
            if not file.startswith(token):
                continue
            if not file.endswith(extension):
                continue

            file_parts = file.split('.')
            for i in range(1, len(template_basename)):
                if template_basename[:-i] != file_parts[:-1]:
                    continue
                if current_path == template_dirname:
                    if file_parts == template_basename:
                        continue # Do not accept template itself

                yield os.path.join(current_path, file)

        if current_path == stop_path:
            break

        # cd ..
        current_path = os.path.split(current_path)[0]
421491
def list_dirs(directory):
    
    return [f for f in pathlib.Path(directory).iterdir() if f.is_dir()]
112509
def _listdir(pth, extensions):
    """"""
    try:
        return [fname for fname in os.listdir(pth)
                if os.path.splitext(fname)[1] in extensions]
    except OSError:  # pragma: nocover
        pass
1208714
def each(&block)
      templates = Hash.new

      valid_paths(env.template_path).each do |template_dir|

        env.logger.debug("[Template] Searching #{template_dir} for templates")

        subdirs = Dir.glob("#{template_dir}/*")
        subdirs.each do |sub|
          if File.directory?("#{sub}")
            name = sub.sub(/#{template_dir}\//, '')
            template = Veewee::Template.new(name, sub, @env)
            if template.exists?
              env.logger.debug("[Template] template '#{name}' found")
              templates[name] = template
            end
          end
        end
      end

      if templates.length == 0
        env.logger.debug("[Template] no templates found")
      end

      Hash[templates.sort].each(&block)
    end
208589
def template_files(include_bundled_software)
      result = {
        "kit" => ".",
        "packages" => ".",
        "src" => "."
      }

      if include_bundled_software
        Dir.chdir(TEMPLATE_PATH) do
          Dir.glob(File.join("bundled", "*")).each do |file|
            result[file] = "kit"
          end
        end
      end

      result
    end
481992
function loadTemplates (dirs, options) {
    // require dirs to be array
    if (!Array.isArray(dirs)) {
        dirs = [dirs]
    }
    // templates indexed by absolute file name
    var templates = {}
    // load all templates in all directories
    return Promise.each(dirs, dir => {
        // load all files under dir
        return globby('**/*'+GLOBAL.ext, {
            cwd: dir,
            follow: true,
        })
        // compile templates for files
        .then(files => {
            return loadTemplatesFiles(dir, files, options, templates)
        })
    })
    // resolve with templates
    .then(() => templates)
}
748426
def list_files(x, path=""):
    
    logger_directory.info("enter list_files")
    file_list = []
    if path:
        # list files from target directory
        files = os.listdir(path)
        for file in files:
            if file.endswith(x) and not file.startswith(("$", "~", ".")):
                # join the path and basename to create full path
                file_list.append(os.path.join(path, file))
    else:
        # list files from current working directory
        files = os.listdir()
        for file in files:
            if file.endswith(x) and not file.startswith(("$", "~", ".")):
                # append basename. not full path
                file_list.append(file)
    logger_directory.info("exit list_files")
    return file_list