Prompts the user to enter new config, using context as a source for the
    field names and sample values.

    :param no_input: Prompt the user at command line for manual configuration?
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
1295406
def add_input(cmd, immediate=False):
    ''''''
    if immediate:
        process_stdin(cmd)
    else:
        mpstate.input_queue.put(cmd)
213363
def _prompt_wrapper(message, default=None, validator=None):
    

    class MockDocument:

        def __init__(self, text):
            self.text = text

    if HAS_INPUT:
        ret = prompt(message, default=default, validator=validator)
    else:
        ret = sys.stdin.readline().strip()
        print(message, ret)
        if validator:
            validator.validate(MockDocument(ret))
    if "q" in ret:
        if not HAS_OUTPUT:
            print("User exit")
        sys.exit("User exit")
    return ret
940661
def parse_input():
    """"""
    parser = argparse.ArgumentParser(
        description=__doc__,
        formatter_class=argparse.RawDescriptionHelpFormatter)
    parser.add_argument('-c', '--config', type=str,
                        help="Specify a configuration file")
    return parser.parse_args()
383406
def prompt_choice_for_config(cookiecutter_dict, env, key, options, no_input):
    
    rendered_options = [
        render_variable(env, raw, cookiecutter_dict) for raw in options
    ]

    if no_input:
        return rendered_options[0]
    return read_user_choice(key, rendered_options)
632840
def new_config_event(self):
        
        try:
            self.on_set_config()
        except Exception as ex:
            self.logger.exception(ex)
            raise StopIteration()
715504
def init_with_context(self, context):
        
        super(PersonalModule, self).init_with_context(context)
        current_user = context['request'].user
        if django.VERSION < (1, 5):
            current_username = current_user.first_name or current_user.username
        else:
            current_username = current_user.get_short_name() or current_user.get_username()
        site_name = get_admin_site_name(context)

        # Personalize
        self.title = _('Welcome,') + ' ' + (current_username)

        # Expose links
        self.pages_link = None
        self.pages_title = None
        self.password_link = reverse('{0}:password_change'.format(site_name))
        self.logout_link = reverse('{0}:logout'.format(site_name))

        if self.cms_page_model:
            try:
                app_label, model_name = self.cms_page_model
                model = apps.get_model(app_label, model_name)
                pages_title = model._meta.verbose_name_plural.lower()
                pages_link = reverse('{site}:{app}_{model}_changelist'.format(site=site_name, app=app_label.lower(), model=model_name.lower()))
            except AttributeError:
                raise ImproperlyConfigured("The value {0} of FLUENT_DASHBOARD_CMS_PAGE_MODEL setting (or cms_page_model value) does not reffer to an existing model.".format(self.cms_page_model))
            except NoReverseMatch:
                pass
            else:
                # Also check if the user has permission to view the module.
                # TODO: When there are modules that use Django 1.8's has_module_permission, add the support here.
                permission_name = 'change_{0}'.format(model._meta.model_name.lower())

                if current_user.has_perm('{0}.{1}'.format(model._meta.app_label, permission_name)):
                    self.pages_title = pages_title
                    self.pages_link = pages_link
165897
def set_password_prompt(self, regex=None):
        
        if regex is None:
            self.manual_password_re = regex
        else:
            self.manual_password_re = to_regexs(regex)
281127
def prompt_yes_or_no(message):
    
    user_input = input("{} [y/n]:".format(message)).lower()
    if user_input.startswith("y"):
        return True
    elif user_input.startswith("n"):
        return False
    else:
        return prompt_yes_or_no(message)
560530
def choice_prompt(prompt, choices=None, choice=None):
    '''
    
    '''
    if not choices:
        choices = ["y", "n", "Y", "N"]

    print(prompt)
    get_input = getattr(__builtins__, 'raw_input', input)
    pretty_choices = '/'.join(choices)
    message = 'Please enter your choice [%s] : ' %(pretty_choices)
    while choice not in choices:
        choice = get_input(message).strip()

        # If the option isn't valid, this is shown next
        message = "Please enter a valid option in [%s]" %(pretty_choices)    
    return choice
105919
def cli(ctx, url=None, api_key=None, admin=False, **kwds):
    
    # TODO: prompt for values someday.
    click.echo("""Welcome to Apollo's Arrow!""")
    if os.path.exists(config.global_config_path()):
        info("Your arrow configuration already exists. Please edit it instead: %s" % config.global_config_path())
        return 0

    while True:
        apollo_url= click.prompt("Please entry your Apollo's URL")
        apollo_username = click.prompt("Please entry your Apollo Username")
        apollo_password = click.prompt("Please entry your Apollo Password", hide_input=True)
        info("Testing connection...")
        try:
            ai = ApolloInstance(apollo_url, apollo_username, apollo_password)
            try:
                ai.metrics.get_metrics()
                # Ok, success
                info("Ok! Everything looks good.")
                break
            except Exception as e:
                print(e)
                warn("Error, we could not access the configuration data for your instance.")
                should_break = click.prompt("Continue despite inability to contact this Apollo Instance? [y/n]")
                if should_break in ('Y', 'y'):
                    break
        except Exception as e:
            warn("Error, we could not access the configuration data for your instance.")
            should_break = click.prompt("Continue despite inability to contact this Apollo Instance? [y/n]")
            if should_break in ('Y', 'y'):
                break

    config_path = config.global_config_path()
    if os.path.exists(config_path):
        warn("File %s already exists, refusing to overwrite." % config_path)
        return -1
    with open(config_path, "w") as f:
        f.write(
            CONFIG_TEMPLATE % {
                'url': apollo_url,
                'username': apollo_username,
                'password': apollo_password,
            })
        info(SUCCESS_MESSAGE)
836734
def prompt(name, default=None):
    

    prompt = name + (default and ' [%s]' % default or '')
    prompt += name.endswith('?') and ' ' or ': '
    while True:
        try:
            rv = raw_input(prompt)
        except NameError:
            rv = input(prompt)
        if rv:
            return rv
        if default is not None:
            return default
144696
def _generate_input(options):
    
    if options.input:
        fp = open(options.input) if options.input != "-" else sys.stdin
        for string in fp.readlines():
            yield string
    if options.strings:
        for string in options.strings:
            yield string
1322140
def prompt(test_input = None):
    
    if test_input != None:
        if type(test_input) == list and len(test_input):
            choice = test_input.pop(0)
        elif type(test_input) == list:
            choice = ''
        else:
            choice = test_input
    else:
        # Coverage: 4 missed statements
        try:
            choice = raw_input()
        except:
            choice = input()
    return choice
1112621
def input(self, prompt, type='', defaultLast=False, **kwargs):
        ''
        if type:
            histlist = list(self.lastInputs[type].keys())
            ret = self._inputLine(prompt, history=histlist, **kwargs)
            if ret:
                self.lastInputs[type][ret] = ret
            elif defaultLast:
                histlist or fail("no previous input")
                ret = histlist[-1]
        else:
            ret = self._inputLine(prompt, **kwargs)

        return ret
403212
def jsbuild_prompt():
    ''' 

    '''
    print(BOKEHJS_BUILD_PROMPT)
    mapping = {"1": True, "2": False}
    value = input("Choice? ")
    while value not in mapping:
        print("Input '%s' not understood. Valid choices: 1, 2\n" % value)
        value = input("Choice? ")
    return mapping[value]
1238270
def input(self, **kwargs):
    

    with_variables = None

    context = kwargs.get('context', {})

    if context.get('leonardo_page', None):
        try:
            context['leonardo_page']['theme']
            context['leonardo_page']['color_scheme']
        except Exception as e:
            LOG.exception(str(e))
        else:
            with_variables = """
            @import "/themes/{}/{}/_variables";
            {}
            """.format(
                context['leonardo_page']['theme']['name'],
                context['leonardo_page']['color_scheme']['name'],
                self.content)

    return self.compiler.compile_string(
        with_variables or self.content,
        filename=self.filename)