ensure pb is not None stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 16 Nov 2009 11:16:28 +0100
branchstable
changeset 3857 6676a839dc97
parent 3856 1c9589e46b16
child 3858 ba96e4607e67
ensure pb is not None
server/schemaserial.py
--- a/server/schemaserial.py	Mon Nov 16 10:52:45 2009 +0100
+++ b/server/schemaserial.py	Mon Nov 16 11:16:28 2009 +0100
@@ -284,18 +284,21 @@
     if not verbose and not os.environ.get('APYCOT_ROOT'):
         pb_size = len(aller) + len(CONSTRAINTS) + len([x for x in eschemas if x.specializes()])
         pb = ProgressBar(pb_size, title=_title)
+    else:
+        pb = None
     rql = 'INSERT CWConstraintType X: X name %(ct)s'
     for cstrtype in CONSTRAINTS:
         if verbose:
             print rql
         cursor.execute(rql, {'ct': unicode(cstrtype)})
-        if not verbose:
+        if pb is not None:
             pb.update()
     groupmap = group_mapping(cursor, interactive=False)
     for ertype in aller:
         # skip eid and has_text relations
         if ertype in VIRTUAL_RTYPES:
-            pb.update()
+            if pb is not None:
+                pb.update()
             continue
         for rql, kwargs in erschema2rql(schema[ertype]):
             if verbose:
@@ -305,13 +308,13 @@
             if verbose:
                 print rql
             cursor.execute(rql, kwargs)
-        if not verbose:
+        if pb is not None:
             pb.update()
     for rql, kwargs in specialize2rql(schema):
         if verbose:
             print rql % kwargs
         cursor.execute(rql, kwargs)
-        if not verbose:
+        if pb is not None:
             pb.update()
     print