Adds a comparison recipe to a base recipe.
327940
def compare(self, compare_recipe, suffix='_compare'):
        """"""
        assert isinstance(compare_recipe, Recipe)
        assert isinstance(suffix, basestring)
        self.compare_recipe.append(compare_recipe)
        self.suffix.append(suffix)
        self.dirty = True
        return self.recipe
295941
def +(other)
      SearchAtom.new(@records.clone.merge!(other.records) { |key, _old, _new|
                                                            _old + _new
                                                          })
    end
1104284
private function _addFilterComparison($firstObj, $firstProperty, $property, $value)
    {
        if ($firstObj && $firstProperty) {
            $this->_parseComparison(self::COMPARISON_LOGIC_WHERE, $property, $value);
        } else if (!$firstObj && $firstProperty) {
            $this->_parseComparison(self::COMPARISON_LOGIC_OR, $property, $value);
        } else {
            $this->_parseComparison(self::COMPARISON_LOGIC_AND, $property, $value);
        }
    }
144525
def add_spectrum(self, compare_to_existing=True, **kwargs):
        """"""
        spec_key = self._KEYS.SPECTRA
        # Make sure that a source is given, and is valid (nor erroneous)
        source = self._check_cat_dict_source(Spectrum, spec_key, **kwargs)
        if source is None:
            return None

        # Try to create a new instance of `Spectrum`
        new_spectrum = self._init_cat_dict(Spectrum, spec_key, **kwargs)
        if new_spectrum is None:
            return None

        is_dupe = False
        for item in self.get(spec_key, []):
            # Only the `filename` should be compared for duplicates. If a
            # duplicate is found, that means the previous `exclude` array
            # should be saved to the new object, and the old deleted
            if new_spectrum.is_duplicate_of(item):
                if SPECTRUM.EXCLUDE in new_spectrum:
                    item[SPECTRUM.EXCLUDE] = new_spectrum[SPECTRUM.EXCLUDE]
                elif SPECTRUM.EXCLUDE in item:
                    item.update(new_spectrum)
                is_dupe = True
                break

        if not is_dupe:
            self.setdefault(spec_key, []).append(new_spectrum)
        return
264840
def p_recipe(self, t):
        """"""
        if len(t) == 3:
            t[0] = t[1] + t[2]
        else:
            t[0] = t[1]
743586
private void addIntoEquivalanceMap(BioPAXElement bpe)
	{
		int key = bpe.hashCode();
		List<BioPAXElement> list = equivalenceMap.get(key);
		if (list == null)
		{
			list = new ArrayList<BioPAXElement>();
			equivalenceMap.put(key, list);
		}
		list.add(bpe);
	}
1084751
def _create_diff_action(diff, diff_key, key, value):

    '''
    
    '''

    if diff_key not in diff.keys():
        diff[diff_key] = {}
    diff[diff_key][key] = value
556599
def _merge_asized(base, other, level=0):
    
    ref2key = lambda ref: ref.name.split(':')[0]
    base.size += other.size
    base.flat += other.flat
    if level > 0:
        base.name = ref2key(base)
    # Add refs from other to base. Any new refs are appended.
    base.refs = list(base.refs) # we may need to append items
    refs = {}
    for ref in base.refs:
        refs[ref2key(ref)] = ref
    for ref in other.refs:
        key = ref2key(ref)
        if key in refs:
            _merge_asized(refs[key], ref, level=level+1)
        else:
            # Don't modify existing Asized instances => deepcopy
            base.refs.append(deepcopy(ref))
            base.refs[-1].name = key
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
23132
public function validateDish(): callable
    {
        return function ($value): RecipeInterface {
            /**
             * @var Recipe $this
             */
            if ($this->exceptedDish instanceof DishInterface) {
                $this->exceptedDish->isExcepted($value);
            }

            return $this;
        };
    }
632095
def add_dependency(self, name, obj):
        """"""

        if name in self._deps:
            if self._deps[name] is obj:
                return
            raise ValueError(
                "There exists a different dep with the same name : %r" % name)
        self._deps[name] = obj
1253722
def merge(self, other):
        """"""
        if not isinstance(other, MetadataRb):
            raise TypeError("MetadataRb to merge should be a 'MetadataRb' "
                            "instance, not %s.", type(other))
        current = self.to_dict()
        new = other.to_dict()

        # compare and gather cookbook dependencies
        meta_writelines = ['%s\n' % self.depends_statement(cbn, meta)
                           for cbn, meta in new.get('depends', {}).items()
                           if cbn not in current.get('depends', {})]

        self.write_statements(meta_writelines)
        return self.to_dict()
125963
def difference_update(self, *others):
        """"""
        self.db.sdiffstore(self.key, [o.key for o in [self.key] + others])
615891
def _add(self, codeobj):
        """"""
        assert isinstance(codeobj, CodeExpression.TYPES)
        self.value = codeobj
280338
def blend(self, blend_recipe, join_base, join_blend):
        
        assert isinstance(blend_recipe, Recipe)

        self.blend_recipes.append(blend_recipe)
        self.blend_types.append('inner')
        self.blend_criteria.append((join_base, join_blend))
        self.dirty = True
        return self.recipe
611347
def comparison_callback(sender, instance, **kwargs):
    """"""
    if validate_instance(instance) and settings.AUTOMATED_LOGGING['to_database']:
        try:
            old = sender.objects.get(pk=instance.pk)
        except Exception:
            return None

        try:
            mdl = ContentType.objects.get_for_model(instance)
            cur, ins = old.__dict__, instance.__dict__
            old, new = {}, {}
            for k in cur.keys():
                # _ fields are not real model fields, only state or cache fields
                # getting filtered
                if re.match('(_)(.*?)', k):
                    continue

                changed = False
                if k in ins.keys():
                    if cur[k] != ins[k]:
                        changed = True
                        new[k] = ModelObject()
                        new[k].value = str(ins[k])
                        new[k].save()

                        try:
                            new[k].type = ContentType.objects.get_for_model(ins[k])
                        except Exception:
                            logger = logging.getLogger(__name__)
                            logger.debug('Could not dermin the content type of the field')

                        new[k].field = Field.objects.get_or_create(name=k, model=mdl)[0]
                        new[k].save()
                else:
                    changed = True

                if changed:
                    old[k] = ModelObject()
                    old[k].value = str(cur[k])
                    old[k].save()

                    try:
                        old[k].type = ContentType.objects.get_for_model(cur[k])
                    except Exception:
                        logger = logging.getLogger(__name__)
                        logger.debug('Could not dermin the content type of the field')

                    old[k].field = Field.objects.get_or_create(name=k, model=mdl)[0]
                    old[k].save()

            if old or new:
                changelog = ModelChangelog()
                changelog.save()

                changelog.modification = ModelModification()
                changelog.modification.save()
                changelog.modification.previously.add(*old.values())
                changelog.modification.currently.add(*new.values())

                changelog.information = ModelObject()
                changelog.information.save()
                changelog.information.value = repr(instance)
                changelog.information.type = ContentType.objects.get_for_model(instance)
                changelog.information.save()
                changelog.save()

                instance.al_chl = changelog

                return instance

        except Exception as e:
            print(e)
            logger = logging.getLogger(__name__)
            logger.warning('automated_logging recorded an exception that should not have happended')
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)