def test_fullIRI(self):
     self.assertEqual('http://example.org/foo#',
                      FullIRI("http://example.org/foo#"))
     self.assertEqual(
         '    <http://example.org/foo#>',
         str(
             FullIRI("http://example.org/foo#").to_functional(
                 self.w.indent())))
     with self.assertRaises(TypeError):
         FullIRI("//just/a/path:")
Exemple #2
0
 def __init__(self, default_prefix: FullIRI = None, ontology: Optional[Ontology] = None, **prefixes: FullIRI):
     self.prefixDeclarations = []
     self.ontology = ontology if ontology is not None else Ontology()
     if default_prefix:
         self.prefixDeclarations.append(Prefix(None, default_prefix))
     if prefixes:
         for k, v in prefixes.items():
             self.prefixDeclarations.append(Prefix(k, v))
Exemple #3
0
 def __setattr__(self, key: str, value) -> None:
     if key.startswith('_') or key in ('prefixDeclarations', 'ontology'):
         super().__setattr__(key, value)
     else:
         prefix = Prefix(PrefixName(key) if key else None, FullIRI(value))
         self.prefixDeclarations.append(prefix)
Exemple #4
0
 def prefixes(self, dflt: Optional[FullIRI], **prefixes: FullIRI) -> None:
     if dflt:
         self.prefixDeclarations.append(Prefix('', dflt))
     for ns, iri in prefixes.items():
         self.prefixDeclarations.append(Prefix(PrefixName(ns), iri))
 def test_fullIRI_URIRef(self):
     self.assertEqual('http://example.org/foo#',
                      FullIRI(URIRef("http://example.org/foo#")))
     self.assertTrue(isinstance(URIRef("http://example.org/foo#"), FullIRI))