Beispiel #1
0
def uuid_subject(namespace = None):
    '''the function generates a unique subject in the provided `namespace` based on
    the :meth:`uuid.uuid4()` method,
    If `namespace` is not specified than the default `SURF` namespace is used

    .. code-block:: python

        >>>  print util.uuid_subject(ns.SIOC)
        http://rdfs.org/sioc/ns#1b6ca1d5-41ed-4768-b86a-42185169faff

    '''

    if not namespace:
        namespace = get_fallback_namespace()

    if not isinstance(namespace, Namespace):
        namespace = Namespace(namespace)

    return namespace[str(uuid4())]
Beispiel #2
0
def uuid_subject(namespace=None):
    '''the function generates a unique subject in the provided `namespace` based on
    the :meth:`uuid.uuid4()` method,
    If `namespace` is not specified than the default `SURF` namespace is used

    .. code-block:: python

        >>>  print util.uuid_subject(ns.SIOC)
        http://rdfs.org/sioc/ns#1b6ca1d5-41ed-4768-b86a-42185169faff

    '''

    if not namespace:
        namespace = get_fallback_namespace()

    if not isinstance(namespace, Namespace):
        namespace = Namespace(namespace)

    return namespace[str(uuid4())]
Beispiel #3
0
def uuid_subject(namespace=None):
    """
    This function generates a unique subject in the provided `namespace` based on the :func:`uuid.uuid4()` method,
    If `namespace` is not specified than the default `SURF` namespace is used

    .. code-block:: python

        >>> from surf import namespace as ns
        >>> print uuid_subject(ns.SIOC)
        http://rdfs.org/sioc/ns#1b6ca1d5-41ed-4768-b86a-42185169faff

    :param namespace: the given namespace
    :type namespace: None or :class:`rdflib.namespace.Namespace` or str or unicode
    :return: the *RDF* subject identifier in the specified namespace
    :rtype: :class:`rdflib.term.URIRef`
    """

    if not namespace:
        namespace = get_fallback_namespace()

    if not isinstance(namespace, Namespace):
        namespace = Namespace(namespace)

    return namespace[str(uuid4())]
Beispiel #4
0
def uuid_subject(namespace=None):
    """
    This function generates a unique subject in the provided `namespace` based on the :func:`uuid.uuid4()` method,
    If `namespace` is not specified than the default `SURF` namespace is used

    .. code-block:: python

        >>> from surf import namespace as ns
        >>> print uuid_subject(ns.SIOC)
        http://rdfs.org/sioc/ns#1b6ca1d5-41ed-4768-b86a-42185169faff

    :param namespace: the given namespace
    :type namespace: None or :class:`rdflib.namespace.Namespace` or str or unicode
    :return: the *RDF* subject identifier in the specified namespace
    :rtype: :class:`rdflib.term.URIRef`
    """

    if not namespace:
        namespace = get_fallback_namespace()

    if not isinstance(namespace, Namespace):
        namespace = Namespace(namespace)

    return namespace[str(uuid4())]