gin/config.py
def _get_default_configurable_parameter_values(fn, whitelist, blacklist):
  """Retrieve all default values for configurable parameters of a function.

  Any parameters included in the supplied blacklist, or not included in the
  supplied whitelist, are excluded.

  Args:
    fn: The function whose parameter values should be retrieved.
    whitelist: The whitelist (or `None`) associated with the function.
    blacklist: The blacklist (or `None`) associated with the function.

  Returns:
    A dictionary mapping configurable parameter names to their default values.
  """
  arg_vals = _ARG_DEFAULTS_CACHE.get(fn)
  if arg_vals is not None:
    return arg_vals.copy()

  # First, grab any default values not captured in the kwargs var.
  arg_spec = _get_cached_arg_spec(fn)
  if arg_spec.defaults:
    default_kwarg_names = arg_spec.args[-len(arg_spec.defaults):]
    arg_vals = dict(zip(default_kwarg_names, arg_spec.defaults))
  else:
    arg_vals = {}

  if six.PY3 and arg_spec.kwonlydefaults:
    arg_vals.update(arg_spec.kwonlydefaults)

  # Now, eliminate keywords that are blacklisted, or aren't whitelisted (if
  # there's a whitelist), or aren't representable as a literal value.
  for k in list(six.iterkeys(arg_vals)):
    whitelist_fail = whitelist and k not in whitelist
    blacklist_fail = blacklist and k in blacklist
    representable = _is_literally_representable(arg_vals[k])
    if whitelist_fail or blacklist_fail or not representable:
      del arg_vals[k]

  _ARG_DEFAULTS_CACHE[fn] = arg_vals
  return arg_vals.copy()
def _get_default_configurable_parameter_values(fn, whitelist, blacklist):
  arg_vals = _ARG_DEFAULTS_CACHE.get(fn)
  if arg_vals is not None:
    return arg_vals.copy()

  # First, grab any default values not captured in the kwargs var.
  arg_spec = _get_cached_arg_spec(fn)
  if arg_spec.defaults:
    default_kwarg_names = arg_spec.args[-len(arg_spec.defaults):]
    arg_vals = dict(zip(default_kwarg_names, arg_spec.defaults))
  else:
    arg_vals = {}

  if six.PY3 and arg_spec.kwonlydefaults:
    arg_vals.update(arg_spec.kwonlydefaults)

  # Now, eliminate keywords that are blacklisted, or aren't whitelisted (if
  # there's a whitelist), or aren't representable as a literal value.
  for k in list(six.iterkeys(arg_vals)):
    whitelist_fail = whitelist and k not in whitelist
    blacklist_fail = blacklist and k in blacklist
    representable = _is_literally_representable(arg_vals[k])
    if whitelist_fail or blacklist_fail or not representable:
      del arg_vals[k]

  _ARG_DEFAULTS_CACHE[fn] = arg_vals
  return arg_vals.copy()
def _get_default_configurable_parameter_values ( fn , whitelist , blacklist ) : arg_vals = _ARG_DEFAULTS_CACHE . get ( fn ) if arg_vals is not None : return arg_vals . copy ( ) # First, grab any default values not captured in the kwargs var. arg_spec = _get_cached_arg_spec ( fn ) if arg_spec . defaults : default_kwarg_names = arg_spec . args [ - len ( arg_spec . defaults ) : ] arg_vals = dict ( zip ( default_kwarg_names , arg_spec . defaults ) ) else : arg_vals = { } if six . PY3 and arg_spec . kwonlydefaults : arg_vals . update ( arg_spec . kwonlydefaults ) # Now, eliminate keywords that are blacklisted, or aren't whitelisted (if # there's a whitelist), or aren't representable as a literal value. for k in list ( six . iterkeys ( arg_vals ) ) : whitelist_fail = whitelist and k not in whitelist blacklist_fail = blacklist and k in blacklist representable = _is_literally_representable ( arg_vals [ k ] ) if whitelist_fail or blacklist_fail or not representable : del arg_vals [ k ] _ARG_DEFAULTS_CACHE [ fn ] = arg_vals return arg_vals . copy ( )
Retrieve all default values for configurable parameters of a function.

  Any parameters included in the supplied blacklist, or not included in the
  supplied whitelist, are excluded.

  Args:
    fn: The function whose parameter values should be retrieved.
    whitelist: The whitelist (or `None`) associated with the function.
    blacklist: The blacklist (or `None`) associated with the function.

  Returns:
    A dictionary mapping configurable parameter names to their default values.
Retrieve all default values for configurable parameters of a function .