Prompt the user to provide a dictionary of data.

    :param str var_name: Variable as specified in the context
    :param default_value: Value that will be returned if no input is provided
    :return: A Python dictionary to use in the context.
180157
def read_user_dict(var_name, default_value):
    
    # Please see http://click.pocoo.org/4/api/#click.prompt
    if not isinstance(default_value, dict):
        raise TypeError

    default_display = 'default'

    user_value = click.prompt(
        var_name,
        default=default_display,
        type=click.STRING,
        value_proc=process_json,
    )

    if user_value == default_display:
        # Return the given default w/o any processing
        return default_value
    return user_value
111711
def get_value(prompt, default=None, hidden=False):
    '''
    '''
    _prompt = '%s : ' % prompt
    if default:
        _prompt = '%s [%s]: ' % (prompt, default)

    if hidden:
        ans = getpass(_prompt)
    else:
        ans = raw_input(_prompt)

    # If user hit Enter and there is a default value
    if not ans and default:
        ans = default
    return ans
686348
def __make_var(self, name: str, shape: list):
        
        return tf.get_variable(name, shape, trainable=self.__network.is_trainable())
952699
def _GetValue(self, name, context, default=utils.NotAValue):
    """"""
    container = self.defaults

    # The caller provided a default value.
    if default is not utils.NotAValue:
      value = default

    # Take the default from the definition.
    elif name in self.defaults:
      value = self.defaults[name]

    else:
      raise UnknownOption("Option %s not defined." % name)

    # We resolve the required key with the default raw data, and then iterate
    # over all elements in the context to see if there are overriding context
    # configurations.
    new_value = self.raw_data.get(name)
    if new_value is not None:
      value = new_value
      container = self.raw_data

    # Now check for any contexts. We enumerate all the possible resolutions and
    # sort by their path length. The last one will be the match with the deepest
    # path (i.e .the most specific match).
    matches = list(self._ResolveContext(context, name, self.raw_data))

    if matches:
      # Sort by the length of the path - longest match path will be at the end.
      matches.sort(key=lambda x: len(x[2]))
      value = matches[-1][1]
      container = matches[-1][0]

      if (len(matches) >= 2 and len(matches[-1][2]) == len(matches[-2][2]) and
          matches[-1][2] != matches[-2][2] and
          matches[-1][1] != matches[-2][1]):
        # This warning specifies that there is an ambiguous match, the config
        # attempts to find the most specific value e.g. if you have a value
        # for X.y in context A,B,C, and a value for X.y in D,B it should choose
        # the one in A,B,C. This warning is for if you have a value in context
        # A,B and one in A,C. The config doesn't know which one to pick so picks
        # one and displays this warning.
        logging.warning(
            "Ambiguous configuration for key %s: "
            "Contexts of equal length: %s (%s) and %s (%s)", name,
            matches[-1][2], matches[-1][1], matches[-2][2], matches[-2][1])

    # If there is a writeback location this overrides any previous
    # values.
    if self.writeback_data:
      new_value = self.writeback_data.get(name)
      if new_value is not None:
        value = new_value
        container = self.writeback_data

    # Allow the global override to force an option value.
    if name in self.global_override:
      return self.global_override, self.global_override[name]

    return container, value
900953
def get_value(self, dictionary):
        
        # We override the default field access in order to support
        # lists in HTML forms.
        if html.is_html_input(dictionary):
            return html.parse_html_list(dictionary, prefix=self.field_name)
        return dictionary.get(self.field_name, empty)
501470
def get(self, var, default=None):
        
        try:
            return self.__get(var)
        except (KeyError, IndexError):
            return default
121208
def get_var_type(self, name):
        
        name = create_string_buffer(name)
        type_ = create_string_buffer(MAXSTRLEN)
        self.library.get_var_type.argtypes = [c_char_p, c_char_p]
        self.library.get_var_type(name, type_)
        return type_.value
453505
def interpret(self, config_dict):
        
        value = config_dict.get(self.name)
        if value is None:
            if self.default is None:
                raise RuntimeError('Missing configuration item: ' + self.name)
            else:
                warnings.warn("Using default {!r} for '{!s}'".format(self.default, self.name),
                              DeprecationWarning)
                if (str != self.value_type) and isinstance(self.default, self.value_type):
                    return self.default
                else:
                    value = self.default

        try:
            if str == self.value_type:
                return str(value)
            if int == self.value_type:
                return int(value)
            if bool == self.value_type:
                if value.lower() == "true":
                    return True
                elif value.lower() == "false":
                    return False
                else:
                    raise RuntimeError(self.name + " must be True or False")
            if float == self.value_type:
                return float(value)
            if list == self.value_type:
                return value.split(" ")
        except Exception:
            raise RuntimeError("Error interpreting config item '{}' with value {!r} and type {}".format(
                self.name, value, self.value_type))

        raise RuntimeError("Unexpected configuration type: " + repr(self.value_type))
985108
def append(self, name, value):
        
        if self.vars is None:
            self.vars = {}
        if name in self.vars:
            self.vars[name].append(value)
        else:
            self.vars[name] = [value]
9383
def prompt_for_config(context, no_input=False):
    
    cookiecutter_dict = OrderedDict([])
    env = StrictEnvironment(context=context)

    # First pass: Handle simple and raw variables, plus choices.
    # These must be done first because the dictionaries keys and
    # values might refer to them.
    for key, raw in iteritems(context[u'cookiecutter']):
        if key.startswith(u'_'):
            cookiecutter_dict[key] = raw
            continue

        try:
            if isinstance(raw, list):
                # We are dealing with a choice variable
                val = prompt_choice_for_config(
                    cookiecutter_dict, env, key, raw, no_input
                )
                cookiecutter_dict[key] = val
            elif not isinstance(raw, dict):
                # We are dealing with a regular variable
                val = render_variable(env, raw, cookiecutter_dict)

                if not no_input:
                    val = read_user_variable(key, val)

                cookiecutter_dict[key] = val
        except UndefinedError as err:
            msg = "Unable to render variable '{}'".format(key)
            raise UndefinedVariableInTemplate(msg, err, context)

    # Second pass; handle the dictionaries.
    for key, raw in iteritems(context[u'cookiecutter']):

        try:
            if isinstance(raw, dict):
                # We are dealing with a dict variable
                val = render_variable(env, raw, cookiecutter_dict)

                if not no_input:
                    val = read_user_dict(key, val)

                cookiecutter_dict[key] = val
        except UndefinedError as err:
            msg = "Unable to render variable '{}'".format(key)
            raise UndefinedVariableInTemplate(msg, err, context)

    return cookiecutter_dict
686720
def _set_default_value(dict_obj, keys, value):
    
    variable = dict_obj

    if len(keys) == 1:
        if not variable.get(keys[0]):
            variable[keys[0]] = value

    else:
        for idx, field in enumerate(keys):
            if idx < len(keys) - 1:
                variable = variable[field]

        if not variable.get(keys[-1]):
            variable[keys[-1]] = value
122686
def val(self, name):
        
        v = getattr(self, name)
        if hasattr(v, 'retrieve_value'):
            v = v.retrieve_value(self.__dict__)
        return v
969838
def get(self, name, default=None):
        """"""
        value = self.params.get(name, default)
        if isinstance(value, str):
            value = os.path.expandvars(value)
        return value
411027
def simple_input(self, variables):
        
        json_args = fill_template_str(json.dumps(self.data), variables)
        return try_get_objects(json_args)
1042250
def dict(self, var, default=NOTSET, cast=None, force=True):
        
        return self._get(var, default=default, cast={str: cast}, force=force)
482651
def get_variable_values(
    schema,  # type: GraphQLSchema
    definition_asts,  # type: List[VariableDefinition]
    inputs,  # type: Any
):
    # type: (...) -> Dict[str, Any]
    """"""
    if inputs is None:
        inputs = {}

    values = {}
    for def_ast in definition_asts:
        var_name = def_ast.variable.name.value
        var_type = type_from_ast(schema, def_ast.type)
        value = inputs.get(var_name)

        if not is_input_type(var_type):
            raise GraphQLError(
                'Variable "${var_name}" expected value of type "{var_type}" which cannot be used as an input type.'.format(
                    var_name=var_name, var_type=print_ast(def_ast.type)
                ),
                [def_ast],
            )
        elif value is None:
            if def_ast.default_value is not None:
                values[var_name] = value_from_ast(
                    def_ast.default_value, var_type
                )  # type: ignore
            if isinstance(var_type, GraphQLNonNull):
                raise GraphQLError(
                    'Variable "${var_name}" of required type "{var_type}" was not provided.'.format(
                        var_name=var_name, var_type=var_type
                    ),
                    [def_ast],
                )
        else:
            errors = is_valid_value(value, var_type)
            if errors:
                message = u"\n" + u"\n".join(errors)
                raise GraphQLError(
                    'Variable "${}" got invalid value {}.{}'.format(
                        var_name, json.dumps(value, sort_keys=True), message
                    ),
                    [def_ast],
                )
            coerced_value = coerce_value(var_type, value)
            if coerced_value is None:
                raise Exception("Should have reported error.")

            values[var_name] = coerced_value

    return values
1013838
def _default_seed(self, var_tbl: dict) -> dict:
        
        var_names = {}
        #for v in self.var_names:
        #    var_names[v]=1
        for v in var_tbl:
            var_names[v]=1
        return var_names