[codegen] Allow 0..1 and 0..n for custiodial history item
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 12 Jul 2016 15:20:47 +0200
changeset 1417 50e9afea655e
parent 1416 915e2adf4bc0
child 1418 ca2fe27ff204
[codegen] Allow 0..1 and 0..n for custiodial history item
schema/seda2.py
xsd2yams.py
--- a/schema/seda2.py	Tue Jul 12 15:02:52 2016 +0200
+++ b/schema/seda2.py	Tue Jul 12 15:20:47 2016 +0200
@@ -1874,7 +1874,7 @@
     inlined = True
     constraints = [RQLConstraint('O in_scheme CS, CS scheme_relation_type CR, CR name "seda_keyword_type_to"')]
 
-@seda_profile_element(cardinalities=['1..n', '1'], default_cardinality='1..n',
+@seda_profile_element(cardinalities=['0..1', '0..n', '1', '1..n'], default_cardinality='0..1',
                       annotable=True)
 class SEDACustodialHistoryItem(EntityType):
     u""""""
--- a/xsd2yams.py	Tue Jul 12 15:02:52 2016 +0200
+++ b/xsd2yams.py	Tue Jul 12 15:20:47 2016 +0200
@@ -170,6 +170,9 @@
     'seda_comment': '1?',
     'seda_custodial_history_item': '1*',
 }
+RTYPE_CARD = {
+    'seda_custodial_history_item': '*',
+}
 
 _CARD_TO_CARDS = {
     '1': ['1'],
@@ -296,6 +299,8 @@
                         rdef_options['card'] = '?*'
                     else:
                         rdef_options['card'] = '**'
+                    if rtype in RTYPE_CARD:
+                        card = RTYPE_CARD[rtype]
                     # create mapping for intermediary entity type if necessary
                     if target_etype not in EXT_ETYPES and not isinstance(target_etype, tuple):
                         cards = _CARD_TO_CARDS[card]