[CalendarServer-changes] [8457] CalendarServer/trunk/calendarserver/tools/shell.py

source_changes at macosforge.org source_changes at macosforge.org
Thu Dec 15 15:36:24 PST 2011


Revision: 8457
          http://trac.macosforge.org/projects/calendarserver/changeset/8457
Author:   wsanchez at apple.com
Date:     2011-12-15 15:36:22 -0800 (Thu, 15 Dec 2011)
Log Message:
-----------
cleanup

Modified Paths:
--------------
    CalendarServer/trunk/calendarserver/tools/shell.py

Modified: CalendarServer/trunk/calendarserver/tools/shell.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/shell.py	2011-12-15 23:02:14 UTC (rev 8456)
+++ CalendarServer/trunk/calendarserver/tools/shell.py	2011-12-15 23:36:22 UTC (rev 8457)
@@ -233,7 +233,7 @@
             log.msg("COMPLETIONS: %r" % (completions,))
         else:
             # Completing command name
-            completions = self._complete_commands(cmd)
+            completions = tuple(self._complete_commands(cmd))
 
         if len(completions) == 1:
             for completion in completions:
@@ -252,7 +252,8 @@
         self.terminal.loseConnection()
         self.service.reactor.stop()
 
-    def tokenize(self, line):
+    @staticmethod
+    def tokenize(line):
         lexer = shlex(line)
         lexer.whitespace_split = True
 
@@ -335,12 +336,14 @@
                 if not hasattr(m, "hidden"):
                     yield (attr[4:], m)
 
+    @staticmethod
+    def _complete(word, items):
+        for item in items:
+            if item.startswith(word):
+                yield item[len(word):]
+
     def _complete_commands(self, word):
-        completions = set()
-        for name, m in self.commands():
-            if name.startswith(word):
-                completions.add(name[len(word):])
-        return completions
+        return self._complete(word, (name for name, method in self.commands()))
 
     def cmd_help(self, tokens):
         """
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20111215/eb0bc15f/attachment-0001.html>


More information about the calendarserver-changes mailing list