GithubHelp home page GithubHelp logo

rdflib / rdflib Goto Github PK

View Code? Open in Web Editor NEW
2.1K 83.0 540.0 21.72 MB

RDFLib is a Python library for working with RDF, a simple yet powerful language for representing information.

Home Page: https://rdflib.readthedocs.org

License: BSD 3-Clause "New" or "Revised" License

Shell 0.19% Python 95.62% Ruby 0.99% HTML 3.14% XSLT 0.05% Dockerfile 0.02%
rdflib semantic-web linked-data python pypi ntriples rdf-xml json-ld turtle turtle-rdf

rdflib's Introduction

RDFLib

Build Status Documentation Status Coveralls branch

GitHub stars Downloads PyPI PyPI DOI

Contribute with Gitpod Gitter Matrix

RDFLib is a pure Python package for working with 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
  • a Graph interface which can be backed by any one of a number of Store implementations
  • store implementations for in-memory, persistent on disk (Berkeley DB) and remote SPARQL endpoints
  • a SPARQL 1.1 implementation - supporting SPARQL 1.1 Queries and Update statements
  • SPARQL function extension mechanisms

RDFlib Family of packages

The RDFlib community maintains many RDF-related Python code repositories with different purposes. For example:

  • rdflib - the RDFLib core
  • sparqlwrapper - a simple Python wrapper around a SPARQL service to remotely execute your queries
  • pyLODE - An OWL ontology documentation tool using Python and templating, based on LODE.
  • pyrdfa3 - RDFa 1.1 distiller/parser library: can extract RDFa 1.1/1.0 from (X)HTML, SVG, or XML in general.
  • pymicrodata - A module to extract RDF from an HTML5 page annotated with microdata.
  • pySHACL - A pure Python module which allows for the validation of RDF graphs against SHACL graphs.
  • OWL-RL - A simple implementation of the OWL2 RL Profile which expands the graph with all possible triples that OWL RL defines.

Please see the list for all packages/repositories here:

Help with maintenance of all of the RDFLib family of packages is always welcome and appreciated.

Versions & Releases

See https://rdflib.dev for the release overview.

Documentation

See https://rdflib.readthedocs.io for our documentation built from the code. Note that there are latest, stable 5.0.0 and 4.2.2 documentation versions, matching releases.

Installation

The stable release of RDFLib may be installed with Python's package management tool pip:

$ pip install rdflib

Some features of RDFLib require optional dependencies which may be installed using pip extras:

$ pip install rdflib[berkeleydb,networkx,html,lxml]

Alternatively manually download the package from the Python Package Index (PyPI) at https://pypi.python.org/pypi/rdflib

The current version of RDFLib is 7.0.0, see the CHANGELOG.md file for what's new in this release.

Installation of the current main branch (for developers)

With pip you can also install rdflib from the git repository with one of the following options:

$ pip install git+https://github.com/rdflib/rdflib@main

or

$ pip install -e git+https://github.com/rdflib/rdflib@main#egg=rdflib

or from your locally cloned repository you can install it with one of the following options:

$ poetry install  # installs into a poetry-managed venv

or

$ pip install -e .

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:

To create graph and load it with RDF data from DBPedia then print the results:

from rdflib import Graph
g = Graph()
g.parse('http://dbpedia.org/resource/Semantic_Web')

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 included in RDFLib:

from rdflib.namespace import DC, DCTERMS, DOAP, FOAF, SKOS, OWL, RDF, RDFS, VOID, XMLNS, XSD

You can use them like this:

from rdflib import Graph, URIRef, Literal
from rdflib.namespace import RDFS, XSD

g = Graph()
semweb = URIRef('http://dbpedia.org/resource/Semantic_Web')
type = g.value(semweb, RDFS.label)

Where RDFS is the RDFS namespace, XSD the XML Schema Datatypes namespace and g.value returns an object of the triple-pattern given (or an arbitrary one if multiple exist).

Or like this, adding a triple to a graph g:

g.add((
    URIRef("http://example.com/person/nick"),
    FOAF.givenName,
    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.givenName is the URI <http://xmlns.com/foaf/0.1/givenName> and XSD.string is the URI <http://www.w3.org/2001/XMLSchema#string>.

You can bind namespaces to prefixes to shorten the URIs for RDF/XML, Turtle, N3, TriG, TriX & JSON-LD serializations:

g.bind("foaf", FOAF)
g.bind("xsd", XSD)

This will allow the n-triples triple above to be serialised like this:

print(g.serialize(format="turtle"))

With these results:

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:

dbpedia = Namespace('http://dbpedia.org/ontology/')

abstracts = list(x for x in g.objects(semweb, dbpedia['abstract']) if x.language=='en')

See also ./examples

Features

The library contains parsers and serializers for RDF/XML, N3, NTriples, N-Quads, Turtle, TriX, JSON-LD, RDFa and Microdata.

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.

A SPARQL 1.1 implementation is included - supporting SPARQL 1.1 Queries and Update statements.

RDFLib is open source and is maintained on GitHub. RDFLib releases, current and previous are listed on PyPI

Multiple other projects are contained within the RDFlib "family", see https://github.com/RDFLib/.

Running tests

Running the tests on the host

Run the test suite with pytest.

poetry install
poetry run pytest

Running test coverage on the host with coverage report

Run the test suite and generate a HTML coverage report with pytest and pytest-cov.

poetry run pytest --cov

Viewing test coverage

Once tests have produced HTML output of the coverage report, view it by running:

poetry run pytest --cov --cov-report term --cov-report html
python -m http.server --directory=htmlcov

Contributing

RDFLib survives and grows via user contributions! Please read our contributing guide and developers guide to get started. Please consider lodging Pull Requests here:

To get a development environment consider using Gitpod or Google Cloud Shell.

Open in Gitpod Open in Cloud Shell

You can also raise issues here:

Support & Contacts

For general "how do I..." queries, please use https://stackoverflow.com and tag your question with rdflib. Existing questions:

If you want to contact the rdflib maintainers, please do so via:

rdflib's People

Contributors

ajnelson-nist avatar ashleysommer avatar aucampia avatar bcogrel avatar dependabot-preview[bot] avatar dependabot[bot] avatar drewp avatar dwinston avatar edmondchuc avatar edsu avatar eikeon avatar florianludwig avatar greenfishk avatar gromgull avatar hsolbrig avatar iherman avatar joernhees avatar jpmccu avatar mwatts15 avatar nicholascar avatar niklasl avatar pchampin avatar pre-commit-ci[bot] avatar rchateauneu avatar takluyver avatar tgbugs avatar uholzer avatar veyndan avatar white-gecko avatar whitmo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rdflib's Issues

repr(Literal) doesn't handle apostrophes correctly

drewpca, 2008-08-05T17:46:05.000Z

repr(Literal("'")) should make something that evals to the same input, but
instead I get too many apostrophes:

rdflib.Literal(''', language=None, datatype=None)


This is under __version__ '2.4.0'

Comment 1 by [email protected]



Comment 2 by [email protected]
Added test case for this issue in r1471. Appears to be working in trunk; can you verify too?


Comment 3 by drewpca
Works, thanks

install via easy_install seems broken

[email protected], 2009-02-25T20:36:05.000Z

What steps will reproduce the problem?
1. easy_install -U "rdflib>=2.4, <=3.0a"
2. 
3.

What is the expected output? What do you see instead?
Should be installed

What version of the product are you using? On what operating system?
Latest OS X, python --version => "Python 2.5.1"

Please provide any additional information below.
Here's the output;
oki:~ wjhuie$ easy_install -U "rdflib>=2.4, <=3.0a"
Searching for rdflib>=2.4,<=3.0a
Reading http://pypi.python.org/simple/rdflib/
Reading http://rdflib.net/
Best match: rdflib 2.4.0
Downloading http://rdflib.net/rdflib-2.4.0.tar.gz
Processing rdflib-2.4.0.tar.gz
Running rdflib-2.4.0/setup.py -q bdist_egg --dist-dir
/var/folders/Ss/SsOhY420GSC3XLYfkXrvL++++TI/-Tmp-/easy_install-dXycHP/rdflib-2.4.0/egg-dist-tmp-BNHEav
warning: no files found matching 'example.py'
Traceback (most recent call last):
  File "/usr/bin/easy_install", line 8, in 
    load_entry_point('setuptools==0.6c7', 'console_scripts', 'easy_install')()
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/setuptools/command/easy_install.py",
line 1670, in main
    with_ei_usage(lambda:
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/setuptools/command/easy_install.py",
line 1659, in with_ei_usage
    return f()
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/setuptools/command/easy_install.py",
line 1674, in 
    distclass=DistributionWithoutHelpCommands, **kw
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/distutils/core.py",
line 151, in setup
    dist.run_commands()
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/distutils/dist.py",
line 974, in run_commands
    self.run_command(cmd)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/distutils/dist.py",
line 994, in run_command
    cmd_obj.run()
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/setuptools/command/easy_install.py",
line 211, in run
    self.easy_install(spec, not self.no_deps)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/setuptools/command/easy_install.py",
line 446, in easy_install
    return self.install_item(spec, dist.location, tmpdir, deps)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/setuptools/command/easy_install.py",
line 471, in install_item
    dists = self.install_eggs(spec, download, tmpdir)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/setuptools/command/easy_install.py",
line 655, in install_eggs
    return self.build_and_install(setup_script, setup_base)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/setuptools/command/easy_install.py",
line 930, in build_and_install
    self.run_setup(setup_script, setup_base, args)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/setuptools/command/easy_install.py",
line 919, in run_setup
    run_setup(setup_script, args)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/setuptools/sandbox.py",
line 27, in run_setup
    lambda: execfile(
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/setuptools/sandbox.py",
line 63, in run
    return func()
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/setuptools/sandbox.py",
line 29, in 
    {'__file__':setup_script, '__name__':'__main__'}
  File "setup.py", line 56, in 
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/distutils/core.py",
line 151, in setup
    dist.run_commands()
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/distutils/dist.py",
line 974, in run_commands
    self.run_command(cmd)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/distutils/dist.py",
line 994, in run_command
    cmd_obj.run()
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/setuptools/command/bdist_egg.py",
line 174, in run
    cmd = self.call_command('install_lib', warn_dir=0)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/setuptools/command/bdist_egg.py",
line 161, in call_command
    self.run_command(cmdname)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/distutils/cmd.py",
line 333, in run_command
    self.distribution.run_command(command)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/distutils/dist.py",
line 994, in run_command
    cmd_obj.run()
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/setuptools/command/install_lib.py",
line 20, in run
    self.build()
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/distutils/command/install_lib.py",
line 112, in build
    self.run_command('build_ext')
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/distutils/cmd.py",
line 333, in run_command
    self.distribution.run_command(command)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/distutils/dist.py",
line 994, in run_command
    cmd_obj.run()
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/setuptools/command/build_ext.py",
line 46, in run
    _build_ext.run(self)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/distutils/command/build_ext.py",
line 290, in run
    self.build_extensions()
  File
"/Users/wjhuie/Library/Python/2.5/site-packages/Pyrex-0.9.8.5-py2.5.egg/Pyrex/Distutils/build_ext.py",
line 82, in build_extensions
    self.build_extension(ext)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/setuptools/command/build_ext.py",
line 175, in build_extension
    _build_ext.build_extension(self,ext)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/distutils/command/build_ext.py",
line 453, in build_extension
    sources = self.swig_sources(sources, ext)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/setuptools/command/build_ext.py",
line 77, in swig_sources
    sources = _build_ext.swig_sources(self, sources) or sources
TypeError: swig_sources() takes exactly 3 arguments (2 given)

Comment 1 by [email protected]
Which version of Py are you running?


Comment 2 by [email protected]
Latest OS X, python --version => "Python 2.5.1"


Comment 3 by [email protected]
Looks like it might be Pyrex causing the issue. Noticed this in the stack trace:

    /Users/wjhuie/Library/Python/2.5/site-packages/Pyrex-0.9.8.5-py2.5.egg/Pyrex/Distutils/build_ext.py

Am not able to reproduce the issue here. I'll try installing Pyrex and see if that does it.

dsl092-168-195:~ eikeon$ sudo easy_install -U "rdflib>=2.4, <=3.0a"Searching for rdflib>=2.4,<=3.0a
Reading http://pypi.python.org/simple/rdflib/
Reading http://rdflib.net/
Best match: rdflib 2.4.0
Downloading http://rdflib.net/rdflib-2.4.0.tar.gz
Processing rdflib-2.4.0.tar.gz
Running rdflib-2.4.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-qcsvDJ/rdflib-2.4.0/egg-dist-
tmp-OWyuQU
warning: no files found matching 'example.py'
zip_safe flag not set; analyzing archive contents...
Adding rdflib 2.4.0 to easy-install.pth file
Installing rdfpipe script to /usr/local/bin

Installed /Library/Python/2.5/site-packages/rdflib-2.4.0-py2.5-macosx-10.5-i386.egg
Processing dependencies for rdflib>=2.4,<=3.0a
Finished processing dependencies for rdflib>=2.4,<=3.0a
dsl092-168-195:~ eikeon$ uname -a
Darwin dsl092-168-195.wdc2.dsl.speakeasy.net 9.6.0 Darwin Kernel Version 9.6.0: Mon Nov 24 17:37:00 
PST 2008; root:xnu-1228.9.59~1/RELEASE_I386 i386
dsl092-168-195:~ eikeon$


Comment 4 by [email protected]
Bingo. Pyrex is causing the problem:

[...]
  File "/Library/Python/2.5/site-packages/Pyrex-0.9.8.5-py2.5.egg/Pyrex/Distutils/build_ext.py", line 82, in 
build_extensions
[...]


Comment 5 by [email protected]
Ahh, yep you're right! 
I removed Pyrex from my site-packages directory and it installed fine.

Thanks!


Comment 6 by [email protected]
It was found that Pyrex was causing the issue.

Sparql FILTER ( BOUND() ) does not perform as per spec

[email protected], 2009-02-11T06:14:26.000Z

What steps will reproduce the problem?
1. Given this source code:
# See http://www.w3.org/TR/rdf-sparql-query/#func-bound
 
from rdflib.store import IOMemory
from rdflib.Graph import ConjunctiveGraph as Graph
from rdflib import URIRef
from StringIO import StringIO
 
n3 = StringIO('''
@prefix foaf:         .
@prefix dc:           .
@prefix xsd:           .
 
_:a  foaf:givenName  "Alice".
 
_:b  foaf:givenName  "Bob" .
_:b  dc:date         "2005-04-04T04:04:04Z"^^xsd:dateTime .
''')
 
db = IOMemory.IOMemory()
graph = Graph(db, identifier=URIRef('#'))
 
graph.parse(n3, format='n3')
 
print list(graph.query("""
PREFIX foaf: 
PREFIX dc:   
PREFIX xsd:   
SELECT ?name
 WHERE { ?x foaf:givenName ?name .
         OPTIONAL { ?x dc:date ?date } .
         FILTER ( bound(?date) ) 
         }
"""))
 
print list(graph.query("""
PREFIX foaf: 
PREFIX dc:   
SELECT ?name
 WHERE { ?x foaf:givenName  ?name .
         OPTIONAL { ?x dc:date ?date } .
         FILTER (!bound(?date)) }
"""))

2. The first print statement should have a single element, with
Literal("Bob") in it.
 
3. The second print statement should have a single element, with the
Literal("Alice") in it.

What is the expected output? What do you see instead?

The first print statement has no results. The second has both Alice and Bob
in it.

According to drewp on irc, svn head of rdflib has an empty result for both
cases. I am using 2.4.0.

Comment 1 by drewpca
rdflib head was r1461 when I ran the test that returned [] and [].


Comment 2 by [email protected]
I have done a test manually using Joseki, and have established that that performs as
per the w3c specification.


Comment 3 by [email protected]



Comment 4 by [email protected]
These issues involve bits that have been moved out of rdflib proper for now. We will re-open them 
or move them to rdfextas as appropriate.

SQLite store plugin fails for stdlib

[email protected], 2008-11-28T13:06:45.000Z

What steps will reproduce the problem?
1. Try to import the SQLite store plugin


What is the expected output? What do you see instead?
Expected to successfully import the store, instead complains that it can't
import pysqlite2, as the python standard library's name is sqlite3.

What version of the product are you using? On what operating system?
Python 2.5 and later, rdflib 2.4.0

Please provide any additional information below.

An easy fix.

In rdflib/store/SQLite.py:

try:
    from pysqlite2 import dbapi2
except ImportError:
    from sqlite3 import dbapi2

Comment 1 by [email protected]



Comment 2 by [email protected]
Fixed in r1719.


Comment 3 by [email protected]
This issue was closed by revision 8e7228dcacdb.

setup.py should check for python.h

gromgull, 2008-01-18T16:29:11.000Z

You you lack the python-dev package the resulting errors do not make the
problem very clear. 

I guess normally setup.py would run configure, which would give a more
sensible error message, perhaps we could check for python.h explicitly :)

Comment 1 by [email protected]



Comment 2 by [email protected]
Current plan is to split off the C bits into their own package in release 2.5; to return rdflib to a pure Python 
package.


Comment 3 by gromgull
I guess this is no longer relevant, since the C parts are gone.

N3 parser returns error if a namespace prefix contains a hyphen.

[email protected], 2008-08-11T14:01:55.000Z

What steps will reproduce the problem?

$ echo "@prefix foo-bar:  ."  > /tmp/test.n3

>>> from rdflib.Graph import Graph
>>> g=Graph();
>>> g.parse('/tmp/test.n3',format='n3');

What is the expected output?

The usual RDF Graph id:

)>

What do you see instead?

ValueError: Token: ': ]*>

module body   in untitled at line 5
function parse    in Graph.py at line 730
function parse    in N3Parser.py at line 32
function parse    in n3proc.py at line 119
function parse    in n3p.py at line 110

What version of the product are you using? 2.4.1 On what operating system? OS X

What version of the product are you using? 2.4.0 On what operating system? CentOS 4.5

Please provide any additional information below.
 
Problem may be avoided by changing the hyphen to an underscore.

Comment 1 by [email protected]
Adding a hyphen to the qname regex in n3meta appears to solve. However, this needs checking by someone 
who is more fluent in regex than I.


Comment 2 by [email protected]



Comment 3 by gromgull



Comment 4 by [email protected]



Comment 5 by gromgull
Fixed in r1755, test-case in test_n3.py

Add/Sub/Mul operators traceback

[email protected], 2008-05-07T13:58:27.000Z

What steps will reproduce the problem?
1. Create two ConjunctiveGraphs, a and b
2. Add some triples to each
3. Try to add them together:  c = a + b

What is the expected output? What do you see instead?

Expected:  Create new graph called c.

Actual:
Traceback (most recent call last):
  File "", line 1, in 
  File "build/bdist.linux-i686/egg/rdflib/Graph.py", line 406, in __add__
AttributeError: 'ConjunctiveGraph' object has no attribute 'graph'

What version of the product are you using? On what operating system?
2.4.0, Linux, Python 2.5.2

Please provide any additional information below.
 
The += operator on graphs works as expected, as it does not use the
non-existant .graph property.

Suggested Fix:

__add__, __mul__ and __sub__ should use the same triple iteration as
__iadd__ function

Comment 1 by [email protected]



Comment 2 by [email protected]



Comment 3 by gromgull
fixed in r1739

DESCRIBE without WHERE clause or empty WHERE clause does not work as expected

[email protected], 2008-10-30T10:34:15.000Z

What steps will reproduce the problem?

query = "DESCRIBE ?uri WHERE { }" # or "DESCRIBE ?uri"
bnd = { Variable("?uri"): DFL['ralf'] }

result = store_graph.query(query, initNs=dict(foaf=FOAF, vc=VC, dflt=DFL),
initBindings=bnd)

Gives:

DESCRIBE ?uri WHERE { ?uri ?p ?a . }
Traceback (most recent call last):
  File "readwrite.py", line 149, in 
    result = store_graph.query(query, initNs=dict(foaf=FOAF, vc=VC,
dflt=DFL), initBindings=bnd)
  File "build/bdist.linux-i686/egg/rdflib/Graph.py", line 738, in query
  File "build/bdist.linux-i686/egg/rdflib/sparql/QueryResult.py", line 250,
in __init__
TypeError: 'NoneType' object is not iterable


Without a WHERE clause (like in
http://www.w3.org/TR/rdf-sparql-query/#describe), this excetpion is thrown:

Traceback (most recent call last):
  File "readwrite.py", line 150, in 
    result = store_graph.query(query, initNs=dict(foaf=FOAF, vc=VC, dflt=DFL))
  File "build/bdist.linux-i686/egg/rdflib/Graph.py", line 738, in query
  File "build/bdist.linux-i686/egg/rdflib/sparql/bison/Processor.py", line
34, in query
  File "build/bdist.linux-i686/egg/rdflib/sparql/bison/Processor.py", line
16, in Parse
SyntaxError: parse error at line 1, column 43: reached end-of-input,
expecting 'VARNAME' or 'ASTERISK'




What is the expected output? What do you see instead?

Description of resource. The query works for a non-empty WHERE clause.



What version of the product are you using? On what operating system?
SVN1460

Please provide any additional information below.

Comment 1 by [email protected]
Sorry, my mistake. This works (expect for "DESCRIBE ?uri").


Comment 2 by [email protected]



Comment 3 by [email protected]



Comment 4 by [email protected]
These issues involve bits that have been moved out of rdflib proper for now. We will re-open them 
or move them to rdfextas as appropriate.

graph.query should return collections.namedtuple

drewpca, 2009-03-24T00:09:05.000Z

graph.query returns a sequence of tuples, but for almost no cost, and full
backward compatibility, they could be collections.namedtuple objects instead.

Then we can write code like this:

for row in graph.query("SELECT ?huge ?list ?of ?vars ..."):
   print row.huge, row.vars
   print repr(row) # nicer than before

I would expect unbound variables to still be in the tuple, as they are now.

Comment 1 by [email protected]



Comment 2 by [email protected]



Comment 3 by [email protected]
These issues involve bits that have been moved out of rdflib proper for now. We will re-open them 
or move them to rdfextas as appropriate.

Literal repr mishandles the input kw arg names

drewpca, 2008-12-19T06:42:14.000Z

>>> Literal('2008-12-18',
datatype=URIRef('http://www.w3.org/2001/XMLSchema#date'))
rdflib.Literal('2008-12-18', language=None,
datatype=rdflib.URIRef('http://www.w3.org/2001/XMLSchema#date'))

The language=None part isn't wrong, but it does make my doctest lines extra
long. 

>>> Literal('bonjour', lang='fr')
rdflib.Literal('bonjour', language='fr', datatype=None)

That one is much worse, because the repr does not eval back to the object
(lang vs language). Similarly, I wish it would omit the datatype=None.

Comment 1 by drewpca



Comment 2 by [email protected]
Literal's __repr__ was changed from language to lang in r1139; which is now consistent with the __init__ method. 
The __repr__ no longer includes lang or datatype if they are None. See r1470.

don't print datatype on literals when NULL

[email protected], 2008-05-14T15:06:16.000Z

What steps will reproduce the problem?

Serialize a graph.

What is the expected output? 

  dcterms:date "2006" .

... or in XML:

 2004

What do you see instead?

  dcterms:date "2006"^^ .


... or in XML:

 2004

Comment 1 by [email protected]



Comment 2 by [email protected]
How do these NULL datatype get into the literals? I couldn't reproduce this (with datatype=None in an in-
memory graph, using the n3 serializer).


Comment 3 by [email protected]
We are not able to reproduce this issue. What were you using for a store?


Comment 4 by [email protected]
I had these problems too with SQLite store, but not with Sleepycat

ZODB store not working

[email protected], 2008-02-03T23:09:27.000Z

ZODB store is not working or at the very least lacking documentation on how to make it work. 

http://groups.google.com/group/rdflib-dev/browse_thread/thread/2dce71930c002743

Comment 1 by [email protected]



Comment 2 by [email protected]
The attached file demonstrates using a ZODB FileStorage as the container for
an rdflib.store.ZODB instance, and includes some notes on interacting with the
transaction machinery.


Comment 3 by [email protected]



Comment 4 by [email protected]



Comment 5 by [email protected]
Change to Unscheduled so we can focus on more core issues in Milestone-Release2.5.


Comment 6 by [email protected]
No longer part of rdflib; at least for now.

fix for GRAPH <some ctx> { ... }

drewpca, 2008-06-20T06:09:33.000Z

A query like 
"SELECT ?s WHERE { GRAPH  { ?s ?p ?o }}"
would fail in the svn version of rdflib. Below is a patch with a test case
that was failing, plus a simple fix to sparql/Algebra.py that seems to work.



Index: test/test_sparql_graph_graph_pattern.py
===================================================================
--- test/test_sparql_graph_graph_pattern.py (revision 1460)
+++ test/test_sparql_graph_graph_pattern.py (working copy)
@@ -1,5 +1,6 @@
-# -*- coding: UTF-8 -*-
+# -*- coding: utf-8 -*-
 from rdflib import ConjunctiveGraph, URIRef, Literal, RDFS
+from rdflib.Graph import Graph
 from StringIO import StringIO
 import unittest
 
@@ -37,5 +38,20 @@
             results == [doc1],
             "expecting : %s .  Got: %s"%([doc1],repr(results)))
 
+class TestSparqlGraph(unittest.TestCase):
+    """GRAPH <...> {...} blocks in a sparql query"""
+    def testGraph(self):
+        node = URIRef('http://example.com')
+        ctx = URIRef("http://example.com/other#context")
+        graph = ConjunctiveGraph()
+        
+        subgraph = Graph(store=graph.store, identifier=ctx)
+        subgraph.add((node, node, node))
+
+        allQuads = list(graph.quads((None, None, None)))
+        self.assertEqual(allQuads, [(node, node, node, subgraph)])
+        q = "SELECT ?s WHERE { GRAPH  {
?s ?p ?o }}"
+        self.assertEqual(len(list(graph.query(q))), 1)
+
Index: rdflib/sparql/Algebra.py
===================================================================
--- rdflib/sparql/Algebra.py    (revision 1460)
+++ rdflib/sparql/Algebra.py    (working copy)
@@ -1002,7 +1002,7 @@
                 #assert len(targetGraph) == 1
                 targetGraph = targetGraph[0]
             else:
-                targetGraph = Graph(tripleStore.store,graphName)
+                targetGraph = Graph(tripleStore.graph.store,graphName)
             tripleStore = sparqlGraph.SPARQLGraph(targetGraph,
                                                   dSCompliance=\
                                                   DAWG_DATASET_COMPLIANCE)

Comment 1 by drewpca
AFAICT this is still an issue in svn r1460. When I ran the patched version just now,
the *other* test in that file was breaking, but I assume that's separate.



% nosetests test/test_sparql_graph_graph_pattern.py 
testGraph (test.test_sparql_graph_graph_pattern.TestSparqlGraph) ... ok
test_OPT_FILTER (test.test_sparql_graph_graph_pattern.TestSparqlOPT_FILTER2) ... FAIL

======================================================================
FAIL: test_OPT_FILTER (test.test_sparql_graph_graph_pattern.TestSparqlOPT_FILTER2)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/my/dl/modified/rdflib/test/test_sparql_graph_graph_pattern.py", line 39, in
test_OPT_FILTER
    "expecting : %s .  Got: %s"%([doc1],repr(results)))
AssertionError: expecting : [rdflib.URIRef('http://eikeon.com/')] .  Got: []

----------------------------------------------------------------------
Ran 2 tests in 0.164s

FAILED (failures=1)


Comment 2 by [email protected]



Comment 3 by [email protected]
This test case and patch did make it in to the 2.4.1 release and appears to be working. Drew, can you verify?


Comment 4 by drewpca
Still broken in r1759. I added my test case (and relocated a different one) and made 
the Algebra.py fix again in http://code.google.com/p/rdflib/source/detail?r=1761

Please review that and I'll merge it in.

All the changes are in /branches/graphpat-27


Comment 5 by [email protected]



Comment 6 by [email protected]
These issues involve bits that have been moved out of rdflib proper for now. We will re-open them 
or move them to rdfextas as appropriate.

make SPARQL unnamed from queries pick triples from known ConjunctiveGraph contexts

[email protected], 2009-02-09T15:07:04.000Z

Here is a patch that makes unnamed graph SPARQL queries look for triples
also in ConjunctiveGraph's contexts matching the from clause.

This is not enough for properly implementing:

http://www.w3.org/TR/rdf-sparql-query/#unnamedGraph

because triples should probably not be taken also from the
ConjunctiveGraph's default context.

Comment 1 by [email protected]



Comment 2 by [email protected]



Comment 3 by [email protected]
These issues involve bits that have been moved out of rdflib proper for now. We will re-open them 
or move them to rdfextas as appropriate.

Relative URIs do not work

[email protected], 2007-12-11T15:05:37.000Z

I would like to use relative URIs for my subjects and rdflib curently
prevents this, to the best of my understanding.

When using an empty rdflib.Namespace("") object for my subjects the URI is
sometimes prepended with "file://".

This breaks relative URIs for publishing to the web etc.

Comment 1 by [email protected]

RDF makes it a bit hard to work with relative URIs as it doesn't really have a concept of them. It used to annoy
me greatly when bits didn't support relative identifiers / paths etc... so it took me some time to adjust to
absolutizing on the way in and relativizing on the way out when you want to keep things relative. But I think that
might be what needs to be done.

Could you provide more specifics on when your relative URIs were being absolutized?

Comment 3 by gromgull

As the concept of relative URIs do not exist for RDF I propose closing this.

Unless some eager soul provides a patch for doing it at serialize time?

Comment 5 by gromgull

Old issues never die.

Related is this delightful thread on lod-mailinglist: http://lists.w3.org/Archives/Public/public-lod/2011Jan/0134.html

Timbl says CWM canonicalizes URIs on import: http://lists.w3.org/Archives/Public/public-lod/2011Jan/0152.html

Shall we follow suit?

Comment 6 by [email protected]

Good

Comment 7 by [email protected]

I find that relative URIs do work in RDF/XML input/output, in situations where they make sense (e.g. rdf:about). The serializer can also generate them, though care is needed to set the correct base URI.

Comment 8 by [email protected]

Yes they do work for XML. But the XML standard then says, when interpreting relative URIs you have to canonicalize them with the help of xml:base etc.. However this is rather a functionality of the XML parser and not something that RDF needs to know about. (just my 2 cents)

test/parser_rdfcore.py

[email protected], 2009-02-18T21:43:43.000Z

Running test/parser_rdfcore.py does this in the setUp:

manifest.load("http://www.w3.org/2000/10/rdf-tests/rdfcore/Manifest.rdf")

Which has the net effect of downloading a file off the internet to run the
test. This isn't very optimal for people running the unit tests, we should
have a copy, or a subset of this file, in the test repository instead of
downloading it each time we run the tests.

Comment 1 by [email protected]



Comment 2 by [email protected]
We could build upon the simple solution in "test/rdfa/run_w3c_rdfa_testsuite.py" (the 
"cached_file" function) to make a generic "download remote test data" piece. Most/all of 
those could be checked in (unless the size becomes unwieldy).

To centralize this would make it easier to oversee and manage such dependencies.


Comment 3 by gromgull
This issue was closed by revision r1777.


Comment 4 by gromgull
This issue was closed by revision 8a52de8585b3.

rdflib plugins should self register

[email protected], 2008-01-27T19:31:59.000Z

Currently plugin.py contains the calls to register for all the plugins that ship with rdflib. Each plugin 
should call this

Comment 1 by [email protected]
Didn't really mean self register, but rather that rdflib.plug module itself shouldn't be registering them.

Plugs can now be registered using pkg_resources entry points. They can also be registered by calling the 
register function in rdflib.plugin. See help(rdflib.plugin) for more information.

Failure parsing valid RDF from identi.ca

[email protected], 2009-02-15T14:31:58.000Z

What steps will reproduce the problem?
  g = Graph()
  url = "http://identi.ca/search/notice/rss?q=SIOC"
  res = g.parse(url) 

Note: this problem only happens when parsing Identi.ca RSS/RDF feed
(parsing other RDF files is OK). the URL provided is a valid RDF file
according to W3C RDF validator.

What is the expected output? What do you see instead?
 - expected: RDF triples resulting from parsing contents of the url

 - actual result is an AttributeError exception (full exception text below)

What version of the product are you using? On what operating system?
 - RdfLib 2.3.1 (the latest version provided by MacPorts py25-rdflib)
 - Python 2.5 (python25 from MacPorts)
 - MacOSX 10.5.6

Please provide any additional information below.

  File "IdentiSearch.py", line 47, in parseUrl
    res = g.parse(url)
  File "/opt/local/lib/python2.5/site-packages/rdflib/Graph.py", line 438,
in parse
    parser.parse(source, self, **args)
  File
"/opt/local/lib/python2.5/site-packages/rdflib/syntax/parsers/RDFXMLParser.py",
line 37, in parse
    self._parser.parse(source)
  File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/xml/sax/expatreader.py",
line 107, in parse
    xmlreader.IncrementalParser.parse(self, source)
  File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/xml/sax/xmlreader.py",
line 123, in parse
    self.feed(buffer)
  File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/xml/sax/expatreader.py",
line 207, in feed
    self._parser.Parse(data, isFinal)
  File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/xml/sax/expatreader.py",
line 349, in end_element_ns
    self._cont_handler.endElementNS(pair, None)
  File
"/opt/local/lib/python2.5/site-packages/rdflib/syntax/parsers/RDFXMLHandler.py",
line 165, in endElementNS
    self.current.end(name, qname)
  File
"/opt/local/lib/python2.5/site-packages/rdflib/syntax/parsers/RDFXMLHandler.py",
line 451, in property_element_end
    self.store.add((self.parent.subject, current.predicate, current.object))
  File "/opt/local/lib/python2.5/site-packages/rdflib/Graph.py", line 193,
in add
    self.__store.add((s, p, o), self, quoted=False)
  File "/opt/local/lib/python2.5/site-packages/rdflib/store/IOMemory.py",
line 134, in add
    for triple, cg in self.triples(triple, context):
  File "/opt/local/lib/python2.5/site-packages/rdflib/store/IOMemory.py",
line 298, in triples
    oi = self.reverse[object]
  File "/opt/local/lib/python2.5/site-packages/rdflib/Literal.py", line 53,
in __eq__
    result = self.__cmp__(other)==False
AttributeError: 'Literal' object has no attribute '__cmp__'

Comment 1 by [email protected]
Looks like it works in trunk. Not much we can do to fix version 2.3.1 ;) We could try to motivate MacPorts 
updating to 2.4.0 which has been out for a couple years at this point. Anyone know how to go about poking 
the MacPorts process? 

{{{
>>> from rdflib.Graph import Graph
>>> g = Graph()
>>> url = "http://identi.ca/search/notice/rss?q=SIOC"
>>> res = g.parse(url) 
>>> len(res)
481
}}}

NOTE: I'm marking this as won't fix since we can't and opening a issue #48 for seeing if we can get MacPorts 
to update to a newer version.

format="nt" multiline literals need escaping

drewpca, 2008-02-22T17:19:18.000Z

What steps will reproduce the problem?

>>> from rdflib import Graph, Literal, URIRef
>>> g = Graph()
>>> g.add((URIRef("foo"), URIRef("foo"), Literal("multi\nline")))
>>> g.serialize(format="nt")
'  """multi\nline""".\n'

The output should be something like this, since ntriples doesn't allow
literals to span multiple lines:
'  "multi\\nline".\n'

Comment 1 by [email protected]



Comment 2 by gromgull
Fixed in r1759

N3 literal parsing failes on \t

[email protected], 2008-01-23T10:32:30.000Z

When I try to parse an N3, I get an error when a literal contains a \t. But
\t is defined to be in N3 strings.

I suspect the failure is in n3proc's unquote:

>>> from rdflib.syntax.parsers.n3p.n3proc import unquote
>>> unquote("\t")
Traceback (most recent call last):
  File "", line 1, in 
  File "build/bdist.linux-i686/egg/rdflib/syntax/parsers/n3p/n3proc.py",
line 85, in unquote
rdflib.syntax.parsers.n3p.n3proc.ParseError: Illegal literal character: '\t'

Comment 1 by [email protected]
This is actually correct, I believe, since "\t" should be escaped as r"\t". For example unquote(r"\t") will give you 
"\t" -- and unquote("\t") (AKA an actual tab character) will give the above error.

In looking into this issue I did notice Literal's n3 method is not correctly escaping "\t". Literal("\t").n3() should be 
"\\t" which is the same as r"\t".


Comment 2 by [email protected]



Comment 3 by gromgull
Eikeon is right - this seem to work fine

{{{
g=rdflib.graph.Graph()
g.parse(StringIO.StringIO(r'  "Gunnar\tlikes chese". '),
format="n3")
print g.serialize()


  
    <_4:name>Gunnar likes chese
  

}}}

parser entry point for rdfadict

[email protected], 2008-02-11T03:04:48.000Z

It should be pretty quick to build a parser plugin that uses rdfadict

Comment 1 by [email protected]
Is this relevant now with the new RDFa parser based on pyRdfa in place (see also Issue #79)? rdfadict seems to 
use pyRdfa internally.

(If anything rdfadict and other pyRdfa users should be notified when a new RDFLib release is made including this 
parser.)


Comment 2 by [email protected]



Comment 3 by [email protected]



Comment 4 by [email protected]
Agreed; Thank you lindstream. Closing this issue as we now have a new rdfa parser (see Issue #79)

XML serialisation should append a newline

[email protected], 2007-11-29T23:55:27.000Z

When you serialise a graph using pretty-xml the final newline (as required
by POSIX for all files) is missing.

Comment 1 by [email protected]
Fixed the issue but wrote the test case general enough to catch other guilty serializers.

FAIL: http://code.google.com/p/rdflib/issues/detail?id=5
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/eikeon/rdflib/core/test/test_graph.py", line 32, in testFinalNewline
    self.assertEqual(len(failed), 0, "No final newline for formats: '%s'" % failed)
AssertionError: No final newline for formats: 'set(['n3', 'nt'])'


Comment 2 by [email protected]



Comment 3 by [email protected]



Comment 4 by gromgull
Fixed in r1757

MacPorts python/py-rdflib needs to be updated

[email protected], 2009-02-18T03:13:25.000Z

Anyone know how to get about getting a MacPorts packages updated?

Comment 1 by [email protected]
Looks like I do now :| https://trac.macports.org/ticket/18962

Not sure if we need to create all the py25-rdflib py26-rdflib etc variants or not. That'll be next to figure out.


Comment 2 by [email protected]
Learned that the variants are needed at the moment. But "blbmp: eikeon: unfortunately, yes; 
http://trac.macports.org/ticket/16723 for longterm"

The variants have been created to py25 and py26. So we should be MacPort happy until we crank out a new 
release (not sure how long mac ports take to update from their svn... perhaps not until 1.8?)

Namespace.title clash

[email protected], 2008-02-21T21:13:03.000Z

On Feb 21, 2008, at 1:59 PM, Philip Cooper wrote:


This is a pretty minor quibble but:

could we change Namespace.py to include a defined property title
Something like:

@property
def title(self):
   return URIRef(self + 'title')

title is a pretty common fragment e.g.
dc = Namespace('http://purl.org/dc/elements/1.1/')
dc.title
fails .... to do the right thing that is.

I know dc['title'] is fine but ... well it's just a common case
for a number of namespaces.

Comment 1 by [email protected]



Comment 2 by [email protected]



Comment 3 by [email protected]
Fixed in r1492


Comment 4 by [email protected]
This issue was closed by revision 5ed54d4fbdbf.

construct() fails

[email protected], 2007-11-27T10:59:23.000Z

What steps will reproduce the problem?
The following code fails:
graph=SPARQLGraph(Graph())
graph.parse('test.rdf')

where = GraphPattern([("?x",URIRef('http://xmlns.com/foaf/0.1/name'),"?name")])
constructPattern =
GraphPattern([(URIRef("http://example.org/person#Alice"),URIRef('http://www.w3.org/2001/vcard-rdf/3.0#FN'),"?name")])
resultObject = Query.queryObject(graph,where)
result = resultObject.construct(constructPattern)


What is the expected output? What do you see instead?
Expected output: No error

Actual output:
Traceback (most recent call last):
  File "sparqlinfer.py", line 44, in ?
    infer('test.rdf','rules.txt')
  File "sparqlinfer.py", line 40, in infer
    r=q.construct()
  File "/var/lib/python-support/python2.4/rdflib/sparql/Query.py", line
799, in construct
    subgraph = SPARQLGraph()
TypeError: __init__() takes at least 2 arguments (1 given)


What version of the product are you using? On what operating system?
Version 2.4.0, Debian "lenny"

Please provide any additional information below.
Changing line 799 in
/var/lib/python-support/python2.4/rdflib/sparql/Query.py to "subgraph =
SPARQLGraph(rdflib.Graph.Graph())" fixes the problem.

Comment 1 by [email protected]



Comment 2 by [email protected]



Comment 3 by [email protected]



Comment 4 by [email protected]



Comment 5 by [email protected]



Comment 6 by [email protected]
These issues involve bits that have been moved out of rdflib proper for now. We will re-open them 
or move them to rdfextas as appropriate.

Code review request

drewpca, 2009-02-08T05:19:46.000Z

Purpose of code changes on this branch:

The NT literal (and uri) serialization was way off spec. This patch
includes the best tests I could find.


After the review, I'll merge this branch into:
/trunk

Comment 2 by [email protected]
Set review issue status to: Started


Comment 3 by [email protected]
Set review issue status to: Verified

add Graph.fromN3

drewpca, 2008-12-26T22:31:59.000Z

It would help the creation of our test cases, rdflib's test cases, bug
reports, and tutorials if there was a one-liner to make a graph initialized
from some N3. I propose this API:

from rdflib.Graph import Graph
graph = Graph.fromN3("""
@prefix ...

""")

Comment 1 by [email protected]
In trunk, I think the 'data' parameter to 'Graph.parse' is good enough. Use like::

    from rdflib.graph import Graph
    graph = Graph( format="n3", data="""@prefix ... """)

Can this issue thus be closed? (Sure, the relevant tests should be adapted to use this as well..)


Comment 2 by drewpca
Yes, that's equivalent to what I was looking for. Thanks for the update.

Should we have a label for 'put this in the release notes'?

n3 parser doesn't error on corrupt terms

drewpca, 2009-02-06T07:34:54.000Z

What steps will reproduce the problem?

from rdflib.Graph import Graph
from rdflib import StringInputSource
g.parse(StringInputSource(":a b c."), format='n3')
list(g.triples((None,None,None)))

->
[(rdflib.URIRef('file:///home/drewp/#a'),
  rdflib.URIRef('file:///home/drewp/#b'),
  rdflib.URIRef('file:///home/drewp/#c'))]

I think that should have errored because the empty prefix was not defined.
And maybe also because b and c were unknown.

Comment 1 by [email protected]



Comment 2 by gromgull
Fixed in r1755

nt parser fails when file has only whitespace after multiple of bufsiz bytes

[email protected], 2008-04-17T14:09:20.000Z

What steps will reproduce the problem?
1. Pick any valid N Triples file
2. Add 2048 whitespace characters
3. parse and see error

What is the expected output? What do you see instead?
Expected output is a graph.
Exception raised: EOF in line

What version of the product are you using? On what operating system?
Latest.

Please provide any additional information below.
 
Fix:

In rdflib/syntax/parsers/ntriples.py

Line 149, in readline() method:
      while True:
         m = r_line.match(self.buffer)
         if m: # the more likely prospect
            self.buffer = self.buffer[m.end():]
            return m.group(1)
         else:
            buffer = self.file.read(bufsiz)
            if not buffer and not self.buffer.isspace():
                raise ParseError("EOF in line")
            elif not buffer:
                return None
            self.buffer += buffer

Comment 1 by [email protected]
Thank you... I'll go ahead and apply the fix.


Comment 2 by [email protected]



Comment 3 by [email protected]



Comment 4 by [email protected]
This issue was closed by revision r1770.


Comment 5 by [email protected]
This issue was closed by revision 7bf73aed4a9a.

ASK queries result in exception: bool object is not iterable

[email protected], 2009-02-16T18:33:48.000Z

What steps will reproduce the problem?
1. Create a Graph, populated with any triple such as :x :y :z
2. Construct a query such as  askQuery = "ASK { :x :y :z }"
3. Run graph.query(askQuery)

Or:

1. Run the attached ask-bug.py file.

Expected:

Return of a result object representing the boolean result.

Actual behavior:

raises this exception.

Traceback (most recent call last):
  File "", line 19, in 
  File "/usr/lib/python2.5/site-packages/rdflib/Graph.py", line 679, in query
    return plugin.get('SPARQLQueryResult',QueryResult)(p.query(strOrQuery,
initBindings, initNs, DEBUG))
  File "/usr/lib/python2.5/site-packages/rdflib/sparql/QueryResult.py",
line 216, in __init__
    result,selectionF,allVars,orderBy,distinct = qResult
TypeError: 'bool' object is not iterable


Using rdflib 2.4.0 installed with pip, on Ubuntu 8.10.

Comment 1 by [email protected]



Comment 2 by [email protected]
Added as test case in r1477. Verified that the test case was failing in 2.4.0 as indicated. The test case as written, 
{{{ self.assertEquals(res.askAnswer, [True]) }}}, is currently passing in trunk (r1477).


Comment 3 by [email protected]
r1480 exposes another error here, where ASK{} will return False when
DAWG_DATASET_COMPLIANCE is set to True, and the triple does exist. This is a seperate
issue to the one seen in this ticket.

naming ambiguity rdflib.URIRef / rdflib.Literal etc (and non lower case module names)

[email protected], 2009-02-14T21:28:16.000Z

The "from rdflib.URIRef import URIRef" in rdflib's __init__.py clobbers rdflib.URIRef as the name of 
the module. This is confusing. Also, nose trips up on this naming ambiguity between the module 
and class; and as a result can not run the test cases.

Comment 1 by [email protected]
Committed changes in r1483 to fix all of the naming clashes except for the three InputSource ones. Just need to 
figure out where we want to put those three classes rdflib.syntax.source ?


Comment 2 by [email protected]
What about naming ambiguities between classes and the modules in rdflib.store?  An
example would be "from rdflib.store.Sleepycat import Sleepycat".  They're not
clobbered in __init__.py or causing test errors now, but they have the potential.


Comment 3 by [email protected]
Hi,

I want use the rdflib.Literal('something', language=None,
datatype=rdflib.URIRef('http://www.w3.org/2001/XMLSchema#string')) as a key value for
dictionary Literal_values.

But I have got an error

How can I use it as key value for a dictionary in python?

Any help would be appreciated

Best,
Mnau


Comment 4 by drewpca
manu.alem, your issue seems unrelated to this bug regarding rdflib imports. If you're 
still having a problem, please post it as a new issue and remember to include your 
exact error message so we can fix it.


Comment 5 by drewpca
Regarding the imports, work has already been done to put Literal/etc in a term.py 
module. But meanwhile, imports that have worked for years are now broken. I shall 
prepare a patch that makes "from rdflib import Literal, URIRef, BNode, Variable" work 
again. I'll also see what it would take to make things like "from rdflib.Graph import 
ConjunctiveGraph" work but print a deprecation warning. If legacy projects can't even 
start up with rdflib 2.5, they're going to hate moving to it.


Comment 6 by [email protected]
While still supporting rdflib.Graph et.al. is very nice for 2.4.x-users (whose code will break otherwise), 
IMHO this breaking change is for the better at large. I have faith that this wouldn't hurt the people 
using 2.4.x too much, as long as we're explicit and helpful in informing about this (and why it's been 
done).

As for supporting convenience import, I think it's both good for those who have used it in 2.4 (I did), 
and for the future as well. I have this for "rdflib/__init__.py"::

    # import common classes, functions and constants:
    # IMPORTANT: make sure to *never* shadow module names with these imports!
    from rdflib.graph import (Graph, ConjunctiveGraph,
            QuotedGraph, ReadOnlyGraphAggregate,
            ModificationException, UnSupportedAggregateOperation)
    from rdflib.namespace import Namespace, RDF, RDFS, OWL, _XSD_NS as XSD
    from rdflib.term import BNode, Identifier, Literal, URIRef, Variable

The big difference from 2.4.x is (at least) that Graph is exposed directly, instead of rdflib.Graph being 
BackwardCompatGraph. I think it's fairly ok now not to expose that though (it's been deprecated for 
quite a while AFAIK).


Comment 7 by [email protected]
Still, do we need an explicit declaration about exactly which namespace changes are ok to go into 
2.5? If we want to do more, should we defer all the rest to 3.0, or progressively rename (e.g. 
lowercase, relocate) "internal" packages for 2.6 etc.?

I'm unsure about how many 3d-party packages import from the internals of syntax etc.. (And what 
tolerance those would have regarding any changes.)


Comment 8 by gromgull
I disagree with lindstream, and semi agree with drewpca. 

I think being able to do: 

import rdflib

and then rdflib.Graph, Literal, etc. 

is a great usability feature. It's annoying to write the extra module in the middle
of rdflib.graph.Graph, we should really try to make working with rdflib as easy as
possible.


Comment 9 by [email protected]
Sorry, I was unclear. We really do agree. :) I just meant that I don't think we need to support the 2.4.x 
uppercase-modules (as I interpreted it drewpca was looking into).

So, no to the old (and currently fixed, i.e. removed):

    from rdflib.Graph import ConjunctiveGraph 

The new full forms are of course (e.g.):

    from rdflib.graph import ConjunctiveGraph
    from rdflib.namespace import Namespace
    from rdflib.term import URIRef

But *also* support:

    from rdflib import ConjunctiveGraph, Namespace, URIRef

I.e. add back the convenience imports in "rdflib/__init__.py".


Comment 10 by [email protected]
I'm going to work on adding the short forms back in now. I do not plan on adding back the upper case modules 
that were clashing with the class names however.


Comment 11 by [email protected]
This issue was updated by revision r1768.

moved


Comment 12 by [email protected]
This issue was updated by revision r1769.

Forgot to add this as part of r1767


Comment 13 by drewpca
The revisions in the last two comments seem to be about some other thing.

Anyway, what is the decision for the __repr__ of URIRef, Literal, etc? Since 
rdflib.URIRef will work, I would like the repr to be shorter:

  GOOD rdflib.URIRef('http://example.com/')
   BAD rdflib.term.URIRef('http://example.com/')

I have implemented the shorter repr and refactored the repetitive __repr__ code in 
branches/repr-43. Note that URIRefs and BNodes now emit unicode strings, which is a 
small change. I think that's correct given that URIRef and BNode are subclasses of the 
unicode type.

The tests are passing in that branch, feel free to just merge it in if you approve of 
the new reprs.

http://code.google.com/p/rdflib/source/detail?r=1793 has the diffs


Comment 14 by [email protected]
Sure; let's go ahead and treat the shorter names as the canonical name. The __repr__ methods, however, are 
supposed to return string objects; see: http://docs.python.org/reference/datamodel.html#object.__repr__

As for the last couple checkins, I've also been lumping in modules with non lower case names into this issue. I've 
modified the summary accordingly.


Comment 15 by [email protected]
This issue was closed by revision r1827.


Comment 16 by [email protected]
This issue was updated by revision 0503aa1c8716.


Comment 17 by [email protected]
This issue was updated by revision fde85e9b6c41.

moved


Comment 18 by [email protected]
This issue was updated by revision ed78f9ad9a6c.

Forgot to add this as part of r1767


Comment 19 by [email protected]
This issue was updated by revision 59e4a5955a32.


Comment 20 by [email protected]
This issue was updated by revision a42eecceb5db.


Comment 21 by [email protected]
This issue was updated by revision db54fad4b5b8.


Comment 22 by [email protected]
This issue was updated by revision f63201454234.


Comment 23 by [email protected]
This issue was updated by revision ee41728ab2e1.


Comment 24 by [email protected]
This issue was updated by revision b643c3c0c7e3.


Comment 25 by [email protected]
This issue was updated by revision deb907127c67.

>= and <= operators return erroneous results in sparql.query()

[email protected], 2008-10-16T18:17:10.000Z

# There seems to be a problem with the >= and <= operators.
# Running on Mac OS X 10.5.4 python 2.5.1
# This code:

#!/usr/bin/python
import sys
sys.path.insert(0, '/Library/Python/2.5/site-packages/rdflib-2.4.0-py2.5-macosx-10.3-fat.egg')

import rdflib
from rdflib import ConjunctiveGraph
from rdflib import BNode, Literal, Namespace, RDF, URIRef, RDFS, sparql, QueryResult
from StringIO import StringIO
from pprint import pprint
g = ConjunctiveGraph()
testgraph = """
    
   
      2007-12-31
      
   
   
      2008-01-06
      
   
   
      2008-01-04
      2008-01-05
      
   
   
      2008-01-07
      2008-01-08
      
   
   
      2008-01-02
      2008-01-03
      
   
   
      2008-01-09
      2008-01-10
      
   
   
      2008-01-01
      2008-01-11
      
   
   
        
"""

g.load(StringIO(testgraph))

print "rdflib version: %s" % rdflib.__version__
r = g.query("""
PREFIX ex: 
PREFIX loc: 
PREFIX rdfs: 
PREFIX xsd: 

SELECT *
WHERE {{?event ex:date ?date .
    FILTER (xsd:date(?date) >= xsd:date("2007-12-31") && xsd:date(?date) <= xsd:date("2008-01-11"))}
    UNION {?event ex:starts ?start; ex:finishes ?end.
        FILTER (xsd:date(?start) >= xsd:date("2008-01-02") && xsd:date(?end) <= xsd:date("2008-01-10"))}
}
ORDER BY ?event
""")
print "Selected: " 
pprint(r.selected)

# returns:

rdflib version: 2.4.0
Selected: 
[(rdflib.URIRef('http://temp.example.org/terms/Event#case1'),
  rdflib.Literal('2008-01-06', language=None, datatype=rdflib.URIRef('http://www.w3.org/2001/XMLSchema#date'))),
 (rdflib.URIRef('http://temp.example.org/terms/Event#case2'),
  rdflib.Literal('2008-01-05', language=None, datatype=rdflib.URIRef('http://www.w3.org/2001/XMLSchema#date')),
  rdflib.Literal('2008-01-04', language=None, datatype=rdflib.URIRef('http://www.w3.org/2001/XMLSchema#date'))),
 (rdflib.URIRef('http://temp.example.org/terms/Event#case3'),
  rdflib.Literal('2008-01-08', language=None, datatype=rdflib.URIRef('http://www.w3.org/2001/XMLSchema#date')),
  rdflib.Literal('2008-01-07', language=None, datatype=rdflib.URIRef('http://www.w3.org/2001/XMLSchema#date')))]

# where it should select cases 1-5. 
# The same code under rdflib version 2.4.1 (with sys.path.insert() commented out) returns:
  
rdflib version: 2.4.1
  File "build/bdist.macosx-10.5-i386/egg/rdflib/Graph.py", line 738, in query
  File "build/bdist.macosx-10.5-i386/egg/rdflib/sparql/bison/Processor.py", line 50, in query
  File "build/bdist.macosx-10.5-i386/egg/rdflib/sparql/Algebra.py", line 389, in TopEvaluate
  File "build/bdist.macosx-10.5-i386/egg/rdflib/sparql/Query.py", line 1015, in select
  File "build/bdist.macosx-10.5-i386/egg/rdflib/sparql/Query.py", line 914, in _orderedSelect
  File "build/bdist.macosx-10.5-i386/egg/rdflib/sparql/Query.py", line 871, in _getFullBinding
  File "build/bdist.macosx-10.5-i386/egg/rdflib/sparql/Query.py", line 1005, in select
  File "build/bdist.macosx-10.5-i386/egg/rdflib/sparql/Query.py", line 81, in _variablesToArray
rdflib.sparql.SPARQLError: SPARQL Error: 'selection' argument must be a string, a Variable, or a list of those.

# Similarly, if the first FILTER statement is modified thus:
FILTER (xsd:date(?date) >= xsd:date("2007-12-30") && xsd:date(?date) <= xsd:date("2008-01-11"))
# under version 2.4.0 it selects case 0

# if the second FILTER statement is modified thus:
FILTER (xsd:date(?start) >= xsd:date("2008-01-01") && xsd:date(?end) <= xsd:date("2008-01-11"))
# under version 2.4.0 it returns cases 1-5

Comment 1 by [email protected]



Comment 2 by [email protected]



Comment 3 by [email protected]
These issues involve bits that have been moved out of rdflib proper for now. We will re-open them 
or move them to rdfextas as appropriate.

Sqlobject store plugin error

[email protected], 2007-12-14T10:43:45.000Z

When executing the following code: 

plugin.get('sqlobject', Store)(id)

the following error occurs:

store = plugin.get('sqlobject', Store)(id)
File "build\bdist.win32\egg\rdflib\plugin.py", line 20, in get
File "build\bdist.win32\egg\rdflib\store\_sqlobject.py", line 34, in 
File "build\bdist.win32\egg\rdflib\store\_sqlobject.py", line 37, in Literals
NameError: name 'validators' is not defined

I'm using rdflib 2.4.0 on windows xp professional (and also tested on
windows vista).

We send the file as an attachment. 


Best regards

Comment 1 by [email protected]



Comment 2 by [email protected]
Acquired dependency? The sqlobject store module now depends on Formencode's validators package.

from formencode import validators


Comment 3 by [email protected]
As well as the formencode import, the version of SQLObject needs to match - SQLObject 0.7 works with the 
following diffs applied -- they need to be perused for sense.


Comment 4 by [email protected]



Comment 5 by [email protected]
The sqlobject store has been removed from rdflib proper.

n3 parser is silent when loading n3-like files

[email protected], 2007-11-28T15:55:07.000Z

What steps will reproduce the problem?
1. set parse input to n3
2. attempt to parse document with contents that "looks" like n3.

- What is the expected output? 

Some sort of exception I would presume.

- What do you see instead?

Nothing. The document output shows a basic RDF as if nothing was ever loaded.

- What version of the product are you using? On what operating system?

rdflib 2.4.0 on Fedora 7.

- Please provide any additional information below.

I managed to replicate this on a file that has the contents:

"made you look"

It was purely accidental, I was using the file as part of some failure case
unit testing I was doing.

Comment 1 by [email protected]



Comment 2 by [email protected]



Comment 3 by [email protected]



Comment 4 by gromgull



Comment 5 by gromgull
Fixed in r1755

MySQL backend open with create=True

[email protected], 2007-11-14T22:41:34.000Z

when running the MySQL backend and allowing it to create a new db on open,
the db 'test' is not found since it doesnt exist by default

Another problem is that the port is expected to be an int, which it is not
after the configuration is parsed.         
configDict = ParseConfigurationString(configuration)

I'm running svn HEAD

Comment 1 by [email protected]



Comment 2 by [email protected]
The work around for the MySQL backend creating your required database is to create an
empty database called 'test'


Comment 3 by [email protected]



Comment 4 by [email protected]



Comment 5 by [email protected]
No longer part of rdflib; at least for now.

Support serialization to TriX format

[email protected], 2008-01-23T03:40:45.000Z

It would be useful if RDFLib supported serialization to the TriX format
(particularly for high fidelity round-tripping of `ConjunctiveGraph`s).

Comment 1 by [email protected]



Comment 2 by [email protected]



Comment 3 by gromgull
This is done here: 
http://code.google.com/p/rdflib/source/browse/trunk/rdflib/syntax/serializers/TriXSerializer.py

With tests here: 
http://code.google.com/p/rdflib/source/browse/trunk/test/test_trix_parse.py
http://code.google.com/p/rdflib/source/browse/trunk/test/test_trix_serialize.py


Comment 4 by drewpca
somehow my notes for this code ended up on this page :(

http://code.google.com/p/rdflib/source/detail?r=1763


Comment 5 by gromgull



Comment 6 by gromgull
Good points - I will fix. 

Note that this has been in SVN since may'09 - but I only closed the ticket yesterday.


Comment 7 by gromgull



Comment 8 by gromgull
This issue was closed by revision r1842.


Comment 9 by gromgull
This issue was closed by revision f3b9d5e71f83.

toPython() doesn't convert datetimes with millis

ed.summers, 2009-02-17T10:55:06.000Z

It's nice that toPython() will convert dateTime XSD datatypes to datetime python objects:

>>> from rdflib import Literal , Namespace
>>> from datetime import datetime
>>> XSD_NS = Namespace(u'http://www.w3.org/2001/XMLSchema#')
>>> Literal('2008-02-09T10:46:29', datatype=XSD_NS.dateTime).toPython()
datetime.datetime(2008, 2, 9, 10, 46, 29)

But if you add milliseconds it doesn't seem to work:

>>> Literal('2009-02-17T05:48:53.203307', datatype=XSD_NS.dateTime).toPython()
rdflib.Literal('2009-02-17T05:48:53.203307', language=None, 
datatype=rdflib.URIRef('http://www.w3.org/2001/XMLSchema#dateTime'))

This bit me recently when I couldn't figure out why adding triples with datetime.now() wasn't 
working as expected:

>>> Literal(datetime.now()).toPython()
rdflib.Literal('2009-02-17T05:52:13.612998', language=None, 
datatype=rdflib.URIRef('http://www.w3.org/2001/XMLSchema#dateTime'))

It appears that RDFAlchemy had to hack around this problem: 
http://www.openvest.com/trac/wiki/CustomizingLiterals

Comment 1 by [email protected]



Comment 2 by [email protected]
Ed, Do you already have a patch for this issue?


Comment 3 by ed.summers
Yeah, looks like I committed as part of r1690?


Comment 4 by ed.summers
Actually that was the improved test, this was the fix r1689.


Comment 5 by ed.summers



Comment 6 by ed.summers
This issue was closed by revision 7071b586b8f8.


Comment 7 by ed.summers
This issue was updated by revision 171938e58cad.

Improved testing of what happens to datetime's with microseconds when
Python version < 2.6.0

Failing sparql test cases

[email protected], 2009-02-17T21:54:57.000Z

A number of sparql tests that were passing in 2.4.0 are failing in trunk.

To test one such test case:

    {{{ python setup.py nosetests --tests test/test_sparql_base_ref.py }}}

Comment 1 by [email protected]
r1210 works r1211 does not... looking at diff now
Looks like DAWG_DATASET_COMPLIANCE = False -> True is the change that causes the tests to fail.


Comment 2 by [email protected]
DAWG_DATASET_COMPLIANCE has been set back to False to match what it was in 2.4.0. The test cases now also 
appear to be in alignment with 2.4.0 (except with a few less failing).


Comment 3 by [email protected]

n3 parse error on \u043d\u04...

drewpca, 2008-04-24T07:45:17.000Z

input.n3 (based on a dbpedia entry):


 "Anna Sergeyevna Kournikova
(Russian: \u0410\u043d\u043d\u0430
\u0421\u0435\u0440\u0433\u0435\u0435\u0432\u043d\u0430
\u041a\u0443\u0440\u043d\u0438\u043a\u043e\u0432\u0430 " .


% python -c "from rdflib.Graph import ConjunctiveGraph as C;
C().parse('anna.n3', format='n3')"
Traceback (most recent call last):
  File "", line 1, in 
  File "build/bdist.linux-i686/egg/rdflib/Graph.py", line 828, in parse
  File "build/bdist.linux-i686/egg/rdflib/Graph.py", line 661, in parse
  File "build/bdist.linux-i686/egg/rdflib/syntax/parsers/N3Parser.py", line
32, in parse
  File "build/bdist.linux-i686/egg/rdflib/syntax/parsers/n3p/n3proc.py",
line 119, in parse
  File "build/bdist.linux-i686/egg/rdflib/syntax/parsers/n3p/n3p.py", line
117, in parse
  File "build/bdist.linux-i686/egg/rdflib/syntax/parsers/n3p/n3proc.py",
line 131, in onFinish
  File "build/bdist.linux-i686/egg/rdflib/syntax/parsers/n3p/n3proc.py",
line 397, in literalFinish
  File "build/bdist.linux-i686/egg/rdflib/syntax/parsers/n3p/n3proc.py",
line 477, in literal
  File "build/bdist.linux-i686/egg/rdflib/syntax/parsers/n3p/n3proc.py",
line 81, in unquote
rdflib.syntax.parsers.n3p.n3proc.ParseError: Illegal escape at: \u043d\u04...


cwm is able to read the file.

Comment 1 by [email protected]



Comment 2 by drewpca
This simpler n3 file has the same issue:

  "this word is in
\u201cquotes\u201d".

The nt parser can read it, but n3 can't. I was using n3 format for relative urls.


Comment 3 by drewpca
Oops- n3 is supposed to have uppercase hex in \u and \U escapes, so this error is
correct. Although I wouldn't mind if we matched the cwm behavior and permitted it :)


Comment 4 by [email protected]



Comment 5 by gromgull
Fixed in r1755

RDF parser blows up on SPARQL Example 8.3.3

[email protected], 2008-03-05T07:18:59.000Z

What steps will reproduce the problem?
1. Set up any Graph at all.
2. Call Graph.query on the SPARQL query below, taken from section 8.3.3. of
the SPARQL spec.
3.

What is the expected output? What do you see instead?  I see this:
rdflib INFO: version: 2.4.0
Traceback (most recent call last):
  File
"/Users/bmacgregor/Documents/eclipse-python/hinote/src/hinotesite/flex/test.py",
line 122, in 
    elif switch == 5: test4()    
  File
"/Users/bmacgregor/Documents/eclipse-python/hinote/src/hinotesite/flex/test.py",
line 79, in test4
    graph.query(query)
  File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/rdflib-2.4.0-py2.5-macosx-10.3-fat.egg/rdflib/Graph.py",
line 679, in query
  File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/rdflib-2.4.0-py2.5-macosx-10.3-fat.egg/rdflib/sparql/bison/Processor.py",
line 28, in query
  File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/rdflib-2.4.0-py2.5-macosx-10.3-fat.egg/rdflib/sparql/bison/Processor.py",
line 18, in Parse
SyntaxError: parse error at line 5, column 1: reached end-of-input,
expecting 'RIGHT_CURLY'



What version of the product are you using? On what operating system?
version: 2.4.0 on Mac OS X


Please provide any additional information below.


PREFIX  data:  
PREFIX  foaf:  
PREFIX  rdfs:  

SELECT ?mbox ?nick ?ppd
FROM NAMED 
FROM NAMED 
WHERE
{
  GRAPH data:aliceFoaf
  {
    ?alice foaf:mbox  ;
           foaf:knows ?whom .
    ?whom  foaf:mbox ?mbox ;
           rdfs:seeAlso ?ppd .
    ?ppd  a foaf:PersonalProfileDocument .
  } .
  GRAPH ?ppd
  {
      ?w foaf:mbox ?mbox ;
         foaf:nick ?nick
  }
}

Comment 1 by [email protected]
My bad.  The above query was rejected, but not by the parser.
However, the following query works for SPARQLER, but is rejected
by the parser.

if __name__ == '__main__':
    from rdflib import URIRef, plugin, store
    from rdflib.Graph import Graph
    mystore = plugin.get('IOMemory', store.Store)()
    graph = Graph(mystore, URIRef("http://foo#bar"))
    query = """
select ?s ?o ?c
where {graph ?c {?s  ?o} . filter (?s = ) } 
"""
    graph.query(query)


Comment 2 by [email protected]



Comment 3 by [email protected]



Comment 4 by [email protected]
These issues involve bits that have been moved out of rdflib proper for now. We will re-open them 
or move them to rdfextas as appropriate.

N3 parser chokes on @base directive

[email protected], 2008-04-22T13:29:00.000Z

What steps will reproduce the problem?
1. Write an N3 or turtle document with an @base directive
2. Try to parse it as format='n3'

What is the expected output? What do you see instead?

I would expect the directive to be processed as providing a base for all
relative URIs in the document.

What version of the product are you using? On what operating system?

2.4.0 on Windows XP

Please provide any additional information below.

Comment 1 by [email protected]



Comment 2 by gromgull



Comment 3 by [email protected]



Comment 4 by gromgull
Fixed in r1755, test-case in test_n3.py


Comment 5 by gromgull
Issue 127 has been merged into this issue.

g1 == g2 doesn't test graph equivalence

[email protected], 2008-04-24T14:54:01.000Z

What steps will reproduce the problem?
1. Create two graphs, g1 and g2
2. Make them equivalent
3. assert g1 == g2

What is the expected output? What do you see instead?

Expected: True
Actual: False

What version of the product are you using? On what operating system?

2.4.0

Please provide any additional information below.

Comment 1 by [email protected]



Comment 2 by [email protected]



Comment 3 by gromgull
I think this is the correct behaviour, but it should be documented. There is the
isomorphic function in graphutils for testing this, but it maybe be expensive. 

I recommend WontFix, but document this for the graph class.


Comment 4 by [email protected]
Over a year ago, but still open.

from rdflib import compare
iso1 = compare.to_isomorphic(graph1)
iso2 = compare.to_isomorphic(graph2)
assert iso1 == iso2

should solve your problem. Who can colse this issue?


Comment 5 by gromgull
(cleaning up issue list)

rdflib egg should not include test directory

[email protected], 2008-03-04T15:44:35.000Z

$ easy_install rdflib==2.4.0
$ python
>>> from test import pystone
timte: Traceback (most recent call last):
File "", line 1, in ?
ImportError: cannot import name pystone 
 
The python core library has a test package I should always be able to use
whatever I install. The rdflib test package should either not be included
in the egg at all or it should be moved inside the rdflib package. The
rdflib toplevel test package hides the test package in python core.

Comment 1 by [email protected]



Comment 2 by [email protected]
Fixed in r1489 for rdflib 2.5 (still need to fix for rdflib 2.4.x)


Comment 3 by [email protected]
Also fixed in 2.4.x branch in r1491.

CIA SVN integration

[email protected], 2007-11-16T16:20:19.000Z

We've lost our integration with CIA in the process of migrating the svn over to google. There may 
be some way to hook them up again, but it looks like google does not provide support for svn 
post-commit scripts at this time. Anyone depending on http://cia.vc/stats/project/rdflib ?

Is this issue a show stopper for anyone re: svn migration? If so we should revert to using 
svn.rdflib.net ASAP.

Anyone care to dig into this issue? I did a quick search and asked on #cia on freenode with the 
response of "alex_joni: eikeon: I don't think google allows for custom scripts to run when a commit 
is handled, so you'll have to hack your way around it (either from a commit mailing list, or replicate 
the svn using svnsync)"

Comment 3 by [email protected]
Google Code now has "web hooks": you give it a URL and Google POSTs to it when a 
commit comes in.


Comment 4 by [email protected]
We're using http://friendfeed.com/rdflib for this now.


Comment 5 by [email protected]

test/leaves.py doesn't work correctly.

[email protected], 2009-02-18T21:29:52.000Z

What steps will reproduce the problem?
1. python test/leaves.py
2. nosetests test/leaves.py

What is the expected output? What do you see instead?

Expected is to see unit tests run. Running it directly has no output,
running it under nose has this output:


test.leaves.test_leaves ... ERROR

======================================================================
ERROR: test.leaves.test_leaves
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/nose/case.py", line 182, in runTest
    self.test(*self.arg)
  File "/home/sthorne/src/rdflib/test/leaves.py", line 36, in test_leaves
NameError: global name 'DocFileSuite' is not defined

----------------------------------------------------------------------
Ran 1 test in 0.002s

FAILED (errors=1)

Comment 1 by [email protected]



Comment 2 by [email protected]
Fixed in r1831 and r1832


Comment 3 by [email protected]
This issue was updated by revision r1832.

Moved to test_leaves.py so that it gets discovered and run. (Fixes issue 49.)


Comment 4 by [email protected]
This issue was updated by revision 76032889132d.


Comment 5 by [email protected]
This issue was updated by revision 5cfb2b2aea4b.

Moved to test_leaves.py so that it gets discovered and run. (Fixes issue 49.)

no-op Store.namespaces() breaks RDF/XML serialization

[email protected], 2008-12-21T18:51:35.000Z

What steps will reproduce the problem?

Run Graph.serialize() off a Redland back-end (or presumably anything else
in which Store.namespaces() is a stub)

What is the expected output? What do you see instead?

Traceback (most recent call last):
  File "experimental/scan.py", line 473, in 
    d.run()
  File "experimental/scan.py", line 438, in run
    print self.model.serialize() #format='n3')  File
"/var/lib/python-support/python2.5/rdflib/Graph.py", line 628, in serialize
    return serializer.serialize(destination, base=base, encoding=encoding,
**arg
s)
  File "/var/lib/python-support/python2.5/rdflib/syntax/serializer.py",
line 28,
 in serialize
    self.serializer.serialize(stream, base=base, encoding=encoding)
  File
"/var/lib/python-support/python2.5/rdflib/syntax/serializers/XMLSerialize
r.py", line 50, in serialize
    bindings = list(self.__bindings())
  File
"/var/lib/python-support/python2.5/rdflib/syntax/serializers/XMLSerialize
r.py", line 26, in __bindings
    prefix, namespace, name = nm.compute_qname(predicate)
  File
"/var/lib/python-support/python2.5/rdflib/syntax/NamespaceManager.py", li
ne 62, in compute_qname
    prefix = "_%s" % len(list(self.store.namespaces()))
TypeError: 'NoneType' object is not iterable

What version of the product are you using? On what operating system?

rdflib 2.4.0
Python 2.5.2

Redland 1.0.7

Linux deuce 2.6.24-16-server #1 SMP Thu Apr 10 13:58:00 UTC 2008 i686 GNU/Linux

Ubuntu 8.10 (intrepid)


Please provide any additional information below.

The base class rdflib.store.Store should probably have a fallback method of
handling namespace maps. Stores that don't implement their own namespace
maps should just inherit the fallback. N3 output is not affected.

Comment 1 by [email protected]



Comment 2 by [email protected]



Comment 3 by [email protected]
This issue was closed by revision r1776.


Comment 4 by [email protected]
This issue was closed by revision e6dc68c6b54d.

GMT dateTime literals don't compare correctly

drewpca, 2008-12-26T22:23:24.000Z

>>> x = Literal("2008-12-01T18:02:00Z",
datatype=URIRef('http://www.w3.org/2001/XMLSchema#dateTime'))
>>> x == x
False

If Z is replaced with "-08:00", or the datatype is removed, then the
self-equality works again.

Comment 1 by [email protected]
Added a test case for this issue in r1469. This issue seems to be fixed in trunk.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.