Commit 7a765cc9 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

[code gen] generate most of RTYPES_IN_TAB from XSD information

parent 278032caeb38
...@@ -21,6 +21,7 @@ used bits). ...@@ -21,6 +21,7 @@ used bits).
from cubicweb import neg_role from cubicweb import neg_role
from xsd import XSDM_MAPPING
from xsd2yams import HAS_ANNOTATIONS, CodeGenerator from xsd2yams import HAS_ANNOTATIONS, CodeGenerator
...@@ -30,17 +31,10 @@ LEVEL_ETYPES = set(('SEDABinaryDataObjectType', 'SEDAPhysicalDataObjectType', ...@@ -30,17 +31,10 @@ LEVEL_ETYPES = set(('SEDABinaryDataObjectType', 'SEDAPhysicalDataObjectType',
RTYPES_IN_TAB = set(( RTYPES_IN_TAB = set((
'seda_binary_data_object', 'seda_binary_data_object',
'seda_physical_data_object', 'seda_physical_data_object',
'seda_format_litteral',
'seda_mime_type_from',
'seda_format_id_from',
'seda_encoding_from',
'seda_creating_application_name',
'seda_creating_application_version',
'seda_date_created_by_application',
'seda_creating_os',
'seda_creating_os_version',
'seda_last_modified',
)) ))
for element_name in ('CodeListVersions', 'FormatIdentification', 'FileInfo'):
for rtype, role, path in XSDM_MAPPING.iter_rtype_role(element_name):
RTYPES_IN_TAB.add(rtype)
class UICFGGenerator(CodeGenerator): class UICFGGenerator(CodeGenerator):
...@@ -104,9 +98,7 @@ class UICFGGenerator(CodeGenerator): ...@@ -104,9 +98,7 @@ class UICFGGenerator(CodeGenerator):
if ('afs', mapping.rtype) in self._processed: if ('afs', mapping.rtype) in self._processed:
return return
self._processed.add(('afs', mapping.rtype)) self._processed.add(('afs', mapping.rtype))
if (mapping.rtype.endswith('code_list_version_from') if mapping.rtype in RTYPES_IN_TAB:
or mapping.rtype.endswith('code_list_version')
or mapping.rtype in RTYPES_IN_TAB):
section = 'hidden' section = 'hidden'
role = mapping.composite or 'subject' role = mapping.composite or 'subject'
elif mapping.composite: elif mapping.composite:
...@@ -129,9 +121,7 @@ class UICFGGenerator(CodeGenerator): ...@@ -129,9 +121,7 @@ class UICFGGenerator(CodeGenerator):
yield mapping.rtype, 'subject', {'label': 'value'} yield mapping.rtype, 'subject', {'label': 'value'}
def primaryview_section_for_rdef_mapping(self, mapping): def primaryview_section_for_rdef_mapping(self, mapping):
if (mapping.rtype.endswith('code_list_version_from') if mapping.rtype in RTYPES_IN_TAB:
or mapping.rtype.endswith('code_list_version')
or mapping.rtype in RTYPES_IN_TAB):
section = 'hidden' section = 'hidden'
role = mapping.composite or 'subject' role = mapping.composite or 'subject'
yield mapping.rtype, neg_role(role), section yield mapping.rtype, neg_role(role), section
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment