[PATCH 3 of 6 saem_ref] [rdf] Hard-code AuthorityRecord type to make things clearer

Sylvain Thenault sylvain.thenault at logilab.fr
Thu Mar 16 10:46:32 CET 2017


# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1489575867 -3600
#      Wed Mar 15 12:04:27 2017 +0100
# Node ID 1f51cb6a736651b25e91183158cf903aceee8d04
# Parent  95ff948c8494fe27da3f37bd20e34f15956d11f1
[rdf] Hard-code AuthorityRecord type to make things clearer

we don't need to get etype has a variable given the function's name.

diff --git a/cubicweb_saem_ref/entities/rdf.py b/cubicweb_saem_ref/entities/rdf.py
--- a/cubicweb_saem_ref/entities/rdf.py
+++ b/cubicweb_saem_ref/entities/rdf.py
@@ -53,15 +53,15 @@ def _complete_agent_rdf_mapping(reg, ety
     reg.register_prefix('vcard', 'http://www.w3.org/2006/vcard/ns#')
     reg.register_attribute_equivalence(etype, 'creation_date', 'dct:created')
     reg.register_attribute_equivalence(etype, 'modification_date', 'dct:modified')
 
 
-def _complete_authority_record_rdf_mapping(reg, etype):
-    _complete_agent_rdf_mapping(reg, etype)
-    reg.register_attribute_equivalence(etype, lambda x: x.dc_title(), 'foaf:name')
-    reg.register_attribute_equivalence(etype, 'start_date', 'schema_org:startDate')
-    reg.register_attribute_equivalence(etype, 'end_date', 'schema_org:endDate')
+def _complete_authority_record_rdf_mapping(reg):
+    _complete_agent_rdf_mapping(reg, 'AuthorityRecord')
+    reg.register_attribute_equivalence('AuthorityRecord', lambda x: x.dc_title(), 'foaf:name')
+    reg.register_attribute_equivalence('AuthorityRecord', 'start_date', 'schema_org:startDate')
+    reg.register_attribute_equivalence('AuthorityRecord', 'end_date', 'schema_org:endDate')
     reg.register_etype_equivalence('PostalAddress', 'vcard:Location')
     reg.register_attribute_equivalence('PostalAddress', 'street', 'vcard:street-address')
     reg.register_attribute_equivalence('PostalAddress', 'postalcode', 'vcard:postal-code')
     reg.register_attribute_equivalence('PostalAddress', 'city', 'vcard:locality')
     reg.register_attribute_equivalence('PostalAddress', 'country', 'vcard:country-name')
@@ -158,11 +158,11 @@ class AuthorityRecordRDFPrimaryAdapter(s
         reg.register_prefix('foaf', 'http://xmlns.com/foaf/0.1/')
         kind = {'person': 'foaf:Person',
                 'authority': 'org:OrganizationUnit',
                 'family': 'foaf:Group'}.get(self.entity.kind, 'foaf:Person')
         _base_rdf_mapping(reg, 'AuthorityRecord', kind)
-        _complete_authority_record_rdf_mapping(reg, self.entity.cw_etype)
+        _complete_authority_record_rdf_mapping(reg)
 
     def fill(self, graph):
         super(AuthorityRecordRDFPrimaryAdapter, self).fill(graph)
         reg = self.registry
         generator = rdfio.RDFGraphGenerator(graph)


More information about the saem-devel mailing list