def prefix_id(self, children): ns, iriref = children iri = smart_urljoin(self.base_iri, self.decode_iriref(iriref)) ns = ns[:-1] # Drop trailing : from namespace self.prefixes[ns] = iri return []
def iri(self, children): (iriref_or_pname, ) = children if iriref_or_pname.startswith("<"): return self.make_named_node( smart_urljoin(self.base_iri, self.decode_iriref(iriref_or_pname))) return iriref_or_pname
def base(self, children): base_directive, base_iriref = children # Workaround for lalr parser token ambiguity in python 2.7 if base_directive.startswith("@") and base_directive != "@base": raise ValueError("Unexpected @base: " + base_directive) self.base_iri = smart_urljoin(self.base_iri, self.decode_iriref(base_iriref)) return []