models.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:pyfc4 作者: ghukill 项目源码 文件源码
def add_namespace(self, ns_prefix, ns_uri):

        '''
        preferred method is to instantiate with repository under 'context',
        but prefixes / namespaces can be added for a Resource instance

        adds to self.rdf.prefixes which will endure through create/update/refresh,
        and get added back to parsed graph namespaces

        Args:
            ns_prefix (str): prefix for namespace, e.g. 'dc', 'foaf'
            ns_uri (str): string of namespace / ontology. e.g. 'http://purl.org/dc/elements/1.1/', 'http://xmlns.com/foaf/0.1/'

        Returns:
            None: binds this new prefix:namespace combination to self.rdf.prefixes for use, and self.rdf.graph for serialization
        '''

        # add to prefixes
        setattr(self.rdf.prefixes, ns_prefix, rdflib.Namespace(ns_uri))

        # bind to graph
        self.rdf.namespace_manager.bind(ns_prefix, ns_uri, override=False)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号