Evaluate the function that determines the ID if the 'id_function'
    option is set and return the result
180564
def call_id_function(opts):
    '''
    
    '''
    if opts.get('id'):
        return opts['id']

    # Import 'salt.loader' here to avoid a circular dependency
    import salt.loader as loader

    if isinstance(opts['id_function'], six.string_types):
        mod_fun = opts['id_function']
        fun_kwargs = {}
    elif isinstance(opts['id_function'], dict):
        mod_fun, fun_kwargs = six.next(six.iteritems(opts['id_function']))
        if fun_kwargs is None:
            fun_kwargs = {}
    else:
        log.error('\'id_function\' option is neither a string nor a dictionary')
        sys.exit(salt.defaults.exitcodes.EX_GENERIC)

    # split module and function and try loading the module
    mod, fun = mod_fun.split('.')
    if not opts.get('grains'):
        # Get grains for use by the module
        opts['grains'] = loader.grains(opts)

    try:
        id_mod = loader.raw_mod(opts, mod, fun)
        if not id_mod:
            raise KeyError
        # we take whatever the module returns as the minion ID
        newid = id_mod[mod_fun](**fun_kwargs)
        if not isinstance(newid, six.string_types) or not newid:
            log.error(
                'Function %s returned value "%s" of type %s instead of string',
                mod_fun, newid, type(newid)
            )
            sys.exit(salt.defaults.exitcodes.EX_GENERIC)
        log.info('Evaluated minion ID from module: %s', mod_fun)
        return newid
    except TypeError:
        log.error(
            'Function arguments %s are incorrect for function %s',
            fun_kwargs, mod_fun
        )
        sys.exit(salt.defaults.exitcodes.EX_GENERIC)
    except KeyError:
        log.error('Failed to load module %s', mod_fun)
        sys.exit(salt.defaults.exitcodes.EX_GENERIC)
527659
def containsID(self, idVal):
        
        for i in self:
            if i.id == idVal:
                return True
        return False
1131467
def get_id(self):
        """"""
        if self._id_attr is None or not hasattr(self, self._id_attr):
            return None
        return getattr(self, self._id_attr)
169707
def usable_id(cls, id):
        
        try:
            # id is maybe a sshkey name
            qry_id = cls.from_name(id)
            if not qry_id:
                qry_id = int(id)
        except DuplicateResults as exc:
            cls.error(exc.errors)
        except Exception:
            qry_id = None

        if not qry_id:
            msg = 'unknown identifier %s' % id
            cls.error(msg)

        return qry_id
1318763
def detect_function_style(self, test_record):
        """"""
        index = 0
        # IMPORTANT: apply regex sequentially and stop on the first match:
        for regex in FUNCTION_STYLE_REGEX:
            if re.search(regex, test_record):
                return index
            index+=1
        return None
737925
def identify(fn):
        '''  '''
        return (
            fn.__globals__['__name__'], # module namespace
            getattr(fn, '__qualname__', getattr(fn, '__name__', '')) # class and function namespace
        )
        def __init__(self, fn):
            self.validate_function(fn)
            self.configured = False
            self.has_backup_plan = False
            if self.has_args():
                self.backup_plan = fn
            else:
                self.id = self.identify(fn)
                self.backup_plan = big.overload._cache.get(self.id, None)
                #if self.id in overload._cache:
                #    self.backup_plan =
                self.configure_with(fn)
            #wraps(fn)(self)

        def __call__(self, *args, **kwargs):
            #print(locals())
            try:  # try running like normal
                return self.fn(*args, **kwargs)
            except Exception as ex:
                if self.has_backup_plan:
                    return self.backup_plan(*args, **kwargs) # run backup plan
                elif self.configured:
                    raise ex # no backup plan, abort
                else:
                    # complete unconfigured setup
                    self.configure_with(*args, **kwargs)
                    return self
104774
def get_true_function(obj):
    ""
    if not callable(obj):
        raise TypeError("%r is not callable." % (obj,))
    ismethod = inspect.ismethod(obj)
    if inspect.isfunction(obj) or ismethod:
        return obj, ismethod
    if hasattr(obj, 'im_func'):
        return obj.im_func, True
    if inspect.isclass(obj):
        return getattr(obj, '__init__', None), True
    if isinstance(obj, object):
        if hasattr(obj, 'func'):
            return get_true_function(obj.func)
        return obj.__call__, True
    raise TypeError("Unknown type of object: %r" % obj)
666675
def _get_id(self):
        """"""
        id = self._options.get('id')
        if id:
            return id

        id = uuid.uuid4().hex
        self.update_options(id=id)
        return id
409414
private function _get_id_option(string $id_option = null): ?string
  {
    if ( !$id_option && !($id_option = $this->get_current()) ){
      return null;
    }
    if ( $id_option && !bbn\str::is_uid($id_option) ){
      $id_option = $this->opt->from_path(...\func_get_args());
    }
    if ( $id_option && bbn\str::is_uid($id_option) ){
      return $id_option;
    }
    return null;
  }
545385
async def _has_id(self, *args, **kwds):
        
        # if there is only one positional argument
        if len(args) == 1:
            # parse the appropriate query
            result = await parse_string(
                self._query,
                self.service.object_resolver,
                self.service.connection_resolver,
                self.service.mutation_resolver,
                obey_auth=False
            )
            # go to the bottom of the result for the list of matching ids
            return self._find_id(result['data'], args[0])
        # otherwise
        else:
            # treat the attribute like a normal filter
            return self._has_id(**kwds)
1059804
def name(function):
    
    if isinstance(function, types.FunctionType):
        return function.__name__
    else:
        return str(function)
1220250
def _default_verify_function(instance, answer, result_host, atol, verbose):
    """"""

    #first check if the length is the same
    if len(instance.arguments) != len(answer):
        raise TypeError("The length of argument list and provided results do not match.")
    #for each element in the argument list, check if the types match
    for i, arg in enumerate(instance.arguments):
        if answer[i] is not None: #skip None elements in the answer list
            if isinstance(answer[i], numpy.ndarray) and isinstance(arg, numpy.ndarray):
                if answer[i].dtype != arg.dtype:
                    raise TypeError("Element " + str(i)
                                    + " of the expected results list is not of the same dtype as the kernel output: "
                                    + str(answer[i].dtype) + " != " + str(arg.dtype) + ".")
                if answer[i].size != arg.size:
                    raise TypeError("Element " + str(i)
                                    + " of the expected results list has a size different from "
                                    + "the kernel argument: "
                                    + str(answer[i].size) + " != " + str(arg.size) + ".")
            elif isinstance(answer[i], numpy.number) and isinstance(arg, numpy.number):
                if answer[i].dtype != arg.dtype:
                    raise TypeError("Element " + str(i)
                                    + " of the expected results list is not the same as the kernel output: "
                                    + str(answer[i].dtype) + " != " + str(arg.dtype) + ".")
            else:
                #either answer[i] and argument have different types or answer[i] is not a numpy type
                if not isinstance(answer[i], numpy.ndarray) or not isinstance(answer[i], numpy.number):
                    raise TypeError("Element " + str(i)
                                    + " of expected results list is not a numpy array or numpy scalar.")
                else:
                    raise TypeError("Element " + str(i)
                                    + " of expected results list and kernel arguments have different types.")

    def _ravel(a):
        if hasattr(a, 'ravel') and len(a.shape) > 1:
            return a.ravel()
        return a

    def _flatten(a):
        if hasattr(a, 'flatten'):
            return a.flatten()
        return a

    correct = True
    for i, arg in enumerate(instance.arguments):
        expected = answer[i]
        if expected is not None:

            result = _ravel(result_host[i])
            expected = _flatten(expected)
            output_test = numpy.allclose(expected, result, atol=atol)

            if not output_test and verbose:
                print("Error: " + util.get_config_string(instance.params) + " detected during correctness check")
                print("this error occured when checking value of the %oth kernel argument" % (i,))
                print("Printing kernel output and expected result, set verbose=False to suppress this debug print")
                numpy.set_printoptions(edgeitems=50)
                print("Kernel output:")
                print(result)
                print("Expected:")
                print(expected)
            correct = correct and output_test

    if not correct:
        logging.debug('correctness check has found a correctness issue')
        raise Exception("Error: " + util.get_config_string(instance.params) + " failed correctness check")

    return correct
1029519
def _id_or_key(list_item):
    '''
    
    '''
    if isinstance(list_item, dict):
        if 'id' in list_item:
            return list_item['id']
        if 'key' in list_item:
            return list_item['key']
    return list_item
525895
function(options) {
    return function(err, resp) {
      if (err) {
        options.error(err);
      } else {
        options.success(resp);
      }
    };
  }
334460
function function_ (options) {
  options.hash.kind = 'function'
  var result = ddata._identifier(options)
  return result ? options.fn(result) : 'ERROR, Cannot find function.'
}
1351292
function (id, fn) {
            id = (id + EMPTY).match(RE_ID_STR)[1];
            var retryCount = 1;
            var timer = util.later(function () {
                    if (++retryCount > POLL_RETIRES) {
                        timer.cancel();
                        return;
                    }
                    var node = doc.getElementById(id);
                    if (node) {
                        fn(node);
                        timer.cancel();
                    }
                }, POLL_INTERVAL, true);
        }
1041015
def p_idcall_expr(p):
      # This can be a function call or a string index
    p[0] = make_call(p[1], p.lineno(1), p[2])
    if p[0] is None:
        return

    if p[0].token in ('STRSLICE', 'VAR', 'STRING'):
        entry = SYMBOL_TABLE.access_call(p[1], p.lineno(1))
        entry.accessed = True
        return

    # TODO: Check that arrays really needs kind=function to be set
    # Both array accesses and functions are tagged as functions
    # functions also has the class_ attribute set to 'function'
    p[0].entry.set_kind(KIND.function, p.lineno(1))
    p[0].entry.accessed = True