def tordf(attrname): prefix, predicate = attrname.split('_', 1) ns = get_namespace_url(prefix) try: return ns[predicate] except: return None
def to_rdf(attr_name): prefix, predicate = attr_name.rsplit('_', 1) ns = get_namespace_url(prefix) try: return ns[predicate] except: return None
def bind_namespaces(self, *namespaces): """ Bind the `namespace` to the `resource`. Useful for pretty serialization of the resource. """ for ns in namespaces: if isinstance(ns, str): self.__namespaces[ns] = get_namespace_url(ns) elif isinstance(ns, (Namespace, ClosedNamespace)): self.__namespaces[get_prefix(ns)] = ns
def bind_namespaces(self, *namespaces): """ Bind the `namespace` to the `resource`. Useful for pretty serialization of the resource. """ for ns in namespaces: if type(ns) in [str, unicode]: self.__namespaces[ns] = get_namespace_url(ns) elif type(ns) in [Namespace, ClosedNamespace]: self.__namespaces[get_prefix(ns)] = ns