changeset 504:e86bd0457a8b

-all implied for many functions
author catherine.devlin@gmail.com
date Wed, 22 Sep 2010 15:24:27 -0400
parents 0b584c8238b4
children d37f38652a76
files sqlpython/connections.py sqlpython/sqlpyPlus.py
diffstat 2 files changed, 9 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
--- a/sqlpython/connections.py	Wed Sep 22 15:16:33 2010 -0400
+++ b/sqlpython/connections.py	Wed Sep 22 15:24:27 2010 -0400
@@ -176,42 +176,6 @@
     identifier_regex = re.compile(
                        r'((?P<object_type>DATABASE LINK|DIRECTORY|FUNCTION|INDEX|JOB|MATERIALIZED VIEW|PACKAGE|PROCEDURE|SEQUENCE|SYNONYM|TABLE|TRIGGER|TYPE|VIEW|BASE TABLE)($|[\\/.\s])+)?(?P<remainder>.*)',
                        re.IGNORECASE)
-    def parse_identifier(self, identifier):
-        """
-        >>> opts = OptionTestDummy(postgres=True, password='password')        
-        >>> db = DatabaseInstance('thedatabase theuser', opts)
-        >>> result = db.parse_identifier('scott.pets')
-        >>> (result['object_type'], result['name1'], result['name2'])
-        (None, 'scott', 'pets')
-        >>> result = db.parse_identifier('pets')
-        >>> (result['object_type'], result['name1'], result['name2'])
-        (None, 'pets', '')
-        >>> result = db.parse_identifier('pe*')
-        >>> (result['object_type'], result['name1'], result['name2'])
-        ('%', '%', 'pe%')
-        >>> result = db.parse_identifier('scott/table/pets')
-        >>> (result['object_type'], result['name1'], result['name2'])
-        ('scott', 'table', 'pets')
-        >>> result = db.parse_identifier('table/scott.pets')
-        >>> (result['object_type'], result['name1'], result['name2'])
-        ('scott', 'table', 'pets')
-        >>> result = db.parse_identifier('')
-        >>> (result['object_type'], result['name1'], result['name2'])
-        ('%', '%', '%')
-        >>> result = db.parse_identifier('table/scott.*')
-        >>> (result['object_type'], result['name1'], result['name2'])
-        ('scott', 'table', '%')
-        """
-        object_type = None
-        for otype in self.gerald_types:
-            stripped = re.search('$' + otype + '\b(.*)', identifier, re.IGNORECASE)
-            if stripped:
-                identifier = stripped.groups(0)
-                object_type = otype
-                break
-        names = identifier.split('.')
-        return (object_type, names)
-                
     def comparison_operator(self, target):
         if ('%' in target) or ('_' in target):
             operator = 'LIKE'
--- a/sqlpython/sqlpyPlus.py	Wed Sep 22 15:16:33 2010 -0400
+++ b/sqlpython/sqlpyPlus.py	Wed Sep 22 15:24:27 2010 -0400
@@ -856,7 +856,6 @@
               make_option('-n', '--num', type='int', help='only code near line #num'),
               make_option('-w', '--width', type='int', default=5, 
                           help='# of lines before and after --lineNo'),
-              make_option('-a', '--all', action='store_true', help="all schemas' objects"),
               #make_option('-x', '--exact', action='store_true', help="match object name exactly")
               ])               
     def do_pull(self, arg, opts):        
@@ -864,6 +863,7 @@
         self._pull(arg, opts)
 
     def _pull(self, arg, opts, vc=None):  
+        opts.all = True
         statekeeper = Statekeeper(opts.dump and self, ('stdout',))
         try:
             for (owner, object_type, name, synonym_name) in self.current_instance.objects(arg, opts):
@@ -1051,9 +1051,11 @@
        
     def object_label(self, object_type, owner, name, synonym_name):
         return '%s %s.%s%s' % (object_type, owner, name, synonym_name and (synonym_name != name) and ' ("%s")' % synonym_name or '')
-    @options(standard_options + [
-              make_option('-A', '--alpha', action='store_true', help='List columns alphabetically')])
+    @options([make_option('-l', '--long', action='store_true', help='long descriptions'),
+              make_option('-r', '--reverse', action='store_true', help="Reverse order while sorting"),
+              make_option('-a', '--alpha', action='store_true', help='List columns alphabetically')])
     def do_describe(self, arg, opts):
+        opts.all = True
         rowlimit = self.rowlimit(arg)
         if opts.alpha:
             sortkey = operator.itemgetter('name')
@@ -1094,8 +1096,9 @@
                     if end_heading.search(line):
                         break
                 self.poutput(''.join(l for (ln, l) in obj.source[:index]))
-    @options([all_users_option])            
+    @options([])            
     def do_deps(self, arg, opts):
+        opts.all = True
         '''Lists indexes, constraints, and triggers depending on an object'''
         #TODO: doesn't account for views; don't know about primary keys
         for (owner, object_type, name, synonym_name) in self.current_instance.objects(arg, opts):
@@ -1106,8 +1109,9 @@
                     for (depname, depobj) in getattr(obj, deptype).items():
                         self.poutput('%s %s' % (deptype, depname))
                 
-    @options([all_users_option])        
+    @options([])        
     def do_comments(self, arg, opts):
+        opts.all = True
         'Prints comments on a table and its columns.'
         for (owner, object_type, name, synonym_name) in self.current_instance.objects(arg, opts):
             obj = self.current_instance.object_metadata(owner, object_type, name)