equal
deleted
inserted
replaced
19 |
19 |
20 __docformat__ = "restructuredtext en" |
20 __docformat__ = "restructuredtext en" |
21 |
21 |
22 import os |
22 import os |
23 import json |
23 import json |
24 |
24 import sys |
25 from logilab.common.shellutils import ProgressBar |
25 |
|
26 from logilab.common.shellutils import ProgressBar, DummyProgressBar |
26 |
27 |
27 from yams import BadSchemaDefinition, schema as schemamod, buildobjs as ybo |
28 from yams import BadSchemaDefinition, schema as schemamod, buildobjs as ybo |
28 |
29 |
29 from cubicweb import Binary |
30 from cubicweb import Binary |
30 from cubicweb.schema import (KNOWN_RPROPERTIES, CONSTRAINTS, ETYPE_NAME_MAP, |
31 from cubicweb.schema import (KNOWN_RPROPERTIES, CONSTRAINTS, ETYPE_NAME_MAP, |
346 execute = cnx.execute |
347 execute = cnx.execute |
347 eschemas = schema.entities() |
348 eschemas = schema.entities() |
348 pb_size = (len(eschemas + schema.relations()) |
349 pb_size = (len(eschemas + schema.relations()) |
349 + len(CONSTRAINTS) |
350 + len(CONSTRAINTS) |
350 + len([x for x in eschemas if x.specializes()])) |
351 + len([x for x in eschemas if x.specializes()])) |
351 pb = ProgressBar(pb_size, title=_title) |
352 if sys.stdout.isatty(): |
|
353 pb = ProgressBar(pb_size, title=_title) |
|
354 else: |
|
355 pb = DummyProgressBar() |
352 groupmap = group_mapping(cnx, interactive=False) |
356 groupmap = group_mapping(cnx, interactive=False) |
353 # serialize all entity types, assuring CWEType is serialized first for proper |
357 # serialize all entity types, assuring CWEType is serialized first for proper |
354 # is / is_instance_of insertion |
358 # is / is_instance_of insertion |
355 eschemas.remove(schema.eschema('CWEType')) |
359 eschemas.remove(schema.eschema('CWEType')) |
356 eschemas.insert(0, schema.eschema('CWEType')) |
360 eschemas.insert(0, schema.eschema('CWEType')) |