Add a new custom condition type parser
        :param name: The name of the condition type
        :type  name: str

        :param cond_class: The Class
        :return:
773747
def add_condition(self, name, cond_class):
        
        # Has this condition type already been defined?
        if name in self.conditions:
            self._log.warn('Overwriting an existing Condition Type class: {type}'.format(type=name))

        if not issubclass(cond_class, ConditionType):
            self._log.error('Condition Type class must implement the base ConditionType interface, please review the '
                            'documentation on defining custom condition types. (Refusing to set the condition type '
                            '"{type}")'.format(type=name))
            return

        self.conditions[name] = cond_class(name)
806614
public void inc(String name, int con) throws IOException
    {
        if (hasLocalVariable(name))
        {
            tinc(name, con);
        }
        else
        {
            VariableElement field = El.getField(subClass, name);
            if (field == null)
            {
                throw new IllegalArgumentException("field "+name+" not found");
            }
            aload(0);
            getField(field);
            TypeMirror type = field.asType();
            tconst(type, con);
            tadd(type);
            aload(0);
            swap();
            putField(field);
        }
    }
469222
def _get_sorted_cond_keys(self, keys_list):
        
        # The names can be found in reflexrulewidget.pt inside the
        # conditionscontainer div.
        cond_list = []
        for key in keys_list:
            if key.startswith('analysisservice-'):
                cond_list.append(key)
        cond_list.sort()
        return cond_list
473198
public void add(CharRange cond)
    {
        if (set.isEmpty())
        {
            set.add(cond);
        }
        else
        {
            List<CharRange> remlist = new ArrayList<CharRange>();
            List<CharRange> addlist = new ArrayList<CharRange>();
            boolean is = false;
            for (CharRange r : set)
            {
                if (r.intersect(cond))
                {
                    remlist.add(r);
                    addlist.addAll(CharRange.removeOverlap(cond, r));
                    is = true;
                }
            }
            if (!is)
            {
                set.add(cond);
            }
            set.removeAll(remlist);
            set.addAll(addlist);
        }
    }
342483
public static void parseConditionToJunction(Condition condition,
			Junction junction, Class<?> persistentClass) {
		// 子条件
		List<Condition> subConditions = condition.getSubConditions();

		// 有子条件则进行遍历获取最终的条件
		if (null != subConditions && !subConditions.isEmpty()) {
			// 子条件当中的and条件集合
			List<Condition> andConditions = condition.getAndConditions();
			if (null != andConditions && !andConditions.isEmpty()) {
				// 创建一个and条件集合
				Conjunction conj = Restrictions.conjunction();
				// 添加到父条件中
				junction.add(conj);
				for (Condition andCondition : andConditions) {
					/*
					 * 把每个条件看做是一个大的条件(包含 and 和 or 2个部分),
					 * 然后使用disjunction连接条件集合来组合这个大条件的(and项 和 or项);
					 * 因为and项和or项都已经被分为2个部分
					 * ,而且又是用disjunction来组合,所以可以保证一个大条件只会被or连接符分隔成2个部分
					 */
					Disjunction dj = Restrictions.disjunction();
					conj.add(dj);
					parseConditionToJunction(andCondition, dj, persistentClass);
				}
			}

			// 子条件当中的or条件集合
			List<Condition> orConditions = condition.getOrConditions();
			if (null != orConditions && !orConditions.isEmpty()) {
				// 创建一个or条件集合
				Disjunction disj = Restrictions.disjunction();
				// 添加到父条件中
				junction.add(disj);
				for (Condition orCondition : orConditions) {
					// 这里的实现原理与上面的andCondition的处理相同
					Disjunction dj = Restrictions.disjunction();
					disj.add(dj);
					parseConditionToJunction(orCondition, dj, persistentClass);
				}
			}
		} else {
			// 条件为最终条件，转换为符合Hibernate的条件，然后条件到条件集合中
			junction.add(condition.getCriterion(persistentClass));
		}
	}
1282595
def filter(self, *condition):
        
        if not condition:
            return self
        cond = true()
        for c in condition:
            if c is not None:
                if isinstance(c, (str, unicode)):
                    c = text(c)
                cond = and_(c, cond)
        if self.condition is not None:
            self.condition = and_(cond, self.condition)
        else:
            self.condition = cond
        return self
1219486
public ConstantNameAndTypeInfo addConstantNameAndType(String name,
                                                          Descriptor type) {
        return ConstantNameAndTypeInfo.make(this, name, type);
    }
677109
def _condition_as_text(lambda_inspection: icontract._represent.ConditionLambdaInspection) -> str:
    """"""
    lambda_ast_node = lambda_inspection.node
    assert isinstance(lambda_ast_node, ast.Lambda)

    body_node = lambda_ast_node.body

    text = None  # type: Optional[str]
    if isinstance(body_node, ast.BoolOp) and isinstance(body_node.op, ast.Or) and len(body_node.values) == 2:
        left, right = body_node.values

        if isinstance(left, ast.UnaryOp) and isinstance(left.op, ast.Not):
            # Handle the case: not A or B is transformed to A => B
            text = ':code:`{}` ⇒ :code:`{}`'.format(
                lambda_inspection.atok.get_text(node=left.operand), lambda_inspection.atok.get_text(node=right))

        elif isinstance(left, (ast.UnaryOp, ast.BinOp, ast.GeneratorExp, ast.IfExp)):
            text = ':code:`not ({})` ⇒ :code:`{}`'.format(
                lambda_inspection.atok.get_text(node=left), lambda_inspection.atok.get_text(node=right))

        elif isinstance(left, ast.Compare) and len(left.ops) == 1:
            text = ':code:`{}` ⇒ :code:`{}`'.format(
                _negate_compare_text(atok=lambda_inspection.atok, node=left),
                lambda_inspection.atok.get_text(node=right))

        elif isinstance(left, (ast.Call, ast.Attribute, ast.Name, ast.Subscript, ast.Index, ast.Slice, ast.ExtSlice,
                               ast.ListComp, ast.SetComp, ast.DictComp)):
            text = ':code:`not {}` ⇒ :code:`{}`'.format(
                lambda_inspection.atok.get_text(node=left), lambda_inspection.atok.get_text(node=right))

    elif isinstance(body_node, ast.IfExp) and isinstance(body_node.orelse, ast.NameConstant) and body_node.orelse.value:
        text = ':code:`{}` ⇒ :code:`{}`'.format(
            lambda_inspection.atok.get_text(node=body_node.test), lambda_inspection.atok.get_text(node=body_node.body))

    if text is None:
        # None of the previous reformatings worked, take the default approach.
        text = ':code:`{}`'.format(lambda_inspection.atok.get_text(node=body_node))

    return text
656564
def check_for_failed_condition(conds)
      failed = (conds || []).find { |c, v| !check_condition?(c, v) }
      if failed
        failed[0] = failed[0][0..-2].to_sym if failed[0][-1] == '!'
      end
      failed
    end
367091
private VarSymbol enterConstant(String name, Type type) {
        VarSymbol c = new VarSymbol(
            PUBLIC | STATIC | FINAL,
            names.fromString(name),
            type,
            predefClass);
        c.setData(type.constValue());
        predefClass.members().enter(c);
        return c;
    }
582729
def Create(self, name):
    
    precondition.AssertType(name, Text)

    try:
      constructor = self._constructors[name]
    except KeyError:
      message = "No constructor for name '%s' has been registered"
      message %= name
      raise ValueError(message)

    instance = constructor()
    if not isinstance(instance, self._cls):
      message = ("Constructor %r for name '%s' returned instance of type %r "
                 "(expected %r)")
      message %= (constructor, name, type(instance), self._cls)
      raise TypeError(message)

    return instance
623683
def add_input(self, in_name, type_or_parse=None):
        
        if type_or_parse is None:
            type_or_parse = GenericType()
        elif not isinstance(type_or_parse, GenericType) and callable(type_or_parse):
            type_or_parse = GenericType(parse=type_or_parse)
        elif not isinstance(type_or_parse, GenericType):
            raise ValueError("the given 'type_or_parse' is invalid")
        self._inputs[in_name] = type_or_parse
659293
def Parse(conditions):
    
    kind = rdf_file_finder.FileFinderCondition.Type
    classes = {
        kind.MODIFICATION_TIME: ModificationTimeCondition,
        kind.ACCESS_TIME: AccessTimeCondition,
        kind.INODE_CHANGE_TIME: InodeChangeTimeCondition,
        kind.SIZE: SizeCondition,
        kind.EXT_FLAGS: ExtFlagsCondition,
    }

    for condition in conditions:
      try:
        yield classes[condition.condition_type](condition)
      except KeyError:
        pass
118847
def add_const_spec(self, const_spec):
        
        if const_spec.name in self.const_specs:
            raise ThriftCompilerError(
                'Cannot define constant "%s". That name is already taken.'
                % const_spec.name
            )
        self.const_specs[const_spec.name] = const_spec
1261811
def _create_validation_error(self,
                                 name,                     # type: str
                                 value,                    # type: Any
                                 validation_outcome=None,  # type: Any
                                 error_type=None,          # type: Type[ValidationError]
                                 help_msg=None,            # type: str
                                 **kw_context_args):
        

        # first merge the info provided in arguments and in self
        error_type = error_type or self.error_type
        help_msg = help_msg or self.help_msg
        ctx = copy(self.kw_context_args)
        ctx.update(kw_context_args)

        # allow the class to override the name
        name = self._get_name_for_errors(name)

        if issubclass(error_type, TypeError) or issubclass(error_type, ValueError):
            # this is most probably a custom error type, it is already annotated with ValueError and/or TypeError
            # so use it 'as is'
            new_error_type = error_type
        else:
            # Add the appropriate TypeError/ValueError base type dynamically
            additional_type = None
            if isinstance(validation_outcome, Exception):
                if is_error_of_type(validation_outcome, TypeError):
                    additional_type = TypeError
                elif is_error_of_type(validation_outcome, ValueError):
                    additional_type = ValueError
            if additional_type is None:
                # not much we can do here, let's assume a ValueError, that is more probable
                additional_type = ValueError

            new_error_type = add_base_type_dynamically(error_type, additional_type)

        # then raise the appropriate ValidationError or subclass
        return new_error_type(validator=self, var_value=value, var_name=name, validation_outcome=validation_outcome,
                              help_msg=help_msg, **ctx)
386779
def DEFINE_constant_string(self, name, default, help):
    """"""
    self.AddOption(
        type_info.String(name=name, default=default or "", description=help),
        constant=True)
609824
def cond_init(m:nn.Module, init_func:LayerFunc):
    ""
    if (not isinstance(m, bn_types)) and requires_grad(m): init_default(m, init_func)