Return a string value that the user enters. Raises exception for cancel.
182708
def get_string(self, prompt, default_str=None) -> str:
        """"""
        accept_event = threading.Event()
        value_ref = [None]

        def perform():
            def accepted(text):
                value_ref[0] = text
                accept_event.set()

            def rejected():
                accept_event.set()

            self.__message_column.remove_all()
            pose_get_string_message_box(self.ui, self.__message_column, prompt, str(default_str), accepted, rejected)
            #self.__message_column.add(self.__make_cancel_row())

        with self.__lock:
            self.__q.append(perform)
            self.document_controller.add_task("ui_" + str(id(self)), self.__handle_output_and_q)
        accept_event.wait()
        def update_message_column():
            self.__message_column.remove_all()
            self.__message_column.add(self.__make_cancel_row())
        self.document_controller.add_task("ui_" + str(id(self)), update_message_column)
        if value_ref[0] is None:
            raise Exception("Cancel")
        return value_ref[0]
635279
def _asString(self, value):
        """"""
        if sys.version_info[0] == 3:
            if isinstance(value, str):
                return value
            elif isinstance(value, bytes):
                return value.decode('utf-8')
        elif sys.version_info[0] == 2:
            return value.encode('ascii')
236959
def get_prep_value(self, value):
        """"""
        try:
            return json.dumps(value)
        except Exception as err:
            raise ValidationError(str(err))
580168
def str(self,local=False,ifempty=None):
        
        ts = self.get(local)
        if not ts: return ifempty
        return ts.strftime('%Y-%m-%d %H:%M:%S')
1270016
def _capture_stderr(callable: Callable[..., CaptureResult], *args, **kwargs) -> CaptureResult:
        
        stream = StringIO()
        with redirect_stderr(stream):
            return_value = callable(*args, **kwargs)
        assert return_value.stderr is None, "stderr appears to have already been captured"
        return CaptureResult(return_value=return_value.return_value, stdout=return_value.stdout,
                             stderr=stream.getvalue(), exception=return_value.exception)
551007
def filter_int(string, default=None, start=None, stop=None):
    """"""
    try:
        i = int(string)
        if start is not None and i < start:
            raise InvalidInputError("value too small")
        if stop is not None and i >= stop:
            raise InvalidInputError("value too large")
        return i
    except ValueError:
        if not string and default is not None:
            # empty string, default was given
            return default
        else:
            raise InvalidInputError
624709
def get_input(prompt, default=None, choices=None, option_value=None):
    
    if option_value is not None:
        return option_value
    
    choices = choices or []
    while 1:
        r = raw_input(prompt+' ').strip()
        if not r and default is not None:
            return default
        if choices:
            if r not in choices:
                r = None
            else:
                break
        else:
            break
    return r
943256
def _strtobool(val):
    
    val = val.lower()
    if val in ('y', 'yes', 't', 'true', 'on', '1'):
        return 1
    elif val in ('n', 'no', 'f', 'false', 'off', '0', ''):
        return 0
    else:
        raise ValueError('Invalid truth value: {0}'.format(val))
436048
def get_choice(prompt, choices):
    
    print()
    checker = []
    for offset, choice in enumerate(choices):
        number = offset + 1
        print("\t{}): '{}'\n".format(number, choice))
        checker.append(str(number))

    response = get_input(prompt, tuple(checker) + ('',))
    if not response:
        print("Exiting...")
        exit()

    offset = int(response) - 1
    selected = choices[offset]

    return selected
1046546
def to_str(value):
    '''
    
    '''
    value = from_str(value)

    if value:
        value = value.replace('"', '\\"')
        if ' ' in value:
            value = '"' + value + '"'
    elif value is None:
        value = 'none'

    return value
279861
def _get_value(self, key, context):
        
        string_quotes = ('"', "'")

        if key[0] in string_quotes and key[-1] in string_quotes:
            return key[1:-1]
        if key in string.digits:
            return int(key)
        return context.get(key, None)
453194
def excepthook(type, value, traceback):  # pylint: disable=unused-argument
    """"""
    try:
        six.reraise(type, value, traceback)
    except type:
        _LOGGER.exception(str(value))
    if isinstance(value, KeyboardInterrupt):
        message = "Cancelling at the user's request."
    else:
        message = handle_unexpected_exception(value)
    print(message, file=sys.stderr)
528554
def quick_str_input(prompt, default_value):
        
        valid = False
        str_val = default_value
        while not valid:
            input_val = raw_input(prompt + "[{0}]: ".format(default_value))

            if input_val == "":
                str_val = default_value
                valid = True
            else:
                try:
                    str_val = text_type(input_val)
                    valid = True

                except ValueError:
                    print("ERROR: must be text.")
                    valid = False

        return str_val
1127865
def currentValue(self):
        
        enum  = self.enum()
        if ( self.isCheckable() ):
            value = 0
            for i in self.checkedIndexes():
                value |= enum[nativestring(self.itemText(i))]
            return value
        else:
            try:
                return enum[nativestring(self.itemText(self.currentIndex()))]
            except KeyError:
                return 0
812299
protected void assureInputFromUser(final String prompt, final String initValue, final List<String> options,
                                       final Consumer<String> setter) {
        final String option = findElementInOptions(options, initValue);
        if (option != null) {
            info(FOUND_VALID_VALUE);
            setter.accept(option);
            return;
        }

        out.printf("Choose from below options as %s %n", prompt);
        for (int i = 0; i < options.size(); i++) {
            out.printf("%d. %s%n", i, options.get(i));
        }

        assureInputFromUser("Enter index to use: ", null,
            str -> {
                try {
                    final int index = Integer.parseInt(str);
                    return 0 <= index && index < options.size();
                } catch (Exception e) {
                    return false;
                }
            },
            "Invalid index.", str -> {
                final int index = Integer.parseInt(str);
                setter.accept(options.get(index));
            }
        );
    }
771407
def str(self, space=False):
    """"""
    return "%s/%s (%s)" % (str(int(self.id)).rjust(space and 4),
                           self.name.ljust(space and 50),
                           "; ".join(str(a) for a in self.args))
970096
public String
getString() throws IOException {
	Token next = get();
	if (!next.isString()) {
		throw exception("expected a string");
	}
	return next.value;
}