Gets all recipes found in the cookbook directories
160026
def get_recipes():
    """"""
    dirnames = set()
    for path in cookbook_paths:
        dirnames.update([d for d in os.listdir(path) if os.path.isdir(
                            os.path.join(path, d)) and not d.startswith('.')])
    recipes = []
    for dirname in dirnames:
        recipes.extend(get_recipes_in_cookbook(dirname))
    return sorted(recipes, key=lambda x: x['name'])
986443
def list_dir_all(cookie, tokens, path):
    ''''''
    pcs_files = []
    page = 1
    while True:
        content = list_dir(cookie, tokens, path, page)
        if not content:
            return (path, None)
        if not content['list']:
            return (path, pcs_files)
        pcs_files.extend(content['list'])
        page = page + 1
306623
def load_cookbooks(cookbook_names)
        Strainer.ui.debug "Sandbox#load_cookbooks(#{cookbook_names.inspect})"
        cookbook_names.collect{ |cookbook_name| load_cookbook(cookbook_name) }
      end
496481
protected function _getMenuFiles()
    {
        $editionPathSelector = new EditionPathProvider(new EditionRootPathProvider(new EditionSelector()));
        $fullAdminDir = $editionPathSelector->getViewsDirectory() . 'admin' . DIRECTORY_SEPARATOR;
        $menuFile = $fullAdminDir . 'menu.xml';

        // including std file
        if (file_exists($menuFile)) {
            $filesToLoad[] = $menuFile;
        }

        // including custom file
        if (file_exists($fullAdminDir . 'user.xml')) {
            $filesToLoad[] = $fullAdminDir . 'user.xml';
        }

        // including module menu files
        $path = getShopBasePath();
        $modulelist = oxNew(\OxidEsales\Eshop\Core\Module\ModuleList::class);
        $activeModuleInfo = $modulelist->getActiveModuleInfo();
        if (is_array($activeModuleInfo)) {
            foreach ($activeModuleInfo as $modulePath) {
                $fullPath = $path . "modules/" . $modulePath;
                // missing file/folder?
                if (is_dir($fullPath)) {
                    // including menu file
                    $menuFile = $fullPath . "/menu.xml";
                    if (file_exists($menuFile) && is_readable($menuFile)) {
                        $filesToLoad[] = $menuFile;
                    }
                }
            }
        }

        return $filesToLoad;
    }
737230
def findall(dir=os.curdir):
    
    files = _find_all_simple(dir)
    if dir == os.curdir:
        make_rel = functools.partial(os.path.relpath, start=dir)
        files = map(make_rel, files)
    return list(files)
652949
def file_update_all(backend, message, dryrun):
    
    kitchen = DKCloudCommandRunner.which_kitchen_name()
    if kitchen is None:
        raise click.ClickException('You must be in a Kitchen')
    recipe_dir = DKRecipeDisk.find_recipe_root_dir()
    if recipe_dir is None:
        raise click.ClickException('You must be in a Recipe folder')
    recipe = DKRecipeDisk.find_recipe_name()

    if dryrun:
        click.secho('%s - Display all changed files in Recipe (%s) in Kitchen(%s) with message (%s)' %
                    (get_datetime(), recipe, kitchen, message), fg='green')
    else:
        click.secho('%s - Updating all changed files in Recipe (%s) in Kitchen(%s) with message (%s)' %
                    (get_datetime(), recipe, kitchen, message), fg='green')
    check_and_print(DKCloudCommandRunner.update_all_files(backend.dki, kitchen, recipe, recipe_dir, message, dryrun))
1169227
def recipe_list(backend, kitchen):
    
    err_str, use_kitchen = Backend.get_kitchen_from_user(kitchen)
    if use_kitchen is None:
        raise click.ClickException(err_str)
    click.secho("%s - Getting the list of Recipes for Kitchen '%s'" % (get_datetime(), use_kitchen), fg='green')
    check_and_print(DKCloudCommandRunner.list_recipe(backend.dki, use_kitchen))
119363
public static function getMenuNotAllowAll(): array
    {
        $setor = !empty($_SESSION['userlogin']) ? $_SESSION['userlogin']['setor'] : "0";
        $path = "public/dash/-menu.json";
        $pathSession = !empty($setor) ? "public/dash/{$setor}/-menu.json" : "";
        $file = [];

        //public base
        if (file_exists(PATH_HOME . $path))
            $file = self::addNotShow(PATH_HOME . $path, $file);

        //public session
        if (!empty($pathSession) && file_exists(PATH_HOME . $pathSession))
            $file = self::addNotShow(PATH_HOME . $pathSession, $file);

        //para cada biblioteca
        foreach (Helper::listFolder(PATH_HOME . VENDOR) as $lib) {
            $base = PATH_HOME . VENDOR . "{$lib}/";

            //lib base
            if (file_exists($base . $path))
                $file = self::addNotShow($base . $path, $file, $base);

            //lib session
            if (!empty($pathSession) && file_exists($base . $pathSession))
                $file = self::addNotShow($base . $pathSession, $file, $base);
        }

        return $file;
    }
1088434
def get_cookbook_path(cookbook_name):
    """"""
    for cookbook_path in cookbook_paths:
        path = os.path.join(cookbook_path, cookbook_name)
        if os.path.exists(path):
            return path
    raise IOError('Can\'t find cookbook with name "{0}"'.format(cookbook_name))
297840
def read_recipe(self, filename):
        
        Global.LOGGER.debug(f"reading recipe {filename}")
        if not os.path.isfile(filename):
            Global.LOGGER.error(filename + " recipe not found, skipping")
            return

        config = configparser.ConfigParser(allow_no_value=True,
                                           delimiters="=")

        config.read(filename)

        for section in config.sections():
            self.sections[section] = config[section]

        Global.LOGGER.debug("Read recipe " + filename)
786039
def get_recipes_in_cookbook(name):
    
    recipes = {}
    path = None
    cookbook_exists = False
    metadata_exists = False
    for cookbook_path in cookbook_paths:
        path = os.path.join(cookbook_path, name)
        path_exists = os.path.exists(path)
        # cookbook exists if present in any of the cookbook paths
        cookbook_exists = cookbook_exists or path_exists
        if not path_exists:
            continue

        _generate_metadata(path, cookbook_path, name)

        # Now try to open metadata.json
        try:
            with open(os.path.join(path, 'metadata.json'), 'r') as f:
                try:
                    cookbook = json.loads(f.read())
                except ValueError as e:
                    msg = "Little Chef found the following error in your"
                    msg += " {0} file:\n  {1}".format(
                        os.path.join(path, 'metadata.json'), e)
                    abort(msg)
                # Add each recipe defined in the cookbook
                metadata_exists = True
                recipe_defaults = {
                    'description': '',
                    'version': cookbook.get('version'),
                    'dependencies': cookbook.get('dependencies', {}).keys(),
                    'attributes': cookbook.get('attributes', {})
                }
                for recipe in cookbook.get('recipes', []):
                    recipes[recipe] = dict(
                        recipe_defaults,
                        name=recipe,
                        description=cookbook['recipes'][recipe]
                    )
            # Cookbook metadata.json was found, don't try next cookbook path
            # because metadata.json in site-cookbooks has preference
            break
        except IOError:
            # metadata.json was not found, try next cookbook_path
            pass
    if not cookbook_exists:
        abort('Unable to find cookbook "{0}"'.format(name))
    elif not metadata_exists:
        abort('Cookbook "{0}" has no metadata.json'.format(name))
    # Add recipes found in the 'recipes' directory but not listed
    # in the metadata
    for cookbook_path in cookbook_paths:
        recipes_dir = os.path.join(cookbook_path, name, 'recipes')
        if not os.path.isdir(recipes_dir):
            continue
        for basename in os.listdir(recipes_dir):
            fname, ext = os.path.splitext(basename)
            if ext != '.rb':
                continue
            if fname != 'default':
                recipe = '%s::%s' % (name, fname)
            else:
                recipe = name
            if recipe not in recipes:
                recipes[recipe] = dict(recipe_defaults, name=recipe)
    # When a recipe has no default recipe (libraries?),
    # add one so that it is listed
    if not recipes:
        recipes[name] = dict(
            recipe_defaults,
            name=name,
            description='This cookbook has no default recipe'
        )
    return recipes.values()
607382
def get_recipe(cls, name, ctx):
        ''''''
        name = name.lower()
        if not hasattr(cls, "recipes"):
            cls.recipes = {}
        if name in cls.recipes:
            return cls.recipes[name]

        recipe_file = None
        for recipes_dir in cls.recipe_dirs(ctx):
            if not exists(recipes_dir):
                continue
            # Find matching folder (may differ in case):
            for subfolder in listdir(recipes_dir):
                if subfolder.lower() == name:
                    recipe_file = join(recipes_dir, subfolder, '__init__.py')
                    if exists(recipe_file):
                        name = subfolder  # adapt to actual spelling
                        break
                    recipe_file = None
            if recipe_file is not None:
                break

        if not recipe_file:
            raise ValueError('Recipe does not exist: {}'.format(name))

        mod = import_recipe('pythonforandroid.recipes.{}'.format(name), recipe_file)
        if len(logger.handlers) > 1:
            logger.removeHandler(logger.handlers[1])
        recipe = mod.recipe
        recipe.ctx = ctx
        cls.recipes[name.lower()] = recipe
        return recipe
472335
def find_next(dir)
      @logger.operation(:finding_next_cookbook, "in #{dir.path}") do
        if COOKBOOK_SENTINELS.any? { |f| File.exists?(File.join(dir.path, f)) }
          @logger.operation(:reading_cookbook, "from #{dir.path}") do
            cookbook = RightScraper::Resources::Cookbook.new(
              @repository,
              strip_repo_dir(dir.path),
              repo_dir)
            @builder.go(dir.path, cookbook)
            cookbook
          end
        else
          @stack << dir
          search_dirs
        end
      end
    end
929801
def get_nodes(environment=None):
    """"""
    if not os.path.exists('nodes'):
        return []
    nodes = []
    for filename in sorted(
            [f for f in os.listdir('nodes')
             if (not os.path.isdir(f)
                 and f.endswith(".json") and not f.startswith('.'))]):
        fqdn = ".".join(filename.split('.')[:-1])  # Remove .json from name
        node = get_node(fqdn)
        if environment is None or node.get('chef_environment') == environment:
            nodes.append(node)
    return nodes
662051
def get_ingredients(self):
        """"""
        return [
            cmdtree.CommandTreeBuilder(self.command),
            cmdtree.CommandTreeDispatcher(),
            argparse.AutocompleteIngredient(),
            argparse.ParserIngredient(),
            crash.VerboseCrashHandler(),
            ansi.ANSIIngredient(),
            log.Logging(),
        ]
797630
def findall(self):
        
        from stat import S_ISREG, S_ISDIR, S_ISLNK

        self.allfiles = allfiles = []
        root = self.base
        stack = [root]
        pop = stack.pop
        push = stack.append

        while stack:
            root = pop()
            names = os.listdir(root)

            for name in names:
                fullname = os.path.join(root, name)

                # Avoid excess stat calls -- just one will do, thank you!
                stat = os.stat(fullname)
                mode = stat.st_mode
                if S_ISREG(mode):
                    allfiles.append(fsdecode(fullname))
                elif S_ISDIR(mode) and not S_ISLNK(mode):
                    push(fullname)
60203
def cookbook_name(file)
      raise ArgumentError, "File cannot be nil or empty" if file.to_s.empty?

      # Name is a special case as we want to fallback to the cookbook directory
      # name if metadata_field fails
      begin
        metadata_field(file, "name")
      rescue RuntimeError
        until (file.split(File::SEPARATOR) & standard_cookbook_subdirs).empty?
          file = File.absolute_path(File.dirname(file.to_s))
        end
        file = File.dirname(file) unless File.extname(file).empty?
        File.basename(file)
      end
    end