def test_select_term_based_on_value_characteristics(): ctx = Context() ctx.add_term('updated', 'http://example.org/ns/updated') ctx.add_term('updatedDate', 'http://example.org/ns/updated', coercion='http://www.w3.org/2001/XMLSchema#date') assert ctx.find_term('http://example.org/ns/updated').name == 'updated' assert ctx.find_term('http://example.org/ns/updated', coercion='http://www.w3.org/2001/XMLSchema#date').name == 'updatedDate'
def test_select_term_based_on_value_characteristics(): ctx = Context() ctx.add_term('updated', 'http://example.org/ns/updated') ctx.add_term('updatedDate', 'http://example.org/ns/updated', coercion='http://www.w3.org/2001/XMLSchema#date') assert ctx.find_term('http://example.org/ns/updated').name == 'updated' assert ctx.find_term( 'http://example.org/ns/updated', coercion='http://www.w3.org/2001/XMLSchema#date').name == 'updatedDate'
def test_select_term_based_on_value_characteristics(): ctx = Context() ctx.add_term("updated", "http://example.org/ns/updated") ctx.add_term( "updatedDate", "http://example.org/ns/updated", coercion="http://www.w3.org/2001/XMLSchema#date", ) assert ctx.find_term("http://example.org/ns/updated").name == "updated" assert (ctx.find_term( "http://example.org/ns/updated", coercion="http://www.w3.org/2001/XMLSchema#date", ).name == "updatedDate")
def update(self, om_properties, context_js, schema_graph): """See :func:`oldman.parsing.schema.context.OMAttributeMdExtractor.update`.""" context = Context(context_js) for (property_iri, reversed), om_property in om_properties.iteritems(): # Efficient search term = context.find_term(property_iri) if term: self._update_property(om_property, term) else: # May not have been found because of its type terms = [ t for t in context.terms.values() if t.id == property_iri ] if len(terms) > 0: for term in terms: self._update_property(om_property, term) # Not declared (worst case) else: name = schema_graph.qname(property_iri).replace(":", "_") self._logger.warn( u"No short name found for property %s. QName %s used instead" % (property_iri, name)) om_property.add_attribute_metadata(name)
def test_create_context(): ctx = Context() ctx.add_term('label', 'http://example.org/ns/label') term = ctx.terms.get('label') assert term.name == 'label' assert ctx.find_term('http://example.org/ns/label') is term
def test_create_context(): ctx = Context() ctx.add_term("label", "http://example.org/ns/label") term = ctx.terms.get("label") assert term.name == "label" assert ctx.find_term("http://example.org/ns/label") is term
def update(self, om_properties, context_js, schema_graph): """See :func:`oldman.parsing.schema.context.OMAttributeMdExtractor.update`.""" context = Context(context_js) for (property_iri, reversed), om_property in om_properties.iteritems(): # Efficient search term = context.find_term(property_iri) if term: self._update_property(om_property, term) else: # May not have been found because of its type terms = [t for t in context.terms.values() if t.id == property_iri] if len(terms) > 0: for term in terms: self._update_property(om_property, term) # Not declared (worst case) else: name = schema_graph.qname(property_iri).replace(":", "_") self._logger.warn(u"No short name found for property %s. QName %s used instead" % (property_iri, name)) om_property.add_attribute_metadata(name)