summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Car <nicholas.car@csiro.au>2020-03-27 22:12:16 +1000
committerNicholas Car <nicholas.car@csiro.au>2020-03-27 22:12:16 +1000
commit9493db95585c0ec172935e34efae80db80e244b0 (patch)
tree0a490ad8c7c03ea9d8f047c57b055c48ead15e1f
parentad5959f97f262032e3c54b13316a3ab4126c57d5 (diff)
downloadrdflib-9493db95585c0ec172935e34efae80db80e244b0.tar.gz
docco updates - all intro files
-rw-r--r--docs/apidocs/examples.rst6
-rw-r--r--docs/apidocs/rdflib.plugins.parsers.pyMicrodata.rst35
-rw-r--r--docs/apidocs/rdflib.plugins.parsers.pyRdfa.extras.rst19
-rw-r--r--docs/apidocs/rdflib.plugins.parsers.pyRdfa.host.rst27
-rw-r--r--docs/apidocs/rdflib.plugins.parsers.pyRdfa.rdfs.rst27
-rw-r--r--docs/apidocs/rdflib.plugins.parsers.pyRdfa.rst85
-rw-r--r--docs/apidocs/rdflib.plugins.parsers.pyRdfa.transform.rst51
-rw-r--r--docs/conf.py121
-rw-r--r--docs/faq.rst48
-rw-r--r--docs/gettingstarted.rst90
-rw-r--r--docs/index.rst6
-rw-r--r--docs/intro_to_creating_rdf.rst123
-rw-r--r--docs/intro_to_graphs.rst72
-rw-r--r--docs/intro_to_parsing.rst18
-rw-r--r--docs/univrdfstore.rst4
-rw-r--r--docs/upgrade2to3.rst60
-rw-r--r--docs/upgrade3to4.rst92
-rw-r--r--rdflib/__init__.py15
18 files changed, 266 insertions, 633 deletions
diff --git a/docs/apidocs/examples.rst b/docs/apidocs/examples.rst
index 01a9d809..d099838f 100644
--- a/docs/apidocs/examples.rst
+++ b/docs/apidocs/examples.rst
@@ -60,7 +60,7 @@ These examples all live in ``./examples`` in the source-distribution of RDFLib.
:show-inheritance:
:mod:`rdfa_example` Module
-----------------------
+--------------------------
.. automodule:: examples.rdfa_example
:members:
@@ -76,7 +76,7 @@ These examples all live in ``./examples`` in the source-distribution of RDFLib.
:show-inheritance:
:mod:`sleepycat_example` Module
------------------------------------
+--------------------------------
.. automodule:: examples.sleepycat_example
:members:
@@ -92,7 +92,7 @@ These examples all live in ``./examples`` in the source-distribution of RDFLib.
:show-inheritance:
:mod:`smushing` Module
--------------------
+----------------------
.. automodule:: examples.smushing
:members:
diff --git a/docs/apidocs/rdflib.plugins.parsers.pyMicrodata.rst b/docs/apidocs/rdflib.plugins.parsers.pyMicrodata.rst
deleted file mode 100644
index 1c0f6734..00000000
--- a/docs/apidocs/rdflib.plugins.parsers.pyMicrodata.rst
+++ /dev/null
@@ -1,35 +0,0 @@
-pyMicrodata Package
-===================
-
-:mod:`pyMicrodata` Package
---------------------------
-
-.. automodule:: rdflib.plugins.parsers.pyMicrodata
- :members:
- :undoc-members:
- :show-inheritance:
-
-:mod:`microdata` Module
------------------------
-
-.. automodule:: rdflib.plugins.parsers.pyMicrodata.microdata
- :members:
- :undoc-members:
- :show-inheritance:
-
-:mod:`registry` Module
-----------------------
-
-.. automodule:: rdflib.plugins.parsers.pyMicrodata.registry
- :members:
- :undoc-members:
- :show-inheritance:
-
-:mod:`utils` Module
--------------------
-
-.. automodule:: rdflib.plugins.parsers.pyMicrodata.utils
- :members:
- :undoc-members:
- :show-inheritance:
-
diff --git a/docs/apidocs/rdflib.plugins.parsers.pyRdfa.extras.rst b/docs/apidocs/rdflib.plugins.parsers.pyRdfa.extras.rst
deleted file mode 100644
index 337a1f73..00000000
--- a/docs/apidocs/rdflib.plugins.parsers.pyRdfa.extras.rst
+++ /dev/null
@@ -1,19 +0,0 @@
-extras Package
-==============
-
-:mod:`extras` Package
----------------------
-
-.. automodule:: rdflib.plugins.parsers.pyRdfa.extras
- :members:
- :undoc-members:
- :show-inheritance:
-
-:mod:`httpheader` Module
-------------------------
-
-.. automodule:: rdflib.plugins.parsers.pyRdfa.extras.httpheader
- :members:
- :undoc-members:
- :show-inheritance:
- :exclude-members: __dict__,__weakref__
diff --git a/docs/apidocs/rdflib.plugins.parsers.pyRdfa.host.rst b/docs/apidocs/rdflib.plugins.parsers.pyRdfa.host.rst
deleted file mode 100644
index e0df6f06..00000000
--- a/docs/apidocs/rdflib.plugins.parsers.pyRdfa.host.rst
+++ /dev/null
@@ -1,27 +0,0 @@
-host Package
-============
-
-:mod:`host` Package
--------------------
-
-.. automodule:: rdflib.plugins.parsers.pyRdfa.host
- :members:
- :undoc-members:
- :show-inheritance:
-
-:mod:`atom` Module
-------------------
-
-.. automodule:: rdflib.plugins.parsers.pyRdfa.host.atom
- :members:
- :undoc-members:
- :show-inheritance:
-
-:mod:`html5` Module
--------------------
-
-.. automodule:: rdflib.plugins.parsers.pyRdfa.host.html5
- :members:
- :undoc-members:
- :show-inheritance:
-
diff --git a/docs/apidocs/rdflib.plugins.parsers.pyRdfa.rdfs.rst b/docs/apidocs/rdflib.plugins.parsers.pyRdfa.rdfs.rst
deleted file mode 100644
index 98915eb3..00000000
--- a/docs/apidocs/rdflib.plugins.parsers.pyRdfa.rdfs.rst
+++ /dev/null
@@ -1,27 +0,0 @@
-rdfs Package
-============
-
-:mod:`rdfs` Package
--------------------
-
-.. automodule:: rdflib.plugins.parsers.pyRdfa.rdfs
- :members:
- :undoc-members:
- :show-inheritance:
-
-:mod:`cache` Module
--------------------
-
-.. automodule:: rdflib.plugins.parsers.pyRdfa.rdfs.cache
- :members:
- :undoc-members:
- :show-inheritance:
-
-:mod:`process` Module
----------------------
-
-.. automodule:: rdflib.plugins.parsers.pyRdfa.rdfs.process
- :members:
- :undoc-members:
- :show-inheritance:
-
diff --git a/docs/apidocs/rdflib.plugins.parsers.pyRdfa.rst b/docs/apidocs/rdflib.plugins.parsers.pyRdfa.rst
deleted file mode 100644
index 8563debd..00000000
--- a/docs/apidocs/rdflib.plugins.parsers.pyRdfa.rst
+++ /dev/null
@@ -1,85 +0,0 @@
-pyRdfa Package
-==============
-
-:mod:`pyRdfa` Package
----------------------
-
-.. automodule:: rdflib.plugins.parsers.pyRdfa
- :members:
- :undoc-members:
- :show-inheritance:
-
-:mod:`embeddedRDF` Module
--------------------------
-
-.. automodule:: rdflib.plugins.parsers.pyRdfa.embeddedRDF
- :members:
- :undoc-members:
- :show-inheritance:
-
-:mod:`initialcontext` Module
-----------------------------
-
-.. automodule:: rdflib.plugins.parsers.pyRdfa.initialcontext
- :members:
- :undoc-members:
- :show-inheritance:
-
-:mod:`options` Module
----------------------
-
-.. automodule:: rdflib.plugins.parsers.pyRdfa.options
- :members:
- :undoc-members:
- :show-inheritance:
-
-:mod:`parse` Module
--------------------
-
-.. automodule:: rdflib.plugins.parsers.pyRdfa.parse
- :members:
- :undoc-members:
- :show-inheritance:
-
-:mod:`property` Module
-----------------------
-
-.. automodule:: rdflib.plugins.parsers.pyRdfa.property
- :members:
- :undoc-members:
- :show-inheritance:
-
-:mod:`state` Module
--------------------
-
-.. automodule:: rdflib.plugins.parsers.pyRdfa.state
- :members:
- :undoc-members:
- :show-inheritance:
-
-:mod:`termorcurie` Module
--------------------------
-
-.. automodule:: rdflib.plugins.parsers.pyRdfa.termorcurie
- :members:
- :undoc-members:
- :show-inheritance:
-
-:mod:`utils` Module
--------------------
-
-.. automodule:: rdflib.plugins.parsers.pyRdfa.utils
- :members:
- :undoc-members:
- :show-inheritance:
-
-Subpackages
------------
-
-.. toctree::
-
- rdflib.plugins.parsers.pyRdfa.extras
- rdflib.plugins.parsers.pyRdfa.host
- rdflib.plugins.parsers.pyRdfa.rdfs
- rdflib.plugins.parsers.pyRdfa.transform
-
diff --git a/docs/apidocs/rdflib.plugins.parsers.pyRdfa.transform.rst b/docs/apidocs/rdflib.plugins.parsers.pyRdfa.transform.rst
deleted file mode 100644
index 7f7a357b..00000000
--- a/docs/apidocs/rdflib.plugins.parsers.pyRdfa.transform.rst
+++ /dev/null
@@ -1,51 +0,0 @@
-transform Package
-=================
-
-:mod:`transform` Package
-------------------------
-
-.. automodule:: rdflib.plugins.parsers.pyRdfa.transform
- :members:
- :undoc-members:
- :show-inheritance:
-
-:mod:`DublinCore` Module
-------------------------
-
-.. automodule:: rdflib.plugins.parsers.pyRdfa.transform.DublinCore
- :members:
- :undoc-members:
- :show-inheritance:
-
-:mod:`OpenID` Module
---------------------
-
-.. automodule:: rdflib.plugins.parsers.pyRdfa.transform.OpenID
- :members:
- :undoc-members:
- :show-inheritance:
-
-:mod:`lite` Module
-------------------
-
-.. automodule:: rdflib.plugins.parsers.pyRdfa.transform.lite
- :members:
- :undoc-members:
- :show-inheritance:
-
-:mod:`metaname` Module
-----------------------
-
-.. automodule:: rdflib.plugins.parsers.pyRdfa.transform.metaname
- :members:
- :undoc-members:
- :show-inheritance:
-
-:mod:`prototype` Module
------------------------
-
-.. automodule:: rdflib.plugins.parsers.pyRdfa.transform.prototype
- :members:
- :undoc-members:
- :show-inheritance:
-
diff --git a/docs/conf.py b/docs/conf.py
index 384abadb..7f60b62a 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -11,47 +11,56 @@
# All configuration values have a default; values that are commented out
# serve to show the default.
-import sys, os, re
+import sys
+import os
+import re
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
-#sys.path.append(os.path.abspath('.'))
+# sys.path.append(os.path.abspath(".."))
+sys.path.append(os.path.abspath(".."))
# -- General configuration -----------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
# extensions = ['sphinx.ext.autodoc', 'sphinx.ext.todo', 'sphinx.ext.doctest']
-extensions = ['sphinx.ext.autodoc', #'sphinx.ext.autosummary',
- 'sphinx.ext.doctest', 'sphinx.ext.intersphinx',
- 'sphinx.ext.todo', 'sphinx.ext.coverage',
- 'sphinx.ext.ifconfig', 'sphinx.ext.viewcode']
+extensions = [
+ "sphinx.ext.autodoc",
+ #'sphinx.ext.autosummary',
+ "sphinx.ext.doctest",
+ "sphinx.ext.intersphinx",
+ "sphinx.ext.todo",
+ "sphinx.ext.coverage",
+ "sphinx.ext.ifconfig",
+ "sphinx.ext.viewcode",
+]
-autodoc_default_flags = [ "special-members" ]
+autodoc_default_flags = ["special-members"]
autosummary_generate = True
# Add any paths that contain templates here, relative to this directory.
-templates_path = ['_templates']
+templates_path = ["_templates"]
-#epydoc_mapping = {
+# epydoc_mapping = {
# '/_static/api/': [r'rdflib\.'],
# }
# The suffix of source filenames.
-source_suffix = '.rst'
+source_suffix = ".rst"
# The encoding of source files.
-source_encoding = 'utf-8'
+source_encoding = "utf-8"
# The master toctree document.
-master_doc = 'index'
+master_doc = "index"
# General information about the project.
-project = u'rdflib'
-copyright = u'2009 - 2013, RDFLib Team'
+project = u"rdflib"
+copyright = u"2009 - 2013, RDFLib Team"
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
@@ -66,30 +75,31 @@ def find_version(filename):
if version_match:
return version_match.group(1)
+
# The full version, including alpha/beta/rc tags.
-release = find_version('../rdflib/__init__.py')
+release = find_version("../rdflib/__init__.py")
# The short X.Y version.
version = re.sub("[0-9]+\\.[0-9]\\..*", "\1", release)
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
-#language = None
+# language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
-#today = ''
+# today = ''
# Else, today_fmt is used as the format for a strftime call.
-#today_fmt = '%B %d, %Y'
+# today_fmt = '%B %d, %Y'
# List of documents that shouldn't be included in the build.
-#unused_docs = []
+# unused_docs = []
# List of directories, relative to source directory, that shouldn't be searched
# for source files.
-exclude_trees = ['_build', 'draft']
+exclude_trees = ["_build", "draft"]
# The reST default role (used for this markup: `text`) to use for all documents.
-#default_role = None
+# default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
add_function_parentheses = True
@@ -100,125 +110,128 @@ add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
-#show_authors = False
+# show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
-pygments_style = 'sphinx'
+pygments_style = "sphinx"
# A list of ignored prefixes for module index sorting.
-#modindex_common_prefix = []
+# modindex_common_prefix = []
# -- Options for HTML output ---------------------------------------------------
# The theme to use for HTML and HTML Help pages. Major themes that come with
# Sphinx are currently 'default' and 'sphinxdoc'.
-html_theme = 'armstrong'
+html_theme = "armstrong"
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
-#html_theme_options = {}
+# html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
-html_theme_path = ["_themes", ]
+html_theme_path = [
+ "_themes",
+]
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
-#html_title = None
+# html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
-#html_short_title = None
+# html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
-#html_logo = None
-html_logo = '_static/rdflib.png'
+# html_logo = None
+html_logo = "_static/rdflib.png"
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
-html_favicon = '_static/rdflib.ico'
+html_favicon = "_static/rdflib.ico"
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
-html_static_path = ['_static']
+html_static_path = ["_static"]
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
-#html_last_updated_fmt = '%b %d, %Y'
+# html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
-#html_use_smartypants = True
+# html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
-#html_sidebars = {}
+# html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
-#html_additional_pages = {}
+# html_additional_pages = {}
# If false, no module index is generated.
-#html_use_modindex = True
+# html_use_modindex = True
# If false, no index is generated.
-#html_use_index = True
+# html_use_index = True
# If true, the index is split into individual pages for each letter.
-#html_split_index = False
+# html_split_index = False
# If true, links to the reST sources are added to the pages.
-#html_show_sourcelink = True
+# html_show_sourcelink = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
-#html_use_opensearch = ''
+# html_use_opensearch = ''
# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
-#html_file_suffix = ''
+# html_file_suffix = ''
# Output file base name for HTML help builder.
-htmlhelp_basename = 'rdflibdoc'
+htmlhelp_basename = "rdflibdoc"
# -- Options for LaTeX output --------------------------------------------------
# The paper size ('letter' or 'a4').
-#latex_paper_size = 'letter'
+# latex_paper_size = 'letter'
# The font size ('10pt', '11pt' or '12pt').
-#latex_font_size = '10pt'
+# latex_font_size = '10pt'
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
- ('index', 'rdflib.tex', u'rdflib Documentation',
- u'RDFLib Team', 'manual'),
+ ("index", "rdflib.tex", u"rdflib Documentation", u"RDFLib Team", "manual"),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
-#latex_logo = None
+# latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
-#latex_use_parts = False
+# latex_use_parts = False
# Additional stuff for the LaTeX preamble.
-#latex_preamble = ''
+# latex_preamble = ''
# Documents to append as an appendix to all manuals.
-#latex_appendices = []
+# latex_appendices = []
# If false, no module index is generated.
-#latex_use_modindex = True
+# latex_use_modindex = True
# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
- 'python': ('http://docs.python.org/2.7', None),
+ "python": ("http://docs.python.org/3.7", None),
}
+
+html_experimental_html5_writer = True
diff --git a/docs/faq.rst b/docs/faq.rst
deleted file mode 100644
index 0bf2b9e3..00000000
--- a/docs/faq.rst
+++ /dev/null
@@ -1,48 +0,0 @@
-=============================================
-Frequently Asked Questions about using RDFLib
-=============================================
-
-Questions about parsing
-=======================
-
-Questions about manipulating
-============================
-
-Questions about serializing
-===========================
-
-Which serialization method is the most efficient?
-=================================================
-
-Currently, the "nt" output format uses the most efficient
-serialization; "rdf/xml" should also be efficient. You can
-serialize to these formats using code similar to the following::
-
- myGraph.serialize(target_nt, format="nt")
- myGraph.serialize(target_rdfxml, format="xml")
-
-How can I use some of the abbreviated RDF/XML syntax?
-=====================================================
-
-Use the "pretty-xml" `format` argument to the `serialize` method::
-
- myGraph.serialize(target_pretty, format="pretty-xml")
-
-How can I control the binding of prefixes to XML namespaces when using RDF/XML?
-===============================================================================
-
-Each graph comes with a `NamespaceManager`__ instance in the `namespace_manager` field; you can use the `bind` method of this instance to bind a prefix to a namespace URI::
-
-
- myGraph.namespace_manager.bind('prefix', URIRef('scheme:my-namespace-uri:'))
-
-__ http://rdflib.net/rdflib-2.4.0/html/public/rdflib.syntax.NamespaceManager.NamespaceManager-class.html
-
-Does RDFLib support serialization to the `TriX`__ format?
-=========================================================
-
-Yes, both parsing and serialising is supported::
-
- graph.serialize(format="trix") and graph.load(source, format="trix")
-
-__ http://www.w3.org/2004/03/trix/
diff --git a/docs/gettingstarted.rst b/docs/gettingstarted.rst
index 41d54cc1..a3637210 100644
--- a/docs/gettingstarted.rst
+++ b/docs/gettingstarted.rst
@@ -17,16 +17,27 @@ The best way to install RDFLib is to use ``pip`` (sudo as required):
$ pip install rdflib
-Support is available through the rdflib-dev group:
+If you want the latest code to run, clone the master branch of the GitHub repo and use that.
+
+Support
+=======
+Usage support is available via questions tagged with ``[rdflib]`` on `StackOverflow <https://stackoverflow.com/questions/tagged/rdflib>`__
+and development support, notifications and detailed discussion through the rdflib-dev group (mailing list):
http://groups.google.com/group/rdflib-dev
-and on the IRC channel `#rdflib <irc://irc.freenode.net/swig>`_ on the freenode.net server
+If you notice an bug or want to request an enhancement, please do so via our Issue Tracker in Github:
-The primary interface that RDFLib exposes for working with RDF is a
-:class:`~rdflib.graph.Graph`. The package uses various Python idioms
+ `<http://github.com/RDFLib/rdflib/issues>`_
+
+How it all works
+================
+*The package uses various Python idioms
that offer an appropriate way to introduce RDF to a Python programmer
-who hasn't worked with RDF before.
+who hasn't worked with RDF before.*
+
+The primary interface that RDFLib exposes for working with RDF is a
+:class:`~rdflib.graph.Graph`.
RDFLib graphs are not sorted containers; they have ordinary ``set``
operations (e.g. :meth:`~rdflib.Graph.add` to add a triple) plus
@@ -35,12 +46,12 @@ methods that search triples and return them in arbitrary order.
RDFLib graphs also redefine certain built-in Python methods in order
to behave in a predictable way; they `emulate container types
<http://docs.python.org/release/2.5.2/ref/sequence-types.html>`_ and
-are best thought of as a set of 3-item triples:
+are best thought of as a set of 3-item tuples ("triples", in RDF-speak):
.. code-block:: text
[
- (subject, predicate, object),
+ (subject0, predicate0, object0),
(subject1, predicate1, object1),
...
(subjectN, predicateN, objectN)
@@ -52,52 +63,77 @@ A tiny usage example:
import rdflib
+ # create a Graph
g = rdflib.Graph()
- result = g.parse("http://www.w3.org/People/Berners-Lee/card")
- print("graph has %s statements." % len(g))
- # prints graph has 79 statements.
+ # parse in an RDF file hosted on the Internet
+ result = g.parse("http://www.w3.org/People/Berners-Lee/card")
+ # loop through each triple in the graph (subj, pred, obj)
for subj, pred, obj in g:
- if (subj, pred, obj) not in g:
+ # check if there is at least one triple in the Graph
+ if (subj, pred, obj) not in g:
raise Exception("It better be!")
- s = g.serialize(format='n3')
+ # print the number of "triples" in the Graph
+ print("graph has {} statements.".format(len(g)))
+ # prints graph has 86 statements.
-A more extensive example:
+ # print out the entire Graph in the RDF Turtle format
+ print(g.serialize(format="turtle").decode("utf-8"))
+
+Here a :class:`~rdflib.graph.Graph` is created and then an RDF file online, Tim Berners-Lee's social network details, is
+parsed into that graph. The ``print()`` statement uses the ``len()`` function to count the number of triples in the
+graph.
+A more extensive example:
.. code-block:: python
- from rdflib import Graph, Literal, BNode, Namespace, RDF, URIRef
- from rdflib.namespace import DC, FOAF
+ from rdflib import Graph, Literal, RDF, URIRef
+ # rdflib knows about some namespaces, like FOAF
+ from rdflib.namespace import FOAF , XSD
+ # create a Graph
g = Graph()
- # Create an identifier to use as the subject for Donna.
- donna = BNode()
+ # Create an RDF URI node to use as the subject for multiple triples
+ donna = URIRef("http://example.org/donna")
+
+ # Add triples using store's add() method.
+ g.add((donna, RDF.type, FOAF.Person))
+ g.add((donna, FOAF.nick, Literal("donna", lang="ed")))
+ g.add((donna, FOAF.name, Literal("Donna Fales")))
+ g.add((donna, FOAF.mbox, URIRef("mailto:donna@example.org")))
- # Add triples using store's add method.
- g.add( (donna, RDF.type, FOAF.Person) )
- g.add( (donna, FOAF.nick, Literal("donna", lang="foo")) )
- g.add( (donna, FOAF.name, Literal("Donna Fales")) )
- g.add( (donna, FOAF.mbox, URIRef("mailto:donna@example.org")) )
+ # Add another person
+ ed = URIRef("http://example.org/edward")
+
+ # Add triples using store's add() method.
+ g.add((ed, RDF.type, FOAF.Person))
+ g.add((ed, FOAF.nick, Literal("ed", datatype=XSD.string)))
+ g.add((ed, FOAF.name, Literal("Edward Scissorhands")))
+ g.add((ed, FOAF.mbox, URIRef("mailto:e.scissorhands@example.org")))
# Iterate over triples in store and print them out.
print("--- printing raw triples ---")
for s, p, o in g:
print((s, p, o))
- # For each foaf:Person in the store print out its mbox property.
+ # For each foaf:Person in the store, print out their mbox property's value.
print("--- printing mboxes ---")
for person in g.subjects(RDF.type, FOAF.Person):
for mbox in g.objects(person, FOAF.mbox):
print(mbox)
- # Bind a few prefix, namespace pairs for more readable output
- g.bind("dc", DC)
+ # Bind the FOAF namespace to a prefix for more readable output
g.bind("foaf", FOAF)
- print( g.serialize(format='n3') )
+ # print all the data in the Notation3 format
+ print("--- printing mboxes ---")
+ print(g.serialize(format='n3').decode("utf-8"))
+
-Many more :doc:`examples <apidocs/examples>` can be found in the :file:`examples` folder in the source distribution.
+More examples
+=============
+There are many more :doc:`examples <apidocs/examples>` in the :file:`examples` folder in the source distribution.
diff --git a/docs/index.rst b/docs/index.rst
index 2ae0e9ce..3f604729 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -16,7 +16,7 @@ working with RDF, including:
* for in-memory and persistent RDF storage - Berkeley DB
-* **a graph interface**
+* **Graph interface**
* to a single graph
* or a conjunctive graph (multiple named graphs)
@@ -101,8 +101,8 @@ and related packaged that you might also find useful.
Further help
-----------
-If you would like more help with using rdflib, please post a question using the tag [rdflib] on StackOverflow. A list of
-existing [rdflib] tagged questions is there at:
+If you would like more help with using rdflib, please post a question using the tag ``[rdflib]`` on StackOverflow. A list of
+existing ``[rdflib]`` tagged questions is there at:
* `<https://stackoverflow.com/questions/tagged/rdflib>`__
diff --git a/docs/intro_to_creating_rdf.rst b/docs/intro_to_creating_rdf.rst
index 1a2b8de5..0c05a241 100644
--- a/docs/intro_to_creating_rdf.rst
+++ b/docs/intro_to_creating_rdf.rst
@@ -7,24 +7,29 @@ Creating RDF triples
Creating Nodes
--------------
-RDF is a graph where the nodes are URI references, Blank Nodes or Literals, in RDFLib represented by the classes :class:`~rdflib.term.URIRef`, :class:`~rdflib.term.BNode`, and :class:`~rdflib.term.Literal`. ``URIRefs`` and ``BNodes`` can both be thought of as resources, such a person, a company, a web-site, etc.
-A ``BNode`` is a node where the exact URI is not known.
-``URIRefs`` are also used to represent the properties/predicates in the RDF graph.
-``Literals`` represent attribute values, such as a name, a date, a number, etc.
+RDF data is a graph where the nodes are URI references, Blank Nodes or Literals. In RDFLib, these node types are
+represented by the classes :class:`~rdflib.term.URIRef`, :class:`~rdflib.term.BNode`, and :class:`~rdflib.term.Literal`.
+``URIRefs`` and ``BNodes`` can both be thought of as resources, such a person, a company, a website, etc.
+* A ``BNode`` is a node where the exact URI is not known.
+* A ``URIRef`` is a node where the exact URI is knonw. ``URIRef``s are also used to represent the properties/predicates in the RDF graph.
+* ``Literals`` represent attribute values, such as a name, a date, a number, etc. The most common literal values are XML data types, e.g. string, int...
-Nodes can be created by the constructors of the node classes::
+
+Nodes can be created by the constructors of the node classes:
+
+.. code-block:: python
from rdflib import URIRef, BNode, Literal
bob = URIRef("http://example.org/people/Bob")
- linda = BNode() # a GUID is generated
+ linda = BNode() # a GUID is generated
- name = Literal('Bob') # passing a string
- age = Literal(24) # passing a python int
- height = Literal(76.5) # passing a python float
+ name = Literal('Bob') # passing a string
+ age = Literal(24) # passing a python int
+ height = Literal(76.5) # passing a python float
-Literals can be created from python objects, this creates ``data-typed literals``, for the details on the mapping see :ref:`rdflibliterals`.
+Literals can be created from Python objects, this creates ``data-typed literals``, for the details on the mapping see :ref:`rdflibliterals`.
For creating many ``URIRefs`` in the same ``namespace``, i.e. URIs with the same prefix, RDFLib has the :class:`rdflib.namespace.Namespace` class::
@@ -32,87 +37,102 @@ For creating many ``URIRefs`` in the same ``namespace``, i.e. URIs with the same
n = Namespace("http://example.org/people/")
- n.bob # = rdflib.term.URIRef(u'http://example.org/people/bob')
- n.eve # = rdflib.term.URIRef(u'http://example.org/people/eve')
+ n.bob # = rdflib.term.URIRef(u'http://example.org/people/bob')
+ n.eve # = rdflib.term.URIRef(u'http://example.org/people/eve')
-This is very useful for schemas where all properties and classes have the same URI prefix, RDFLib pre-defines Namespaces for the most common RDF schemas::
+This is very useful for schemas where all properties and classes have the same URI prefix. RDFLib defines Namespaces for some common RDF/OWL schemas, including most W3C ones:
+
+.. code-block:: python
+
+ from rdflib.namespace import CSVW, DC, DCAT, DCTERMS, DOAP, FOAF, ODRL2, ORG, OWL, \
+ PROF, PROV, RDF, RDFS, SDO, SH, SKOS, SOSA, SSN, TIME, \
+ VOID, XMLNS, XSD
+
+ RDF.type
+ # = rdflib.term.URIRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#type")
+
+ FOAF.knows
+ # = rdflib.term.URIRef("http://xmlns.com/foaf/0.1/knows")
- from rdflib.namespace import RDF, FOAF
+ PROF.isProfileOf
+ # = rdflib.term.URIRef("http://www.w3.org/ns/dx/prof/isProfileOf")
- RDF.type
- # = rdflib.term.URIRef(u'http://www.w3.org/1999/02/22-rdf-syntax-ns#type')
+ SOSA.Sensor
+ # = rdflib.term.URIRef("http://www.w3.org/ns/sosa/Sensor")
- FOAF.knows
- # = rdflib.term.URIRef(u'http://xmlns.com/foaf/0.1/knows')
Adding Triples
--------------
-We already saw in :doc:`intro_to_parsing`, how triples can be added with with the :meth:`~rdflib.graph.Graph.parse` function.
+We already saw in :doc:`intro_to_parsing`, how triples can be added from files and online locations with with the :meth:`~rdflib.graph.Graph.parse` function.
-Triples can also be added with the :meth:`~rdflib.graph.Graph.add` function:
+Triples can also be added within Python code directly, using the :meth:`~rdflib.graph.Graph.add` function:
.. automethod:: rdflib.graph.Graph.add
:noindex:
-:meth:`~rdflib.graph.Graph.add` takes a 3-tuple of RDFLib nodes. Try the following with the nodes and namespaces we defined previously::
+:meth:`~rdflib.graph.Graph.add` takes a 3-tuple (a "triple") of RDFLib nodes. Try the following with the nodes and namespaces we defined previously:
- from rdflib import Graph
- g = Graph()
+.. code-block:: python
+
+ from rdflib import Graph
+ g = Graph()
+ g.bind("foaf", FOAF)
- g.add( (bob, RDF.type, FOAF.Person) )
- g.add( (bob, FOAF.name, name) )
- g.add( (bob, FOAF.knows, linda) )
- g.add( (linda, RDF.type, FOAF.Person) )
- g.add( (linda, FOAF.name, Literal('Linda') ) )
+ g.add((bob, RDF.type, FOAF.Person))
+ g.add((bob, FOAF.name, name))
+ g.add((bob, FOAF.knows, linda))
+ g.add((linda, RDF.type, FOAF.Person))
+ g.add((linda, FOAF.name, Literal("Linda")))
- print g.serialize(format='turtle')
+ print(g.serialize(format="turtle").decode("utf-8"))
outputs:
.. code-block:: n3
- @prefix foaf: <http://xmlns.com/foaf/0.1/> .
- @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
- @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
- @prefix xml: <http://www.w3.org/XML/1998/namespace> .
+ @prefix foaf: <http://xmlns.com/foaf/0.1/> .
- <http://example.org/people/Bob> a foaf:Person ;
- foaf:knows [ a foaf:Person ;
- foaf:name "Linda" ] ;
- foaf:name "Bob" .
+ <http://example.org/people/Bob> a foaf:Person ;
+ foaf:knows [ a foaf:Person ;
+ foaf:name "Linda" ] ;
+ foaf:name "Bob" .
For some properties, only one value per resource makes sense (i.e they are *functional properties*, or have max-cardinality of 1). The :meth:`~rdflib.graph.Graph.set` method is useful for this:
.. code-block:: python
- g.add( ( bob, FOAF.age, Literal(42) ) )
- print "Bob is ", g.value( bob, FOAF.age )
- # prints: Bob is 42
-
- g.set( ( bob, FOAF.age, Literal(43) ) ) # replaces 42 set above
- print "Bob is now ", g.value( bob, FOAF.age )
- # prints: Bob is now 43
+ g.add((bob, FOAF.age, Literal(42)))
+ print("Bob is ", g.value(bob, FOAF.age))
+ # prints: Bob is 42
+
+ g.set((bob, FOAF.age, Literal(43))) # replaces 42 set above
+ print("Bob is now ", g.value(bob, FOAF.age))
+ # prints: Bob is now 43
:meth:`rdflib.graph.Graph.value` is the matching query method, it will return a single value for a property, optionally raising an exception if there are more.
You can also add triples by combining entire graphs, see :ref:`graph-setops`.
+
Removing Triples
-^^^^^^^^^^^^^^^^
+----------------
Similarly, triples can be removed by a call to :meth:`~rdflib.graph.Graph.remove`:
.. automethod:: rdflib.graph.Graph.remove
:noindex:
-When removing, it is possible to leave parts of the triple unspecified (i.e. passing ``None``), this will remove all matching triples::
+When removing, it is possible to leave parts of the triple unspecified (i.e. passing ``None``), this will remove all matching triples:
+
+.. code-block:: python
+
+ g.remove((bob, None, None)) # remove all triples about bob
- g.remove( (bob, None, None) ) # remove all triples about bob
An example
-^^^^^^^^^^
+----------
LiveJournal produces FOAF data for their users, but they seem to use
``foaf:member_name`` for a person's full name. To align with data from
@@ -124,5 +144,8 @@ for ``foaf:member_name`` (a poor man's one-way
from rdflib.namespace import FOAF
g.parse("http://danbri.livejournal.com/data/foaf")
- for s,_,n in g.triples((None, FOAF['member_name'], None)):
- g.add((s, FOAF['name'], n))
+ for s, p, o in g.triples((None, FOAF['member_name'], None)):
+ g.add((s, FOAF['name'], o))
+
+Note that since rdflib 5.0.0, using ``foaf:member_name`` is somewhat prevented in rdflib since FOAF is declared as a :meth:`~rdflib.namespace.ClosedNamespace`
+class instance that has a closed set of members and ``foaf:member_name`` isnt one of them! \ No newline at end of file
diff --git a/docs/intro_to_graphs.rst b/docs/intro_to_graphs.rst
index 0c76e6f4..aa0fecf3 100644
--- a/docs/intro_to_graphs.rst
+++ b/docs/intro_to_graphs.rst
@@ -4,7 +4,7 @@
Navigating Graphs
=================
-An RDF Graph is a set of RDF triples, and we try to mirror exactly this in RDFLib, and the graph tries to emulate a container type:
+An RDF Graph is a set of RDF triples, and we try to mirror exactly this in RDFLib. The Python :meth:`~rdflib.graph.Graph` tries to emulate a container type.
Graphs as Iterators
-------------------
@@ -13,25 +13,29 @@ RDFLib graphs override :meth:`~rdflib.graph.Graph.__iter__` in order to support
.. code-block:: python
- for subject,predicate,obj in someGraph:
- if not (subject,predicate,obj) in someGraph:
- raise Exception("Iterator / Container Protocols are Broken!!")
+ for subject, predicate, object in someGraph:
+ if not (subject, predicate, object) in someGraph:
+ raise Exception("Iterator / Container Protocols are Broken!!")
Contains check
--------------
-Graphs implement :meth:`~rdflib.graph.Graph.__contains__`, so you can check if a triple is in a graph with ``triple in graph`` syntax::
+Graphs implement :meth:`~rdflib.graph.Graph.__contains__`, so you can check if a triple is in a graph with ``triple in graph`` syntax:
- from rdflib import URIRef
- from rdflib.namespace import RDF
- bob = URIRef("http://example.org/people/bob")
- if ( bob, RDF.type, FOAF.Person ) in graph:
- print "This graph knows that Bob is a person!"
+.. code-block:: python
+
+ from rdflib import URIRef
+ from rdflib.namespace import RDF
+ bob = URIRef("http://example.org/people/bob")
+ if (bob, RDF.type, FOAF.Person) in graph:
+ print("This graph knows that Bob is a person!")
-Note that this triple does not have to be completely bound::
+Note that this triple does not have to be completely bound:
+
+.. code-block:: python
- if (bob, None, None) in graph:
- print "This graph contains triples about Bob!"
+ if (bob, None, None) in graph:
+ print("This graph contains triples about Bob!")
.. _graph-setops:
@@ -51,40 +55,41 @@ operation effect
``G1 ^ G2`` xor (triples in either G1 or G2, but not in both)
============ ==================================================
-.. warning:: Set-operations on graphs assume bnodes are shared between graphs. This may or may not do what you want. See :doc:`merging` for details.
+.. warning:: Set-operations on graphs assume Blank Nodes are shared between graphs. This may or may not do what you want. See :doc:`merging` for details.
Basic Triple Matching
---------------------
Instead of iterating through all triples, RDFLib graphs support basic triple pattern matching with a :meth:`~rdflib.graph.Graph.triples` function.
-This function is a generator of triples that match the pattern given by the arguments. The arguments of these are RDF terms that restrict the triples that are returned. Terms that are :data:`None` are treated as a wildcard. For example::
+This function is a generator of triples that match the pattern given by the arguments. The arguments of these are RDF terms that restrict the triples that are returned. Terms that are :data:`None` are treated as a wildcard. For example:
+.. code-block:: python
- g.load("some_foaf.rdf")
- for s,p,o in g.triples( (None, RDF.type, FOAF.Person) ):
- print "%s is a person"%s
-
- for s,p,o in g.triples( (None, RDF.type, None) ):
- print "%s is a %s"%(s,o)
-
- bobgraph = Graph()
+ g.load("some_foaf.rdf")
+ for s, p, o in g.triples((None, RDF.type, FOAF.Person)):
+ print("{} is a person".format(s))
- bobgraph += g.triples( (bob, None, None) )
+ for s, p, o in g.triples((None, RDF.type, None)):
+ print("{} is a {}".format(s, o))
-If you are not interested in whole triples, you can get only the bits you want with the methods :meth:`~rdflib.graph.Graph.objects`, :meth:`~rdflib.graph.Graph.subjects`, :meth:`~rdflib.graph.Graph.predicates`, :meth:`~rdflib.graph.Graph.predicate_objects`, etc. Each take parameters for the components of the triple to constraint::
+ bobgraph = Graph()
- for person in g.subjects(RDF.type, FOAF.Person):
- print "%s is a person"%person
+ bobgraph += g.triples((bob, None, None))
+If you are not interested in whole triples, you can get only the bits you want with the methods :meth:`~rdflib.graph.Graph.objects`, :meth:`~rdflib.graph.Graph.subjects`, :meth:`~rdflib.graph.Graph.predicates`, :meth:`~rdflib.graph.Graph.predicate_objects`, etc. Each take parameters for the components of the triple to constraint:
-Finally, for some properties, only one value per resource makes sense (i.e they are *functional properties*, or have max-cardinality of 1). The :meth:`~rdflib.graph.Graph.value` method is useful for this, as it returns just a single node, not a generator::
+.. code-block:: python
- name = g.value(bob, FOAF.name) # get any name of bob
- # get the one person that knows bob and raise an exception if more are found
- mbox = g.value(predicate = FOAF.name, object = bob, any = False)
+ for person in g.subjects(RDF.type, FOAF.Person):
+ print("{} is a person".format(person))
+Finally, for some properties, only one value per resource makes sense (i.e they are *functional properties*, or have max-cardinality of 1). The :meth:`~rdflib.graph.Graph.value` method is useful for this, as it returns just a single node, not a generator:
+.. code-block:: python
+ name = g.value(bob, FOAF.name) # get any name of bob
+ # get the one person that knows bob and raise an exception if more are found
+ mbox = g.value(predicate = FOAF.name, object=bob, any=False)
:class:`~rdflib.graph.Graph` methods for accessing triples
@@ -112,8 +117,3 @@ Here is a list of all convenience methods for querying Graphs:
:noindex:
.. automethod:: rdflib.graph.Graph.predicate_objects
:noindex:
-
-
-
-
-
diff --git a/docs/intro_to_parsing.rst b/docs/intro_to_parsing.rst
index fdf9a6bd..6dd16a3d 100644
--- a/docs/intro_to_parsing.rst
+++ b/docs/intro_to_parsing.rst
@@ -8,7 +8,7 @@ Reading an NT file
-------------------
RDF data has various syntaxes (``xml``, ``n3``, ``ntriples``,
-``trix``, etc) that you might want to read. The simplest format is
+``trix``, ``JSON-LD``, etc) that you might want to read. The simplest format is
``ntriples``, a line-based format. Create the file :file:`demo.nt` in
the current directory with these two lines:
@@ -24,14 +24,16 @@ either a mime-type or the name (a :doc:`list of available parsers
file will be, you can use :func:`rdflib.util.guess_format` which will
guess based on the file extension.
-In an interactive python interpreter, try this::
+In an interactive python interpreter, try this:
+
+.. code-block:: python
from rdflib import Graph
g = Graph()
g.parse("demo.nt", format="nt")
- len(g) # prints 2
+ print(len(g)) # prints 2
import pprint
for stmt in g:
@@ -40,7 +42,7 @@ In an interactive python interpreter, try this::
# prints :
(rdflib.term.URIRef('http://bigasterisk.com/foaf.rdf#drewp'),
rdflib.term.URIRef('http://example.com/says'),
- rdflib.term.Literal(u'Hello world'))
+ rdflib.term.Literal('Hello world'))
(rdflib.term.URIRef('http://bigasterisk.com/foaf.rdf#drewp'),
rdflib.term.URIRef('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'),
rdflib.term.URIRef('http://xmlns.com/foaf/0.1/Person'))
@@ -52,14 +54,16 @@ subjects, predicates, and objects are all rdflib types.
Reading remote graphs
---------------------
-Reading graphs from the net is just as easy::
+Reading graphs from the net is just as easy:
+
+.. code-block:: python
g.parse("http://bigasterisk.com/foaf.rdf")
- len(g)
+ print(len(g))
# prints 42
The format defaults to ``xml``, which is the common format for .rdf
files you'll find on the net.
RDFLib will also happily read RDF from any file-like object,
-i.e. anything with a ``.read`` method.
+i.e. anything with a ``.read()`` method.
diff --git a/docs/univrdfstore.rst b/docs/univrdfstore.rst
index a1c54e90..9187935b 100644
--- a/docs/univrdfstore.rst
+++ b/docs/univrdfstore.rst
@@ -6,9 +6,9 @@ A Universal RDF Store Interface
This document attempts to summarize some fundamental components of an RDF store. The motivation is to outline a standard set of interfaces for providing the support needed to persist an `RDF Graph`_ in a way that is universal and not tied to any specific implementation.
-For the most part, the interface adheres to the core RDF model and uses terminology that is consistent with the RDF Model specifications. However, this suggested interface also extends an RDF store with additional requirements necessary to facilitate those aspects of `Notation 3`_ that go beyond the RDF model to provide a framework for `First Order Predicate Logic`_ processing and persistence.
+For the most part, the interfaces adhere to the core RDF model and use terminology that is consistent with the RDF Model specifications. However, these suggested interfaces also extends an RDF store with additional requirements necessary to facilitate those aspects of `Notation 3`_ that go beyond the RDF model to provide a framework for `First Order Predicate Logic`_ processing and persistence.
-.. _RDF Graph: http://www.w3.org/TR/rdf-concepts/#dfn-rdf-graph
+.. _RDF Graph: https://www.w3.org/TR/rdf11-concepts/#data-model
.. _Notation 3: http://www.w3.org/2000/10/swap/Primer
.. _First Order Predicate Logic: http://en.wikipedia.org/wiki/First-order_predicate_logic
diff --git a/docs/upgrade2to3.rst b/docs/upgrade2to3.rst
deleted file mode 100644
index 4773c176..00000000
--- a/docs/upgrade2to3.rst
+++ /dev/null
@@ -1,60 +0,0 @@
-.. _upgrade2to3: Upgrading from RDFLib version 2.X to 3.X
-
-========================================
-Upgrading from RDFLib version 2.X to 3.X
-========================================
-
-Introduction
-============
-This page details the changes required to upgrade from RDFLib 2.X to 3.X.
-
-Some older Linux distributions still ship 2.4.X. If needed, you can also install 2.4 using easy_install/setup tools.
-
-Version 3.0 reorganised some packages, and moved non-core parts of rdflib to the `rdfextras project <http://code.google.com/p/rdfextras/>`_
-
-
-Features moved to rdfextras
-===========================
-
- * SPARQL Support is now in rdfextras / rdflib-sparql
- * The RDF Commandline tools are now in rdfextras
-
-.. warning:: If you install packages with just distutils - you will need to register the sparql plugins manually - we strongly recommend installing with setuptools or distribute!
- To register the plugins add this somewhere in your program:
-
- .. code-block:: python
-
- rdflib.plugin.register('sparql', rdflib.query.Processor,
- 'rdfextras.sparql.processor', 'Processor')
- rdflib.plugin.register('sparql', rdflib.query.Result,
- 'rdfextras.sparql.query', 'SPARQLQueryResult')
-
-
-Unstable features that were removed
-===================================
-
- The RDBMS back stores (MySQL/PostgreSQL) were removed, but are in the process of being moved to rdfextras. The Redland, SQLite and ZODB stores were all removed.
-
-Packages/Classes that were renamed
-==================================
-
-Previously all packages and classes had colliding names, i.e. both package and the class was called "Graph"::
-
- from rdflib.Graph import Graph, ConjunctiveGraph
-
-Now all packages are lower-case, i.e::
-
- from rdflib.graph import Graph, ConjunctiveGraph
-
-Most classes you need are available from the top level rdflib package::
-
- from rdflib import Graph, URIRef, BNode, Literal
-
-Namespace classes for RDF, RDFS, OWL are now directly in the rdflib package, i.e. in 2.4::
-
- from rdflib.RDF import RDFNS as RDF
-
-in 3.0::
-
- from rdflib import RDF
-
diff --git a/docs/upgrade3to4.rst b/docs/upgrade3to4.rst
deleted file mode 100644
index 574d129a..00000000
--- a/docs/upgrade3to4.rst
+++ /dev/null
@@ -1,92 +0,0 @@
-.. _upgrade3to4: Upgrading from RDFLib version 3.X to 4.X
-
-========================================
-Upgrading from RDFLib version 3.X to 4.X
-========================================
-
-RDFLib version 4.0 introduced a small number of backwards compatible changes that you should know about when porting code from version 3 or earlier.
-
-SPARQL and SPARQLStore are now included in core
------------------------------------------------
-
-For version 4.0 we've merged the SPARQL implementation from ``rdflib-sparql``, the SPARQL(Update)Store from ``rdflib-sparqlstore`` and miscellaneous utilities from ``rdfextras``. If you used any of these previously, everything you need should now be included.
-
-
-Datatyped literals
-------------------
-
-We separate lexical and value space operations for datatyped literals.
-
-This mainly affects the way datatyped literals are compared. Lexical space comparisons are done by default for ``==`` and ``!=``, meaning the exact lexical representation and the exact data-types have to match for literals to be equal. Value space comparisons are also available through the :meth:`rdflib.term.Identifier.eq` and :meth:`rdflib.term.Identifier.neq` methods, ``< > <= >=`` are also done in value space.
-
-Most things now work in a fairly sane and sensible way, if you do not have existing stores/intermediate stored sorted lists, or hash-dependent something-or-other, you should be good to go.
-
-Things to watch out for:
-
-Literals no longer compare equal across data-types with ```==```
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-i.e.
-
-.. code-block:: python
-
- >>> Literal(2, datatype=XSD.int) == Literal(2, datatype=XSD.float)
- False
-
-
-But a new method :meth:`rdflib.term.Identifier.eq` on all Nodes has been introduced, which does semantic equality checking, i.e.:
-
-.. code-block:: python
-
- >>> Literal(2, datatype=XSD.int).eq(Literal(2, datatype=XSD.float))
- True
-
-The ``eq`` method is still limited to what data-types map to the same *value space*, i.e. all numeric types map to numbers and will compare, ``xsd:string`` and ``plain literals`` both map to strings and compare fine, but:
-
-.. code-block:: python
-
- >>> Literal(2, datatype=XSD.int).eq(Literal('2'))
- False
-
-
-
-Literals will be normalised according to datatype
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-If you care about the exact lexical representation of a literal, and not just the value. Either set :data:`rdflib.NORMALIZE_LITERALS` to ``False`` before creating your literal, or pass ``normalize=False`` to the Literal constructor
-
-Ordering of literals and nodes has changed
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Comparing literals with ``<, >, <=, >=`` now work same as in SPARQL filter expressions.
-
-Greater-than/less-than ordering comparisons are also done in value space, when compatible datatypes are used.
-Incompatible datatypes are ordered by data-type, or by lang-tag.
-For other nodes the ordering is ``None < BNode < URIRef < Literal``
-
-Any comparison with non-rdflib Node are ``NotImplemented``
-In PY2.X some stable order will be made up by python.
-In PY3 this is an error.
-
-Custom mapping of datatypes to python objects
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-You can add new mappings of datatype URIs to python objects using the :func:`rdflib.term.bind` method.
-This also allows you to specify a constructor for constructing objects from the lexical string representation, and a serialization method for generating a lexical string representation from an object.
-
-
-
-Minor Changes
---------------
-
-* :class:`rdflib.namespace.Namespace` is no longer a sub-class of :class:`rdflib.term.URIRef`
- this was changed as it makes no sense for a namespace to be a node in a graph, and was causing numerous bug. Unless you do something very special, you should not notice this change.
-
-* The identifiers for Graphs are now converted to URIRefs if they are not a :class:`rdflib.term.Node`, i.e. no more graphs with string identifiers. Again, unless you do something quite unusual, you should not notice.
-
-* String concatenation with URIRefs now returns URIRefs, not strings::
-
- >>> URIRef("http://example.org/people/") + "Bill"
- rdflib.term.URIRef(u'http://example.org/people/Bill')
-
- This is be convenient, but may cause trouble if you expected a string.
diff --git a/rdflib/__init__.py b/rdflib/__init__.py
index 29cc681c..3256f12d 100644
--- a/rdflib/__init__.py
+++ b/rdflib/__init__.py
@@ -45,8 +45,8 @@ A tiny example:
__docformat__ = "restructuredtext en"
# The format of the __version__ line is matched by a regex in setup.py
-__version__ = "5.0.0-dev"
-__date__ = "2017/01/29"
+__version__ = "5.0.0"
+__date__ = "2020-04-03"
__all__ = [
'URIRef',
@@ -60,10 +60,9 @@ __all__ = [
'Graph',
'ConjunctiveGraph',
- 'RDF',
- 'RDFS',
- 'OWL',
- 'XSD',
+ 'CSVW', 'DC', 'DCAT', 'DCTERMS', 'DOAP', 'FOAF', 'ODRL2', 'ORG', 'OWL',
+ 'PROF', 'PROV', 'RDF', 'RDFS', 'SDO', 'SH', 'SKOS', 'SOSA', 'SSN', 'TIME',
+ 'VOID', 'XMLNS', 'XSD',
'util',
]
@@ -163,7 +162,9 @@ from rdflib.namespace import Namespace
from rdflib.graph import Dataset, Graph, ConjunctiveGraph
-from rdflib.namespace import RDF, RDFS, OWL, XSD
+from rdflib.namespace import CSVW, DC, DCAT, DCTERMS, DOAP, FOAF, ODRL2, ORG, OWL, \
+ PROF, PROV, RDF, RDFS, SDO, SH, SKOS, SOSA, SSN, TIME, \
+ VOID, XMLNS, XSD
from rdflib import plugin
from rdflib import query