changeset 411:83185d382d10

changed do_psql
author catherine@DellZilla
date Thu, 15 Oct 2009 19:39:14 -0400
parents 22c96b70ee41
children 3f566f30d14d
files sqlpython/sqlpyPlus.py
diffstat 1 files changed, 12 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/sqlpython/sqlpyPlus.py	Thu Oct 15 18:52:33 2009 -0400
+++ b/sqlpython/sqlpyPlus.py	Thu Oct 15 19:39:14 2009 -0400
@@ -1202,21 +1202,20 @@
         commands = {}
         for c in self.do_psql.__doc__.splitlines()[2:]:
             (abbrev, command) = c.split(None, 1)
-            commands[abbrev[1:]] = command
-        words = arg.split(None,1)
-        try:
-            abbrev = words[0]
-        except IndexError:
-            return
+            commands[abbrev] = command
+        parts = arg.parsed.raw.split(None,1)
+        abbrev = parts[0]
         try:
-            args = words[1]
+            remainder = parts[1]
         except IndexError:
-            args = ''
-        try:
-            return self.onecmd('%s %s%s%s' % (commands[abbrev], args, arg.parsed.terminator, arg.parsed.suffix))
-        except KeyError:
-            self.perror('psql command \%s not yet supported.' % abbrev)
-
+            remainder = ''
+        if abbrev in commands:
+            newcommand = '%s %s' % (commands[abbrev], remainder)
+            return self.onecmd(newcommand)
+        else:
+            self.perror('No abbreviated command for %s' % abbrev)
+            self.perror(self.do_psql.__doc__)
+            
     def _do_dir(self, type, arg, opts):
         self.do_ls("%s/%s%s%s" % (type, str(arg), arg.parsed.terminator, arg.parsed.suffix), opts)