[xsd2yams] Move MULTIPLE_CHILDREN data structure to xsd2yams
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 06 Dec 2017 15:13:23 +0100
changeset 2898 8bd8b3533dec
parent 2897 f0c61b4feff1
child 2899 ed666cbea6af
[xsd2yams] Move MULTIPLE_CHILDREN data structure to xsd2yams so it's importable at code generation time where the cubicweb_seda package isn't available.
cubicweb_seda/__init__.py
cubicweb_seda/hooks.py
cubicweb_seda/schema/__init__.py
cubicweb_seda/xsd2yams.py
--- a/cubicweb_seda/__init__.py	Tue Dec 05 13:49:24 2017 +0100
+++ b/cubicweb_seda/__init__.py	Wed Dec 06 15:13:23 2017 +0100
@@ -70,30 +70,3 @@
                     stack.append(target)
         for rdef, role in _iter_external_rdefs(schema[etype], skip_external_rtypes):
             yield rdef, role
-
-
-# list of entity types that may be used multiple times at a same level, and
-# through which relation
-MULTIPLE_CHILDREN = [
-    ('SEDAArchiveUnit', 'seda_archive_unit'),
-    ('SEDABinaryDataObject', 'seda_binary_data_object'),
-    ('SEDAPhysicalDataObject', 'seda_physical_data_object'),
-    ('SEDADataObjectReference', 'seda_data_object_reference'),
-    ('SEDARelatedTransferReference', 'seda_related_transfer_reference'),
-    ('SEDAWriter', 'seda_writer_from'),
-    ('SEDAAddressee', 'seda_addressee_from'),
-    ('SEDARecipient', 'seda_recipient_from'),
-    ('SEDASpatial', 'seda_spatial'),
-    ('SEDATemporal', 'seda_temporal '),
-    ('SEDAJuridictional', 'seda_juridictional'),
-    ('SEDAKeyword', 'seda_keyword'),
-    ('SEDATag', 'seda_tag'),
-    ('SEDAIsVersionOf', 'seda_is_version_of'),
-    ('SEDAReplaces', 'seda_replaces'),
-    ('SEDARequires', 'seda_requires'),
-    ('SEDAIsPartOf', 'seda_is_part_of'),
-    ('SEDAReferences', 'seda_references'),
-    ('SEDAEvent', 'seda_event'),
-    ('SEDACustodialHistoryItem', 'seda_custodial_history_item'),
-    ('SEDARelationship', 'seda_relationship'),
-]
--- a/cubicweb_seda/hooks.py	Tue Dec 05 13:49:24 2017 +0100
+++ b/cubicweb_seda/hooks.py	Wed Dec 06 15:13:23 2017 +0100
@@ -25,7 +25,7 @@
 from cubicweb.predicates import is_instance, score_entity
 from cubicweb.server import hook
 
-from . import MULTIPLE_CHILDREN
+from .xsd2yams import MULTIPLE_CHILDREN
 from .entities import rule_type_from_etype, diag
 from .entities.generated import (CHOICE_RTYPE,
                                  CHECK_CARD_ETYPES, CHECK_CHILDREN_CARD_RTYPES)
--- a/cubicweb_seda/schema/__init__.py	Tue Dec 05 13:49:24 2017 +0100
+++ b/cubicweb_seda/schema/__init__.py	Wed Dec 06 15:13:23 2017 +0100
@@ -23,7 +23,7 @@
 
 from cubes.skos import schema as skos
 
-from . import MULTIPLE_CHILDREN
+from .xsd2yams import MULTIPLE_CHILDREN
 
 _('1')
 _('0..1')
--- a/cubicweb_seda/xsd2yams.py	Tue Dec 05 13:49:24 2017 +0100
+++ b/cubicweb_seda/xsd2yams.py	Wed Dec 06 15:13:23 2017 +0100
@@ -81,6 +81,32 @@
     'width',
 ])
 
+# list of entity types that may be used multiple times at a same level, and
+# through which relation
+MULTIPLE_CHILDREN = [
+    ('SEDAArchiveUnit', 'seda_archive_unit'),
+    ('SEDABinaryDataObject', 'seda_binary_data_object'),
+    ('SEDAPhysicalDataObject', 'seda_physical_data_object'),
+    ('SEDADataObjectReference', 'seda_data_object_reference'),
+    ('SEDARelatedTransferReference', 'seda_related_transfer_reference'),
+    ('SEDAWriter', 'seda_writer_from'),
+    ('SEDAAddressee', 'seda_addressee_from'),
+    ('SEDARecipient', 'seda_recipient_from'),
+    ('SEDASpatial', 'seda_spatial'),
+    ('SEDATemporal', 'seda_temporal '),
+    ('SEDAJuridictional', 'seda_juridictional'),
+    ('SEDAKeyword', 'seda_keyword'),
+    ('SEDATag', 'seda_tag'),
+    ('SEDAIsVersionOf', 'seda_is_version_of'),
+    ('SEDAReplaces', 'seda_replaces'),
+    ('SEDARequires', 'seda_requires'),
+    ('SEDAIsPartOf', 'seda_is_part_of'),
+    ('SEDAReferences', 'seda_references'),
+    ('SEDAEvent', 'seda_event'),
+    ('SEDACustodialHistoryItem', 'seda_custodial_history_item'),
+    ('SEDARelationship', 'seda_relationship'),
+]
+
 RDEF_CONSTRAINTS = {
     # x-ref constraints
     'seda_data_object_reference_id': 'S container C, O container C',