From 745213087372eea32f54f635ab0d8344860341b8 Mon Sep 17 00:00:00 2001 From: 5Fingers Date: Thu, 8 Jan 2015 23:55:37 +0200 Subject: [PATCH] Update globals.py I created the Completer class for the auto-complete --- imports/globals.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/imports/globals.py b/imports/globals.py index c8a8169..2133af3 100644 --- a/imports/globals.py +++ b/imports/globals.py @@ -44,6 +44,23 @@ class init: giturl = 'https://github.com/ytisf/theZoo/blob/master' +########################################################## +class Completer: + def __init__(self, commands): + self.commands = commands + self.prefix = None + + def complete(self, prefix, index): + if prefix != self.prefix: + self.matchingCommand = [w for w in self.commands if w.startswith(prefix) + ] + self.prefix = prefix + try: + return self.matchingCommand[index] + except IndexError: + return None +################################################################ + class bcolors: PURPLE = '' BLUE = ''