Apply variables to a Recipe
487018
def order_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 - Get Order information for Kitchen %s' % (get_datetime(), use_kitchen), fg='green')

    check_and_print(
            DKCloudCommandRunner.list_order(backend.dki, use_kitchen))
155850
def query(self):
        
        if len(self._cauldron.ingredients()) == 0:
            raise BadRecipe('No ingredients have been added to this recipe')
        if not self.dirty and self._query:
            return self._query

        # Step 1: Gather up global filters and user filters and
        # apply them as if they had been added to recipe().filters(...)

        for extension in self.recipe_extensions:
            extension.add_ingredients()

        # Step 2: Build the query (now that it has all the filters
        # and apply any blend recipes

        # Get the parts of the query from the cauldron
        # We don't need to regather order_bys
        recipe_parts = self._cauldron.brew_query_parts()
        recipe_parts['order_bys'] = self._prepare_order_bys()

        for extension in self.recipe_extensions:
            recipe_parts = extension.modify_recipe_parts(recipe_parts)

        # Start building the query
        query = self._session.query(*recipe_parts['columns'])
        if self._select_from is not None:
            query = query.select_from(self._select_from)
        recipe_parts['query'] = query \
            .group_by(*recipe_parts['group_bys']) \
            .order_by(*recipe_parts['order_bys']) \
            .filter(*recipe_parts['filters'])

        if recipe_parts['havings']:
            for having in recipe_parts['havings']:
                recipe_parts['query'] = recipe_parts['query'].having(having)

        for extension in self.recipe_extensions:
            recipe_parts = extension.modify_prequery_parts(recipe_parts)

        if self._select_from is None and len(
            recipe_parts['query'].selectable.froms
        ) != 1:
            raise BadRecipe(
                'Recipes must use ingredients that all come from '
                'the same table. \nDetails on this recipe:\n{'
                '}'.format(str(self._cauldron))
            )

        for extension in self.recipe_extensions:
            recipe_parts = extension.modify_postquery_parts(recipe_parts)

        recipe_parts = run_hooks(
            recipe_parts, 'modify_query', self.dynamic_extensions
        )

        # Apply limit on the outermost query
        # This happens after building the comparison recipe
        if self._limit and self._limit > 0:
            recipe_parts['query'] = recipe_parts['query'].limit(self._limit)

        if self._offset and self._offset > 0:
            recipe_parts['query'] = recipe_parts['query'].offset(self._offset)

        # Step 5:  Clear the dirty flag,
        # Patch the query if there's a comparison query
        # cache results

        self._query = recipe_parts['query']
        self.dirty = False
        return self._query
87431
private function prepare(): callable
    {
        return function (): void {
            /**
             * @var Chef $this
             */
            $this->recipe->prepare($this->workPlan, $this);

            $this->checkMissingIngredients();

            $this->position = 0;
        };
    }
300044
def run_recipe(recipe, task, rinput, workenv, logger_control):
    """"""

    # Creating custom logger file
    recipe_logger = logging.getLogger(logger_control['default'])

    if logger_control['enabled']:
        logfile = os.path.join(workenv.resultsdir, logger_control['logfile'])
        logformat = logger_control['format']
        _logger.debug('creating file logger %r from Recipe logger', logfile)
        fh = create_recipe_file_logger(recipe_logger, logfile, logformat)
    else:
        fh = logging.NullHandler()

    recipe_logger.addHandler(fh)

    with working_directory(workenv.workdir):
        try:
            run_recipe_timed(task, recipe, rinput)
            return task
        finally:
            recipe_logger.removeHandler(fh)
589106
def execute_recipe!(stack_name, layer, recipe, app_name = Momentum.config[:app_base_name])
      raise "No recipe provided" unless recipe
      stack = Momentum::OpsWorks.get_stack(@ow, stack_name)
      app = Momentum::OpsWorks.get_app(@ow, stack, app_name)
      layer_names = layer ? [layer] : Momentum.config[:app_layers]
      layers = Momentum::OpsWorks.get_layers(@ow, stack, layer_names)
      instance_ids = layers.inject([]) { |ids, l| ids + Momentum::OpsWorks.get_online_instance_ids(@ow, layer_id: l[:layer_id]) }
      raise 'No online instances found!' if instance_ids.empty?
      @ow.create_deployment(
        stack_id: stack[:stack_id],
        app_id: app[:app_id],
        command: {
          name: 'execute_recipes',
          args: {
            'recipes' => [recipe.to_s]
          }
        },
        instance_ids: instance_ids
      )
    end
81300
private void variable( HashMap<String, Expression> variables, FormattableContainer currentRule ) {
        StringBuilder builder = cachesBuilder;
        builder.append( '@' );
        char ch;
        LOOP: for( ;; ) {
            ch = read();
            switch( ch ) {
                case ':':
                    if( !isVariableName(builder) ) {
                        builder.append( ch );
                        continue;
                    }
                    break LOOP;
                case ';':
                    String name = trim( builder );
                    if( name.startsWith( "@import " ) ) {
                        importFile( currentRule, name.substring( 8 ).trim() );
                        return;
                    }
                    if( name.endsWith( "()" ) ) {
                        currentRule.add( new VariableExpression( reader, name.substring( 0, name.length() - 2 ) ) ); // reference to detached ruleset
                    } else {
                        currentRule.add( new CssAtRule( reader, name + ';') ); // directives like @charset "UTF-8";
                    }
                    return;
//                    throw createException( "Unrecognized input: '" + name + "'" );
                default:
                    builder.append( ch );
            }
        }
        String name = trim( builder );
        Expression value = parseExpression( (char)0 );
        ch = read();
        if( ch == '}' ) {
            back( ch );
        } else {
            if( ch != ';' ) {
                throw createException( "Unrecognized input: '" + ch + "'" );
            }
        }
        variables.put( name, value );
    }
562254
def addVars(filename, varNamesStr, outOf=None):
    """
    filename, varnames, outOf = __saveVarsHelper(filename, varNamesStr, outOf)
    f = None
    try:
        f = open(filename, "rb")
        h = cPickle.load(f)
        f.close()

        h.update(dict(zip(varnames, atIndices(outOf, varnames))))
        f = open(filename, "wb")
        cPickle.dump( h, f , 1 )
    finally:
        if f: f.close()
1308732
def perform_templating(args):
    """"""
    engine = engines.engines[args.engine]

    if args.vary:
        it = variable_outfile_iterator(args.outfiles,
                                       args.infiles,
                                       args.args,
                                       engine)
    else:
        it = constant_outfile_iterator(args.outfiles,
                                       args.infiles,
                                       args.args)

    process_combinations(it, engine,
                         tolerant=args.tolerant,
                         read_old=args.read_old,
                         delete_empty=args.delete_empty,
                         )
336611
def missing_vars(template_vars, parsed_content, obj):
    """"""
    missing = []
    default_vars = grok_vars(parsed_content)
    for var in template_vars:
        if var not in default_vars and var not in obj:
            missing.append(var)

    if missing:
        e_msg = "Missing required variables %s" % \
                ','.join(missing)
        raise aomi_excep.AomiData(e_msg)
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
288689
def order_run(backend, kitchen, recipe, variation, node):
    
    err_str, use_kitchen = Backend.get_kitchen_from_user(kitchen)
    if use_kitchen is None:
        raise click.ClickException(err_str)
    if recipe is None:
        recipe = DKRecipeDisk.find_recipe_name()
        if recipe is None:
            raise click.ClickException('You must be in a recipe folder, or provide a recipe name.')

    msg = '%s - Create an Order:\n\tKitchen: %s\n\tRecipe: %s\n\tVariation: %s\n' % (get_datetime(), use_kitchen, recipe, variation)
    if node is not None:
        msg += '\tNode: %s\n' % node

    click.secho(msg, fg='green')
    check_and_print(DKCloudCommandRunner.create_order(backend.dki, use_kitchen, recipe, variation, node))
485489
def setup_variables(options = {})
        @color = (preferred_color || options.delete(:color))
        @outline = (preferred_outline || options.delete(:outline))
        @width, @height = options.delete(:size)
        @min_value, @max_value = options[:min_value], options[:max_value]
        @opacity = options[:opacity] || 1.0
        @complexity = options[:complexity]
      end
21496
def blend_vars(secrets, opt):
    """"""
    base_obj = load_vars(opt)
    merged = merge_dicts(base_obj, secrets)
    template_obj = dict((k, v) for k, v in iteritems(merged) if v)
    # give templates something to iterate over
    template_obj['aomi_items'] = template_obj.copy()
    return template_obj
1265435
def _parse_variable_defaults(cls, defaults):
        """"""

        default_dict = {}

        for item in defaults:
            key = next(iter(item))
            value = item[key]

            if key in default_dict:
                raise RecipeFileInvalid("Default variable value specified twice", name=key, old_value=default_dict[key], new_value=value)

            default_dict[key] = value

        return default_dict
1316420
def apply_attributes(self, nc, table, prefix=''):
        
        for name, value in sorted(table.items()):
            if name in nc.ncattrs():
                LOG.debug('already have a value for %s' % name)
                continue
            if value is not None:
                setattr(nc, name, value)
            else:
                funcname = prefix+name  # _global_ + product_tile_height
                func = getattr(self, funcname, None)
                if func is not None:
                    value = func()
                    if value is not None:
                        setattr(nc, name, value)
                else:
                    LOG.info('no routine matching %s' % funcname)
331729
def substitute_variables(command, level, name, value, target=None, **kwargs):
    """"""
    rule = kwargs.get('rule', {})
    rule_value = rule.get('value', '') if rule else ''
    substitutes = {
        '${level}': str(level),
        '${target}': str(target),
        '${name}': '"' + str(name) + '"',
        '${value}': str(value),
        '${limit_value}': str(rule_value),
    }

    result = command
    for pattern, value in substitutes.items():
        result = result.replace(pattern, value)

    return result
1150429
public function prepareVars()
    {
        $this->populateTableWidget();
        $this->vars['table'] = $this->table;
        $this->vars['size'] = $this->size;
        $this->vars['rowSorting'] = $this->rowSorting;
    }