def _apply_context(k, v): if '@type' != k: return v if model.is_iri(v): return context.get_term(v) elif isinstance(v, list): return [context.get_term(y) for y in v] else: msg = '@type must be single array of IRIs.' raise TypeError(msg)
def shorten_prop_prefixes(context): return functor.trans_props(context.apply_prefix, pred=lambda k, v: '@id' != context.get_type(k) or model.is_iri(v) or isinstance(v, dict))
def drop_unmapped(context): return functor.drop_properties( lambda k, v: '@' == k[0] or k in context.defns or model.is_iri(k))
def test_unqualified_text_is_not_iri(self): self.assertFalse(model.is_iri('this-is-not-an-IRI'))
def test_http_prefix_is_iri(self): self.assertTrue(model.is_iri("http://example.org/test#chapter"))