Esempio n. 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
Esempio n. 2
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
Esempio n. 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
Esempio n. 4
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
Esempio n. 5
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`, str)
    :rtype: tuple
    """

    sp = '#' if uri.rfind('#') != -1 else '/'
    base, predicate = uri.rsplit(sp, 1)
    return get_namespace('%s%s' % (base, sp))[1], predicate
Esempio n. 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
Esempio n. 7
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, str)
    :rtype: tuple
    """

    sp = '#' if uri.rfind('#') != -1 else'/'
    base, predicate = uri.rsplit(sp, 1)
    return get_namespace('%s%s' % (base, sp))[0], predicate
Esempio n. 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