[PATCH 03 of 18 seda] [xsd2yams] Move MULTIPLE_CHILDREN data structure to xsd2yams

Sylvain Thenault sylvain.thenault at logilab.fr
Mon Dec 11 16:53:35 CET 2017


# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1512569603 -3600
#      Wed Dec 06 15:13:23 2017 +0100
# Node ID 41e2e0bb2020adacbe70b42e99c4e7d156c3e827
# Parent  441cd81963f1c767ea88d1e1a4409f17820d4100
[xsd2yams] Move MULTIPLE_CHILDREN data structure to xsd2yams

so it's importable at code generation time where the cubicweb_seda package isn't
available.

diff --git a/cubicweb_seda/__init__.py b/cubicweb_seda/__init__.py
--- a/cubicweb_seda/__init__.py
+++ b/cubicweb_seda/__init__.py
@@ -68,32 +68,5 @@ def iter_all_rdefs(schema, container_ety
                 if target not in visited:
                     visited.add(target)
                     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'),
-]
diff --git a/cubicweb_seda/hooks.py b/cubicweb_seda/hooks.py
--- a/cubicweb_seda/hooks.py
+++ b/cubicweb_seda/hooks.py
@@ -23,11 +23,11 @@ from yams.schema import role_name
 
 from cubicweb import _
 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)
 
 
diff --git a/cubicweb_seda/schema/__init__.py b/cubicweb_seda/schema/__init__.py
--- a/cubicweb_seda/schema/__init__.py
+++ b/cubicweb_seda/schema/__init__.py
@@ -21,11 +21,11 @@ from yams.buildobjs import String
 from cubicweb import _
 from cubicweb.schema import ERQLExpression, RRQLExpression, RQLConstraint
 
 from cubes.skos import schema as skos
 
-from . import MULTIPLE_CHILDREN
+from .xsd2yams import MULTIPLE_CHILDREN
 
 _('1')
 _('0..1')
 _('0..n')
 _('1..n')
diff --git a/cubicweb_seda/xsd2yams.py b/cubicweb_seda/xsd2yams.py
--- a/cubicweb_seda/xsd2yams.py
+++ b/cubicweb_seda/xsd2yams.py
@@ -79,10 +79,36 @@ SKIP_ATTRS = set([
     'weight',
     'when',
     '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',
     'seda_archive_unit_ref_id_to': 'S container C, O container C',
     'seda_signed_object_id': 'S container C, O container C',


More information about the saem-devel mailing list