summaryrefslogtreecommitdiff
path: root/ql/completer.py
diff options
context:
space:
mode:
authorMichaƂ Zimniewicz <michzimny@users.noreply.github.com>2016-11-25 18:23:01 +0100
committerGitHub <noreply@github.com>2016-11-25 18:23:01 +0100
commit29b99d5e50af876141187c7bdf52d663f3ac0807 (patch)
tree8628229e4a90c60f966de097079b2261e503e07e /ql/completer.py
parent0a27bbf9ce1f5b1a52bc62ff4d9e5c2f960b030c (diff)
parent70f771d2ab31847333b2c438466fe35895bc24db (diff)
Merge pull request #7 from michzimny/porting_to_python2
Porting to python2
Diffstat (limited to 'ql/completer.py')
-rw-r--r--ql/completer.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/ql/completer.py b/ql/completer.py
index a9b7d8d..89920d4 100644
--- a/ql/completer.py
+++ b/ql/completer.py
@@ -1,4 +1,5 @@
import readline
+import sys
class Completer(object):
@@ -10,8 +11,15 @@ class Completer(object):
readline.set_completer_delims('') # allow options with whitespace
readline.parse_and_bind('tab: complete')
+ def __encode_completion_string(self, s):
+ try:
+ return s.encode(sys.stdin.encoding) if isinstance(s, unicode) else s
+ except NameError: # Python 3.x does not have a 'unicode' type
+ pass
+ return s
+
def __init__(self, options):
- self.options = options
+ self.options = [self.__encode_completion_string(s) for s in options]
def complete(self, text, state):
text = text.lower()