From 07b14073457aee7538c44457d0d06f5f9431d5f9 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Wed, 11 Nov 2015 15:55:28 +0100 Subject: [PATCH] Patches #1530 --- lib/core/shell.py | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/lib/core/shell.py b/lib/core/shell.py index 7b53bc389..74ae4e452 100644 --- a/lib/core/shell.py +++ b/lib/core/shell.py @@ -7,7 +7,6 @@ See the file 'doc/COPYING' for copying permission import atexit import os -import rlcompleter from lib.core import readlineng as readline from lib.core.data import logger @@ -16,6 +15,29 @@ from lib.core.enums import AUTOCOMPLETE_TYPE from lib.core.enums import OS from lib.core.settings import MAX_HISTORY_LENGTH +try: + import rlcompleter + + class CompleterNG(rlcompleter.Completer): + def global_matches(self, text): + """ + Compute matches when text is a simple name. + Return a list of all names currently defined in self.namespace + that match. + """ + + matches = [] + n = len(text) + + for ns in (self.namespace,): + for word in ns: + if word[:n] == text: + matches.append(word) + + return matches +except: + readline._readline = None + def readlineAvailable(): """ Check if the readline is available. By default @@ -74,24 +96,6 @@ def loadHistory(completion=None): warnMsg = "there was a problem loading the history file '%s' (%s)" % (historyPath, msg) logger.warn(warnMsg) -class CompleterNG(rlcompleter.Completer): - def global_matches(self, text): - """ - Compute matches when text is a simple name. - Return a list of all names currently defined in self.namespace - that match. - """ - - matches = [] - n = len(text) - - for ns in (self.namespace,): - for word in ns: - if word[:n] == text: - matches.append(word) - - return matches - def autoCompletion(completion=None, os=None, commands=None): if not readlineAvailable(): return