Validates that x is a multiple of the reference (`x % ref == 0`)
359
def is_multiple_of(ref):
    
    def is_multiple_of_ref(x):
        if x % ref == 0:
            return True
        else:
            raise IsNotMultipleOf(wrong_value=x, ref=ref)
            # raise Failure('x % {ref} == 0 does not hold for x={val}'.format(ref=ref, val=x))

    is_multiple_of_ref.__name__ = 'is_multiple_of_{}'.format(ref)
    return is_multiple_of_ref
248525
def contains(ref_value):
    
    def contains_ref_value(x):
        if ref_value in x:
            return True
        else:
            raise DoesNotContainValue(wrong_value=x, ref_value=ref_value)

    contains_ref_value.__name__ = 'contains_{}'.format(ref_value)
    return contains_ref_value
791990
def _get_absolute_reference(self, ref_key):
        """"""

        key_str = u", ".join(map(str, ref_key))
        return u"S[" + key_str + u"]"
812812
def is_elem_ref(elem_ref):
    
    return (
        elem_ref
        and isinstance(elem_ref, tuple)
        and len(elem_ref) == 3
        and (elem_ref[0] == ElemRefObj or elem_ref[0] == ElemRefArr)
    )
277612
def p_const_ref(self, p):
        ''''''
        p[0] = ast.ConstReference(p[1], lineno=p.lineno(1))
543320
def validate_multiindex(self, obj):
        
        levels = [l if l is not None else "level_{0}".format(i)
                  for i, l in enumerate(obj.index.names)]
        try:
            return obj.reset_index(), levels
        except ValueError:
            raise ValueError("duplicate names/columns in the multi-index when "
                             "storing as a table")
555535
function getRefValue (ref) {
  const thing = ref ? (ref.value ? ref.value : ref) : null
  if (thing && thing.$ref && typeof thing.$ref === 'string') {
    return thing.$ref
  }
}
1108987
function convertR1C1toA1 (ref) {
  if (!R1C1.test(ref)) {
    throw new Error(`${ref} is not a valid R1C1 cell reference`)
  }

  var refParts = ref
    .replace(R1C1, '$1,$2')
    .split(',')

  var row = refParts[0]
  var column = refParts[1]
  var columnStr = ''

  for (; column; column = Math.floor((column - 1) / 26)) {
    columnStr = String.fromCharCode(((column - 1) % 26) + 65) + columnStr
  }

  return columnStr + row
}
815353
private int getSkipCorrectedReference(List<Integer> tokenPositions, int refNumber) {
    int correctedRef = 0;
    int i = 0;
    for (int tokenPosition : tokenPositions) {
      if (i++ >= refNumber) {
        break;
      }
      correctedRef += tokenPosition;
    }
    return correctedRef - 1;
  }
101266
def _handle_array_ref(self, node, scope, ctxt, stream):
        
        ary = self._handle_node(node.name, scope, ctxt, stream)
        subscript = self._handle_node(node.subscript, scope, ctxt, stream)
        return ary[fields.PYVAL(subscript)]
5700
def _cli_check_ref_format(fmt):
    ''''''

    if fmt is None:
        return None

    fmt = fmt.lower()
    if not fmt in api.get_reference_formats():
        errstr = "Reference format '" + fmt + "' does not exist.\n"
        errstr += "For a complete list of formats, use the 'bse list-ref-formats' command"
        raise RuntimeError(errstr)

    return fmt
420432
function checkSchemaHasReferences(schema) {
  if (schema.$ref) {
    return true;
  }

  return Object.values(schema).some((value) => {
    if (_.isArray(value)) {
      return value.some(checkSchemaHasReferences);
    } else if (_.isObject(value)) {
      return checkSchemaHasReferences(value);
    }

    return false;
  });
}
230110
def _validate_handler(column_name, value, predicate_refs):
    """"""

    # only does validate when attribute value is not None
    # else, just return it, let sqlalchemy decide if the value was legal according to `nullable` argument's value
    if value is not None:
        for predicate_ref in predicate_refs:
            predicate, predicate_name, predicate_args = _decode_predicate_ref(predicate_ref)
            validate_result = predicate(value, *predicate_args)

            if isinstance(validate_result, dict) and 'value' in validate_result:
                value = validate_result['value']
            elif type(validate_result) != bool:
                raise Exception(
                    'predicate (name={}) can only return bool or dict(value=new_value) value'.format(predicate_name))
            elif not validate_result:
                raise ModelInvalid(u'db model validate failed: column={}, value={}, predicate={}, arguments={}'.format(
                    column_name, value, predicate_name, ','.join(map(str, predicate_args))
                ))
    return value
1297340
def checkReference(self, reference):
        
        pattern = re.compile(r'[\s,;"\'&\\]')
        if pattern.findall(reference.strip()):
            return False
        return True
228429
function isSelfReference(ref, nodes) {
            let scope = ref.from;

            while (scope) {
                if (nodes.indexOf(scope.block) >= 0) {
                    return true;
                }

                scope = scope.upper;
            }

            return false;
        }
292718
def has_length(ref_length):
    
    def has_length_(x):
        if len(x) == ref_length:
            return True
        else:
            raise WrongLength(wrong_value=x, ref_length=ref_length)

    has_length_.__name__ = 'length_equals_{}'.format(ref_length)
    return has_length_
476311
def is_valid(self):
        
        return len(self.ref) == 1 and \
               len(self.alt) == 1 and \
               len(self.alt[0]) == 1