예제 #1
0
def uri_split(uri):
    """ Split the `uri` into base path and remainder,
    the base is everything that comes before the last *#*' or */* including it

    .. code-block:: python

        >>> print util.uri_split('http://mynamespace/ns#some_property')
        ('NS1', 'some_property')

    """

    sp = uri.rfind('#') != -1 and '#' or '/'
    base, predicate = uri.rsplit(sp, 1)
    return get_namespace('%s%s' % (base, sp))[0], predicate
예제 #2
0
파일: util.py 프로젝트: zxenia/surfrdf
def uri_split(uri):
    """ Split the `uri` into base path and remainder,
    the base is everything that comes before the last *#*' or */* including it

    .. code-block:: python

        >>> print util.uri_split('http://mynamespace/ns#some_property')
        ('NS1', 'some_property')

    """

    sp = uri.rfind('#') != -1 and '#' or '/'
    base, predicate = uri.rsplit(sp, 1)
    return get_namespace('%s%s' % (base, sp))[0], predicate
예제 #3
0
def namespace_split(uri):
    """ Same as `uri_split`, but instead of the base of the uri, returns the
    registered `namespace` for this uri

    .. code-block:: python

        >>> print util.namespace_split('http://mynamespace/ns#some_property')
        (rdflib.URIRef('http://mynamespace/ns#'), 'some_property')

    """

    sp = uri.rfind('#') != -1 and '#' or '/'
    base, predicate = uri.rsplit(sp, 1)
    return get_namespace('%s%s' % (base, sp))[1], predicate
예제 #4
0
파일: util.py 프로젝트: zxenia/surfrdf
def namespace_split(uri):
    """ Same as `uri_split`, but instead of the base of the uri, returns the
    registered `namespace` for this uri

    .. code-block:: python

        >>> print util.namespace_split('http://mynamespace/ns#some_property')
        (rdflib.URIRef('http://mynamespace/ns#'), 'some_property')

    """

    sp = uri.rfind('#') != -1 and '#' or '/'
    base, predicate = uri.rsplit(sp, 1)
    return get_namespace('%s%s' % (base, sp))[1], predicate
예제 #5
0
파일: util.py 프로젝트: cosminbasca/surfrdf
def namespace_split(uri):
    """
    Same as :func:`uri_split`, but instead of the base of the uri, returns the
    registered `namespace` for this uri

    .. code-block:: python

        >>> print namespace_split('http://mynamespace/ns#some_property')
        (rdflib.URIRef('http://mynamespace/ns#'), 'some_property')

    :param str uri: the uri
    :return: a (namespace, predicate) tuple. Types: (:class:`rdflib.term.URIRef`, str)
    :rtype: tuple
    """

    sp = '#' if uri.rfind('#') != -1 else '/'
    base, predicate = uri.rsplit(sp, 1)
    return get_namespace('%s%s' % (base, sp))[1], predicate
예제 #6
0
def namespace_split(uri):
    """
    Same as :func:`uri_split`, but instead of the base of the uri, returns the
    registered `namespace` for this uri

    .. code-block:: python

        >>> print namespace_split('http://mynamespace/ns#some_property')
        (rdflib.URIRef('http://mynamespace/ns#'), 'some_property')

    :param str uri: the uri
    :return: a (namespace, predicate) tuple. Types: (:class:`rdflib.term.URIRef`, basestring)
    :rtype: tuple
    """

    sp = '#' if uri.rfind('#') != -1 else '/'
    base, predicate = uri.rsplit(sp, 1)
    return get_namespace('%s%s' % (base, sp))[1], predicate
예제 #7
0
파일: util.py 프로젝트: cosminbasca/surfrdf
def uri_split(uri):
    """
    Split the `uri` into base path and remainder,
    the base is everything that comes before the last *#*' or */* including it

    .. code-block:: python

        >>> print uri_split('http://mynamespace/ns#some_property')
        ('NS1', 'some_property')

    :param uri: the uri
    :type uri: :class:`rdflib.term.URIRef` or basestring
    :return: a (base, remainder) tuple. Types: (str, str)
    :rtype: tuple
    """

    sp = '#' if uri.rfind('#') != -1 else'/'
    base, predicate = uri.rsplit(sp, 1)
    return get_namespace('%s%s' % (base, sp))[0], predicate
예제 #8
0
def uri_split(uri):
    """
    Split the `uri` into base path and remainder,
    the base is everything that comes before the last *#*' or */* including it

    .. code-block:: python

        >>> print uri_split('http://mynamespace/ns#some_property')
        ('NS1', 'some_property')

    :param uri: the uri
    :type uri: :class:`rdflib.term.URIRef` or basestring
    :return: a (base, remainder) tuple. Types: (str, basestring)
    :rtype: tuple
    """

    sp = '#' if uri.rfind('#') != -1 else '/'
    base, predicate = uri.rsplit(sp, 1)
    return get_namespace('%s%s' % (base, sp))[0], predicate