diff options
author | Nicholas Car <nicholas.car@surroundaustralia.com> | 2020-04-22 12:42:58 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-22 12:42:58 +1000 |
commit | 88338195dc18de91c7122c025cc619951c876043 (patch) | |
tree | 96f9e9679320123ac94f2d3afd3957bf14b24a9a | |
parent | 7b9bc9dca5ab467759639a7be2f0219a78c97a67 (diff) | |
parent | 3f0401dc527ef70abb1f0b76bdd281972ae2655c (diff) | |
download | rdflib-88338195dc18de91c7122c025cc619951c876043.tar.gz |
Merge branch 'master' into namespaces_all
40 files changed, 917 insertions, 775 deletions
@@ -16,4 +16,5 @@ build/ *~ test_reports/*latest.ttl # PyCharm -.idea/
\ No newline at end of file +.idea/ +prepare_changelog.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index 06cdada7..a72b4d66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,223 @@ +2020/04/18 RELEASE 5.0.0 +======================== +5.0.0 is a major stable release and is the last release to support Python 2 & 3.4. 5.0.0 is mostly backwards- +compatible with 4.2.2 and is intended for long-term, bug fix only support. + +5.0.0 comes two weeks after the 5.0.0RC1 and includes a small number of additional bug fixes. Note that +rdflib-jsonld has released a version 0.5.0 to be compatible with rdflib 5.0.0. + +_**All PRs merged since 5.0.0RC1:**_ + +### General Bugs Fixed: + * Fix n3 parser exponent syntax of floats with leading dot. + [PR #1012](https://github.com/RDFLib/rdflib/pull/1012) + * FIX: Change is comparison to == for tuple + [PR #1009](https://github.com/RDFLib/rdflib/pull/1009) + * fix #913 : Added _parseBoolean function to enforce correct Lexical-to-value mapping + [PR #995](https://github.com/RDFLib/rdflib/pull/995) + +### Enhanced Features: + * Issue 1003 + [PR #1005](https://github.com/RDFLib/rdflib/pull/1005) + +### SPARQL Fixes: + * CONSTRUCT resolve with initBindings fixes #1001 + [PR #1002](https://github.com/RDFLib/rdflib/pull/1002) + +### Documentation Fixes: + * DOC: Use sphinxcontrib-apidoc and various cleanups + [PR #1010](https://github.com/RDFLib/rdflib/pull/1010) + * Update copyright year in docs conf.py + [PR #1006](https://github.com/RDFLib/rdflib/pull/1006) + * slightly improved styling, small index text changes + [PR #1004](https://github.com/RDFLib/rdflib/pull/1004) + + +2020/04/04 RELEASE 5.0.0RC1 +=========================== + +After more than three years, RDFLib 5.0.0rc1 is finally released. + +This is a rollup of all of the bugfixes merged, and features introduced to RDFLib since +RDFLib 4.2.2 was released in Jan 2017. + +While all effort was taken to minimize breaking changes in this release, there are some. + +Please see the upgrade4to5 document in the docs directory for more information on some specific differences from 4.2.2 to 5.0.0. + +_**All issues closed and PRs merged since 4.2.2:**_ + +### General Bugs Fixed: + * Pr 451 redux + [PR #978](https://github.com/RDFLib/rdflib/pull/978) + * NTriples fails to parse URIs with only a scheme + [ISSUE #920](https://github.com/RDFLib/rdflib/issues/920), [PR #974](https://github.com/RDFLib/rdflib/pull/974) + * Cannot clone on windows - Remove colons from test result files. + [ISSUE #901](https://github.com/RDFLib/rdflib/issues/901), [PR #971](https://github.com/RDFLib/rdflib/pull/971) + * Add requirement for requests to setup.py + [PR #969](https://github.com/RDFLib/rdflib/pull/969) + * fixed URIRef including native unicode characters + [PR #961](https://github.com/RDFLib/rdflib/pull/961) + * DCTERMS.format not working + [ISSUE #932](https://github.com/RDFLib/rdflib/issues/932) + * infixowl.manchesterSyntax do not encode strings + [PR #906](https://github.com/RDFLib/rdflib/pull/906) + * Fix blank node label to not contain '_:' during parsing + [PR #886](https://github.com/RDFLib/rdflib/pull/886) + * rename new SPARQLWrapper to SPARQLConnector + [PR #872](https://github.com/RDFLib/rdflib/pull/872) + * Fix #859. Unquote and Uriquote Literal Datatype. + [PR #860](https://github.com/RDFLib/rdflib/pull/860) + * Parsing nquads + [ISSUE #786](https://github.com/RDFLib/rdflib/issues/786) + * ntriples spec allows for upper-cased lang tag, fixes #782 + [PR #784](https://github.com/RDFLib/rdflib/pull/784), [ISSUE #782](https://github.com/RDFLib/rdflib/issues/782) + * Adds escaped single quote to literal parser + [PR #736](https://github.com/RDFLib/rdflib/pull/736) + * N3 parse error on single quote within single quotes + [ISSUE #732](https://github.com/RDFLib/rdflib/issues/732) + * Fixed #725 + [PR #730](https://github.com/RDFLib/rdflib/pull/730) + * test for issue #725: canonicalization collapses BNodes + [PR #726](https://github.com/RDFLib/rdflib/pull/726) + * RGDA1 graph canonicalization sometimes still collapses distinct BNodes + [ISSUE #725](https://github.com/RDFLib/rdflib/issues/725) + * Accept header should use a q parameter + [PR #720](https://github.com/RDFLib/rdflib/pull/720) + * Added test for Issue #682 and fixed. + [PR #718](https://github.com/RDFLib/rdflib/pull/718) + * Incompatibility with Python3: unichr + [ISSUE #687](https://github.com/RDFLib/rdflib/issues/687) + * namespace.py include colon in ALLOWED_NAME_CHARS + [PR #663](https://github.com/RDFLib/rdflib/pull/663) + * namespace.py fix compute_qname missing namespaces + [PR #649](https://github.com/RDFLib/rdflib/pull/649) + * RDFa parsing Error! `__init__()` got an unexpected keyword argument 'encoding' + [ISSUE #639](https://github.com/RDFLib/rdflib/issues/639) + * Bugfix: `term.Literal.__add__` + [PR #451](https://github.com/RDFLib/rdflib/pull/451) + * fixup of #443 + [PR #445](https://github.com/RDFLib/rdflib/pull/445) + * Microdata to rdf second edition bak + [PR #444](https://github.com/RDFLib/rdflib/pull/444) + +### Enhanced Features: + * Register additional serializer plugins for SPARQL mime types. + [PR #987](https://github.com/RDFLib/rdflib/pull/987) + * Pr 388 redux + [PR #979](https://github.com/RDFLib/rdflib/pull/979) + * Allows RDF terms introduced by JSON-LD 1.1 + [PR #970](https://github.com/RDFLib/rdflib/pull/970) + * make SPARQLConnector work with DBpedia + [PR #941](https://github.com/RDFLib/rdflib/pull/941) + * ClosedNamespace returns right exception for way of access + [PR #866](https://github.com/RDFLib/rdflib/pull/866) + * Not adding all namespaces for n3 serializer + [PR #832](https://github.com/RDFLib/rdflib/pull/832) + * Adds basic support of xsd:duration + [PR #808](https://github.com/RDFLib/rdflib/pull/808) + * Add possibility to set authority and basepath to skolemize graph + [PR #807](https://github.com/RDFLib/rdflib/pull/807) + * Change notation3 list realization to non-recursive function. + [PR #805](https://github.com/RDFLib/rdflib/pull/805) + * Suppress warning for not using custom encoding. + [PR #800](https://github.com/RDFLib/rdflib/pull/800) + * Add support to parsing large xml inputs + [ISSUE #749](https://github.com/RDFLib/rdflib/issues/749) + [PR #750](https://github.com/RDFLib/rdflib/pull/750) + * improve hash efficiency by directly using str/unicode hash + [PR #746](https://github.com/RDFLib/rdflib/pull/746) + * Added the csvw prefix to the RDFa initial context. + [PR #594](https://github.com/RDFLib/rdflib/pull/594) + * syncing changes from pyMicrodata + [PR #587](https://github.com/RDFLib/rdflib/pull/587) + * Microdata parser: updated the parser to the latest version of the microdata->rdf note (published in December 2014) + [PR #443](https://github.com/RDFLib/rdflib/pull/443) + * Literal.toPython() support for xsd:hexBinary + [PR #388](https://github.com/RDFLib/rdflib/pull/388) + +### SPARQL Fixes: + * Total order patch patch + [PR #862](https://github.com/RDFLib/rdflib/pull/862) + * use <<= instead of deprecated << + [PR #861](https://github.com/RDFLib/rdflib/pull/861) + * Fix #847 + [PR #856](https://github.com/RDFLib/rdflib/pull/856) + * RDF Literal `"1"^^xsd:boolean` should _not_ coerce to True + [ISSUE #847](https://github.com/RDFLib/rdflib/issues/847) + * Makes NOW() return an UTC date + [PR #844](https://github.com/RDFLib/rdflib/pull/844) + * NOW() SPARQL should return an xsd:dateTime with a timezone + [ISSUE #843](https://github.com/RDFLib/rdflib/issues/843) + * fix property paths bug: issue #715 + [PR #822](https://github.com/RDFLib/rdflib/pull/822), [ISSUE #715](https://github.com/RDFLib/rdflib/issues/715) + * MulPath: correct behaviour of n3() + [PR #820](https://github.com/RDFLib/rdflib/pull/820) + * Literal total ordering + [PR #793](https://github.com/RDFLib/rdflib/pull/793) + * Remove SPARQLWrapper dependency + [PR #744](https://github.com/RDFLib/rdflib/pull/744) + * made UNION faster by not preventing duplicates + [PR #741](https://github.com/RDFLib/rdflib/pull/741) + * added a hook to add custom functions to SPARQL + [PR #723](https://github.com/RDFLib/rdflib/pull/723) + * Issue714 + [PR #717](https://github.com/RDFLib/rdflib/pull/717) + * Use <<= instead of deprecated << in SPARQL parser + [PR #417](https://github.com/RDFLib/rdflib/pull/417) + * Custom FILTER function for SPARQL engine + [ISSUE #274](https://github.com/RDFLib/rdflib/issues/274) + +### Code Quality and Cleanups: + * a slightly opinionated autopep8 run + [PR #870](https://github.com/RDFLib/rdflib/pull/870) + * remove rdfa and microdata parsers from core RDFLib + [PR #828](https://github.com/RDFLib/rdflib/pull/828) + * ClosedNamespace KeyError -> AttributeError + [PR #827](https://github.com/RDFLib/rdflib/pull/827) + * typo in rdflib/plugins/sparql/update.py + [ISSUE #760](https://github.com/RDFLib/rdflib/issues/760) + * Fix logging in interactive mode + [PR #731](https://github.com/RDFLib/rdflib/pull/731) + * make namespace module flake8-compliant, change exceptions in that mod… + [PR #711](https://github.com/RDFLib/rdflib/pull/711) + * delete ez_setup.py? + [ISSUE #669](https://github.com/RDFLib/rdflib/issues/669) + * code duplication issue between rdflib and pymicrodata + [ISSUE #582](https://github.com/RDFLib/rdflib/issues/582) + * Transition from 2to3 to use of six.py to be merged in 5.0.0-dev + [PR #519](https://github.com/RDFLib/rdflib/pull/519) + * sparqlstore drop deprecated methods and args + [PR #516](https://github.com/RDFLib/rdflib/pull/516) + * python3 code seems shockingly inefficient + [ISSUE #440](https://github.com/RDFLib/rdflib/issues/440) + * removed md5_term_hash, fixes #240 + [PR #439](https://github.com/RDFLib/rdflib/pull/439), [ISSUE #240](https://github.com/RDFLib/rdflib/issues/240) + +### Testing: + * 3.7 for travis + [PR #864](https://github.com/RDFLib/rdflib/pull/864) + * Added trig unit tests to highlight some current parsing/serializing issues + [PR #431](https://github.com/RDFLib/rdflib/pull/431) + +### Documentation Fixes: + * Fix a doc string in the query module + [PR #976](https://github.com/RDFLib/rdflib/pull/976) + * setup.py: Make the license field use an SPDX identifier + [PR #789](https://github.com/RDFLib/rdflib/pull/789) + * Update README.md + [PR #764](https://github.com/RDFLib/rdflib/pull/764) + * Update namespaces_and_bindings.rst + [PR #757](https://github.com/RDFLib/rdflib/pull/757) + * DOC: README.md: rdflib-jsonld, https uris + [PR #712](https://github.com/RDFLib/rdflib/pull/712) + * make doctest support py2/py3 + [ISSUE #707](https://github.com/RDFLib/rdflib/issues/707) + * `pip install rdflib` (as per README.md) gets OSError on Mint 18.1 + [ISSUE #704](https://github.com/RDFLib/rdflib/issues/704) + + + 2017/01/29 RELEASE 4.2.2 ======================== @@ -1,3 +1,5 @@ +![](docs/_static/logo-rdflib.png) + RDFLib ====== [![Build Status](https://travis-ci.org/RDFLib/rdflib.png?branch=master)](https://travis-ci.org/RDFLib/rdflib) @@ -6,98 +8,160 @@ RDFLib [![PyPI](https://img.shields.io/pypi/v/rdflib.svg)](https://pypi.python.org/pypi/rdflib) [![PyPI](https://img.shields.io/pypi/pyversions/rdflib.svg)](https://pypi.python.org/pypi/rdflib) +RDFLib is a pure Python package work working with [RDF](http://www.w3.org/RDF/). RDFLib contains most things you need to work with RDF, including: + +* parsers and serializers for RDF/XML, N3, NTriples, N-Quads, Turtle, TriX, Trig and JSON-LD (via a plugin). +* a Graph interface which can be backed by any one of a number of Store implementations +* store implementations for in-memory storage and persistent storage on top of the Berkeley DB +* a SPARQL 1.1 implementation - supporting SPARQL 1.1 Queries and Update statements + +## RDFlib Family of packages +The RDFlib community maintains many RDF-related Python code repositories with different purposes. For example: + +* [rdflib](https://github.com/RDFLib/rdflib) - the rdflib core +* [sparqlwrapper](https://github.com/RDFLib/sparqlwrapper) - a simple Python wrapper around a SPARQL service to remotely execute your queries +* [pyLODE](https://github.com/RDFLib/pyLODE) - An OWL ontology documentation tool using Python and templating, based on LODE. +* [rdflib-jsonld](https://github.com/RDFLib/rdflib-jsonld) - an rdflib plugin that is an implementation of JSON-LD -RDFLib is a Python library for working with RDF, a simple yet -powerful language for representing information as graphs. +Please see the list for all packages/repositories here: -RDFLib may be installed with pip (use sudo as required): +* <https://github.com/RDFLib> + + +## Installation +RDFLib may be installed with Python's package management tool *pip*: $ pip install rdflib Alternatively manually download the package from the Python Package Index (PyPI) at https://pypi.python.org/pypi/rdflib -The current version of RDFLib is 4.2.2, see the ``CHANGELOG.md`` -file for what's new. +The current version of RDFLib is 5.0.0, see the ``CHANGELOG.md`` +file for what's new in this release. -Getting Started ---------------- +## Getting Started +RDFLib aims to be a pythonic RDF API. rdflib's main data object is a `Graph` which is a Python collection +of RDF *Subject, Predicate, Object* Triples: -RDFLib aims to be a pythonic RDF API, a Graph is a python collection -of RDF Subject,Predicate,Object Triples: +To create graph and load it with RDF data from DBPedia then print the results: ```python import rdflib -g=rdflib.Graph() +g = rdflib.Graph() g.load('http://dbpedia.org/resource/Semantic_Web') -for s,p,o in g: +for s, p, o in g: print(s, p, o) ``` - The components of the triples are URIs (resources) or Literals -(values), URIs are grouped together by *namespace*, common namespaces are +(values). + +URIs are grouped together by *namespace*, common namespaces are included in RDFLib: ```python - -semweb=rdflib.URIRef('http://dbpedia.org/resource/Semantic_Web') -type=g.value(semweb, rdflib.RDFS.label) +from rdflib.namespace import DC, DCTERMS, DOAP, FOAF, SKOS, OWL, RDF, RDFS, VOID, XMLNS, XSD ``` +You can use them like this: + +```python +semweb = rdflib.URIRef('http://dbpedia.org/resource/Semantic_Web') +type = g.value(semweb, rdflib.RDFS.label) +``` Where `rdflib.RDFS` is the RDFS Namespace, `graph.value` returns an object of the triple-pattern given (or an arbitrary one if more -exist). New Namespaces can also be defined: +exist). + +Or like this, adding a triple to a graph `g`: ```python +g.add(( + rdflib.URIRef("http://example.com/person/nick"), + FOAF.givenName, + rdflib.Literal("Nick", datatype=XSD.string) +)) +``` +The triple (in n-triples notation) `<http://example.com/person/nick> <http://xmlns.com/foaf/0.1/givenName> "Nick"^^<http://www.w3.org/2001/XMLSchema#string> .` +is created where the property `FOAF.giveName` is the URI `<http://xmlns.com/foaf/0.1/givenName>` and `XSD.string` is the +URI `<http://www.w3.org/2001/XMLSchema#string>`. -dbpedia=rdflib.Namespace('http://dbpedia.org/ontology/') +You can bind namespaces to prefixes to shorten the URIs for RDF/XML, Turtle, N3, TriG, TriX & JSON-LD serializations: -abstracts=list(x for x in g.objects(semweb, dbpedia['abstract']) if x.language=='en') + ```python +g.bind("foaf", FOAF) +g.bind("xsd", XSD) +``` +This will allow the n-triples triple above to be serialised like this: + ```python +print(g.serialize(format="turtle").decode("utf-8")) ``` -See also [./examples](./examples) +With these results: +```turtle +PREFIX foaf: <http://xmlns.com/foaf/0.1/> +PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> + +<http://example.com/person/nick> foaf:givenName "Nick"^^xsd:string . +``` + +New Namespaces can also be defined: + +```python +dbpedia = rdflib.Namespace('http://dbpedia.org/ontology/') +abstracts = list(x for x in g.objects(semweb, dbpedia['abstract']) if x.language=='en') +``` + +See also [./examples](./examples) -Features --------- +## Features The library contains parsers and serializers for RDF/XML, N3, -NTriples, N-Quads, Turtle, TriX, RDFa and Microdata. +NTriples, N-Quads, Turtle, TriX, RDFa and Microdata. JSON-LD parsing/serializing can be achieved using the +[JSON-LD plugin](https://github.com/RDFLib/rdflib-jsonld). The library presents a Graph interface which can be backed by any one of a number of Store implementations. This core RDFLib package includes store implementations for -in memory storage and persistent storage on top of the Berkeley DB. +in-memory storage and persistent storage on top of the Berkeley DB. A SPARQL 1.1 implementation is included - supporting SPARQL 1.1 Queries and Update statements. RDFLib is open source and is maintained on [GitHub](https://github.com/RDFLib/rdflib/). RDFLib releases, current and previous are listed on [PyPI](https://pypi.python.org/pypi/rdflib/) -RDFLib has a plugin-architecture for store-implementation, as well as parsers/serializers, several other projects exist which extend RDFLib features: +Multiple other projects are contained within the RDFlib "family", see <https://github.com/RDFLib/>. + + +## Documentation +See <https://rdflib.readthedocs.io> for our documentation built from the code. + + +## Support +For general "how do I..." queries, please use https://stackoverflow.com and tag your question with `rdflib`. +Existing questions: - * [rdflib-jsonld](https://github.com/RDFLib/rdflib-jsonld) - Serializer and parser for [json-ld](http://json-ld.org) +* <https://stackoverflow.com/questions/tagged/rdflib> -Support -------- -More information is available on the project webpage: +## Releases +See <https://rdflib.dev> for the release schedule. -https://github.com/RDFLib/rdflib/ -The documentation can be built by doing:: +## Contributing +rdflib survives and grows via user contributions! Please consider lodging Pull Requests here: - $ python setup.py build_sphinx +* <https://github.com/RDFLib/rdflib/pulls> -And is also available from ReadTheDocs: +You can also raise issues here: -https://rdflib.readthedocs.io +* <https://github.com/RDFLib/rdflib/issues> -Support is available through the rdflib-dev group: -https://groups.google.com/group/rdflib-dev +## Contacts +If you want to contact the rdflib maintainers, please do so via the rdflib-dev mailing list: -and on the IRC channel #rdflib on the freenode.net server +* <https://groups.google.com/group/rdflib-dev> diff --git a/docs/_themes/armstrong/static/rtd.css_t b/docs/_themes/armstrong/static/rtd.css_t index f5f08642..489911a2 100644 --- a/docs/_themes/armstrong/static/rtd.css_t +++ b/docs/_themes/armstrong/static/rtd.css_t @@ -66,6 +66,9 @@ div.documentwrapper { background-color: {{ theme_light_color }}; } +p.logo { + padding-top: 30px; +} /* HEADINGS --------------------------------------------------------------- */ diff --git a/docs/apidocs/.gitignore b/docs/apidocs/.gitignore new file mode 100644 index 00000000..89867378 --- /dev/null +++ b/docs/apidocs/.gitignore @@ -0,0 +1,2 @@ +modules.rst +rdflib*.rst diff --git a/docs/apidocs/modules.rst b/docs/apidocs/modules.rst deleted file mode 100644 index 0b1fa9e2..00000000 --- a/docs/apidocs/modules.rst +++ /dev/null @@ -1,7 +0,0 @@ -rdflib -====== - -.. toctree:: - :maxdepth: 10 - - rdflib diff --git a/docs/apidocs/rdflib.extras.rst b/docs/apidocs/rdflib.extras.rst deleted file mode 100644 index 7cd472bb..00000000 --- a/docs/apidocs/rdflib.extras.rst +++ /dev/null @@ -1,46 +0,0 @@ -rdflib.extras package -===================== - -Submodules ----------- - -rdflib.extras.cmdlineutils module ---------------------------------- - -.. automodule:: rdflib.extras.cmdlineutils - :members: - :undoc-members: - :show-inheritance: - -rdflib.extras.describer module ------------------------------- - -.. automodule:: rdflib.extras.describer - :members: - :undoc-members: - :show-inheritance: - -rdflib.extras.external\_graph\_libs module ------------------------------------------- - -.. automodule:: rdflib.extras.external_graph_libs - :members: - :undoc-members: - :show-inheritance: - -rdflib.extras.infixowl module ------------------------------ - -.. automodule:: rdflib.extras.infixowl - :members: - :undoc-members: - :show-inheritance: - - -Module contents ---------------- - -.. automodule:: rdflib.extras - :members: - :undoc-members: - :show-inheritance: diff --git a/docs/apidocs/rdflib.plugins.parsers.rst b/docs/apidocs/rdflib.plugins.parsers.rst deleted file mode 100644 index e3ba5ff3..00000000 --- a/docs/apidocs/rdflib.plugins.parsers.rst +++ /dev/null @@ -1,70 +0,0 @@ -rdflib.plugins.parsers package -============================== - -Submodules ----------- - -rdflib.plugins.parsers.notation3 module ---------------------------------------- - -.. automodule:: rdflib.plugins.parsers.notation3 - :members: - :undoc-members: - :show-inheritance: - -rdflib.plugins.parsers.nquads module ------------------------------------- - -.. automodule:: rdflib.plugins.parsers.nquads - :members: - :undoc-members: - :show-inheritance: - -rdflib.plugins.parsers.nt module --------------------------------- - -.. automodule:: rdflib.plugins.parsers.nt - :members: - :undoc-members: - :show-inheritance: - -rdflib.plugins.parsers.ntriples module --------------------------------------- - -.. automodule:: rdflib.plugins.parsers.ntriples - :members: - :undoc-members: - :show-inheritance: - -rdflib.plugins.parsers.rdfxml module ------------------------------------- - -.. automodule:: rdflib.plugins.parsers.rdfxml - :members: - :undoc-members: - :show-inheritance: - -rdflib.plugins.parsers.trig module ----------------------------------- - -.. automodule:: rdflib.plugins.parsers.trig - :members: - :undoc-members: - :show-inheritance: - -rdflib.plugins.parsers.trix module ----------------------------------- - -.. automodule:: rdflib.plugins.parsers.trix - :members: - :undoc-members: - :show-inheritance: - - -Module contents ---------------- - -.. automodule:: rdflib.plugins.parsers - :members: - :undoc-members: - :show-inheritance: diff --git a/docs/apidocs/rdflib.plugins.rst b/docs/apidocs/rdflib.plugins.rst deleted file mode 100644 index aa93c1bd..00000000 --- a/docs/apidocs/rdflib.plugins.rst +++ /dev/null @@ -1,40 +0,0 @@ -rdflib.plugins package -====================== - -Subpackages ------------ - -.. toctree:: - - rdflib.plugins.parsers - rdflib.plugins.serializers - rdflib.plugins.sparql - rdflib.plugins.stores - -Submodules ----------- - -rdflib.plugins.memory module ----------------------------- - -.. automodule:: rdflib.plugins.memory - :members: - :undoc-members: - :show-inheritance: - -rdflib.plugins.sleepycat module -------------------------------- - -.. automodule:: rdflib.plugins.sleepycat - :members: - :undoc-members: - :show-inheritance: - - -Module contents ---------------- - -.. automodule:: rdflib.plugins - :members: - :undoc-members: - :show-inheritance: diff --git a/docs/apidocs/rdflib.plugins.serializers.rst b/docs/apidocs/rdflib.plugins.serializers.rst deleted file mode 100644 index c5ce952c..00000000 --- a/docs/apidocs/rdflib.plugins.serializers.rst +++ /dev/null @@ -1,78 +0,0 @@ -rdflib.plugins.serializers package -================================== - -Submodules ----------- - -rdflib.plugins.serializers.n3 module ------------------------------------- - -.. automodule:: rdflib.plugins.serializers.n3 - :members: - :undoc-members: - :show-inheritance: - -rdflib.plugins.serializers.nquads module ----------------------------------------- - -.. automodule:: rdflib.plugins.serializers.nquads - :members: - :undoc-members: - :show-inheritance: - -rdflib.plugins.serializers.nt module ------------------------------------- - -.. automodule:: rdflib.plugins.serializers.nt - :members: - :undoc-members: - :show-inheritance: - -rdflib.plugins.serializers.rdfxml module ----------------------------------------- - -.. automodule:: rdflib.plugins.serializers.rdfxml - :members: - :undoc-members: - :show-inheritance: - -rdflib.plugins.serializers.trig module --------------------------------------- - -.. automodule:: rdflib.plugins.serializers.trig - :members: - :undoc-members: - :show-inheritance: - -rdflib.plugins.serializers.trix module --------------------------------------- - -.. automodule:: rdflib.plugins.serializers.trix - :members: - :undoc-members: - :show-inheritance: - -rdflib.plugins.serializers.turtle module ----------------------------------------- - -.. automodule:: rdflib.plugins.serializers.turtle - :members: - :undoc-members: - :show-inheritance: - -rdflib.plugins.serializers.xmlwriter module -------------------------------------------- - -.. automodule:: rdflib.plugins.serializers.xmlwriter - :members: - :undoc-members: - :show-inheritance: - - -Module contents ---------------- - -.. automodule:: rdflib.plugins.serializers - :members: - :undoc-members: - :show-inheritance: diff --git a/docs/apidocs/rdflib.plugins.sparql.results.rst b/docs/apidocs/rdflib.plugins.sparql.results.rst deleted file mode 100644 index b9ff9310..00000000 --- a/docs/apidocs/rdflib.plugins.sparql.results.rst +++ /dev/null @@ -1,70 +0,0 @@ -rdflib.plugins.sparql.results package -===================================== - -Submodules ----------- - -rdflib.plugins.sparql.results.csvresults module ------------------------------------------------ - -.. automodule:: rdflib.plugins.sparql.results.csvresults - :members: - :undoc-members: - :show-inheritance: - -rdflib.plugins.sparql.results.graph module ------------------------------------------- - -.. automodule:: rdflib.plugins.sparql.results.graph - :members: - :undoc-members: - :show-inheritance: - -rdflib.plugins.sparql.results.jsonresults module ------------------------------------------------- - -.. automodule:: rdflib.plugins.sparql.results.jsonresults - :members: - :undoc-members: - :show-inheritance: - -rdflib.plugins.sparql.results.rdfresults module ------------------------------------------------ - -.. automodule:: rdflib.plugins.sparql.results.rdfresults - :members: - :undoc-members: - :show-inheritance: - -rdflib.plugins.sparql.results.tsvresults module ------------------------------------------------ - -.. automodule:: rdflib.plugins.sparql.results.tsvresults - :members: - :undoc-members: - :show-inheritance: - -rdflib.plugins.sparql.results.txtresults module ------------------------------------------------ - -.. automodule:: rdflib.plugins.sparql.results.txtresults - :members: - :undoc-members: - :show-inheritance: - -rdflib.plugins.sparql.results.xmlresults module ------------------------------------------------ - -.. automodule:: rdflib.plugins.sparql.results.xmlresults - :members: - :undoc-members: - :show-inheritance: - - -Module contents ---------------- - -.. automodule:: rdflib.plugins.sparql.results - :members: - :undoc-members: - :show-inheritance: diff --git a/docs/apidocs/rdflib.plugins.sparql.rst b/docs/apidocs/rdflib.plugins.sparql.rst deleted file mode 100644 index 768f4a1d..00000000 --- a/docs/apidocs/rdflib.plugins.sparql.rst +++ /dev/null @@ -1,109 +0,0 @@ -rdflib.plugins.sparql package -============================= - -Subpackages ------------ - -.. toctree:: - - rdflib.plugins.sparql.results - -Submodules ----------- - -rdflib.plugins.sparql.aggregates module ---------------------------------------- - -.. automodule:: rdflib.plugins.sparql.aggregates - :members: - :undoc-members: - :show-inheritance: - -rdflib.plugins.sparql.algebra module ------------------------------------- - -.. automodule:: rdflib.plugins.sparql.algebra - :members: - :undoc-members: - :show-inheritance: - -rdflib.plugins.sparql.datatypes module --------------------------------------- - -.. automodule:: rdflib.plugins.sparql.datatypes - :members: - :undoc-members: - :show-inheritance: - -rdflib.plugins.sparql.evaluate module -------------------------------------- - -.. automodule:: rdflib.plugins.sparql.evaluate - :members: - :undoc-members: - :show-inheritance: - -rdflib.plugins.sparql.evalutils module --------------------------------------- - -.. automodule:: rdflib.plugins.sparql.evalutils - :members: - :undoc-members: - :show-inheritance: - -rdflib.plugins.sparql.operators module --------------------------------------- - -.. automodule:: rdflib.plugins.sparql.operators - :members: - :undoc-members: - :show-inheritance: - -rdflib.plugins.sparql.parser module ------------------------------------ - -.. automodule:: rdflib.plugins.sparql.parser - :members: - :undoc-members: - :show-inheritance: - -rdflib.plugins.sparql.parserutils module ----------------------------------------- - -.. automodule:: rdflib.plugins.sparql.parserutils - :members: - :undoc-members: - :show-inheritance: - -rdflib.plugins.sparql.processor module --------------------------------------- - -.. automodule:: rdflib.plugins.sparql.processor - :members: - :undoc-members: - :show-inheritance: - -rdflib.plugins.sparql.sparql module ------------------------------------ - -.. automodule:: rdflib.plugins.sparql.sparql - :members: - :undoc-members: - :show-inheritance: - -rdflib.plugins.sparql.update module ------------------------------------ - -.. automodule:: rdflib.plugins.sparql.update - :members: - :undoc-members: - :show-inheritance: - - -Module contents ---------------- - -.. automodule:: rdflib.plugins.sparql - :members: - :undoc-members: - :show-inheritance: diff --git a/docs/apidocs/rdflib.plugins.stores.rst b/docs/apidocs/rdflib.plugins.stores.rst deleted file mode 100644 index 7367f47b..00000000 --- a/docs/apidocs/rdflib.plugins.stores.rst +++ /dev/null @@ -1,54 +0,0 @@ -rdflib.plugins.stores package -============================= - -Submodules ----------- - -rdflib.plugins.stores.auditable module --------------------------------------- - -.. automodule:: rdflib.plugins.stores.auditable - :members: - :undoc-members: - :show-inheritance: - -rdflib.plugins.stores.concurrent module ---------------------------------------- - -.. automodule:: rdflib.plugins.stores.concurrent - :members: - :undoc-members: - :show-inheritance: - -rdflib.plugins.stores.regexmatching module ------------------------------------------- - -.. automodule:: rdflib.plugins.stores.regexmatching - :members: - :undoc-members: - :show-inheritance: - -rdflib.plugins.stores.sparqlconnector module --------------------------------------------- - -.. automodule:: rdflib.plugins.stores.sparqlconnector - :members: - :undoc-members: - :show-inheritance: - -rdflib.plugins.stores.sparqlstore module ----------------------------------------- - -.. automodule:: rdflib.plugins.stores.sparqlstore - :members: - :undoc-members: - :show-inheritance: - - -Module contents ---------------- - -.. automodule:: rdflib.plugins.stores - :members: - :undoc-members: - :show-inheritance: diff --git a/docs/apidocs/rdflib.rst b/docs/apidocs/rdflib.rst deleted file mode 100644 index 99fa6132..00000000 --- a/docs/apidocs/rdflib.rst +++ /dev/null @@ -1,159 +0,0 @@ -rdflib package -============== - -Subpackages ------------ - -.. toctree:: - - rdflib.extras - rdflib.plugins - rdflib.tools - -Submodules ----------- - -rdflib.collection module ------------------------- - -.. automodule:: rdflib.collection - :members: - :undoc-members: - :show-inheritance: - -rdflib.compare module ---------------------- - -.. automodule:: rdflib.compare - :members: - :undoc-members: - :show-inheritance: - -rdflib.compat module --------------------- - -.. automodule:: rdflib.compat - :members: - :undoc-members: - :show-inheritance: - -rdflib.events module --------------------- - -.. automodule:: rdflib.events - :members: - :undoc-members: - :show-inheritance: - -rdflib.exceptions module ------------------------- - -.. automodule:: rdflib.exceptions - :members: - :undoc-members: - :show-inheritance: - -rdflib.graph module -------------------- - -.. automodule:: rdflib.graph - :members: - :undoc-members: - :show-inheritance: - -rdflib.namespace module ------------------------ - -.. automodule:: rdflib.namespace - :members: - :undoc-members: - :show-inheritance: - -rdflib.parser module --------------------- - -.. automodule:: rdflib.parser - :members: - :undoc-members: - :show-inheritance: - -rdflib.paths module -------------------- - -.. automodule:: rdflib.paths - :members: - :undoc-members: - :show-inheritance: - -rdflib.plugin module --------------------- - -.. automodule:: rdflib.plugin - :members: - :undoc-members: - :show-inheritance: - -rdflib.query module -------------------- - -.. automodule:: rdflib.query - :members: - :undoc-members: - :show-inheritance: - -rdflib.resource module ----------------------- - -.. automodule:: rdflib.resource - :members: - :undoc-members: - :show-inheritance: - -rdflib.serializer module ------------------------- - -.. automodule:: rdflib.serializer - :members: - :undoc-members: - :show-inheritance: - -rdflib.store module -------------------- - -.. automodule:: rdflib.store - :members: - :undoc-members: - :show-inheritance: - -rdflib.term module ------------------- - -.. automodule:: rdflib.term - :members: - :undoc-members: - :show-inheritance: - -rdflib.util module ------------------- - -.. automodule:: rdflib.util - :members: - :undoc-members: - :show-inheritance: - -rdflib.void module ------------------- - -.. automodule:: rdflib.void - :members: - :undoc-members: - :show-inheritance: - - -Module contents ---------------- - -.. automodule:: rdflib - :members: - :undoc-members: - :show-inheritance: diff --git a/docs/apidocs/rdflib.tools.rst b/docs/apidocs/rdflib.tools.rst deleted file mode 100644 index eaf8edf8..00000000 --- a/docs/apidocs/rdflib.tools.rst +++ /dev/null @@ -1,54 +0,0 @@ -rdflib.tools package -==================== - -Submodules ----------- - -rdflib.tools.csv2rdf module ---------------------------- - -.. automodule:: rdflib.tools.csv2rdf - :members: - :undoc-members: - :show-inheritance: - -rdflib.tools.graphisomorphism module ------------------------------------- - -.. automodule:: rdflib.tools.graphisomorphism - :members: - :undoc-members: - :show-inheritance: - -rdflib.tools.rdf2dot module ---------------------------- - -.. automodule:: rdflib.tools.rdf2dot - :members: - :undoc-members: - :show-inheritance: - -rdflib.tools.rdfpipe module ---------------------------- - -.. automodule:: rdflib.tools.rdfpipe - :members: - :undoc-members: - :show-inheritance: - -rdflib.tools.rdfs2dot module ----------------------------- - -.. automodule:: rdflib.tools.rdfs2dot - :members: - :undoc-members: - :show-inheritance: - - -Module contents ---------------- - -.. automodule:: rdflib.tools - :members: - :undoc-members: - :show-inheritance: diff --git a/docs/conf.py b/docs/conf.py index 0e0d56ef..76f893fb 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -27,6 +27,7 @@ sys.path.append(os.path.abspath("..")) # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. # extensions = ['sphinx.ext.autodoc', 'sphinx.ext.todo', 'sphinx.ext.doctest'] extensions = [ + "sphinxcontrib.apidoc", "sphinx.ext.autodoc", #'sphinx.ext.autosummary', "sphinx.ext.doctest", @@ -37,7 +38,9 @@ extensions = [ "sphinx.ext.viewcode", ] -autodoc_default_flags = ["special-members"] +apidoc_module_dir = "../rdflib" +apidoc_output_dir = "apidocs" +autodoc_default_options = {"special-members": True} autosummary_generate = True @@ -48,7 +51,6 @@ templates_path = ["_templates"] # '/_static/api/': [r'rdflib\.'], # } - # The suffix of source filenames. source_suffix = ".rst" @@ -60,12 +62,13 @@ master_doc = "index" # General information about the project. project = u"rdflib" -copyright = u"2009 - 2013, RDFLib Team" +copyright = u"2009 - 2020, 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 # built documents. + # Find version. We have to do this because we can't import it in Python 3 until # its been automatically converted in the setup process. def find_version(filename): @@ -231,7 +234,9 @@ latex_documents = [ # Example configuration for intersphinx: refer to the Python standard library. intersphinx_mapping = { - "python": ("http://docs.python.org/3.7", None), + "python": ("https://docs.python.org/3.7", None), } html_experimental_html5_writer = True + +needs_sphinx = "2.4" diff --git a/docs/index.rst b/docs/index.rst index 3f604729..a76ef159 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -19,7 +19,7 @@ working with RDF, including: * **Graph interface** * to a single graph - * or a conjunctive graph (multiple named graphs) + * or a conjunctive graph (multiple Named Graphs) * or a dataset of graphs * **SPARQL 1.1 implementation** @@ -100,7 +100,9 @@ and related packaged that you might also find useful. Further help ------------ +------------ +For asynchronous chat support, try our gitter channel at `<https://gitter.im/RDFLib/rdflib>`__ + 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: diff --git a/docs/intro_to_creating_rdf.rst b/docs/intro_to_creating_rdf.rst index 3d279f99..d676a5d5 100644 --- a/docs/intro_to_creating_rdf.rst +++ b/docs/intro_to_creating_rdf.rst @@ -12,7 +12,7 @@ represented by the classes :class:`~rdflib.term.URIRef`, :class:`~rdflib.term.BN ``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. +* 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... @@ -148,4 +148,4 @@ for ``foaf:member_name`` (a poor man's one-way 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 +class instance that has a closed set of members and ``foaf:member_name`` isnt one of them! diff --git a/docs/intro_to_sparql.rst b/docs/intro_to_sparql.rst index 31d1e7fa..5ab34287 100644 --- a/docs/intro_to_sparql.rst +++ b/docs/intro_to_sparql.rst @@ -65,7 +65,7 @@ equivalent. As an alternative to using ``PREFIX`` in the SPARQL query, namespace bindings can be passed in with the ``initNs`` kwarg, see -:doc:`namespace_and_bindings`. +:doc:`namespaces_and_bindings`. Variables can also be pre-bound, using ``initBindings`` kwarg can be used to pass in a ``dict`` of initial bindings, this is particularly diff --git a/docs/sphinx-requirements.txt b/docs/sphinx-requirements.txt index e69de29b..55809050 100644 --- a/docs/sphinx-requirements.txt +++ b/docs/sphinx-requirements.txt @@ -0,0 +1,3 @@ +sphinx==3.0.2 +sphinxcontrib-apidoc +git+https://github.com/gniezen/n3pygments.git diff --git a/docs/univrdfstore.rst b/docs/univrdfstore.rst index 6d722724..f6822e5b 100644 --- a/docs/univrdfstore.rst +++ b/docs/univrdfstore.rst @@ -200,6 +200,7 @@ Triple Interfaces An RDF store could provide a standard set of interfaces for the manipulation, management, and/or retrieval of its contained triples (asserted or quoted): .. module:: rdflib.store + :noindex: .. automethod:: rdflib.store.Store.add :noindex: diff --git a/docs/upgrade4to5.rst b/docs/upgrade4to5.rst index 2eb9239d..8916ab35 100644 --- a/docs/upgrade4to5.rst +++ b/docs/upgrade4to5.rst @@ -9,13 +9,258 @@ RDFLib version 5.0.0 appeared over 3 years after the previous release, 4.2.2 and Major Changes ------------- -Paragraphs of explanation -Minor heading +Literal Ordering +^^^^^^^^^^^^^^^^ +Literal total ordering `PR #793 <https://github.com/RDFLib/rdflib/pull/793>`_ is implemented. That means all literals can now be compared to be greater than or less than any other literal. +This is required for implementing some specific SPARQL features, but it is counter-intuitive to those who are expecting a TypeError when certain normally-incompatible types are compared. +For example, comparing a ``Literal(int(1), datatype=xsd:integer)`` to ``Literal(datetime.date(10,01,2020), datatype=xsd:date)`` using a ``>`` or ``<`` operator in rdflib 4.2.2 and earlier, would normally throw a TypeError, +however in rdflib 5.0.0 this operation now returns a True or False according to the Literal Total Ordering according the rules outlined in `PR #793 <https://github.com/RDFLib/rdflib/pull/793>`_ + +Removed RDF Parsers +^^^^^^^^^^^^^^^^^^^ +The RDFa and Microdata format RDF parsers were removed from rdflib. There are still other python libraries available to implement these parsers. + +All Changes +----------- + +This list has been assembled from Pull Request and commit information. + +General Bugs Fixed: +^^^^^^^^^^^^^^^^^^^ +* Pr 451 redux + `PR #978 <https://github.com/RDFLib/rdflib/pull/978>`_ +* NTriples fails to parse URIs with only a scheme + `ISSUE #920 <https://github.com/RDFLib/rdflib/issues/920>`_ + `PR #974 <https://github.com/RDFLib/rdflib/pull/974>`_ +* cannot clone it on windows - Remove colons from test result files. Fix #901. + `ISSUE #901 <https://github.com/RDFLib/rdflib/issues/901>`_ + `PR #971 <https://github.com/RDFLib/rdflib/pull/971>`_ +* Add requirement for requests to setup.py + `PR #969 <https://github.com/RDFLib/rdflib/pull/969>`_ +* fixed URIRef including native unicode characters + `PR #961 <https://github.com/RDFLib/rdflib/pull/961>`_ +* DCTERMS.format not working + `ISSUE #932 <https://github.com/RDFLib/rdflib/issues/932>`_ +* infixowl.manchesterSyntax do not encode strings + `PR #906 <https://github.com/RDFLib/rdflib/pull/906>`_ +* Fix blank node label to not contain '_:' during parsing + `PR #886 <https://github.com/RDFLib/rdflib/pull/886>`_ +* rename new SPARQLWrapper to SPARQLConnector + `PR #872 <https://github.com/RDFLib/rdflib/pull/872>`_ +* Fix #859. Unquote and Uriquote Literal Datatype. + `PR #860 <https://github.com/RDFLib/rdflib/pull/860>`_ +* Parsing nquads + `ISSUE #786 <https://github.com/RDFLib/rdflib/issues/786>`_ +* ntriples spec allows for upper-cased lang tag, fixes #782 + `PR #784 <https://github.com/RDFLib/rdflib/pull/784>`_ +* Error parsing N-Triple file using RDFlib + `ISSUE #782 <https://github.com/RDFLib/rdflib/issues/782>`_ +* Adds escaped single quote to literal parser + `PR #736 <https://github.com/RDFLib/rdflib/pull/736>`_ +* N3 parse error on single quote within single quotes + `ISSUE #732 <https://github.com/RDFLib/rdflib/issues/732>`_ +* Fixed #725 + `PR #730 <https://github.com/RDFLib/rdflib/pull/730>`_ +* test for issue #725: canonicalization collapses BNodes + `PR #726 <https://github.com/RDFLib/rdflib/pull/726>`_ +* RGDA1 graph canonicalization sometimes still collapses distinct BNodes + `ISSUE #725 <https://github.com/RDFLib/rdflib/issues/725>`_ +* Accept header should use a q parameter + `PR #720 <https://github.com/RDFLib/rdflib/pull/720>`_ +* Added test for Issue #682 and fixed. + `PR #718 <https://github.com/RDFLib/rdflib/pull/718>`_ +* Incompatibility with Python3: unichr + `ISSUE #687 <https://github.com/RDFLib/rdflib/issues/687>`_ +* namespace.py include colon in ALLOWED_NAME_CHARS + `PR #663 <https://github.com/RDFLib/rdflib/pull/663>`_ +* namespace.py fix compute_qname missing namespaces + `PR #649 <https://github.com/RDFLib/rdflib/pull/649>`_ +* RDFa parsing Error! `__init__()` got an unexpected keyword argument 'encoding' + `ISSUE #639 <https://github.com/RDFLib/rdflib/issues/639>`_ +* Bugfix: `term.Literal.__add__` + `PR #451 <https://github.com/RDFLib/rdflib/pull/451>`_ +* fixup of #443 + `PR #445 <https://github.com/RDFLib/rdflib/pull/445>`_ +* Microdata to rdf second edition bak + `PR #444 <https://github.com/RDFLib/rdflib/pull/444>`_ + +Enhanced Features: +^^^^^^^^^^^^^^^^^^ +* Register additional serializer plugins for SPARQL mime types. + `PR #987 <https://github.com/RDFLib/rdflib/pull/987>`_ +* Pr 388 redux + `PR #979 <https://github.com/RDFLib/rdflib/pull/979>`_ +* Allows RDF terms introduced by JSON-LD 1.1 + `PR #970 <https://github.com/RDFLib/rdflib/pull/970>`_ +* make SPARQLConnector work with DBpedia + `PR #941 <https://github.com/RDFLib/rdflib/pull/941>`_ +* ClosedNamespace returns right exception for way of access + `PR #866 <https://github.com/RDFLib/rdflib/pull/866>`_ +* Not adding all namespaces for n3 serializer + `PR #832 <https://github.com/RDFLib/rdflib/pull/832>`_ +* Adds basic support of xsd:duration + `PR #808 <https://github.com/RDFLib/rdflib/pull/808>`_ +* Add possibility to set authority and basepath to skolemize graph + `PR #807 <https://github.com/RDFLib/rdflib/pull/807>`_ +* Change notation3 list realization to non-recursive function. + `PR #805 <https://github.com/RDFLib/rdflib/pull/805>`_ +* Suppress warning for not using custom encoding. + `PR #800 <https://github.com/RDFLib/rdflib/pull/800>`_ +* Add support to parsing large xml inputs + `ISSUE #749 <https://github.com/RDFLib/rdflib/issues/749>`_ + `PR #750 <https://github.com/RDFLib/rdflib/pull/750>`_ +* improve hash efficiency by directly using str/unicode hash + `PR #746 <https://github.com/RDFLib/rdflib/pull/746>`_ +* Added the csvw prefix to the RDFa initial context. + `PR #594 <https://github.com/RDFLib/rdflib/pull/594>`_ +* syncing changes from pyMicrodata + `PR #587 <https://github.com/RDFLib/rdflib/pull/587>`_ +* Microdata parser: updated the parser to the latest version of the microdata->rdf note (published in December 2014) + `PR #443 <https://github.com/RDFLib/rdflib/pull/443>`_ +* Literal.toPython() support for xsd:hexBinary + `PR #388 <https://github.com/RDFLib/rdflib/pull/388>`_ + +SPARQL Fixes: ^^^^^^^^^^^^^ -Paragraphs of explanation +* Total order patch patch + `PR #862 <https://github.com/RDFLib/rdflib/pull/862>`_ +* use <<= instead of deprecated << + `PR #861 <https://github.com/RDFLib/rdflib/pull/861>`_ +* Fix #847 + `PR #856 <https://github.com/RDFLib/rdflib/pull/856>`_ +* RDF Literal "1"^^xsd:boolean should _not_ coerce to True + `ISSUE #847 <https://github.com/RDFLib/rdflib/issues/847>`_ +* Makes NOW() return an UTC date + `PR #844 <https://github.com/RDFLib/rdflib/pull/844>`_ +* NOW() SPARQL should return an xsd:dateTime with a timezone + `ISSUE #843 <https://github.com/RDFLib/rdflib/issues/843>`_ +* fix property paths bug: issue #715 + `PR #822 <https://github.com/RDFLib/rdflib/pull/822>`_ + `ISSUE #715 <https://github.com/RDFLib/rdflib/issues/715>`_ +* MulPath: correct behaviour of n3() + `PR #820 <https://github.com/RDFLib/rdflib/pull/820>`_ +* Literal total ordering + `PR #793 <https://github.com/RDFLib/rdflib/pull/793>`_ +* Remove SPARQLWrapper dependency + `PR #744 <https://github.com/RDFLib/rdflib/pull/744>`_ +* made UNION faster by not preventing duplicates + `PR #741 <https://github.com/RDFLib/rdflib/pull/741>`_ +* added a hook to add custom functions to SPARQL + `PR #723 <https://github.com/RDFLib/rdflib/pull/723>`_ +* Issue714 + `PR #717 <https://github.com/RDFLib/rdflib/pull/717>`_ +* Use <<= instead of deprecated << in SPARQL parser + `PR #417 <https://github.com/RDFLib/rdflib/pull/417>`_ +* Custom FILTER function for SPARQL engine + `ISSUE #274 <https://github.com/RDFLib/rdflib/issues/274>`_ + +Code Quality and Cleanups: +^^^^^^^^^^^^^^^^^^^^^^^^^^ +* a slightly opinionated autopep8 run + `PR #870 <https://github.com/RDFLib/rdflib/pull/870>`_ +* remove rdfa and microdata parsers from core RDFLib + `PR #828 <https://github.com/RDFLib/rdflib/pull/828>`_ +* ClosedNamespace KeyError -> AttributeError + `PR #827 <https://github.com/RDFLib/rdflib/pull/827>`_ +* typo in rdflib/plugins/sparql/update.py + `ISSUE #760 <https://github.com/RDFLib/rdflib/issues/760>`_ +* Fix logging in interactive mode + `PR #731 <https://github.com/RDFLib/rdflib/pull/731>`_ +* make namespace module flake8-compliant, change exceptions in that mod… + `PR #711 <https://github.com/RDFLib/rdflib/pull/711>`_ +* delete ez_setup.py? + `ISSUE #669 <https://github.com/RDFLib/rdflib/issues/669>`_ +* code duplication issue between rdflib and pymicrodata + `ISSUE #582 <https://github.com/RDFLib/rdflib/issues/582>`_ +* Transition from 2to3 to use of six.py to be merged in 5.0.0-dev + `PR #519 <https://github.com/RDFLib/rdflib/pull/519>`_ +* sparqlstore drop deprecated methods and args + `PR #516 <https://github.com/RDFLib/rdflib/pull/516>`_ +* python3 code seems shockingly inefficient + `ISSUE #440 <https://github.com/RDFLib/rdflib/issues/440>`_ +* removed md5_term_hash, fixes #240 + `PR #439 <https://github.com/RDFLib/rdflib/pull/439>`_ + `ISSUE #240 <https://github.com/RDFLib/rdflib/issues/240>`_ + +Testing: +^^^^^^^^ +* 3.7 for travis + `PR #864 <https://github.com/RDFLib/rdflib/pull/864>`_ +* Added trig unit tests to highlight some current parsing/serializing issues + `PR #431 <https://github.com/RDFLib/rdflib/pull/431>`_ + +Documentation Fixes: +^^^^^^^^^^^^^^^^^^^^ +* Fix a doc string in the query module + `PR #976 <https://github.com/RDFLib/rdflib/pull/976>`_ +* setup.py: Make the license field use an SPDX identifier + `PR #789 <https://github.com/RDFLib/rdflib/pull/789>`_ +* Update README.md + `PR #764 <https://github.com/RDFLib/rdflib/pull/764>`_ +* Update namespaces_and_bindings.rst + `PR #757 <https://github.com/RDFLib/rdflib/pull/757>`_ +* DOC: README.md: rdflib-jsonld, https uris + `PR #712 <https://github.com/RDFLib/rdflib/pull/712>`_ +* make doctest support py2/py3 + `ISSUE #707 <https://github.com/RDFLib/rdflib/issues/707>`_ +* `pip install rdflib` (as per README.md) gets OSError on Mint 18.1 + `ISSUE #704 <https://github.com/RDFLib/rdflib/issues/704>`_ + `PR #717 <https://github.com/RDFLib/rdflib/pull/717>`_ +* Use <<= instead of deprecated << in SPARQL parser + `PR #417 <https://github.com/RDFLib/rdflib/pull/417>`_ +* Custom FILTER function for SPARQL engine + `ISSUE #274 <https://github.com/RDFLib/rdflib/issues/274>`_ + +Code Quality and Cleanups: +^^^^^^^^^^^^^^^^^^^^^^^^^^ +* a slightly opinionated autopep8 run + `PR #870 <https://github.com/RDFLib/rdflib/pull/870>`_ +* remove rdfa and microdata parsers from core RDFLib + `PR #828 <https://github.com/RDFLib/rdflib/pull/828>`_ +* ClosedNamespace KeyError -> AttributeError + `PR #827 <https://github.com/RDFLib/rdflib/pull/827>`_ +* typo in rdflib/plugins/sparql/update.py + `ISSUE #760 <https://github.com/RDFLib/rdflib/issues/760>`_ +* Fix logging in interactive mode + `PR #731 <https://github.com/RDFLib/rdflib/pull/731>`_ +* make namespace module flake8-compliant, change exceptions in that mod… + `PR #711 <https://github.com/RDFLib/rdflib/pull/711>`_ +* delete ez_setup.py? + `ISSUE #669 <https://github.com/RDFLib/rdflib/issues/669>`_ +* code duplication issue between rdflib and pymicrodata + `ISSUE #582 <https://github.com/RDFLib/rdflib/issues/582>`_ +* Transition from 2to3 to use of six.py to be merged in 5.0.0-dev + `PR #519 <https://github.com/RDFLib/rdflib/pull/519>`_ +* sparqlstore drop deprecated methods and args + `PR #516 <https://github.com/RDFLib/rdflib/pull/516>`_ +* python3 code seems shockingly inefficient + `ISSUE #440 <https://github.com/RDFLib/rdflib/issues/440>`_ +* removed md5_term_hash, fixes #240 + `PR #439 <https://github.com/RDFLib/rdflib/pull/439>`_ + `ISSUE #240 <https://github.com/RDFLib/rdflib/issues/240>`_ + +Testing: +^^^^^^^^ +* 3.7 for travis + `PR #864 <https://github.com/RDFLib/rdflib/pull/864>`_ +* Added trig unit tests to highlight some current parsing/serializing issues + `PR #431 <https://github.com/RDFLib/rdflib/pull/431>`_ +Documentation Fixes: +^^^^^^^^^^^^^^^^^^^^ +* Fix a doc string in the query module + `PR #976 <https://github.com/RDFLib/rdflib/pull/976>`_ +* setup.py: Make the license field use an SPDX identifier + `PR #789 <https://github.com/RDFLib/rdflib/pull/789>`_ +* Update README.md + `PR #764 <https://github.com/RDFLib/rdflib/pull/764>`_ +* Update namespaces_and_bindings.rst + `PR #757 <https://github.com/RDFLib/rdflib/pull/757>`_ +* DOC: README.md: rdflib-jsonld, https uris + `PR #712 <https://github.com/RDFLib/rdflib/pull/712>`_ +* make doctest support py2/py3 + `ISSUE #707 <https://github.com/RDFLib/rdflib/issues/707>`_ +* `pip install rdflib` (as per README.md) gets OSError on Mint 18.1 + `ISSUE #704 <https://github.com/RDFLib/rdflib/issues/704>`_ -Minor Changes --------------- -This list has been assembled semi-automatically from Pull Request and commit information. diff --git a/rdflib/__init__.py b/rdflib/__init__.py index fa24ae4f..1ea4d6da 100644 --- a/rdflib/__init__.py +++ b/rdflib/__init__.py @@ -46,7 +46,7 @@ __docformat__ = "restructuredtext en" # The format of the __version__ line is matched by a regex in setup.py __version__ = "5.0.0" -__date__ = "2020-04-03" +__date__ = "2020-04-18" __all__ = [ "URIRef", diff --git a/rdflib/compat.py b/rdflib/compat.py index bf6fa9bc..228c6a1c 100644 --- a/rdflib/compat.py +++ b/rdflib/compat.py @@ -136,7 +136,7 @@ def decodeStringEscape(s): def decodeUnicodeEscape(s): """ s is a unicode string - replace \n and \\u00AC unicode escapes + replace ``\\n`` and ``\\u00AC`` unicode escapes """ if not six.PY3: s = s.encode('utf-8').decode('string-escape') diff --git a/rdflib/graph.py b/rdflib/graph.py index efd58eba..80dc02f8 100644 --- a/rdflib/graph.py +++ b/rdflib/graph.py @@ -293,8 +293,9 @@ class Graph(Node): For more on named graphs, see: http://www.w3.org/2004/03/trix/ """ - def __init__(self, store="default", identifier=None, namespace_manager=None): + def __init__(self, store="default", identifier=None, namespace_manager=None, base=None): super(Graph, self).__init__() + self.base = base self.__identifier = identifier or BNode() if not isinstance(self.__identifier, Node): @@ -952,6 +953,11 @@ class Graph(Node): Format support can be extended with plugins, but "xml", "n3", "turtle", "nt", "pretty-xml", "trix", "trig" and "nquads" are built in. """ + + # if base is not given as attribute use the base set for the graph + if base is None: + base = self.base + serializer = plugin.get(format, Serializer)(self) if destination is None: stream = BytesIO() @@ -1336,14 +1342,16 @@ class ConjunctiveGraph(Graph): All queries are carried out against the union of all graphs. """ - def __init__(self, store="default", identifier=None): + def __init__(self, store="default", identifier=None, default_graph_base=None): super(ConjunctiveGraph, self).__init__(store, identifier=identifier) assert self.store.context_aware, ( "ConjunctiveGraph must be backed by" " a context aware store." ) self.context_aware = True self.default_union = True # Conjunctive! - self.default_context = Graph(store=self.store, identifier=identifier or BNode()) + self.default_context = Graph( + store=self.store, identifier=identifier or BNode(), base=default_graph_base + ) def __str__(self): pattern = ( @@ -1483,12 +1491,12 @@ class ConjunctiveGraph(Graph): else: yield self.get_context(context) - def get_context(self, identifier, quoted=False): + def get_context(self, identifier, quoted=False, base=None): """Return a context graph for the given identifier identifier must be a URIRef or BNode. """ - return Graph(store=self.store, identifier=identifier, namespace_manager=self) + return Graph(store=self.store, identifier=identifier, namespace_manager=self, base=base) def remove_context(self, context): """Removes the given context from the graph""" @@ -1651,13 +1659,13 @@ class Dataset(ConjunctiveGraph): .. versionadded:: 4.0 """ - def __init__(self, store="default", default_union=False): + def __init__(self, store="default", default_union=False, default_graph_base=None): super(Dataset, self).__init__(store=store, identifier=None) if not self.store.graph_aware: raise Exception("DataSet must be backed by a graph-aware store!") self.default_context = Graph( - store=self.store, identifier=DATASET_DEFAULT_GRAPH_ID + store=self.store, identifier=DATASET_DEFAULT_GRAPH_ID, base=default_graph_base ) self.default_union = default_union @@ -1668,7 +1676,7 @@ class Dataset(ConjunctiveGraph): ) return pattern % self.store.__class__.__name__ - def graph(self, identifier=None): + def graph(self, identifier=None, base=None): if identifier is None: from rdflib.term import rdflib_skolem_genid @@ -1678,6 +1686,7 @@ class Dataset(ConjunctiveGraph): identifier = BNode().skolemize() g = self._graph(identifier) + g.base = base self.store.add_graph(g) return g diff --git a/rdflib/paths.py b/rdflib/paths.py index 163f046f..6a8ee50e 100644 --- a/rdflib/paths.py +++ b/rdflib/paths.py @@ -32,18 +32,19 @@ In SPARQL the syntax is as follows: | | of the path by zero or one matches of elt. | +--------------------+-------------------------------------------------+ |!iri or | Negated property set. An IRI which is not one of| -|!(iri\ :sub:`1`\ | | iri\ :sub:`1`...iri\ :sub:`n`. | -|... |iri\ :sub:`n`) | !iri is short for !(iri). | +|!(iri\ :sub:`1`\ \| | iri\ :sub:`1`...iri\ :sub:`n`. | +|... \|iri\ :sub:`n`)| !iri is short for !(iri). | +--------------------+-------------------------------------------------+ |!^iri or | Negated property set where the excluded matches | -|!(^iri\ :sub:`1`\ | | are based on reversed path. That is, not one of | -|... |^iri\ :sub:`n`)| iri\ :sub:`1`...iri\ :sub:`n` as reverse paths. | +|!(^iri\ :sub:`1`\ \|| are based on reversed path. That is, not one of | +|...\|^iri\ :sub:`n`)| iri\ :sub:`1`...iri\ :sub:`n` as reverse paths. | | | !^iri is short for !(^iri). | +--------------------+-------------------------------------------------+ -|!(iri\ :sub:`1`\ | | A combination of forward and reverse | -|...|iri\ :sub:`j`\ || properties in a negated property set. | -|^iri\ :sub:`j+1`\ | | | -|... |^iri\ :sub:`n`)| | +|!(iri\ :sub:`1`\ \| | A combination of forward and reverse | +|...\|iri\ :sub:`j`\ | properties in a negated property set. | +|\|^iri\ :sub:`j+1`\ | | +|\|... \|^iri\ | | +|:sub:`n`)| | | +--------------------+-------------------------------------------------+ |(elt) | A group path elt, brackets control precedence. | +--------------------+-------------------------------------------------+ diff --git a/rdflib/plugins/memory.py b/rdflib/plugins/memory.py index 7345311a..6741e316 100644 --- a/rdflib/plugins/memory.py +++ b/rdflib/plugins/memory.py @@ -360,7 +360,7 @@ class IOMemory(Store): if self.__tripleHasContext(enctriple, cid)) def contexts(self, triple=None): - if triple is None or triple is (None, None, None): + if triple is None or triple == (None, None, None): return (context for context in self.__all_contexts) enctriple = self.__encodeTriple(triple) diff --git a/rdflib/plugins/parsers/notation3.py b/rdflib/plugins/parsers/notation3.py index 4b6ff5d1..c57f5bcf 100755 --- a/rdflib/plugins/parsers/notation3.py +++ b/rdflib/plugins/parsers/notation3.py @@ -349,9 +349,7 @@ ws = re.compile(r'[ \t]*') # Whitespace not including NL signed_integer = re.compile(r'[-+]?[0-9]+') # integer integer_syntax = re.compile(r'[-+]?[0-9]+') decimal_syntax = re.compile(r'[-+]?[0-9]*\.[0-9]+') -exponent_syntax = re.compile(r'[-+]?(?:[0-9]+\.[0-9]*(?:e|E)[-+]?[0-9]+|'+ - r'\.[0-9](?:e|E)[-+]?[0-9]+|'+ - r'[0-9]+(?:e|E)[-+]?[0-9]+)') +exponent_syntax = re.compile(r'[-+]?(?:[0-9]+\.[0-9]*|\.[0-9]+|[0-9]+)(?:e|E)[-+]?[0-9]+') digitstring = re.compile(r'[0-9]+') # Unsigned integer interesting = re.compile(r"""[\\\r\n\"\']""") langcode = re.compile(r'[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*') diff --git a/rdflib/plugins/serializers/rdfxml.py b/rdflib/plugins/serializers/rdfxml.py index 631c8fe0..4242fc05 100644 --- a/rdflib/plugins/serializers/rdfxml.py +++ b/rdflib/plugins/serializers/rdfxml.py @@ -46,7 +46,11 @@ class XMLSerializer(Serializer): yield prefix, namespace def serialize(self, stream, base=None, encoding=None, **args): - self.base = base + # if base is given here, use that, if not and a base is set for the graph use that + if base is not None: + self.base = base + elif self.store.base is not None: + self.base = self.store.base self.__stream = stream self.__serialized = {} encoding = self.encoding @@ -62,6 +66,8 @@ class XMLSerializer(Serializer): # If provided, write xml:base attribute for the RDF if "xml_base" in args: write(' xml:base="%s"\n' % args['xml_base']) + elif self.base: + write(' xml:base="%s"\n' % self.base) # TODO: # assert( # namespaces["http://www.w3.org/1999/02/22-rdf-syntax-ns#"]=='rdf') @@ -163,7 +169,11 @@ class PrettyXMLSerializer(Serializer): def serialize(self, stream, base=None, encoding=None, **args): self.__serialized = {} store = self.store - self.base = base + # if base is given here, use that, if not and a base is set for the graph use that + if base is not None: + self.base = base + elif store.base is not None: + self.base = store.base self.max_depth = args.get("max_depth", 3) assert self.max_depth > 0, "max_depth must be greater than 0" @@ -184,6 +194,8 @@ class PrettyXMLSerializer(Serializer): if "xml_base" in args: writer.attribute(XMLBASE, args["xml_base"]) + elif self.base: + writer.attribute(XMLBASE, self.base) writer.namespaces(namespaces.items()) diff --git a/rdflib/plugins/serializers/trig.py b/rdflib/plugins/serializers/trig.py index 6c05ad75..250e1c09 100644 --- a/rdflib/plugins/serializers/trig.py +++ b/rdflib/plugins/serializers/trig.py @@ -39,7 +39,7 @@ class TrigSerializer(TurtleSerializer): for triple in context: self.preprocessTriple(triple) - self._contexts[context]=(self.orderSubjects(), self._subjects, self._references) + self._contexts[context] = (self.orderSubjects(), self._subjects, self._references) def reset(self): super(TrigSerializer, self).reset() @@ -49,7 +49,11 @@ class TrigSerializer(TurtleSerializer): spacious=None, **args): self.reset() self.stream = stream - self.base = base + # if base is given here, use that, if not and a base is set for the graph use that + if base is not None: + self.base = base + elif self.store.base is not None: + self.base = self.store.base if spacious is not None: self._spacious = spacious diff --git a/rdflib/plugins/serializers/trix.py b/rdflib/plugins/serializers/trix.py index fceec6bd..0a574493 100644 --- a/rdflib/plugins/serializers/trix.py +++ b/rdflib/plugins/serializers/trix.py @@ -29,6 +29,11 @@ class TriXSerializer(Serializer): self.writer = XMLWriter(stream, nm, encoding, extra_ns={"": TRIXNS}) self.writer.push(TRIXNS[u"TriX"]) + # if base is given here, use that, if not and a base is set for the graph use that + if base is None and self.store.base is not None: + base = self.store.base + if base is not None: + self.writer.attribute("http://www.w3.org/XML/1998/namespacebase", base) self.writer.namespaces() if isinstance(self.store, ConjunctiveGraph): @@ -44,6 +49,8 @@ class TriXSerializer(Serializer): def _writeGraph(self, graph): self.writer.push(TRIXNS[u"graph"]) + if graph.base: + self.writer.attribute("http://www.w3.org/XML/1998/namespacebase", graph.base) if isinstance(graph.identifier, URIRef): self.writer.element( TRIXNS[u"uri"], content=text_type(graph.identifier)) diff --git a/rdflib/plugins/serializers/turtle.py b/rdflib/plugins/serializers/turtle.py index 1c58ba1b..8a41587c 100644 --- a/rdflib/plugins/serializers/turtle.py +++ b/rdflib/plugins/serializers/turtle.py @@ -224,7 +224,11 @@ class TurtleSerializer(RecursiveSerializer): spacious=None, **args): self.reset() self.stream = stream - self.base = base + # if base is given here, use that, if not and a base is set for the graph use that + if base is not None: + self.base = base + elif self.store.base is not None: + self.base = self.store.base if spacious is not None: self._spacious = spacious @@ -246,6 +250,8 @@ class TurtleSerializer(RecursiveSerializer): self.endDocument() stream.write(b("\n")) + self.base = None + def preprocessTriple(self, triple): super(TurtleSerializer, self).preprocessTriple(triple) for i, node in enumerate(triple): @@ -291,6 +297,9 @@ class TurtleSerializer(RecursiveSerializer): def startDocument(self): self._started = True ns_list = sorted(self.namespaces.items()) + + if self.base: + self.write(self.indent() + '@base <%s> .\n' % self.base) for prefix, uri in ns_list: self.write(self.indent() + '@prefix %s: <%s> .\n' % (prefix, uri)) if ns_list and self._spacious: diff --git a/rdflib/plugins/sparql/sparql.py b/rdflib/plugins/sparql/sparql.py index d6d445e8..be980f44 100644 --- a/rdflib/plugins/sparql/sparql.py +++ b/rdflib/plugins/sparql/sparql.py @@ -173,7 +173,10 @@ class FrozenBindings(FrozenDict): if not type(key) in (BNode, Variable): return key - return self._d[key] + if key not in self._d: + return self.ctx.initBindings[key] + else: + return self._d[key] def project(self, vars): return FrozenBindings( diff --git a/rdflib/store.py b/rdflib/store.py index 32c3f650..5d2d2f55 100644 --- a/rdflib/store.py +++ b/rdflib/store.py @@ -290,8 +290,8 @@ class Store(object): QuotedGraph, Date? DateRange? :param context: A conjunctive query can be indicated by either - providing a value of None, or a specific context can be - queries by passing a Graph instance (if store is context aware). + providing a value of None, or a specific context can be + queries by passing a Graph instance (if store is context aware). """ subject, predicate, object = triple_pattern diff --git a/rdflib/term.py b/rdflib/term.py index 3d290258..125210df 100644 --- a/rdflib/term.py +++ b/rdflib/term.py @@ -1383,6 +1383,16 @@ def _unhexlify(value): value = value.encode() return unhexlify(value) +def _parseBoolean(value): + true_accepted_values = ['1', 'true'] + false_accepted_values = ['0', 'false'] + new_value = value.lower() + if new_value in true_accepted_values: + return True + if new_value not in false_accepted_values: + warnings.warn('Parsing weird boolean, % r does not map to True or False' % value, category = DeprecationWarning) + return False + # Cannot import Namespace/XSD because of circular dependencies _XSD_PFX = 'http://www.w3.org/2001/XMLSchema#' _RDF_PFX = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#' @@ -1552,7 +1562,7 @@ XSDToPython = { URIRef(_XSD_PFX + 'normalizedString'): None, URIRef(_XSD_PFX + 'token'): None, URIRef(_XSD_PFX + 'language'): None, - URIRef(_XSD_PFX + 'boolean'): lambda i: i.lower() == 'true', + URIRef(_XSD_PFX + 'boolean'): _parseBoolean, URIRef(_XSD_PFX + 'decimal'): Decimal, URIRef(_XSD_PFX + 'integer'): long_type, URIRef(_XSD_PFX + 'nonPositiveInteger'): int, @@ -6,9 +6,14 @@ from setuptools import setup, find_packages kwargs = {} kwargs['install_requires'] = [ 'six', 'isodate', 'pyparsing'] -kwargs['tests_require'] = ['html5lib', 'networkx'] +kwargs['tests_require'] = ['html5lib', 'networkx', 'nose', 'doctest-ignore-unicode'] kwargs['test_suite'] = "nose.collector" -kwargs['extras_require'] = {'html': ['html5lib'], 'sparql': ['requests']} +kwargs['extras_require'] = { + 'html': ['html5lib'], + 'sparql': ['requests'], + 'tests': kwargs['tests_require'], + 'docs': ['sphinx < 4', 'sphinxcontrib-apidoc'] + } def find_version(filename): _version_re = re.compile(r'__version__ = "(.*)"') diff --git a/test/test_issue1003.py b/test/test_issue1003.py new file mode 100644 index 00000000..fdc56c82 --- /dev/null +++ b/test/test_issue1003.py @@ -0,0 +1,117 @@ +from rdflib import Graph, Dataset, Literal, Namespace, RDF, URIRef +from rdflib.namespace import SKOS, DCTERMS + +""" +Testing scenarios: + 1. no base set + 2. base set at graph creation + 3. base set at serialization + 4. base set at both graph creation & serialization, serialization overrides + 5. multiple serialization side effect checking + 6. checking results for RDF/XML + 7. checking results for N3 + 8. checking results for TriX & TriG +""" + +# variables +base_one = Namespace("http://one.org/") +base_two = Namespace("http://two.org/") +title = Literal("Title", lang="en") +description = Literal("Test Description", lang="en") +creator = URIRef("https://creator.com") +cs = URIRef("") + +# starting graph +g = Graph() +g.add((cs, RDF.type, SKOS.ConceptScheme)) +g.add((cs, DCTERMS.creator, creator)) +g.add((cs, DCTERMS.source, URIRef("nick"))) +g.bind("dct", DCTERMS) +g.bind("skos", SKOS) + + +# 1. no base set for graph, no base set for serialization +g1 = Graph() +g1 += g +# @base should not be in output +assert "@base" not in g.serialize(format='turtle').decode("utf-8") + + +# 2. base one set for graph, no base set for serialization +g2 = Graph(base=base_one) +g2 += g +# @base should be in output, from Graph (one) +assert "@base <http://one.org/> ." in g2.serialize(format='turtle').decode("utf-8") + + +# 3. no base set for graph, base two set for serialization +g3 = Graph() +g3 += g +# @base should be in output, from serialization (two) +assert "@base <http://two.org/> ." in g3.serialize(format='turtle', base=base_two).decode("utf-8") + + +# 4. base one set for graph, base two set for serialization, Graph one overrides +g4 = Graph(base=base_one) +g4 += g +# @base should be in output, from graph (one) +assert "@base <http://two.org/> ." in g4.serialize(format='turtle', base=base_two).decode("utf-8") +# just checking that the serialization setting (two) hasn't snuck through +assert "@base <http://one.org/> ." not in g4.serialize(format='turtle', base=base_two).decode("utf-8") + + +# 5. multiple serialization side effect checking +g5 = Graph() +g5 += g +# @base should be in output, from serialization (two) +assert "@base <http://two.org/> ." in g5.serialize(format='turtle', base=base_two).decode("utf-8") + +# checking for side affects - no base now set for this serialization +# @base should not be in output +assert "@base" not in g5.serialize(format='turtle').decode("utf-8") + + +# 6. checking results for RDF/XML +g6 = Graph() +g6 += g +g6.bind("dct", DCTERMS) +g6.bind("skos", SKOS) +assert "@xml:base" not in g6.serialize(format='xml').decode("utf-8") +assert 'xml:base="http://one.org/"' in g6.serialize(format='xml', base=base_one).decode("utf-8") +g6.base = base_two +assert 'xml:base="http://two.org/"' in g6.serialize(format='xml').decode("utf-8") +assert 'xml:base="http://one.org/"' in g6.serialize(format='xml', base=base_one).decode("utf-8") + +# 7. checking results for N3 +g7 = Graph() +g7 += g +g7.bind("dct", DCTERMS) +g7.bind("skos", SKOS) +assert "@xml:base" not in g7.serialize(format='xml').decode("utf-8") +assert "@base <http://one.org/> ." in g7.serialize(format='n3', base=base_one).decode("utf-8") +g7.base = base_two +assert "@base <http://two.org/> ." in g7.serialize(format='n3').decode("utf-8") +assert "@base <http://one.org/> ." in g7.serialize(format='n3', base=base_one).decode("utf-8") + +# 8. checking results for TriX & TriG +# TriX can specify a base per graph but setting a base for the whole +base_three = Namespace("http://three.org/") +ds1 = Dataset() +ds1.bind("dct", DCTERMS) +ds1.bind("skos", SKOS) +g8 = ds1.graph(URIRef('http://g8.com/'), base=base_one) +g9 = ds1.graph(URIRef('http://g9.com/')) +g8 += g +g9 += g +g9.base = base_two +ds1.base = base_three + +trix = ds1.serialize(format='trix', base=Namespace("http://two.org/")).decode("utf-8") +assert '<graph xml:base="http://one.org/">' in trix +assert '<graph xml:base="http://two.org/">' in trix +assert '<TriX xml:base="http://two.org/"' in trix + +trig = ds1.serialize(format='trig', base=Namespace("http://two.org/")).decode("utf-8") +assert '@base <http://one.org/> .' not in trig +assert '@base <http://three.org/> .' not in trig +assert '@base <http://two.org/> .' in trig diff --git a/test/test_literal.py b/test/test_literal.py index dae2d187..3ed62d11 100644 --- a/test/test_literal.py +++ b/test/test_literal.py @@ -1,7 +1,7 @@ import unittest import rdflib # needed for eval(repr(...)) below -from rdflib.term import Literal, URIRef, _XSD_DOUBLE, bind +from rdflib.term import Literal, URIRef, _XSD_DOUBLE, bind, _XSD_BOOLEAN from six import integer_types, PY3, string_types @@ -100,6 +100,29 @@ class TestDoubleOutput(unittest.TestCase): out = vv._literal_n3(use_plain=True) self.assertTrue(out in ["8.8e-01", "0.88"], out) +class TestParseBoolean(unittest.TestCase): + """confirms the fix for https://github.com/RDFLib/rdflib/issues/913""" + def testTrueBoolean(self): + test_value = Literal("tRue", datatype = _XSD_BOOLEAN) + self.assertTrue(test_value.value) + test_value = Literal("1",datatype = _XSD_BOOLEAN) + self.assertTrue(test_value.value) + + def testFalseBoolean(self): + test_value = Literal("falsE", datatype = _XSD_BOOLEAN) + self.assertFalse(test_value.value) + test_value = Literal("0",datatype = _XSD_BOOLEAN) + self.assertFalse(test_value.value) + + def testNonFalseBoolean(self): + test_value = Literal("abcd", datatype = _XSD_BOOLEAN) + self.assertRaises(DeprecationWarning) + self.assertFalse(test_value.value) + test_value = Literal("10",datatype = _XSD_BOOLEAN) + self.assertRaises(DeprecationWarning) + self.assertFalse(test_value.value) + + class TestBindings(unittest.TestCase): diff --git a/test/test_n3.py b/test/test_n3.py index 5d447732..5cdc74b5 100644 --- a/test/test_n3.py +++ b/test/test_n3.py @@ -1,7 +1,8 @@ from rdflib.graph import Graph, ConjunctiveGraph import unittest from rdflib.term import Literal, URIRef -from rdflib.plugins.parsers.notation3 import BadSyntax +from rdflib.plugins.parsers.notation3 import BadSyntax, exponent_syntax +import itertools from six import b from six.moves.urllib.error import URLError @@ -164,6 +165,31 @@ foo-bar:Ex foo-bar:name "Test" . """ g = Graph() g.parse("test/n3/issue156.n3", format="n3") + def testIssue999(self): + """ + Make sure the n3 parser does recognize exponent and leading dot in ".171e-11" + """ + data = """ +@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . + +<http://qudt.org/vocab/unit/MilliM-PER-YR> + a <http://qudt.org/schema/qudt/Unit> ; + <http://qudt.org/schema/qudt/conversionMultiplier> .171e-11 ; + <http://qudt.org/schema/qudt/conversionOffset> 0e+00 ; + <http://qudt.org/schema/qudt/description> "0.001-fold of the SI base unit metre divided by the unit year" ; + <http://qudt.org/schema/qudt/hasQuantityKind> <http://qudt.org/vocab/quantitykind/Velocity> ; + <http://qudt.org/schema/qudt/iec61360Code> "0112/2///62720#UAA868" ; + <http://qudt.org/schema/qudt/uneceCommonCode> "H66" ; + rdfs:isDefinedBy <http://qudt.org/2.1/vocab/unit> ; + rdfs:isDefinedBy <http://qudt.org/vocab/unit> ; + rdfs:label "MilliM PER YR" ; + <http://www.w3.org/2004/02/skos/core#prefLabel> "millimetre per year" ; +. + """ + g = Graph() + g.parse(data=data, format="n3") + g.parse(data=data, format="turtle") + def testDotInPrefix(self): g = Graph() g.parse( @@ -226,5 +252,24 @@ foo-bar:Ex foo-bar:name "Test" . """ g2), 'Document with declared empty prefix must match default #' +class TestRegularExpressions(unittest.TestCase): + def testExponents(self): + signs = ("", "+", "-") + mantissas = ("1", "1.", ".1", + "12", "12.", "1.2", ".12", + "123", "123.", "12.3", "1.23", ".123") + es = "eE" + exps = ("1", "12", "+1", "-1", "+12", "-12") + for parts in itertools.product(signs, mantissas, es, exps): + expstring = "".join(parts) + self.assertTrue(exponent_syntax.match(expstring)) + + def testInvalidExponents(self): + # Add test cases as needed + invalid = (".e1",) + for expstring in invalid: + self.assertFalse(exponent_syntax.match(expstring)) + + if __name__ == '__main__': unittest.main() diff --git a/test/test_sparql_construct_bindings.py b/test/test_sparql_construct_bindings.py new file mode 100644 index 00000000..d5a68b94 --- /dev/null +++ b/test/test_sparql_construct_bindings.py @@ -0,0 +1,40 @@ +from rdflib import Graph, URIRef, Literal, BNode +from rdflib.plugins.sparql import prepareQuery +from rdflib.compare import isomorphic + +import unittest +from nose.tools import eq_ + +class TestConstructInitBindings(unittest.TestCase): + + def test_construct_init_bindings(self): + """ + This is issue https://github.com/RDFLib/rdflib/issues/1001 + """ + + g1 = Graph() + + q_str = (""" + PREFIX : <urn:ns1:> + CONSTRUCT { + ?uri :prop1 ?val1; + :prop2 ?c . + } + WHERE { + bind(uri(concat("urn:ns1:", ?a)) as ?uri) + bind(?b as ?val1) + } + """) + q_prepared = prepareQuery(q_str) + + expected = [ + (URIRef('urn:ns1:A'),URIRef('urn:ns1:prop1'), Literal('B')), + (URIRef('urn:ns1:A'),URIRef('urn:ns1:prop2'), Literal('C')) + ] + results = g1.query(q_prepared, initBindings={ + 'a': Literal('A'), + 'b': Literal('B'), + 'c': Literal('C') + }) + + eq_(sorted(results, key=lambda x: str(x[1])), expected) |