Adding Namespace.contains() by JaimieMurdock · Pull Request #1237 · RDFLib/rdflib (original) (raw)

No issue for this, just a quick addition for usability/literacy while working with the library.

Proposed Changes

This has possible extension to NamespaceManager, testing if a URIRef is in any managed namespace.

class NamespaceManager():
    def __contians__(self, ref):
        return any(ref.startswith(ns) for x, ns in self.namespaces())

Note that in NamespaceManager, namespaces are stored as URIRefs, not Namespace objects :/

Hoping this starts a discussion about some usability concerns.