How to use the changelog.InputError function in changelog

To help you get started, we’ve selected a few changelog examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mistio / mist-ee / changelog.py View on Github external
required    If True, user input must not be empty.
    retry       If True and invalid value, prompt again.
    confirm     If True, user is asked to confirm input value.
    """

    if default is not None and (default or not required):
        prompt = "%s (default is '%s'): " % (msg, default)
    else:
        prompt = "%s: " % msg
    while True:
        value = raw_input(prompt).strip() or default or ''
        try:
            if required and not value:
                raise InputError("Required value can't be empty.")
            if match and not re.match(match, value):
                raise InputError("Input value must match '%s'." % match)
        except InputError as exc:
            if retry:
                print >> sys.stderr, "WARNING: %s" % exc
                continue
            raise
        if confirm:
            if not prompt_boolean(
                "Input value is '%s'. Please confirm." % value,
                default=True, retry=True
            ):
                continue
        break
    return value
github mistio / mist-ce / changelog.py View on Github external
default     Default value to display.
    match       If provided, user input must match this regex string.
    required    If True, user input must not be empty.
    retry       If True and invalid value, prompt again.
    confirm     If True, user is asked to confirm input value.
    """

    if default is not None and (default or not required):
        prompt = "%s (default is '%s'): " % (msg, default)
    else:
        prompt = "%s: " % msg
    while True:
        value = raw_input(prompt).strip() or default or ''
        try:
            if required and not value:
                raise InputError("Required value can't be empty.")
            if match and not re.match(match, value):
                raise InputError("Input value must match '%s'." % match)
        except InputError as exc:
            if retry:
                print >> sys.stderr, "WARNING: %s" % exc
                continue
            raise
        if confirm:
            if not prompt_boolean(
                "Input value is '%s'. Please confirm." % value,
                default=True, retry=True
            ):
                continue
        break
    return value
github mistio / mist-ce / changelog.py View on Github external
required    If True, user input must not be empty.
    retry       If True and invalid value, prompt again.
    confirm     If True, user is asked to confirm input value.
    """

    if default is not None and (default or not required):
        prompt = "%s (default is '%s'): " % (msg, default)
    else:
        prompt = "%s: " % msg
    while True:
        value = raw_input(prompt).strip() or default or ''
        try:
            if required and not value:
                raise InputError("Required value can't be empty.")
            if match and not re.match(match, value):
                raise InputError("Input value must match '%s'." % match)
        except InputError as exc:
            if retry:
                print >> sys.stderr, "WARNING: %s" % exc
                continue
            raise
        if confirm:
            if not prompt_boolean(
                "Input value is '%s'. Please confirm." % value,
                default=True, retry=True
            ):
                continue
        break
    return value
github mistio / mist-ee / changelog.py View on Github external
default     Default value to display.
    match       If provided, user input must match this regex string.
    required    If True, user input must not be empty.
    retry       If True and invalid value, prompt again.
    confirm     If True, user is asked to confirm input value.
    """

    if default is not None and (default or not required):
        prompt = "%s (default is '%s'): " % (msg, default)
    else:
        prompt = "%s: " % msg
    while True:
        value = raw_input(prompt).strip() or default or ''
        try:
            if required and not value:
                raise InputError("Required value can't be empty.")
            if match and not re.match(match, value):
                raise InputError("Input value must match '%s'." % match)
        except InputError as exc:
            if retry:
                print >> sys.stderr, "WARNING: %s" % exc
                continue
            raise
        if confirm:
            if not prompt_boolean(
                "Input value is '%s'. Please confirm." % value,
                default=True, retry=True
            ):
                continue
        break
    return value
github mistio / mist-ce / changelog.py View on Github external
retry       If True and invalid value, prompt again.
    confirm     If True, user is asked to confirm input value.
    """

    if default is not None and (default or not required):
        prompt = "%s (default is '%s'): " % (msg, default)
    else:
        prompt = "%s: " % msg
    while True:
        value = raw_input(prompt).strip() or default or ''
        try:
            if required and not value:
                raise InputError("Required value can't be empty.")
            if match and not re.match(match, value):
                raise InputError("Input value must match '%s'." % match)
        except InputError as exc:
            if retry:
                print >> sys.stderr, "WARNING: %s" % exc
                continue
            raise
        if confirm:
            if not prompt_boolean(
                "Input value is '%s'. Please confirm." % value,
                default=True, retry=True
            ):
                continue
        break
    return value