Пример #1
0
    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)
Пример #2
0
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))
Пример #3
0
def drop_unmapped(context):

    return functor.drop_properties(
        lambda k, v: '@' == k[0] or k in context.defns or model.is_iri(k))
Пример #4
0
    def test_unqualified_text_is_not_iri(self):

        self.assertFalse(model.is_iri('this-is-not-an-IRI'))
Пример #5
0
    def test_http_prefix_is_iri(self):

        self.assertTrue(model.is_iri("http://example.org/test#chapter"))