• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python util.coerce_to_uri函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中rdfrest.util.coerce_to_uri函数的典型用法代码示例。如果您正苦于以下问题:Python coerce_to_uri函数的具体用法?Python coerce_to_uri怎么用?Python coerce_to_uri使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了coerce_to_uri函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: del_source_trace

 def del_source_trace(self, val):
     """I break the link between this trace and one of its source traces
     """
     source_uri = coerce_to_uri(val)
     # do not trust edit, as there are many verifications to make
     with self.edit() as editable:
         editable.remove((self.uri, KTBS.hasSource, source_uri))
开发者ID:ktbs,项目名称:ktbs,代码行数:7,代码来源:trace.py


示例2: add_origin

 def add_origin(self, origin):
     """
     I add an obsel type to this attribute.
     """
     origin_uri = coerce_to_uri(origin)
     with self.edit(_trust=True) as editable:
         editable.add((self.uri, _HAS_REL_ORIGIN, origin_uri))
开发者ID:ktbs,项目名称:ktbs,代码行数:7,代码来源:trace_model.py


示例3: remove_parent

 def remove_parent(self, model):
     """
     I remove model as a parent model to this model.
     """
     with self.edit(_trust=True) as graph:
         graph.remove((self.uri, KTBS.hasParentModel,
                       coerce_to_uri(model, self.uri)))
开发者ID:ktbs,项目名称:ktbs,代码行数:7,代码来源:trace_model.py


示例4: create_obsel_type

    def create_obsel_type(self, id=None, supertypes=(), label=None):
        """
        I create a new obsel type in this model.

        :param id: see :ref:`ktbs-resource-creation`
        :param supertypes: explain.
        :param label: explain.

        :rtype: `ObselTypeMixin`:class:
        """
        # redefining built-in 'id' #pylint: disable=W0622
        if id is None  and  label is None:
            raise ValueError("id or label must be supplied")
        uri = mint_uri_from_label(label, self, id)
        with self.edit(_trust=True) as graph:
            base_uri = self.uri
            graph_add = graph.add
            graph_add((uri, RDF.type, KTBS.ObselType))
            if label is not None:
                graph_add((uri, SKOS.prefLabel, Literal(label)))
            for i in supertypes:
                graph_add((uri, KTBS.hasSuperObselType,
                           coerce_to_uri(i, base_uri)))
        ret = self.factory(uri, [KTBS.ObselType])
        assert isinstance(ret, ObselTypeMixin)
        return ret
开发者ID:ktbs,项目名称:ktbs,代码行数:26,代码来源:trace_model.py


示例5: add_source_trace

 def add_source_trace(self, val):
     """I add a source trace to this trace
     """
     source_uri = coerce_to_uri(val)
     # do not trust edit, as there are many verifications to make
     with self.edit() as editable:
         editable.add((self.uri, KTBS.hasSource, source_uri))
开发者ID:ktbs,项目名称:ktbs,代码行数:7,代码来源:trace.py


示例6: add_obsel_type

 def add_obsel_type(self, obsel_type):
     """
     I add an obsel type to this attribute.
     """
     obsel_type_uri = coerce_to_uri(obsel_type)
     with self.edit(_trust=True) as editable:
         editable.add((self.uri, _HAS_ATT_OBSELTYPE, obsel_type_uri))
开发者ID:ktbs,项目名称:ktbs,代码行数:7,代码来源:trace_model.py


示例7: serialize_json_method

def serialize_json_method(graph, method, bindings=None):

    valconv = ValueConverter(method.uri)
    valconv_uri = valconv.uri

    yield u"""{
    "@context": "%s",
    "@id": "%s",
    "@type": "Method",
    "hasParentMethod": "%s",
    "parameter": [""" % (
        CONTEXT_URI, method.uri, valconv_uri(coerce_to_uri(method.parent))
    )

    own_params = method.iter_parameters_with_values(False)
    yield u",".join(
        u"\n        %s" % dumps("%s=%s" % item)
        for item in own_params
    ) + "]"

    used_by = list(method.state.subjects(KTBS.hasMethod, method.uri))
    if used_by:
        yield  u""",\n        "isMethodOf": %s""" \
          % dumps([ valconv_uri(i) for i in used_by ])

    children = list(method.state.subjects(KTBS.hasParentMethod, method.uri))
    if children:
        yield  u""",\n        "isParentMethodOf": %s""" \
          % dumps([ valconv_uri(i) for i in children])

    for i in iter_other_arcs(graph, method.uri, valconv):
        yield i

    yield u""",\n    "inBase": "%s"\n}\n""" % valconv_uri(method.base.uri)
开发者ID:ktbs,项目名称:ktbs,代码行数:34,代码来源:jsonld_serializers.py


示例8: add_destination

 def add_destination(self, destination):
     """
     I add an obsel type to this attribute.
     """
     destination_uri = coerce_to_uri(destination)
     with self.edit(_trust=True) as editable:
         editable.add((self.uri, _HAS_REL_DESTINATION, destination_uri))
开发者ID:ktbs,项目名称:ktbs,代码行数:7,代码来源:trace_model.py


示例9: remove_destination

 def remove_destination(self, destination):
     """
     I remove an obsel type from this attribute.
     """
     destination_uri = coerce_to_uri(destination)
     with self.edit(_trust=True) as editable:
         editable.remove((self.uri, _HAS_REL_DESTINATION, destination_uri))
开发者ID:ktbs,项目名称:ktbs,代码行数:7,代码来源:trace_model.py


示例10: remove_obsel_type

 def remove_obsel_type(self, obsel_type):
     """
     I remove an obsel type from this attribute.
     """
     obsel_type_uri = coerce_to_uri(obsel_type)
     with self.edit(_trust=True) as editable:
         editable.remove((self.uri, _HAS_ATT_OBSELTYPE, obsel_type_uri))
开发者ID:ktbs,项目名称:ktbs,代码行数:7,代码来源:trace_model.py


示例11: remove_origin

 def remove_origin(self, origin):
     """
     I remove an obsel type from this attribute.
     """
     origin_uri = coerce_to_uri(origin)
     with self.edit(_trust=True) as editable:
         editable.remove((self.uri, _HAS_REL_ORIGIN, origin_uri))
开发者ID:ktbs,项目名称:ktbs,代码行数:7,代码来源:trace_model.py


示例12: remove_data_type

 def remove_data_type(self, data_type):
     """
     I remove the data type from this attribute.
     """
     data_type_uri = coerce_to_uri(data_type)
     with self.edit(_trust=True) as editable:
         editable.remove((self.uri, _HAS_ATT_DATATYPE, data_type_uri))
开发者ID:ktbs,项目名称:ktbs,代码行数:7,代码来源:trace_model.py


示例13: mint_uri_from_label

def mint_uri_from_label(label, target, uri=None, suffix=""):
    """
    Mint a URI for a resource posted to `target` based on `label`.

    :param label:  the label for the resource to create
    :param target: the resource "containing" the resource to create
    :param uri:    if provided, will be used instead (must be fresh)
    :param suffix: if provided, will be added to the end of the URI

    :return: a URI not present in `target.state`
    :rtype: rdflib.URIRef
    :raise: InvalidDataError if `uri` is provided and not acceptable
    """
    if uri is not None:
        uri = coerce_to_uri(uri, target.uri)
        if not check_new(target.state, uri):
            raise InvalidDataError("URI already in use <%s>" % uri)
        if not uri.startswith(target.uri):
            raise InvalidDataError(
                "URI is wrong <%s> (did you forget a leading '#'?)" % uri)
    else:
        label = label.lower()
        prefix = target.uri
        if prefix[-1] != "/":
            prefix = "%s#" % prefix
        prefix = "%s%s" % (prefix, _NON_ALPHA.sub("-", label))
        uri = URIRef("%s%s" % (prefix, suffix))
        if not check_new(target.state, uri):
            prefix = "%s-" % prefix
            uri = make_fresh_uri(target.state, prefix, suffix)
    return uri
开发者ID:ktbs,项目名称:ktbs,代码行数:31,代码来源:utils.py


示例14: __init__

 def __init__(self, uri, collection, host_graph, host_parameters):
     # not calling parents __init__ #pylint: disable=W0231
     self.uri = coerce_to_uri(uri, collection.uri)
     self.collection = collection
     self.host_graph = host_graph
     self.host_parameters = host_parameters
     if __debug__:
         self._readonly_graph = ReadOnlyGraph(host_graph)
开发者ID:ktbs,项目名称:ktbs,代码行数:8,代码来源:obsel.py


示例15: set_model

 def set_model(self, model):
     """I set the model of this trace.
     model can be a Model or a URI; relative URIs are resolved against this
     trace's URI.
     """
     model_uri = coerce_to_uri(model, self.uri)
     with self.edit(_trust=True) as graph:
         graph.set((self.uri, KTBS.hasModel, model_uri))
开发者ID:ktbs,项目名称:ktbs,代码行数:8,代码来源:trace.py


示例16: create_attribute_type

    def create_attribute_type(self, id=None, obsel_types=None, data_types=None,
                              value_is_list=False, label=None):
        """
        I create a new obsel type in this model.

        :param id: see :ref:`ktbs-resource-creation`
        :param obsel_types: explain.
        :param data_types: explain.
        :param value_is_list: explain.
        :param label: explain.

        :rtype: `AttributeTypeMixin`:class:
        """
        # redefining built-in 'id' #pylint: disable=W0622
        if id is None  and  label is None:
            raise ValueError("id or label must be supplied")
        uri = mint_uri_from_label(label, self, id)
        with self.edit(_trust=True) as graph:
            base_uri = self.uri
            graph_add = graph.add
            graph_add((uri, RDF.type, KTBS.AttributeType))
            if label is not None:
                graph_add((uri, SKOS.prefLabel, Literal(label)))
            if obsel_types is not None:
                # TODO remove test below when enough time has passed (2016-03-18)
                if isinstance(obsel_types, basestring) or isinstance(obsel_types, ObselTypeMixin):
                    warn("Model abstract API has changed: you should provide an *iterable* of obsel_types")
                    obsel_types = [obsel_types]
                for obsel_type in obsel_types:
                    obsel_type_uri = coerce_to_uri(obsel_type, base_uri)
                    graph_add ((uri, _HAS_ATT_OBSELTYPE, obsel_type_uri))
            if data_types is not None:
                # TODO remove test below when enough time has passed (2016-03-18)
                if isinstance(data_types, basestring):
                    warn("Model abstract API has changed: you should provide an *iterable* of data_types")
                    data_types = [data_types]
                for data_type in data_types:
                    data_type_uri = coerce_to_uri(data_type, base_uri)
                    graph_add ((uri, _HAS_ATT_DATATYPE, data_type_uri))
            # TODO SOON make use of value_is_list
            # ... in the meantime, we lure pylint into ignoring it:
            _ = value_is_list
        ret = self.factory(uri, [KTBS.AttributeType])
        assert isinstance(ret, AttributeTypeMixin)
        return ret
开发者ID:ktbs,项目名称:ktbs,代码行数:45,代码来源:trace_model.py


示例17: create_relation_type

    def create_relation_type(self, id=None, origins=None, destinations=None,
                                supertypes=(), label=None):
        """
        I create a new relation type in this model.

        :param id: see :ref:`ktbs-resource-creation`
        :param origins: explain.
        :param destinations: explain.
        :param supertypes: explain.
        :param label: explain.

        :rtype: `RelationTypeMixin`:class:
        """
        # redefining built-in 'id' #pylint: disable=W0622
        if id is None  and  label is None:
            raise ValueError("id or label must be supplied")
        uri = mint_uri_from_label(label, self, id)
        with self.edit(_trust=True) as graph:
            base_uri = self.uri
            graph_add = graph.add
            graph_add((uri, RDF.type, KTBS.RelationType))
            if label is not None:
                graph_add((uri, SKOS.prefLabel, Literal(label)))
            if origins is not None:
                # TODO remove test below when enough time has passed (2016-03-18)
                if isinstance(origins, basestring) or isinstance(origins, ObselTypeMixin):
                    warn("Model abstract API has changed: you should provide an *iterable* of origins")
                    origins = [origins]
                for origin in origins:
                    origin_uri = coerce_to_uri(origin, self.uri)
                    graph_add((uri, _HAS_REL_ORIGIN, origin_uri))
            if destinations is not None:
                # TODO remove test below when enough time has passed (2016-03-18)
                if isinstance(destinations, basestring) or isinstance(destinations, ObselTypeMixin):
                    warn("Model abstract API has changed: you should provide an *iterable* of destinations")
                    destinations = [destinations]
                for destination in destinations:
                    destination_uri = coerce_to_uri(destination, self.uri)
                    graph_add((uri, _HAS_REL_DESTINATION, destination_uri))
            for i in supertypes:
                graph_add((uri, KTBS.hasSuperRelationType,
                     coerce_to_uri(i, base_uri)))
        ret = self.factory(uri, [KTBS.RelationType])
        assert isinstance(ret, RelationTypeMixin)
        return ret
开发者ID:ktbs,项目名称:ktbs,代码行数:45,代码来源:trace_model.py


示例18: set_method

 def set_method(self, val):
     """I set the method that this computed trace will use
     """
     method_uri = coerce_to_uri(val)
     # do not trust edit, as there is many verifications to make
     with self.edit() as editable:
         editable.set((self.uri, KTBS.hasMethod, method_uri))
     self.force_state_refresh()
     self.obsel_collection.force_state_refresh()
开发者ID:ktbs,项目名称:ktbs,代码行数:9,代码来源:trace.py


示例19: get_base

    def get_base(self, id):
        """
        I return the base corresponding to the given URI.

        :rtype: `~.base.BaseMixin`:class:
        """
        # redefining built-in 'id' #pylint: disable-msg=W0622
        base_uri = coerce_to_uri(id, self.uri)
        return self.factory(base_uri, [KTBS.Base])
开发者ID:ktbs,项目名称:ktbs,代码行数:9,代码来源:ktbs_root.py


示例20: add_data_type

 def add_data_type(self, data_type):
     """
     I add the data type to this attribute.
     """
     # TODO LATER check data_type?
     # what kind of datatype do we accept? see ktbs.namespace
     data_type_uri = coerce_to_uri(data_type)
     with self.edit(_trust=True) as editable:
         editable.add((self.uri, _HAS_ATT_DATATYPE, data_type_uri))
开发者ID:ktbs,项目名称:ktbs,代码行数:9,代码来源:trace_model.py



注:本文中的rdfrest.util.coerce_to_uri函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python i18n._函数代码示例发布时间:2022-05-26
下一篇:
Python util.from_n3函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap