aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Dolbec <dolsen@gentoo.org>2018-07-02 14:40:21 -0700
committerBrian Dolbec <dolsen@gentoo.org>2018-07-06 22:22:11 -0700
commit0a745d03d5dbfd1b6e31db92a5ce55aa33084c7a (patch)
tree7ac65f62b0665016730255e6c36a2ca4e5f88285
parentgkeysgpg/cli.py: Fix doctring typos (diff)
downloadgentoo-keys-0a745d03d5dbfd1b6e31db92a5ce55aa33084c7a.tar.gz
gentoo-keys-0a745d03d5dbfd1b6e31db92a5ce55aa33084c7a.tar.bz2
gentoo-keys-0a745d03d5dbfd1b6e31db92a5ce55aa33084c7a.zip
gkeys/utils.py: Add get_ack function
Signed-off-by: Brian Dolbec <dolsen@gentoo.org>
-rw-r--r--gkeys/gkeys/utils.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/gkeys/gkeys/utils.py b/gkeys/gkeys/utils.py
index 64f11aa..f08acc1 100644
--- a/gkeys/gkeys/utils.py
+++ b/gkeys/gkeys/utils.py
@@ -39,6 +39,8 @@ try:
except AttributeError:
StringTypes = [str]
+Y_N = ("y", "yes", "n", "no")
+
def encoder(text, _encoding_):
return codecs.encode(text, _encoding_, 'replace')
@@ -161,6 +163,13 @@ def path(path_elements):
return pathname
+def get_ack(prompt_msg, accepted=Y_N):
+ ack = None
+ while ack not in accepted:
+ ack = py_input(prompt_msg).lower()
+ return ack
+
+
if __name__ == '__main__':
import doctest
doctest.testmod(sys.modules[__name__])