Alon Bar-Lev has uploaded a new change for review.

Change subject: dialog: support case insensitive queryString
......................................................................

dialog: support case insensitive queryString

Change-Id: I99c56db902b7d47a6523b126463f54ef5b305738
Signed-off-by: Alon Bar-Lev <[email protected]>
---
M src/otopi/dialog.py
M src/plugins/otopi/dialog/human.py
M src/plugins/otopi/dialog/machine.py
3 files changed, 14 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/otopi refs/changes/23/11523/1

diff --git a/src/otopi/dialog.py b/src/otopi/dialog.py
index 3bd9ab8..5889e75 100644
--- a/src/otopi/dialog.py
+++ b/src/otopi/dialog.py
@@ -61,6 +61,7 @@
         name,
         note=None,
         validValues=None,
+        caseSensitive=True,
         hidden=False,
         prompt=False,
         default=None,
@@ -71,6 +72,7 @@
         name -- name of variable.
         note -- note to present.
         validValues -- tuple of valid values.
+        caseSensitive -- consider validValues as such.
         hidden -- if tty echo will be disabled.
         prompt -- do not echo new line after note if possible.
         default -- if not None use this if empty.
diff --git a/src/plugins/otopi/dialog/human.py 
b/src/plugins/otopi/dialog/human.py
index 3fd5390..0f8139f 100644
--- a/src/plugins/otopi/dialog/human.py
+++ b/src/plugins/otopi/dialog/human.py
@@ -144,10 +144,14 @@
         name,
         note=None,
         validValues=None,
+        caseSensitive=True,
         hidden=False,
         prompt=False,
         default=None,
     ):
+        if not caseSensitive and validValues is not None:
+            validValues = [v.lower() for v in validValues]
+
         accepted = False
         while not accepted:
             if note is None:
@@ -162,6 +166,8 @@
             value = self._readline(hidden=hidden)
             if not value and default is not None:
                 value = default
+            if not caseSensitive:
+                value = value.lower()
             if validValues is not None and value not in validValues:
                 self.logger.error(_('Invalid value'))
             elif not value and value != default:
diff --git a/src/plugins/otopi/dialog/machine.py 
b/src/plugins/otopi/dialog/machine.py
index 9d3ca61..94d7bcd 100644
--- a/src/plugins/otopi/dialog/machine.py
+++ b/src/plugins/otopi/dialog/machine.py
@@ -132,10 +132,14 @@
         name,
         note=None,
         validValues=None,
+        caseSensitive=True,
         hidden=False,
         prompt=False,
         default=False,
     ):
+        if not caseSensitive and validValues is not None:
+            validValues = [v.lower() for v in validValues]
+
         if note is None:
             note = _("\nPlease specify value for '{name}' {values}: ").format(
                 name=name,
@@ -152,6 +156,8 @@
         value = self._readline()
         if not value and default is not None:
             value = default
+        if not caseSensitive:
+            value = value.lower()
         if (
             (validValues is not None and value not in validValues) or
             (not value and value != default)


--
To view, visit http://gerrit.ovirt.org/11523
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I99c56db902b7d47a6523b126463f54ef5b305738
Gerrit-PatchSet: 1
Gerrit-Project: otopi
Gerrit-Branch: master
Gerrit-Owner: Alon Bar-Lev <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to