changeset 397:510b6e2f0ae5

bzr works with gerald
author catherine@DellZilla
date Thu, 08 Oct 2009 09:59:12 -0400
parents 9c724e555c91
children b38368484d82
files sqlpython/sqlpyPlus.py
diffstat 1 files changed, 13 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/sqlpython/sqlpyPlus.py	Thu Oct 08 09:36:07 2009 -0400
+++ b/sqlpython/sqlpyPlus.py	Thu Oct 08 09:59:12 2009 -0400
@@ -801,9 +801,12 @@
                           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, vc=None):        
+              ])               
+    def do_pull(self, arg, opts):        
         """Displays source code."""
+        self._pull(arg, opts)
+
+    def _pull(self, arg, opts, vc=None):        
         opts.exact = True
         statekeeper = Statekeeper(opts.dump and self, ('stdout',))
         (username, schemas) = self.metadata()
@@ -821,10 +824,10 @@
                         os.makedirs(path)
                     except OSError:
                         pass
-                    filename = os.path.join(path, '%s.sql' % object_name.lower())
+                    filename = os.path.join(path, '%s.sql' % metadata.object_name.lower())
                     self.stdout = open(filename, 'w')
                 if opts.get('num') is not None:
-                    txt = code.splitlines()
+                    txt = txt.splitlines()
                     txt = centeredSlice(txt, center=opts.num+1, width=opts.width)
                     txt = '\n'.join(txt)
                 else:
@@ -918,7 +921,7 @@
                 return
         subprocess.call([program, 'init'])
         opts.dump = True
-        self.do_pull(arg, opts, vc=[program, 'add'])
+        self._pull(arg, opts, vc=[program, 'add'])
         subprocess.call([program, 'commit', '-m', '"%s"' % opts.message or 'committed from sqlpython'])        
     
     @options([
@@ -1457,22 +1460,18 @@
         
         seekpatt = r'[/\\]?%s[/\\]?' % (
             arg.replace('*', '.*').replace('?','.').replace('%', '.*'))        
+        if opts.get('exact'):
+            seekpatt = '^%s$' % seekpatt
         seek = re.compile(seekpatt, re.IGNORECASE)
-        if opts.get('exact'):
-            find = seek.match
-        else:
-            find = seek.search
-        import pdb; pdb.set_trace();
         qualified = opts.get('all')
         for (schema_name, schema) in schemas.items():
             if schema_name == username or opts.get('all'):
-                #import pdb; pdb.set_trace()        
                 for (name, dbobj) in schema.schema.items():                
                     metadata = MetaData(object_name=name, schema_name=schema_name, db_object=dbobj)
                     if (not arg) or (
-                           find(metadata.descriptor(qualified)) or 
-                           find(metadata.name(qualified)) or 
-                           find(metadata.db_type)):
+                           seek.search(metadata.descriptor(qualified)) or 
+                           seek.search(metadata.name(qualified)) or 
+                           seek.search(metadata.db_type)):
                         yield metadata
 
     @options([make_option('-l', '--long', action='store_true', help='long descriptions'),