diff options
author | ogrisel <devnull@localhost> | 2006-06-25 15:08:19 +0000 |
---|---|---|
committer | ogrisel <devnull@localhost> | 2006-06-25 15:08:19 +0000 |
commit | b20eff9b9b18aa992752dc237f7bb79e05710916 (patch) | |
tree | 995a06a66746ed7153abb0f5a9fa42394a93361e | |
parent | ecd5acb32f0b424e2d54bde5f33b89bd5abe6ff3 (diff) | |
download | rdflib-b20eff9b9b18aa992752dc237f7bb79e05710916.tar.gz |
fixing EOL problems by setting the svn:eol-style property to native and replacing \r\n by a single \n
42 files changed, 3013 insertions, 3013 deletions
@@ -1,616 +1,616 @@ -2006/02/27
- RELEASE 2.3.1
-
- Added save method to BackwardCompatibleGraph so that
- example.py etc work again.
-
- Applied patch from Drew Perttula to add local_time_zone
- argument to util's date_time method.
-
- Fixed a relativize bug in the rdf/xml serializer.
-
- Fixed NameError: global name 'URIRef' is not defined error in
- Sleepycat.py by adding missing import.
-
- Applied patch for Seq to sort list by integer, added by Drew
- Hess.
-
- Added a preserve_bnode_ids option to rdf/xml parser.
-
- Applied assorted patches for tests (see
- http://tracker.asemantics.com/rdflib/ticket/8 )
-
- Applied redland.diff (see
- http://tracker.asemantics.com/rdflib/ticket/9 )
-
- Applied changes specified
- http://tracker.asemantics.com/rdflib/ticket/7
-
- Added a set method to Graph.
-
- Fixed RDF/XML serializer so that it does not choke on n3 bits
- (rather it'll just ignore them)
-
-
-2005/12/23
- RELEASE 2.3.0
-
- See http://rdflib.net/2.3.0/ for most up-to-date release notes
-
- Added N3 support to Graph and Store.
-
- Added Sean's n3p parser, and ntriples parser.
-
- Sleepycat implementation has been revamped in the process of
- expanding it to support the new requirements n3
- requirements. It also now persists a journal -- more to come.
-
- detabified source files.
-
- Literal and parsers now distinguish between datatype of None and datatype of "".
-
- Store-agnostic 'fallback' implementation of REGEX matching
- (inefficient but provides the capability to stores that don't
- support it natively). Implemented as a 'wrapper' around any
- Store which replaces REGEX terms with None (before dispatching
- to the store) and whittles out results that don't match the
- given REGEX term expression(s).
-
- Store-agnostic 'fallback' implementation of transactional
- rollbacks (also inefficient but provides the capablity to
- stores that don't support it natively). Implemented as a
- wrapper that tracks a 'thread-safe' list of reversal
- operations (for every add, track the remove call that reverts
- the store, and vice versa). Upon store.rollback(), execute the
- reverse operations. However, this doesn't guarantee
- durability, since if the system fails before the rollbacks are
- all executed, the store will remain in an invalid state, but
- it provides Atomicity in the best case scenario.
-
-
-2005/10/10
- RELEASE 2.2.3
-
- Fixed Sleepycat backend to commit after an add and
- remove. This should help just a bit with those unclean
- shutdowns ;)
-
- Fixed use of logging so that it does not mess with the root
- logger. Thank you, Arve, for pointing this one out.
-
- Fixed Graph's value method to have default for subject in
- addition to predicate and object.
-
- Fixed Fourthought backend to be consistent with interface. It
- now supports an empty constructor and an open method that
- takes a configuration string.
-
-
-2005/09/10
- RELEASE 2.2.2
-
- Applied patch from inkel to add encoding argument to all
- serialization related methods.
-
- Fixed XMLSerializer bug regarding default namespace bindings.
-
- Fixed namespace binding bug involving binding a second default
- namespace.
-
- Applied patch from Gunnar AAstrand Grimnes to add context
- support to __iadd__ on Graph. (Am considering the lack of
- context support a bug. Any users currently using __iadd__, let
- me know if this breaks any of your code.)
-
- Added Fourthought backend contributed by Chimezie Ogbuji.
-
- Fixed a RDF/XML parser bug relating to XMLLiteral and
- escaping.
-
- Fixed setup.py so that install does not try to uninstall
- (rename_old) before installing; there's now an uninstall
- command if one needs to uninstall.
-
-
-2005/08/25
- RELEASE 2.2.1
-
- Fixed issue regarding Python2.3 compatibility.
-
- Fixed minor issue with URIRef's absolute method.
-
-
-2005/08/12
- RELEASE 2.1.4
-
- Added optional base argument to URIRef.
-
- Fixed bug where load and parse had inconsistent behavior.
-
- Added a FileInputSource.
-
- Added skeleton sparql parser and test framework.
-
- Included pyparsing (pyparsing.sourceforge.net) for sparql parsing.
-
- Added attribute support to namespaces.
-
-
-2005/06/28
- RELEASE 2.1.3
-
- Added Ivan's sparql-p implementation.
-
- Literal is now picklable.
-
- Added optional base argument to serialize methods about which to relativize.
-
- Applied patch to remove some dependencies on Python 2.4
- features.
-
- Fixed BNode's n3 serialization bug (recently introduced).
-
- Fixed a collections related bug.
-
-
-2005/05/13
- RELEASE 2.1.2
-
- Added patch from Sidnei da Silva that adds a sqlobject based backend.
-
- Fixed bug in PrettyXMLSerializer (rdf prefix decl was missing sometimes)
-
- Fixed bug in RDF/XML parser where empty collections where
- causing exceptions.
-
-
-2005/05/01
- RELEASE 2.1.1
-
- Fixed a number of bugs relating to 2.0 backward compatibility.
-
- Fixed split_uri to handle URIs with _ in them properly.
-
- Fixed bug in RDF/XML handler's absolutize that would cause some URIRefs to end in ##
-
- Added check_context to Graph.
-
- Added patch the improves IOMemory implementation.
-
-
-2005/04/12
- RELEASE 2.1.0
-
- Merged TripleStore and InformationStore into Graph.
-
- Added plugin support (or at least cleaned up, made consistent the
- plugin support that existed).
-
- Added value and seq methods to Graph.
-
- Renamed prefix_mapping to bind.
-
- Added namespaces method that is a generator over all prefix,
- namespace bindings.
-
- Added notion of NamespaceManager.
-
- Added couple new backends, IOMemory and ZODB.
-
-
-2005/03/19
- RELEASE 2.0.6
-
- Added pretty-xml serializer (inlines BNodes where possible,
- typed nodes, Collections).
-
- Fixed bug in NTParser and n3 methods where not all characters
- where being escaped.
-
- Changed label and comment methods to return default passed in
- when there is no label or comment. Moved methods to Store
- Class. Store no longer inherits from Schema.
-
- Fixed bug involving a case with rdf:about='#'
-
- Changed InMemoryBackend to update third index in the same style it
- does the first two.
-
-
-2005/01/08
- RELEASE 2.0.5
-
- Added publicID argument to Store's load method.
-
- Added RDF and RDFS to top level rdflib package.
-
-
-2004/10/14
- RELEASE 2.0.4
-
- Removed unfinished functionality.
-
- Fixed bug where another prefix other than rdf was getting
- defined for the rdf namespace (causing an assertion to fail).
-
- Fixed bug in serializer where nodeIDs were not valid NCNames.
-
-
-2004/04/21
- RELEASE 2.0.3
-
- Added missing "from __future__ import generators" statement to
- InformationStore.
-
- Simplified RDF/XML serializer fixing a few bugs involving
- BNodes.
-
- Added a reset method to RDF/XML parser.
-
- Changed 'if foo' to "if foo is not None" in a few places in
- the RDF/XML parser.
-
- Fully qualified imports in rdflib.syntax {parser, serializer}.
-
- Context now goes through InformationStore (was bypassing it
- going directly to backend).
-
-
-2004/03/22
- RELEASE 2.0.2
-
- Improved performance of Identifier equality tests.
-
- Added missing "from __future__ import generators" statements
- needed to run on Python2.2.
-
- Added alternative to shlib.move() if it isn't present.
-
- Fixed bug that occured when specifying a backend to
- InformationStore's constructor.
-
- Fixed bug recently introduced into InformationStore's remove
- method.
-
-
-2004/03/15
- RELEASE 2.0.1
-
- Fixed a bug in the SleepyCatBackend multi threaded concurrency
- support. (Tested fairly extensively under the following
- conditions: multi threaded, multi process, and both). NOTE:
- fix involved change to database format -- so 2.0.1 will not be
- able to open databases created with 2.0.0
-
- Removed the use of the Concurrent wrapper around
- InMemoryBackend and modified InMemoryBackend to handle
- concurrent requests. (Motivated by Concurrent's poor
- performance on bigger TripleStores.)
-
- Improved the speed of len(store) by making backends
- responsible for implementing __len__.
-
- Context objects now have a identifier property.
-
-
-2004/03/10
- RELEASE 2.0.0
-
- Fixed a few bugs in the SleepyCatBackend multi process
- concurrency support.
-
- Removed rdflib.Resource
-
- Changed remove to now take a triple pattern and removed
- remove_triples method.
-
- Added __iadd__ method to Store in support of store +=
- another_store.
-
-
-2004/01/04
- RELEASE 1.3.2
-
- Added a serialization dispatcher.
-
- Added format arg to save method.
-
- Store now remembers prefix/namespace bindings.
-
- Backends are now more pluggable
-
- ...
-
-2003/10/14
- RELEASE 1.3.1
-
- Fixed bug in serializer where triples where only getting
- serialized the first time.
-
- Added type checking for contexts.
-
- Fixed bug that caused comparisons with a Literal to fail when
- the right hand side was not a string.
-
- Added DB_INIT_CDB flag to SCBacked for supporting multiple
- reader/single writer access
-
- Changed rdf:RDF to be optional to conform with latest spec.
-
- Fixed handling of XMLLiterals
-
-
-2003/04/40
- RELEASE 1.3.0
-
- Removed bag_id support and added it to OLD_TERMS.
-
- Added a double hash for keys in SCBacked.
-
- Fixed _HTTPClient so that it no longer removes metadata about
- a context right after it adds it.
-
- Added a KDTreeStore and RedlandStore backends.
-
- Added a StoreTester.
-
-
-2003/02/28
- RELEASE 1.2.4
-
- Fixed bug in SCBackend where language and datatype information
- where being ignored.
-
- Fixed bug in transitive_subjects.
-
- Updated some of the test cases that where not up to date.
-
- async_load now adds more http header and error information to
- the InformationStore.
-
-
-2003/02/11
- RELEASE 1.2.3
-
- Fixed bug in load methods where relative URLs where not being
- absolutized correctly on Windows.
-
- Fixed serializer so that it throws an exception when trying to
- serialize a graph with a predicate that can not be split.
-
-
-2003/02/07
- RELEASE 1.2.2
-
- Added an exists method to the BackwardCompatibility mixin.
-
- Added versions of remove, remove_triples and triples methods
- to the BackwardCompatility mixin for TripleStores that take an
- s, p, o as opposed to an (s, p, o).
-
-
-2003/02/03
- RELEASE 1.2.1
-
- Added support for parsing XMLLiterals.
-
- Added support for proper charmod checking (only works in
- Python2.3).
-
- Fixed remaining rdfcore test cases that where not passing.
-
- Fixed windows bug in AbstractInformationStore's run method.
-
-
-2003/01/02
- RELEASE 1.2.0
-
- Added systemID, line #, and column # to error messages.
-
- BNode prefix is now composed of ascii_letters instead of letters.
-
- Added a bsddb backed InformationStore.
-
- Added an asyncronous load method, methods for scheduling context
- updates, and a run method.
-
-
-2002/12/16
- RELEASE 1.1.5
-
- Introduction of InformationStore, a TripleStore with the
- addition of context support.
-
- Resource __getitem__ now returns object (no longer returns a
- Resource for the object).
-
- Fixed bug in parser that was introduced in last release
- regaurding unqualified names.
-
-
-2002/12/10
- RELEASE 1.1.4
-
- Interface realigned with last stable release.
-
- Serializer now uses more of the abbreviated forms where
- possible.
-
- Parser optimized and cleaned up.
-
- Added third index to InMemoryStore.
-
- The load and parse methods now take a single argument.
-
- Added a StringInputSource for to support parsing from strings.
-
- Renamed rdflib.BTreeTripleStore.TripleStore to
- rdflib.BTreeTripleStore.BTreeTripleStore.
-
- Minor reorganization of mix-in classes.
-
-
-2002/12/03
- RELEASE 1.1.3
-
- BNodes now created with a more unique identifier so BNodes
- from different sessions do not collide.
-
- Added initial support for XML Literals (for now they are
- parsed into Literals).
-
- Resource is no longer a special kind of URIRef.
-
- Resource no longer looks at range to determine default return
- type for __getitem__. Instead there is now a get(predicate, default)
- method.
-
-
-2002/11/21
- RELEASE 1.1.2
-
- Fixed Literal's __eq__ method so that Literal('foo')=='foo' etc.
-
- Fixed Resource's __setitem__ method so that it does not raise
- a dictionary changed size while iterating exception.
-
-
-2002/11/09
- RELEASE 1.1.1
-
- Resource is now a special kind of URIRef
-
- Resource's __getitem__ now looks at rdfs:range to determine
- return type in default case.
-
-
-
-2002/11/05
- RELEASE 1.1.0 # A new development branch
-
- Cleaned up interface and promoted it to SIR: Simple Interface
- for RDF.
-
- Updated parser to use SAX2 interfaces instead of using expat directly.
-
- Added BTreeTripleStore, a ZODB BTree TripleStore backend. And
- a default pre-mixed TripleStore that uses it.
-
- Synced with latest (Editor's draft) RDF/XML spec.
-
- Added datatype support.
-
- Cleaned up interfaces for load/parse: removed generate_path
- from loadsave andrenamed parse_URI to parse.
-
-
-2002/10/08
- RELEASE 0.9.6 # The end of a development brant
-
- BNode can now be created with specified value.
-
- Literal now has a language attribute.
-
- Parser now creates Literals with language attribute set
- appropriately as determined by xml:lang attributes.
-
-
- TODO: Serializer-Literals-language attribute
-
- TODO: Change __eq__ so that Literal("foo")=="foo" etc
-
- TripleStores now support "in" operator.
- For example: if (s, p, o) in store: print "Found ", s, p, o
-
- Added APIs/object for working at level of a Resource. NOTE:
- This functionality is still experimental
-
- Consecutive Collections now parse correctly.
-
-2002/08/06
- RELEASE 0.9.5
-
- Added support for rdf:parseType="Collection"
-
- Added items generator for getting items in a Collection
-
- Renamed rdflib.triple_store to rdflib.TripleStore to better follow
- python style conventions.
-
- Added an Identifier Class
-
- Moved each node into its own Python module.
-
- Added rdflib.util with a first and uniq function.
-
- Added a little more to example.py
-
- Removed generate_uri since we have BNodes now.
-
-
-2002/07/29
- RELEASE 0.9.4
-
- Added support for proposed rdf:nodeID to both the parser and
- serializer.
-
- Reimplemented serializer which now nests things where
- possible.
-
- Added partial support for XML Literal parseTypes.
-
-
-2002/07/16
- RELEASE 0.9.3
-
- Fixed bug where bNodes where being created for nested property
- elements when they where not supposed to be.
-
- Added lax mode that will convert rdf/xml files that contain bare
- IDs etc. Also, lax mode will only report parse errors instead of
- raising exceptions.
-
- Added missing check for valid attribute names in the case of
- production 5.18 of latest WD spec.
-
-
-2002/07/05
- RELEASE 0.9.2
-
- Added missing constants for SUBPROPERTYOF, ISDEFINEDBY.
-
- Added test case for running all of the rdf/xml test cases.
-
- Reimplemented rdf/xml parser to conform to latest WD.
-
-
-2002/06/10
- RELEASE 0.9.1
-
- There is now a remove and a remove_triples (no more overloaded
- remove).
-
- Layer 2 has been merged with layer 1 since there is no longer a
- need for them to be separate layers.
-
- The generate_uri method has moved to LoadSave since triple stores
- do not have a notion of a uri. [Also, with proper bNode support on
- its way the need for a generate_uri might not be as high.]
-
- Fixed bug in node's n3 function: URI -> URIRef.
-
- Replaced string based exceptions with class based exceptions.
-
- Added PyUnit TestCase for parser.py
-
- Added N-Triples parser.
-
- Added __len__ and __eq__ methods to store interface.
-
-
-2002/06/04
- RELEASE 0.9.0
-
- Initial release after being split from redfootlib.
-
-
+2006/02/27 + RELEASE 2.3.1 + + Added save method to BackwardCompatibleGraph so that + example.py etc work again. + + Applied patch from Drew Perttula to add local_time_zone + argument to util's date_time method. + + Fixed a relativize bug in the rdf/xml serializer. + + Fixed NameError: global name 'URIRef' is not defined error in + Sleepycat.py by adding missing import. + + Applied patch for Seq to sort list by integer, added by Drew + Hess. + + Added a preserve_bnode_ids option to rdf/xml parser. + + Applied assorted patches for tests (see + http://tracker.asemantics.com/rdflib/ticket/8 ) + + Applied redland.diff (see + http://tracker.asemantics.com/rdflib/ticket/9 ) + + Applied changes specified + http://tracker.asemantics.com/rdflib/ticket/7 + + Added a set method to Graph. + + Fixed RDF/XML serializer so that it does not choke on n3 bits + (rather it'll just ignore them) + + +2005/12/23 + RELEASE 2.3.0 + + See http://rdflib.net/2.3.0/ for most up-to-date release notes + + Added N3 support to Graph and Store. + + Added Sean's n3p parser, and ntriples parser. + + Sleepycat implementation has been revamped in the process of + expanding it to support the new requirements n3 + requirements. It also now persists a journal -- more to come. + + detabified source files. + + Literal and parsers now distinguish between datatype of None and datatype of "". + + Store-agnostic 'fallback' implementation of REGEX matching + (inefficient but provides the capability to stores that don't + support it natively). Implemented as a 'wrapper' around any + Store which replaces REGEX terms with None (before dispatching + to the store) and whittles out results that don't match the + given REGEX term expression(s). + + Store-agnostic 'fallback' implementation of transactional + rollbacks (also inefficient but provides the capablity to + stores that don't support it natively). Implemented as a + wrapper that tracks a 'thread-safe' list of reversal + operations (for every add, track the remove call that reverts + the store, and vice versa). Upon store.rollback(), execute the + reverse operations. However, this doesn't guarantee + durability, since if the system fails before the rollbacks are + all executed, the store will remain in an invalid state, but + it provides Atomicity in the best case scenario. + + +2005/10/10 + RELEASE 2.2.3 + + Fixed Sleepycat backend to commit after an add and + remove. This should help just a bit with those unclean + shutdowns ;) + + Fixed use of logging so that it does not mess with the root + logger. Thank you, Arve, for pointing this one out. + + Fixed Graph's value method to have default for subject in + addition to predicate and object. + + Fixed Fourthought backend to be consistent with interface. It + now supports an empty constructor and an open method that + takes a configuration string. + + +2005/09/10 + RELEASE 2.2.2 + + Applied patch from inkel to add encoding argument to all + serialization related methods. + + Fixed XMLSerializer bug regarding default namespace bindings. + + Fixed namespace binding bug involving binding a second default + namespace. + + Applied patch from Gunnar AAstrand Grimnes to add context + support to __iadd__ on Graph. (Am considering the lack of + context support a bug. Any users currently using __iadd__, let + me know if this breaks any of your code.) + + Added Fourthought backend contributed by Chimezie Ogbuji. + + Fixed a RDF/XML parser bug relating to XMLLiteral and + escaping. + + Fixed setup.py so that install does not try to uninstall + (rename_old) before installing; there's now an uninstall + command if one needs to uninstall. + + +2005/08/25 + RELEASE 2.2.1 + + Fixed issue regarding Python2.3 compatibility. + + Fixed minor issue with URIRef's absolute method. + + +2005/08/12 + RELEASE 2.1.4 + + Added optional base argument to URIRef. + + Fixed bug where load and parse had inconsistent behavior. + + Added a FileInputSource. + + Added skeleton sparql parser and test framework. + + Included pyparsing (pyparsing.sourceforge.net) for sparql parsing. + + Added attribute support to namespaces. + + +2005/06/28 + RELEASE 2.1.3 + + Added Ivan's sparql-p implementation. + + Literal is now picklable. + + Added optional base argument to serialize methods about which to relativize. + + Applied patch to remove some dependencies on Python 2.4 + features. + + Fixed BNode's n3 serialization bug (recently introduced). + + Fixed a collections related bug. + + +2005/05/13 + RELEASE 2.1.2 + + Added patch from Sidnei da Silva that adds a sqlobject based backend. + + Fixed bug in PrettyXMLSerializer (rdf prefix decl was missing sometimes) + + Fixed bug in RDF/XML parser where empty collections where + causing exceptions. + + +2005/05/01 + RELEASE 2.1.1 + + Fixed a number of bugs relating to 2.0 backward compatibility. + + Fixed split_uri to handle URIs with _ in them properly. + + Fixed bug in RDF/XML handler's absolutize that would cause some URIRefs to end in ## + + Added check_context to Graph. + + Added patch the improves IOMemory implementation. + + +2005/04/12 + RELEASE 2.1.0 + + Merged TripleStore and InformationStore into Graph. + + Added plugin support (or at least cleaned up, made consistent the + plugin support that existed). + + Added value and seq methods to Graph. + + Renamed prefix_mapping to bind. + + Added namespaces method that is a generator over all prefix, + namespace bindings. + + Added notion of NamespaceManager. + + Added couple new backends, IOMemory and ZODB. + + +2005/03/19 + RELEASE 2.0.6 + + Added pretty-xml serializer (inlines BNodes where possible, + typed nodes, Collections). + + Fixed bug in NTParser and n3 methods where not all characters + where being escaped. + + Changed label and comment methods to return default passed in + when there is no label or comment. Moved methods to Store + Class. Store no longer inherits from Schema. + + Fixed bug involving a case with rdf:about='#' + + Changed InMemoryBackend to update third index in the same style it + does the first two. + + +2005/01/08 + RELEASE 2.0.5 + + Added publicID argument to Store's load method. + + Added RDF and RDFS to top level rdflib package. + + +2004/10/14 + RELEASE 2.0.4 + + Removed unfinished functionality. + + Fixed bug where another prefix other than rdf was getting + defined for the rdf namespace (causing an assertion to fail). + + Fixed bug in serializer where nodeIDs were not valid NCNames. + + +2004/04/21 + RELEASE 2.0.3 + + Added missing "from __future__ import generators" statement to + InformationStore. + + Simplified RDF/XML serializer fixing a few bugs involving + BNodes. + + Added a reset method to RDF/XML parser. + + Changed 'if foo' to "if foo is not None" in a few places in + the RDF/XML parser. + + Fully qualified imports in rdflib.syntax {parser, serializer}. + + Context now goes through InformationStore (was bypassing it + going directly to backend). + + +2004/03/22 + RELEASE 2.0.2 + + Improved performance of Identifier equality tests. + + Added missing "from __future__ import generators" statements + needed to run on Python2.2. + + Added alternative to shlib.move() if it isn't present. + + Fixed bug that occured when specifying a backend to + InformationStore's constructor. + + Fixed bug recently introduced into InformationStore's remove + method. + + +2004/03/15 + RELEASE 2.0.1 + + Fixed a bug in the SleepyCatBackend multi threaded concurrency + support. (Tested fairly extensively under the following + conditions: multi threaded, multi process, and both). NOTE: + fix involved change to database format -- so 2.0.1 will not be + able to open databases created with 2.0.0 + + Removed the use of the Concurrent wrapper around + InMemoryBackend and modified InMemoryBackend to handle + concurrent requests. (Motivated by Concurrent's poor + performance on bigger TripleStores.) + + Improved the speed of len(store) by making backends + responsible for implementing __len__. + + Context objects now have a identifier property. + + +2004/03/10 + RELEASE 2.0.0 + + Fixed a few bugs in the SleepyCatBackend multi process + concurrency support. + + Removed rdflib.Resource + + Changed remove to now take a triple pattern and removed + remove_triples method. + + Added __iadd__ method to Store in support of store += + another_store. + + +2004/01/04 + RELEASE 1.3.2 + + Added a serialization dispatcher. + + Added format arg to save method. + + Store now remembers prefix/namespace bindings. + + Backends are now more pluggable + + ... + +2003/10/14 + RELEASE 1.3.1 + + Fixed bug in serializer where triples where only getting + serialized the first time. + + Added type checking for contexts. + + Fixed bug that caused comparisons with a Literal to fail when + the right hand side was not a string. + + Added DB_INIT_CDB flag to SCBacked for supporting multiple + reader/single writer access + + Changed rdf:RDF to be optional to conform with latest spec. + + Fixed handling of XMLLiterals + + +2003/04/40 + RELEASE 1.3.0 + + Removed bag_id support and added it to OLD_TERMS. + + Added a double hash for keys in SCBacked. + + Fixed _HTTPClient so that it no longer removes metadata about + a context right after it adds it. + + Added a KDTreeStore and RedlandStore backends. + + Added a StoreTester. + + +2003/02/28 + RELEASE 1.2.4 + + Fixed bug in SCBackend where language and datatype information + where being ignored. + + Fixed bug in transitive_subjects. + + Updated some of the test cases that where not up to date. + + async_load now adds more http header and error information to + the InformationStore. + + +2003/02/11 + RELEASE 1.2.3 + + Fixed bug in load methods where relative URLs where not being + absolutized correctly on Windows. + + Fixed serializer so that it throws an exception when trying to + serialize a graph with a predicate that can not be split. + + +2003/02/07 + RELEASE 1.2.2 + + Added an exists method to the BackwardCompatibility mixin. + + Added versions of remove, remove_triples and triples methods + to the BackwardCompatility mixin for TripleStores that take an + s, p, o as opposed to an (s, p, o). + + +2003/02/03 + RELEASE 1.2.1 + + Added support for parsing XMLLiterals. + + Added support for proper charmod checking (only works in + Python2.3). + + Fixed remaining rdfcore test cases that where not passing. + + Fixed windows bug in AbstractInformationStore's run method. + + +2003/01/02 + RELEASE 1.2.0 + + Added systemID, line #, and column # to error messages. + + BNode prefix is now composed of ascii_letters instead of letters. + + Added a bsddb backed InformationStore. + + Added an asyncronous load method, methods for scheduling context + updates, and a run method. + + +2002/12/16 + RELEASE 1.1.5 + + Introduction of InformationStore, a TripleStore with the + addition of context support. + + Resource __getitem__ now returns object (no longer returns a + Resource for the object). + + Fixed bug in parser that was introduced in last release + regaurding unqualified names. + + +2002/12/10 + RELEASE 1.1.4 + + Interface realigned with last stable release. + + Serializer now uses more of the abbreviated forms where + possible. + + Parser optimized and cleaned up. + + Added third index to InMemoryStore. + + The load and parse methods now take a single argument. + + Added a StringInputSource for to support parsing from strings. + + Renamed rdflib.BTreeTripleStore.TripleStore to + rdflib.BTreeTripleStore.BTreeTripleStore. + + Minor reorganization of mix-in classes. + + +2002/12/03 + RELEASE 1.1.3 + + BNodes now created with a more unique identifier so BNodes + from different sessions do not collide. + + Added initial support for XML Literals (for now they are + parsed into Literals). + + Resource is no longer a special kind of URIRef. + + Resource no longer looks at range to determine default return + type for __getitem__. Instead there is now a get(predicate, default) + method. + + +2002/11/21 + RELEASE 1.1.2 + + Fixed Literal's __eq__ method so that Literal('foo')=='foo' etc. + + Fixed Resource's __setitem__ method so that it does not raise + a dictionary changed size while iterating exception. + + +2002/11/09 + RELEASE 1.1.1 + + Resource is now a special kind of URIRef + + Resource's __getitem__ now looks at rdfs:range to determine + return type in default case. + + + +2002/11/05 + RELEASE 1.1.0 # A new development branch + + Cleaned up interface and promoted it to SIR: Simple Interface + for RDF. + + Updated parser to use SAX2 interfaces instead of using expat directly. + + Added BTreeTripleStore, a ZODB BTree TripleStore backend. And + a default pre-mixed TripleStore that uses it. + + Synced with latest (Editor's draft) RDF/XML spec. + + Added datatype support. + + Cleaned up interfaces for load/parse: removed generate_path + from loadsave andrenamed parse_URI to parse. + + +2002/10/08 + RELEASE 0.9.6 # The end of a development brant + + BNode can now be created with specified value. + + Literal now has a language attribute. + + Parser now creates Literals with language attribute set + appropriately as determined by xml:lang attributes. + + + TODO: Serializer-Literals-language attribute + + TODO: Change __eq__ so that Literal("foo")=="foo" etc + + TripleStores now support "in" operator. + For example: if (s, p, o) in store: print "Found ", s, p, o + + Added APIs/object for working at level of a Resource. NOTE: + This functionality is still experimental + + Consecutive Collections now parse correctly. + +2002/08/06 + RELEASE 0.9.5 + + Added support for rdf:parseType="Collection" + + Added items generator for getting items in a Collection + + Renamed rdflib.triple_store to rdflib.TripleStore to better follow + python style conventions. + + Added an Identifier Class + + Moved each node into its own Python module. + + Added rdflib.util with a first and uniq function. + + Added a little more to example.py + + Removed generate_uri since we have BNodes now. + + +2002/07/29 + RELEASE 0.9.4 + + Added support for proposed rdf:nodeID to both the parser and + serializer. + + Reimplemented serializer which now nests things where + possible. + + Added partial support for XML Literal parseTypes. + + +2002/07/16 + RELEASE 0.9.3 + + Fixed bug where bNodes where being created for nested property + elements when they where not supposed to be. + + Added lax mode that will convert rdf/xml files that contain bare + IDs etc. Also, lax mode will only report parse errors instead of + raising exceptions. + + Added missing check for valid attribute names in the case of + production 5.18 of latest WD spec. + + +2002/07/05 + RELEASE 0.9.2 + + Added missing constants for SUBPROPERTYOF, ISDEFINEDBY. + + Added test case for running all of the rdf/xml test cases. + + Reimplemented rdf/xml parser to conform to latest WD. + + +2002/06/10 + RELEASE 0.9.1 + + There is now a remove and a remove_triples (no more overloaded + remove). + + Layer 2 has been merged with layer 1 since there is no longer a + need for them to be separate layers. + + The generate_uri method has moved to LoadSave since triple stores + do not have a notion of a uri. [Also, with proper bNode support on + its way the need for a generate_uri might not be as high.] + + Fixed bug in node's n3 function: URI -> URIRef. + + Replaced string based exceptions with class based exceptions. + + Added PyUnit TestCase for parser.py + + Added N-Triples parser. + + Added __len__ and __eq__ methods to store interface. + + +2002/06/04 + RELEASE 0.9.0 + + Initial release after being split from redfootlib. + + @@ -1,32 +1,32 @@ -LICENSE AGREEMENT FOR RDFLIB 0.9.0 THROUGH 2.3.1
-------------------------------------------------
-Copyright (c) 2002-2005, Daniel Krech, http://eikeon.com/
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
- * Redistributions of source code must retain the above copyright
-notice, this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above
-copyright notice, this list of conditions and the following
-disclaimer in the documentation and/or other materials provided
-with the distribution.
-
- * Neither the name of Daniel Krech nor the names of its
-contributors may be used to endorse or promote products derived
-from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+LICENSE AGREEMENT FOR RDFLIB 0.9.0 THROUGH 2.3.1 +------------------------------------------------ +Copyright (c) 2002-2005, Daniel Krech, http://eikeon.com/ +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following +disclaimer in the documentation and/or other materials provided +with the distribution. + + * Neither the name of Daniel Krech nor the names of its +contributors may be used to endorse or promote products derived +from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/doc/InformationStore.html b/doc/InformationStore.html index a438f39d..530cae5b 100644 --- a/doc/InformationStore.html +++ b/doc/InformationStore.html @@ -1,52 +1,52 @@ -<?xml version="1.0"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
- "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
- <head>
- <title>InformationStore</title>
- <link REL="STYLESHEET" HREF="rdflib.css"/>
- </head>
- <body>
- <div CLASS="NAV">
- [ <a href="../index.html">RDFLib</A> |
- <a href="./index.html">Documentation</a> ]
- </div>
- <h1>InformationStore</h1>
-
- <p>
- RDFLib's InformationStore is a <a href="triple_store.html">TripleStore</a> with support
-for contexts.
- </p>
-
- <h2>InformationStore Interface</h2>
-
- <p>
- The InformationStore Interface extends the TripleStore
-interface. See the <a href="triple_store.html">TripleStore
-documentation</a> for a description of the TripleStore interface.
- <p>
- InformationStore overrides the following methods from
-TripleStore to allow an optional context argument:
- </p>
-
- <dl>
- <dt>add(<var>triple</var>, <var>context</var>)</dt>
- <dd>Adds triple, a tuple of the form (subject, predicate, object), to the InformationStore.</dd>
- <dt>remove(<var>triple</var>, <var>context</var>)</dt>
- <dd>Removes triple, a tuple of the form (subject, predicate, object), to the InformationStore.</dd>
- <dt>triples(<var>pattern</var>, <var>context</var>)</dt>
- <dd>A <a href="http://www.python.org/doc/2.2.2/whatsnew/node5.html">generator</a> over all the triples in the InformationStore matching pattern. Pattern is a tuple of the form (subject, predicate, object) where each of subject, predicate and object are either specified or None to indicate any value will match.
- </dd>
-
- <dt>contexts(triple=None)</dt>
- <dd>A generator over all the contexts or if triple is specified a generator over all the contexts triple is in.</dd>
-
- <dl>
- <dt>__init__(self, path=None, backend=None)</dt>
- <dt>load(self, location, format="xml")</dt>
- <dt>get_context(self, identifier)</dt>
- <dt>remove_context(self, identifier)</dt>
- </dl>
-
- </body>
-</html>
+<?xml version="1.0"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" + "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> + <head> + <title>InformationStore</title> + <link REL="STYLESHEET" HREF="rdflib.css"/> + </head> + <body> + <div CLASS="NAV"> + [ <a href="../index.html">RDFLib</A> | + <a href="./index.html">Documentation</a> ] + </div> + <h1>InformationStore</h1> + + <p> + RDFLib's InformationStore is a <a href="triple_store.html">TripleStore</a> with support +for contexts. + </p> + + <h2>InformationStore Interface</h2> + + <p> + The InformationStore Interface extends the TripleStore +interface. See the <a href="triple_store.html">TripleStore +documentation</a> for a description of the TripleStore interface. + <p> + InformationStore overrides the following methods from +TripleStore to allow an optional context argument: + </p> + + <dl> + <dt>add(<var>triple</var>, <var>context</var>)</dt> + <dd>Adds triple, a tuple of the form (subject, predicate, object), to the InformationStore.</dd> + <dt>remove(<var>triple</var>, <var>context</var>)</dt> + <dd>Removes triple, a tuple of the form (subject, predicate, object), to the InformationStore.</dd> + <dt>triples(<var>pattern</var>, <var>context</var>)</dt> + <dd>A <a href="http://www.python.org/doc/2.2.2/whatsnew/node5.html">generator</a> over all the triples in the InformationStore matching pattern. Pattern is a tuple of the form (subject, predicate, object) where each of subject, predicate and object are either specified or None to indicate any value will match. + </dd> + + <dt>contexts(triple=None)</dt> + <dd>A generator over all the contexts or if triple is specified a generator over all the contexts triple is in.</dd> + + <dl> + <dt>__init__(self, path=None, backend=None)</dt> + <dt>load(self, location, format="xml")</dt> + <dt>get_context(self, identifier)</dt> + <dt>remove_context(self, identifier)</dt> + </dl> + + </body> +</html> diff --git a/doc/index.html b/doc/index.html index 4b65b5a3..8c7b2be5 100644 --- a/doc/index.html +++ b/doc/index.html @@ -1,26 +1,26 @@ -<html>
- <head>
- <title>RDFLib documentation</title>
- <link rel="stylesheet" href="rdflib.css"/>
- </head>
- <body>
- <div class="nav">
- [ <a href="http://rdflib.net/">RDFLib</A> |
- <a href="../index.html">RDFLib Readme</a> ]
- </div>
- <h1>RDFLib Documentation</h1>
-
- <p>
- For general information about RDFLib, see the <a href="http://rdflib.net/">RDFLib homepage</a>.
- </p>
-
- <h2>Getting Started</h2>
-
- <ul>
- <li><a href="installing.html">Installing RDFLib</a></li>
- <li><a href="../html/index.html">rdflib API Documentation</a> (currently generated from source using epydoc)</li>
- <li><a href="examples.html">Examples</a></li>
- </ul>
-
- </body>
-</html>
+<html> + <head> + <title>RDFLib documentation</title> + <link rel="stylesheet" href="rdflib.css"/> + </head> + <body> + <div class="nav"> + [ <a href="http://rdflib.net/">RDFLib</A> | + <a href="../index.html">RDFLib Readme</a> ] + </div> + <h1>RDFLib Documentation</h1> + + <p> + For general information about RDFLib, see the <a href="http://rdflib.net/">RDFLib homepage</a>. + </p> + + <h2>Getting Started</h2> + + <ul> + <li><a href="installing.html">Installing RDFLib</a></li> + <li><a href="../html/index.html">rdflib API Documentation</a> (currently generated from source using epydoc)</li> + <li><a href="examples.html">Examples</a></li> + </ul> + + </body> +</html> diff --git a/doc/installing.html b/doc/installing.html index e2e869e3..bdfd9332 100644 --- a/doc/installing.html +++ b/doc/installing.html @@ -1,31 +1,31 @@ -<html>
- <head>
- <title>Installing RDFLib</title>
- <link REL="STYLESHEET" HREF="rdflib.css"/>
- </head>
- <body>
- <div CLASS="NAV">
- [ <a href="http://rdflib.net/">RDFLib</A> |
- <a href="./index.html">Documentation</a> ]
- </div>
-
- <h1>Installing RDFLib</h1>
-
- <h2>Prerequisites</h2>
- <ul>
- <li><a href="http://python.org/2.2/">Python version 2.2.1</a> or later.</li>
- </ul>
-
- <h2>Running Install</h2>
- <p>From the rdflib-2.x directory run the following command:</p>
- <pre class="code_sample">python setup.py install</pre>
-
- <p>
- See the documentation for <a
-href="./InformationStore.html">InformationStore</a> or <a
-href="./triple_store.html">TripleStore</a>, RDFLib's primary
-interfaces. Or try some <a href="./examples.html">examples</a>.
- </p>
-
- </body>
+<html> + <head> + <title>Installing RDFLib</title> + <link REL="STYLESHEET" HREF="rdflib.css"/> + </head> + <body> + <div CLASS="NAV"> + [ <a href="http://rdflib.net/">RDFLib</A> | + <a href="./index.html">Documentation</a> ] + </div> + + <h1>Installing RDFLib</h1> + + <h2>Prerequisites</h2> + <ul> + <li><a href="http://python.org/2.2/">Python version 2.2.1</a> or later.</li> + </ul> + + <h2>Running Install</h2> + <p>From the rdflib-2.x directory run the following command:</p> + <pre class="code_sample">python setup.py install</pre> + + <p> + See the documentation for <a +href="./InformationStore.html">InformationStore</a> or <a +href="./triple_store.html">TripleStore</a>, RDFLib's primary +interfaces. Or try some <a href="./examples.html">examples</a>. + </p> + + </body> </html>
\ No newline at end of file diff --git a/doc/rdflib.css b/doc/rdflib.css index d869948d..5246feb0 100644 --- a/doc/rdflib.css +++ b/doc/rdflib.css @@ -1,88 +1,88 @@ -.sidebar {
- border: 1px solid #00000;
- background: #EEE;
- padding: 5px;
-}
-
-.announcement {
- border: 1px solid #00000;
- padding: 5px;
-}
-
-pre.code_sample {
- background: #EEE;
- padding: 5px;
-}
-
-.ednote {
- color: #999;
- font-style: italic;
-}
-
-.cvs_id {
- clear: both;
- color: #999;
- font-size: small;
- border-top: solid 1px #999;
-}
-
-.author {
- font-size: larger;
- font-style: italic;
-}
-
-var {
- font-weight: normal;
- font-style: italic;
- color: #000;
-}
-
-
-
-body {
- font-family: "verdana", "Trebuchet MS", sans-serif;
- margin: 1.5em 5% 3em 5%;
-}
-
-h1, h2, h3, b, dt {
- font-family: "Trebuchet MS", sans-serif;
- color: #00000;
-}
-
-a {
- font-weight: bold;
- color: #000;
- text-decoration: none
-}
-
-a:hover {
- font-weight: bold;
- color: #000;
- background-color: #ddd;
- text-decoration: none
-}
-
-div.NAV {
- position: absolute; top: 0em;
- color: #999;
-}
-div.NAV A {
- color: #999;
- text-decoration: none;
-}
-
-DIV.announcement dl {
- margin-left: 0px;
-}
-
-
-DIV.document_versions, DIV.download {
- float: right;
- clear: right;
- border: solid 1px black;
- font-size: smaller;
- margin: 0em 0em 1em 1em;
- padding: 0.5em 1em 1em 1em;
- background: #eee;
-}
-
+.sidebar { + border: 1px solid #00000; + background: #EEE; + padding: 5px; +} + +.announcement { + border: 1px solid #00000; + padding: 5px; +} + +pre.code_sample { + background: #EEE; + padding: 5px; +} + +.ednote { + color: #999; + font-style: italic; +} + +.cvs_id { + clear: both; + color: #999; + font-size: small; + border-top: solid 1px #999; +} + +.author { + font-size: larger; + font-style: italic; +} + +var { + font-weight: normal; + font-style: italic; + color: #000; +} + + + +body { + font-family: "verdana", "Trebuchet MS", sans-serif; + margin: 1.5em 5% 3em 5%; +} + +h1, h2, h3, b, dt { + font-family: "Trebuchet MS", sans-serif; + color: #00000; +} + +a { + font-weight: bold; + color: #000; + text-decoration: none +} + +a:hover { + font-weight: bold; + color: #000; + background-color: #ddd; + text-decoration: none +} + +div.NAV { + position: absolute; top: 0em; + color: #999; +} +div.NAV A { + color: #999; + text-decoration: none; +} + +DIV.announcement dl { + margin-left: 0px; +} + + +DIV.document_versions, DIV.download { + float: right; + clear: right; + border: solid 1px black; + font-size: smaller; + margin: 0em 0em 1em 1em; + padding: 0.5em 1em 1em 1em; + background: #eee; +} + @@ -1,49 +1,49 @@ -from rdflib import Graph
-from rdflib import URIRef, Literal, BNode, Namespace
-from rdflib import RDF
-
-store = Graph()
-
-# Bind a few prefix, namespace pairs.
-store.bind("dc", "http://http://purl.org/dc/elements/1.1/")
-store.bind("foaf", "http://xmlns.com/foaf/0.1/")
-
-# Create a namespace object for the Friend of a friend namespace.
-FOAF = Namespace("http://xmlns.com/foaf/0.1/")
-
-# Create an identifier to use as the subject for Donna.
-donna = BNode()
-
-# Add triples using store's add method.
-store.add((donna, RDF.type, FOAF["Person"]))
-store.add((donna, FOAF["nick"], Literal("donna", lang="foo")))
-store.add((donna, FOAF["name"], Literal("Donna Fales")))
-
-# Iterate over triples in store and print them out.
-print "--- printing raw triples ---"
-for s, p, o in store:
- print s, p, o
-
-# For each foaf:Person in the store print out its mbox property.
-print "--- printing mboxes ---"
-for person in store.subjects(RDF.type, FOAF["Person"]):
- for mbox in store.objects(person, FOAF["mbox"]):
- print mbox
-
-# Serialize the store as RDF/XML to the file foaf.rdf.
-store.save("foaf.rdf", format="pretty-xml")
-
-# Let's show off the serializers
-
-print "RDF Serializations:"
-
-# Serialize as XML
-print "--- start: rdf-xml ---"
-print store.serialize(format="pretty-xml")
-print "--- end: rdf-xml ---\n"
-
-# Serialize as NTriples
-print "--- start: ntriples ---"
-print store.serialize(format="nt")
-print "--- end: ntriples ---\n"
-
+from rdflib import Graph +from rdflib import URIRef, Literal, BNode, Namespace +from rdflib import RDF + +store = Graph() + +# Bind a few prefix, namespace pairs. +store.bind("dc", "http://http://purl.org/dc/elements/1.1/") +store.bind("foaf", "http://xmlns.com/foaf/0.1/") + +# Create a namespace object for the Friend of a friend namespace. +FOAF = Namespace("http://xmlns.com/foaf/0.1/") + +# Create an identifier to use as the subject for Donna. +donna = BNode() + +# Add triples using store's add method. +store.add((donna, RDF.type, FOAF["Person"])) +store.add((donna, FOAF["nick"], Literal("donna", lang="foo"))) +store.add((donna, FOAF["name"], Literal("Donna Fales"))) + +# Iterate over triples in store and print them out. +print "--- printing raw triples ---" +for s, p, o in store: + print s, p, o + +# For each foaf:Person in the store print out its mbox property. +print "--- printing mboxes ---" +for person in store.subjects(RDF.type, FOAF["Person"]): + for mbox in store.objects(person, FOAF["mbox"]): + print mbox + +# Serialize the store as RDF/XML to the file foaf.rdf. +store.save("foaf.rdf", format="pretty-xml") + +# Let's show off the serializers + +print "RDF Serializations:" + +# Serialize as XML +print "--- start: rdf-xml ---" +print store.serialize(format="pretty-xml") +print "--- end: rdf-xml ---\n" + +# Serialize as NTriples +print "--- start: ntriples ---" +print store.serialize(format="nt") +print "--- end: ntriples ---\n" + diff --git a/rdflib/sparql/parser.py b/rdflib/sparql/parser.py index a9991c32..54ceca09 100644 --- a/rdflib/sparql/parser.py +++ b/rdflib/sparql/parser.py @@ -271,7 +271,7 @@ WHERE { PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT ?name ?mbox WHERE { - ?x foaf:name ?name ;
+ ?x foaf:name ?name ; foaf:mbox ?mbox . } """, @@ -301,7 +301,7 @@ WHERE { PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT ?PREFIX ?WHERE WHERE { - ?x foaf:name ?PREFIX ;
+ ?x foaf:name ?PREFIX ; foaf:mbox ?WHERE . } """, @@ -310,33 +310,33 @@ WHERE { PREFIX WHERE: <http://xmlns.com/foaf/0.1/> SELECT ?name ?mbox WHERE { - ?x WHERE:name ?name ;
+ ?x WHERE:name ?name ; WHERE:mbox ?mbox . } """, -# some test cases from grammar.py
-"SELECT ?title WHERE { <http://example.org/book/book1> <http://purl.org/dc/elements/1.1/title> ?title . }",
-
-"""PREFIX foaf: <http://xmlns.com/foaf/0.1/>
-SELECT ?name ?mbox
-WHERE { ?person foaf:name ?name .
-OPTIONAL { ?person foaf:mbox ?mbox}
-}""",
-
-"""PREFIX foaf: <http://xmlns.com/foaf/0.1/>
-SELECT ?name ?name2
-WHERE { ?person foaf:name ?name .
-OPTIONAL { ?person foaf:knows ?p2 . ?p2 foaf:name ?name2 . }
-}""",
-
-"""PREFIX foaf: <http://xmlns.com/foaf/0.1/>
-#PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
-SELECT ?name ?mbox
-WHERE
-{
-{ ?person rdf:type foaf:Person } .
-OPTIONAL { ?person foaf:name ?name } .
-OPTIONAL {?person foaf:mbox ?mbox} .
+# some test cases from grammar.py +"SELECT ?title WHERE { <http://example.org/book/book1> <http://purl.org/dc/elements/1.1/title> ?title . }", + +"""PREFIX foaf: <http://xmlns.com/foaf/0.1/> +SELECT ?name ?mbox +WHERE { ?person foaf:name ?name . +OPTIONAL { ?person foaf:mbox ?mbox} +}""", + +"""PREFIX foaf: <http://xmlns.com/foaf/0.1/> +SELECT ?name ?name2 +WHERE { ?person foaf:name ?name . +OPTIONAL { ?person foaf:knows ?p2 . ?p2 foaf:name ?name2 . } +}""", + +"""PREFIX foaf: <http://xmlns.com/foaf/0.1/> +#PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> +SELECT ?name ?mbox +WHERE +{ +{ ?person rdf:type foaf:Person } . +OPTIONAL { ?person foaf:name ?name } . +OPTIONAL {?person foaf:mbox ?mbox} . }""" ] diff --git a/rdflib/store/Concurrent.py b/rdflib/store/Concurrent.py index ed228208..fdb8f314 100644 --- a/rdflib/store/Concurrent.py +++ b/rdflib/store/Concurrent.py @@ -1,93 +1,93 @@ -from __future__ import generators
-
-from threading import Lock
-
-class ResponsibleGenerator(object):
- """A generator that will help clean up when it is done being used."""
-
- __slots__ = ['cleanup', 'gen']
-
- def __init__(self, gen, cleanup):
- self.cleanup = cleanup
- self.gen = gen
-
- def __del__(self):
- self.cleanup()
-
- def __iter__(self):
- return self
-
- def next(self):
- return self.gen.next()
-
-
-class Concurrent(object):
-
- def __init__(self, store):
- self.store = store
-
- # number of calls to visit still in progress
- self.__visit_count = 0
-
- # lock for locking down the indices
- self.__lock = Lock()
-
- # lists for keeping track of added and removed triples while
- # we wait for the lock
- self.__pending_removes = []
- self.__pending_adds = []
-
- def add(self, (s, p, o)):
- if self.__visit_count==0:
- self.store.add((s, p, o))
- else:
- self.__pending_adds.append((s, p, o))
-
- def remove(self, (subject, predicate, object)):
- if self.__visit_count==0:
- self.store.remove((subject, predicate, object))
- else:
- self.__pending_removes.append((subject, predicate, object))
-
- def triples(self, (subject, predicate, object)):
- g = self.store.triples((subject, predicate, object))
- pending_removes = self.__pending_removes
- self.__begin_read()
- for s, p, o in ResponsibleGenerator(g, self.__end_read):
- if not (s, p, o) in pending_removes:
- yield s, p, o
-
- for (s, p, o) in self.__pending_adds:
- if (subject==None or subject==s) and (predicate==None or predicate==p) and (object==None or object==o):
- yield s, p, o
-
- def __len__(self):
- return self.store.__len__()
-
- def __begin_read(self):
- lock = self.__lock
- lock.acquire()
- self.__visit_count = self.__visit_count + 1
- lock.release()
-
- def __end_read(self):
- lock = self.__lock
- lock.acquire()
- self.__visit_count = self.__visit_count - 1
- if self.__visit_count==0:
- pending_removes = self.__pending_removes
- while pending_removes:
- (s, p, o) = pending_removes.pop()
- try:
- self.store.remove((s, p, o))
- except:
- # TODO: change to try finally?
- print s, p, o, "Not in store to remove"
- pending_adds = self.__pending_adds
- while pending_adds:
- (s, p, o) = pending_adds.pop()
- self.store.add((s, p, o))
- lock.release()
-
-
-
+from __future__ import generators + +from threading import Lock + +class ResponsibleGenerator(object): + """A generator that will help clean up when it is done being used.""" + + __slots__ = ['cleanup', 'gen'] + + def __init__(self, gen, cleanup): + self.cleanup = cleanup + self.gen = gen + + def __del__(self): + self.cleanup() + + def __iter__(self): + return self + + def next(self): + return self.gen.next() + + +class Concurrent(object): + + def __init__(self, store): + self.store = store + + # number of calls to visit still in progress + self.__visit_count = 0 + + # lock for locking down the indices + self.__lock = Lock() + + # lists for keeping track of added and removed triples while + # we wait for the lock + self.__pending_removes = [] + self.__pending_adds = [] + + def add(self, (s, p, o)): + if self.__visit_count==0: + self.store.add((s, p, o)) + else: + self.__pending_adds.append((s, p, o)) + + def remove(self, (subject, predicate, object)): + if self.__visit_count==0: + self.store.remove((subject, predicate, object)) + else: + self.__pending_removes.append((subject, predicate, object)) + + def triples(self, (subject, predicate, object)): + g = self.store.triples((subject, predicate, object)) + pending_removes = self.__pending_removes + self.__begin_read() + for s, p, o in ResponsibleGenerator(g, self.__end_read): + if not (s, p, o) in pending_removes: + yield s, p, o + + for (s, p, o) in self.__pending_adds: + if (subject==None or subject==s) and (predicate==None or predicate==p) and (object==None or object==o): + yield s, p, o + + def __len__(self): + return self.store.__len__() + + def __begin_read(self): + lock = self.__lock + lock.acquire() + self.__visit_count = self.__visit_count + 1 + lock.release() + + def __end_read(self): + lock = self.__lock + lock.acquire() + self.__visit_count = self.__visit_count - 1 + if self.__visit_count==0: + pending_removes = self.__pending_removes + while pending_removes: + (s, p, o) = pending_removes.pop() + try: + self.store.remove((s, p, o)) + except: + # TODO: change to try finally? + print s, p, o, "Not in store to remove" + pending_adds = self.__pending_adds + while pending_adds: + (s, p, o) = pending_adds.pop() + self.store.add((s, p, o)) + lock.release() + + + diff --git a/rdflib/syntax/__init__.py b/rdflib/syntax/__init__.py index 578d79b4..457fef72 100644 --- a/rdflib/syntax/__init__.py +++ b/rdflib/syntax/__init__.py @@ -1 +1 @@ -# RDF Library
+# RDF Library diff --git a/rdflib/util.py b/rdflib/util.py index 3ceba303..b9075865 100644 --- a/rdflib/util.py +++ b/rdflib/util.py @@ -1,236 +1,236 @@ -from rdflib.URIRef import URIRef
-from rdflib.BNode import BNode
-from rdflib.Literal import Literal
-from rdflib.Variable import Variable
-from rdflib.Graph import Graph, QuotedGraph
-from rdflib.Statement import Statement
-
-from rdflib.exceptions import SubjectTypeError, PredicateTypeError, ObjectTypeError, ContextTypeError
-from rdflib.compat import rsplit
-from cPickle import loads
-
-def first(seq):
- for result in seq:
- return result
- return None
-
-def uniq(sequence, strip=0):
- """removes duplicate strings from the sequence."""
- set = {}
- if strip:
- map(lambda val, default: set.__setitem__(val.strip(), default),
- sequence, [])
- else:
- map(set.__setitem__, sequence, [])
- return set.keys()
-
-def more_than(sequence, number):
- "Returns 1 if sequence has more items than number and 0 if not."
- i = 0
- for item in sequence:
- i += 1
- if i > number:
- return 1
- return 0
-
-def term(str, default=None):
- """See also from_n3"""
- if not str:
- return default
- elif str.startswith("<") and str.endswith(">"):
- return URIRef(str[1:-1])
- elif str.startswith('"') and str.endswith('"'):
- return Literal(str[1:-1])
- elif str.startswith("_"):
- return BNode(str)
- else:
- msg = "Unknown Term Syntax: '%s'" % str
- raise Exception(msg)
-
-
-
-from time import mktime, time, gmtime, localtime, timezone, altzone, daylight
-
-def date_time(t=None, local_time_zone=False):
- """http://www.w3.org/TR/NOTE-datetime ex: 1997-07-16T19:20:30Z
-
- >>> date_time(1126482850)
- '2005-09-11T23:54:10Z'
-
- >>> date_time(1126482850, local_time_zone=True)
- '2005-09-11T19:54:10-04:00'
-
- >>> date_time(1)
- '1970-01-01T00:00:01Z'
-
- >>> date_time(0)
- '1970-01-01T00:00:00Z'
- """
- if t is None:
- t = time()
-
- if local_time_zone:
- time_tuple = localtime(t)
- if time_tuple[8]:
- tz_mins = altzone // 60
- else:
- tz_mins = timezone // 60
- tzd = "-%02d:%02d" % (tz_mins // 60, tz_mins % 60)
- else:
- time_tuple = gmtime(t)
- tzd = "Z"
-
- year, month, day, hh, mm, ss, wd, y, z = time_tuple
- s = "%0004d-%02d-%02dT%02d:%02d:%02d%s" % ( year, month, day, hh, mm, ss, tzd)
- return s
-
-def parse_date_time(val):
- """always returns seconds in UTC
-
- # tests are written like this to make any errors easier to understand
- >>> parse_date_time('2005-09-11T23:54:10Z') - 1126482850.0
- 0.0
-
- >>> parse_date_time('2005-09-11T16:54:10-07:00') - 1126482850.0
- 0.0
-
- >>> parse_date_time('1970-01-01T00:00:01Z') - 1.0
- 0.0
-
- >>> parse_date_time('1970-01-01T00:00:00Z') - 0.0
- 0.0
- >>> parse_date_time("2005-09-05T10:42:00") - 1125916920.0
- 0.0
- """
-
- if "T" not in val:
- val += "T00:00:00Z"
-
- ymd, time = val.split("T")
- hms, tz_str = time[0:8], time[8:]
-
- if not tz_str or tz_str=="Z":
- time = time[:-1]
- tz_offset = 0
- else:
- signed_hrs = int(tz_str[:3])
- mins = int(tz_str[4:6])
- secs = (cmp(signed_hrs, 0) * mins + signed_hrs * 60) * 60
- tz_offset = -secs
-
- year, month, day = ymd.split("-")
- hour, minute, second = hms.split(":")
-
- t = mktime((int(year), int(month), int(day), int(hour),
- int(minute), int(second), 0, 0, 0))
- t = t - timezone + tz_offset
- return t
-
-def from_n3(s, default=None, backend=None):
- """ Creates the Identifier corresponding to the given n3 string. WARNING: untested, may contain bugs. TODO: add test cases."""
- if not s:
- return default
- if s.startswith('<'):
- return URIRef(s[1:-1])
- elif s.startswith('"'):
- # TODO: would a regex be faster?
- value, rest = rsplit(s, '"', 1)
- value = value[1:] # strip leading quote
- if rest.startswith("@"):
- if "^^" in rest:
- language, rest = rsplit(rest, '^^', 1)
- language = language[1:] # strip leading at sign
- else:
- language = rest[1:] # strip leading at sign
- rest = ''
- else:
- language = None
- if rest.startswith("^^"):
- datatype = rest[3:-1]
- else:
- datatype = None
- value = value.replace('\\"', '"').replace('\\\\', '\\').decode("unicode-escape")
- return Literal(value, language, datatype)
- elif s.startswith('{'):
- identifier = from_n3(s[1:-1])
- return QuotedGraph(backend, identifier)
- elif s.startswith('['):
- identifier = from_n3(s[1:-1])
- return Graph(backend, identifier)
- else:
- if s.startswith("_:"):
- return BNode(s[2:])
- else:
- return BNode(s)
-
-def check_context(c):
- if not (isinstance(c, URIRef) or \
- isinstance(c, BNode)):
- raise ContextTypeError("%s:%s" % (c, type(c)))
-
-def check_subject(s):
- """ Test that s is a valid subject identifier."""
- if not (isinstance(s, URIRef) or isinstance(s, BNode)):
- raise SubjectTypeError(s)
-
-def check_predicate(p):
- """ Test that p is a valid predicate identifier."""
- if not isinstance(p, URIRef):
- raise PredicateTypeError(p)
-
-def check_object(o):
- """ Test that o is a valid object identifier."""
- if not (isinstance(o, URIRef) or \
- isinstance(o, Literal) or \
- isinstance(o, BNode)):
- raise ObjectTypeError(o)
-
-def check_statement((s, p, o)):
- if not (isinstance(s, URIRef) or isinstance(s, BNode)):
- raise SubjectTypeError(s)
-
- if not isinstance(p, URIRef):
- raise PredicateTypeError(p)
-
- if not (isinstance(o, URIRef) or \
- isinstance(o, Literal) or \
- isinstance(o, BNode)):
- raise ObjectTypeError(o)
-
-def check_pattern((s, p, o)):
- if s and not (isinstance(s, URIRef) or isinstance(s, BNode)):
- raise SubjectTypeError(s)
-
- if p and not isinstance(p, URIRef):
- raise PredicateTypeError(p)
-
- if o and not (isinstance(o, URIRef) or \
- isinstance(o, Literal) or \
- isinstance(o, BNode)):
- raise ObjectTypeError(o)
-
-def graph_to_dot(graph, dot):
- """ Turns graph into dot (graphviz graph drawing format) using pydot. """
- import pydot
- nodes = {}
- for s, o in graph.subject_objects():
- for i in s,o:
- if i not in nodes.keys():
- nodes[i] = i
- for s, p, o in graph.triples((None,None,None)):
- dot.add_edge(pydot.Edge(nodes[s], nodes[o], label=p))
-
-
-if __name__ == "__main__":
- # try to make the tests work outside of the time zone they were written in
- #import os, time
- #os.environ['TZ'] = 'US/Pacific'
- #try:
- # time.tzset()
- #except AttributeError, e:
- # print e
- #pass
- # tzset missing! see
- # http://mail.python.org/pipermail/python-dev/2003-April/034480.html
- import doctest
- doctest.testmod()
+from rdflib.URIRef import URIRef +from rdflib.BNode import BNode +from rdflib.Literal import Literal +from rdflib.Variable import Variable +from rdflib.Graph import Graph, QuotedGraph +from rdflib.Statement import Statement + +from rdflib.exceptions import SubjectTypeError, PredicateTypeError, ObjectTypeError, ContextTypeError +from rdflib.compat import rsplit +from cPickle import loads + +def first(seq): + for result in seq: + return result + return None + +def uniq(sequence, strip=0): + """removes duplicate strings from the sequence.""" + set = {} + if strip: + map(lambda val, default: set.__setitem__(val.strip(), default), + sequence, []) + else: + map(set.__setitem__, sequence, []) + return set.keys() + +def more_than(sequence, number): + "Returns 1 if sequence has more items than number and 0 if not." + i = 0 + for item in sequence: + i += 1 + if i > number: + return 1 + return 0 + +def term(str, default=None): + """See also from_n3""" + if not str: + return default + elif str.startswith("<") and str.endswith(">"): + return URIRef(str[1:-1]) + elif str.startswith('"') and str.endswith('"'): + return Literal(str[1:-1]) + elif str.startswith("_"): + return BNode(str) + else: + msg = "Unknown Term Syntax: '%s'" % str + raise Exception(msg) + + + +from time import mktime, time, gmtime, localtime, timezone, altzone, daylight + +def date_time(t=None, local_time_zone=False): + """http://www.w3.org/TR/NOTE-datetime ex: 1997-07-16T19:20:30Z + + >>> date_time(1126482850) + '2005-09-11T23:54:10Z' + + >>> date_time(1126482850, local_time_zone=True) + '2005-09-11T19:54:10-04:00' + + >>> date_time(1) + '1970-01-01T00:00:01Z' + + >>> date_time(0) + '1970-01-01T00:00:00Z' + """ + if t is None: + t = time() + + if local_time_zone: + time_tuple = localtime(t) + if time_tuple[8]: + tz_mins = altzone // 60 + else: + tz_mins = timezone // 60 + tzd = "-%02d:%02d" % (tz_mins // 60, tz_mins % 60) + else: + time_tuple = gmtime(t) + tzd = "Z" + + year, month, day, hh, mm, ss, wd, y, z = time_tuple + s = "%0004d-%02d-%02dT%02d:%02d:%02d%s" % ( year, month, day, hh, mm, ss, tzd) + return s + +def parse_date_time(val): + """always returns seconds in UTC + + # tests are written like this to make any errors easier to understand + >>> parse_date_time('2005-09-11T23:54:10Z') - 1126482850.0 + 0.0 + + >>> parse_date_time('2005-09-11T16:54:10-07:00') - 1126482850.0 + 0.0 + + >>> parse_date_time('1970-01-01T00:00:01Z') - 1.0 + 0.0 + + >>> parse_date_time('1970-01-01T00:00:00Z') - 0.0 + 0.0 + >>> parse_date_time("2005-09-05T10:42:00") - 1125916920.0 + 0.0 + """ + + if "T" not in val: + val += "T00:00:00Z" + + ymd, time = val.split("T") + hms, tz_str = time[0:8], time[8:] + + if not tz_str or tz_str=="Z": + time = time[:-1] + tz_offset = 0 + else: + signed_hrs = int(tz_str[:3]) + mins = int(tz_str[4:6]) + secs = (cmp(signed_hrs, 0) * mins + signed_hrs * 60) * 60 + tz_offset = -secs + + year, month, day = ymd.split("-") + hour, minute, second = hms.split(":") + + t = mktime((int(year), int(month), int(day), int(hour), + int(minute), int(second), 0, 0, 0)) + t = t - timezone + tz_offset + return t + +def from_n3(s, default=None, backend=None): + """ Creates the Identifier corresponding to the given n3 string. WARNING: untested, may contain bugs. TODO: add test cases.""" + if not s: + return default + if s.startswith('<'): + return URIRef(s[1:-1]) + elif s.startswith('"'): + # TODO: would a regex be faster? + value, rest = rsplit(s, '"', 1) + value = value[1:] # strip leading quote + if rest.startswith("@"): + if "^^" in rest: + language, rest = rsplit(rest, '^^', 1) + language = language[1:] # strip leading at sign + else: + language = rest[1:] # strip leading at sign + rest = '' + else: + language = None + if rest.startswith("^^"): + datatype = rest[3:-1] + else: + datatype = None + value = value.replace('\\"', '"').replace('\\\\', '\\').decode("unicode-escape") + return Literal(value, language, datatype) + elif s.startswith('{'): + identifier = from_n3(s[1:-1]) + return QuotedGraph(backend, identifier) + elif s.startswith('['): + identifier = from_n3(s[1:-1]) + return Graph(backend, identifier) + else: + if s.startswith("_:"): + return BNode(s[2:]) + else: + return BNode(s) + +def check_context(c): + if not (isinstance(c, URIRef) or \ + isinstance(c, BNode)): + raise ContextTypeError("%s:%s" % (c, type(c))) + +def check_subject(s): + """ Test that s is a valid subject identifier.""" + if not (isinstance(s, URIRef) or isinstance(s, BNode)): + raise SubjectTypeError(s) + +def check_predicate(p): + """ Test that p is a valid predicate identifier.""" + if not isinstance(p, URIRef): + raise PredicateTypeError(p) + +def check_object(o): + """ Test that o is a valid object identifier.""" + if not (isinstance(o, URIRef) or \ + isinstance(o, Literal) or \ + isinstance(o, BNode)): + raise ObjectTypeError(o) + +def check_statement((s, p, o)): + if not (isinstance(s, URIRef) or isinstance(s, BNode)): + raise SubjectTypeError(s) + + if not isinstance(p, URIRef): + raise PredicateTypeError(p) + + if not (isinstance(o, URIRef) or \ + isinstance(o, Literal) or \ + isinstance(o, BNode)): + raise ObjectTypeError(o) + +def check_pattern((s, p, o)): + if s and not (isinstance(s, URIRef) or isinstance(s, BNode)): + raise SubjectTypeError(s) + + if p and not isinstance(p, URIRef): + raise PredicateTypeError(p) + + if o and not (isinstance(o, URIRef) or \ + isinstance(o, Literal) or \ + isinstance(o, BNode)): + raise ObjectTypeError(o) + +def graph_to_dot(graph, dot): + """ Turns graph into dot (graphviz graph drawing format) using pydot. """ + import pydot + nodes = {} + for s, o in graph.subject_objects(): + for i in s,o: + if i not in nodes.keys(): + nodes[i] = i + for s, p, o in graph.triples((None,None,None)): + dot.add_edge(pydot.Edge(nodes[s], nodes[o], label=p)) + + +if __name__ == "__main__": + # try to make the tests work outside of the time zone they were written in + #import os, time + #os.environ['TZ'] = 'US/Pacific' + #try: + # time.tzset() + #except AttributeError, e: + # print e + #pass + # tzset missing! see + # http://mail.python.org/pipermail/python-dev/2003-April/034480.html + import doctest + doctest.testmod() diff --git a/run_tests.py b/run_tests.py index 4d2f9e59..2c95fba6 100644 --- a/run_tests.py +++ b/run_tests.py @@ -1,58 +1,58 @@ -import unittest, inspect
-import rdflib
-
-quick = True
-verbose = False
-
-from test.identifier_equality import *
-
-from test.graph import *
-from test.graph2_2 import *
-
-from test.triple_store import *
-from test.context import *
-
-# # Graph no longer has the type checking at the moment. Do we want to
-# # put it back? Should we?
-# #
-# # from test.type_check import *
-
-from test.parser import *
-if not quick:
- from test import parser_rdfcore
- if verbose:
- parser_rdfcore.verbose = 1
- from test.parser_rdfcore import *
-
-from test.rdf import * # how does this manage to be 9 tests?
-
-from test.n3 import *
-from test.n3_quoting import *
-from test.nt import *
-
-from test.util import *
-from test.seq import SeqTestCase
-
-from test.store_performace import *
-
-from test.rules import *
-
-import test.rdfa
-
-if __name__ == "__main__":
-
- test.rdfa.main()
-
- if verbose:
- ts = unittest.makeSuite
- tests = [
- c for c in vars().values()
- if inspect.isclass(c)
- and not isinstance(c, rdflib.Namespace)
- and issubclass(c, unittest.TestCase)
- ]
- suite = unittest.TestSuite(map(ts, tests))
- unittest.TextTestRunner(verbosity=2).run(suite)
- else:
- unittest.main()
-
+import unittest, inspect +import rdflib + +quick = True +verbose = False + +from test.identifier_equality import * + +from test.graph import * +from test.graph2_2 import * + +from test.triple_store import * +from test.context import * + +# # Graph no longer has the type checking at the moment. Do we want to +# # put it back? Should we? +# # +# # from test.type_check import * + +from test.parser import * +if not quick: + from test import parser_rdfcore + if verbose: + parser_rdfcore.verbose = 1 + from test.parser_rdfcore import * + +from test.rdf import * # how does this manage to be 9 tests? + +from test.n3 import * +from test.n3_quoting import * +from test.nt import * + +from test.util import * +from test.seq import SeqTestCase + +from test.store_performace import * + +from test.rules import * + +import test.rdfa + +if __name__ == "__main__": + + test.rdfa.main() + + if verbose: + ts = unittest.makeSuite + tests = [ + c for c in vars().values() + if inspect.isclass(c) + and not isinstance(c, rdflib.Namespace) + and issubclass(c, unittest.TestCase) + ] + suite = unittest.TestSuite(map(ts, tests)) + unittest.TextTestRunner(verbosity=2).run(suite) + else: + unittest.main() + @@ -1,66 +1,66 @@ -# Install rdflib
-from distutils.core import setup
-from rdflib import __version__, __date__
-from distutils.extension import Extension
-from distutils.core import Command
-
-
-class uninstall(Command):
- description = "uninstall everything by renaming rdflib to 'rdflib-%s' % int(time())"
-
- user_options = [ ]
-
- def initialize_options (self):
- pass
-
- def finalize_options (self):
- pass
-
- def run (self):
- "Look for and rename rdflib if one has already been installed."
- from distutils.sysconfig import get_python_lib
- from os import rename
- from os.path import join, exists
- from time import time
-
- lib_dir = get_python_lib()
- rdflib_dir = join(lib_dir, "rdflib")
- if exists(rdflib_dir):
- backup = "%s-%s" % (rdflib_dir, int(time()))
- print "Renaming previously installed rdflib to: \n %s" % backup
- rename(rdflib_dir, backup)
-
-setup(
- cmdclass={'uninstall': uninstall},
- name = 'rdflib',
- version = __version__,
- description = "RDF library containing an RDF triple store and RDF/XML parser/serializer",
- author = "Daniel 'eikeon' Krech",
- author_email = "eikeon@eikeon.com",
- maintainer = "Daniel 'eikeon' Krech",
- maintainer_email = "eikeon@eikeon.com",
- url = "http://rdflib.net/",
- license = "http://rdflib.net/latest/LICENSE",
- platforms = ["any"],
- classifiers = ["Programming Language :: Python"],
- long_description = "RDF library containing an RDF triple store and RDF/XML parser/serializer",
- download_url = "http://rdflib.net/%s/rdflib-%s.tar.gz" % (__date__, __version__),
-
- packages = ['rdflib',
- 'rdflib.store',
- 'rdflib.store.FOPLRelationalModel',
- 'rdflib.sparql',
- 'rdflib.sparql.bison',
- 'rdflib.syntax',
- 'rdflib.syntax.serializers',
- 'rdflib.syntax.parsers',
- 'rdflib.syntax.parsers.n3p'],
- ext_modules = [
- Extension(
- name='rdflib.sparql.bison.SPARQLParserc',
- sources=['src/bison/SPARQLParser.c'],
- ),
- ]
-
- )
-
+# Install rdflib +from distutils.core import setup +from rdflib import __version__, __date__ +from distutils.extension import Extension +from distutils.core import Command + + +class uninstall(Command): + description = "uninstall everything by renaming rdflib to 'rdflib-%s' % int(time())" + + user_options = [ ] + + def initialize_options (self): + pass + + def finalize_options (self): + pass + + def run (self): + "Look for and rename rdflib if one has already been installed." + from distutils.sysconfig import get_python_lib + from os import rename + from os.path import join, exists + from time import time + + lib_dir = get_python_lib() + rdflib_dir = join(lib_dir, "rdflib") + if exists(rdflib_dir): + backup = "%s-%s" % (rdflib_dir, int(time())) + print "Renaming previously installed rdflib to: \n %s" % backup + rename(rdflib_dir, backup) + +setup( + cmdclass={'uninstall': uninstall}, + name = 'rdflib', + version = __version__, + description = "RDF library containing an RDF triple store and RDF/XML parser/serializer", + author = "Daniel 'eikeon' Krech", + author_email = "eikeon@eikeon.com", + maintainer = "Daniel 'eikeon' Krech", + maintainer_email = "eikeon@eikeon.com", + url = "http://rdflib.net/", + license = "http://rdflib.net/latest/LICENSE", + platforms = ["any"], + classifiers = ["Programming Language :: Python"], + long_description = "RDF library containing an RDF triple store and RDF/XML parser/serializer", + download_url = "http://rdflib.net/%s/rdflib-%s.tar.gz" % (__date__, __version__), + + packages = ['rdflib', + 'rdflib.store', + 'rdflib.store.FOPLRelationalModel', + 'rdflib.sparql', + 'rdflib.sparql.bison', + 'rdflib.syntax', + 'rdflib.syntax.serializers', + 'rdflib.syntax.parsers', + 'rdflib.syntax.parsers.n3p'], + ext_modules = [ + Extension( + name='rdflib.sparql.bison.SPARQLParserc', + sources=['src/bison/SPARQLParser.c'], + ), + ] + + ) + diff --git a/test/__init__.py b/test/__init__.py index 16e38532..792d6005 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -1 +1 @@ -#
+# diff --git a/test/parser.py b/test/parser.py index a80a1417..da7c1649 100644 --- a/test/parser.py +++ b/test/parser.py @@ -1,43 +1,43 @@ -import unittest
-
-from rdflib import Graph
-from rdflib import URIRef, BNode, Literal, RDF, RDFS
-from rdflib.StringInputSource import StringInputSource
-
-
-class ParserTestCase(unittest.TestCase):
- backend = 'default'
- path = 'store'
-
- def setUp(self):
- self.graph = Graph(backend=self.backend)
- self.graph.open(self.path)
-
- def tearDown(self):
- self.graph.close()
-
- def testNoPathWithHash(self):
- g = self.graph
- g.parse(StringInputSource("""\
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<rdf:RDF
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
->
-
-<rdfs:Class rdf:about="http://example.org#">
- <rdfs:label>testing</rdfs:label>
-</rdfs:Class>
-
-</rdf:RDF>
-"""), publicID="http://example.org")
-
- subject = URIRef("http://example.org#")
- label = g.value(subject, RDFS.label)
- self.assertEquals(label, Literal("testing"))
- type = g.value(subject, RDF.type)
- self.assertEquals(type, RDFS.Class)
-
-
-if __name__ == "__main__":
- unittest.main()
+import unittest + +from rdflib import Graph +from rdflib import URIRef, BNode, Literal, RDF, RDFS +from rdflib.StringInputSource import StringInputSource + + +class ParserTestCase(unittest.TestCase): + backend = 'default' + path = 'store' + + def setUp(self): + self.graph = Graph(backend=self.backend) + self.graph.open(self.path) + + def tearDown(self): + self.graph.close() + + def testNoPathWithHash(self): + g = self.graph + g.parse(StringInputSource("""\ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" +> + +<rdfs:Class rdf:about="http://example.org#"> + <rdfs:label>testing</rdfs:label> +</rdfs:Class> + +</rdf:RDF> +"""), publicID="http://example.org") + + subject = URIRef("http://example.org#") + label = g.value(subject, RDFS.label) + self.assertEquals(label, Literal("testing")) + type = g.value(subject, RDF.type) + self.assertEquals(type, RDFS.Class) + + +if __name__ == "__main__": + unittest.main() diff --git a/test/parser_rdfcore.py b/test/parser_rdfcore.py index 8a7747b5..4083fad9 100644 --- a/test/parser_rdfcore.py +++ b/test/parser_rdfcore.py @@ -1,204 +1,204 @@ -import unittest
-
-from rdflib import URIRef, BNode, Literal
-from rdflib.Namespace import Namespace
-from rdflib.exceptions import ParserError
-from rdflib.constants import TYPE
-
-from rdflib import Graph
-from rdflib.util import first
-
-
-verbose = 0
-
-from encodings.utf_8 import StreamWriter
-
-import sys
-sw = StreamWriter(sys.stdout)
-def write(msg):
- sw.write(msg+"\n")
- #sys.stdout.write(msg+"\n")
-
-class TestStore(Graph):
- def __init__(self, expected):
- super(TestStore, self).__init__()
- self.expected = expected
-
- def add(self, (s, p, o)):
- if not isinstance(s, BNode) and not isinstance(o, BNode):
- if not (s, p, o) in self.expected:
- m = u"Triple not in expected result: %s, %s, %s" % (s.n3(), p.n3(), o.n3())
- if verbose: write(m)
- #raise Exception(m)
- super(TestStore, self).add((s, p, o))
-
-
-TEST = Namespace("http://www.w3.org/2000/10/rdf-tests/rdfcore/testSchema#")
-
-import os
-def resolve(rel):
- return "http://www.w3.org/2000/10/rdf-tests/rdfcore/" + rel
-
-def _testPositive(uri, manifest):
- if verbose: write(u"TESTING: %s" % uri)
- result = 0 # 1=failed, 0=passed
- inDoc = first(manifest.objects(uri, TEST["inputDocument"]))
- outDoc = first(manifest.objects(uri, TEST["outputDocument"]))
- expected = Graph()
- if outDoc[-3:]==".nt":
- format = "nt"
- else:
- format = "xml"
- expected.load(outDoc, format=format)
- store = TestStore(expected)
- if inDoc[-3:]==".nt":
- format = "nt"
- else:
- format = "xml"
-
- try:
- store.load(inDoc, format=format)
- except ParserError, pe:
- write("Failed '")
- write(inDoc)
- write("' failed with")
- raise pe
- try:
- write(type(pe))
- except:
- write("sorry could not dump out error.")
- result = 1
- else:
- if not store.isomorphic(expected):
- write(u"""Failed: '%s'""" % uri)
-# print """ In:\n"""
-# for s, p, o in store:
-# print "%s %s %s." % (s.n3(), p.n3(), o.n3())
-# print """ Out:\n"""
-# for s, p, o in expected:
-# print "%s %s %s." % (s.n3(), p.n3(), o.n3())
-
- result += 1
-
- if verbose:
- write(""" In:\n""")
- for s, p, o in store:
- msg = u"%s %s %s." % (s.n3(), p.n3(), o.n3())
- write(msg)
- write(""" Out:\n""")
- for s, p, o in expected:
- write(u"%s %s %s." % (s.n3(), p.n3(), o.n3()))
-
- return result
-
-def _testNegative(uri, manifest):
- if verbose: write(u"TESTING: %s" % uri)
- result = 0 # 1=failed, 0=passed
- inDoc = first(manifest.objects(uri, TEST["inputDocument"]))
- store = Graph()
-
- test = BNode()
- results.add((test, RESULT["test"], uri))
- results.add((test, RESULT["system"], system))
-
- try:
- if inDoc[-3:]==".nt":
- format = "nt"
- else:
- format = "xml"
- store.load(inDoc, format=format)
- except ParserError, pe:
- results.add((test, TYPE, RESULT["PassingRun"]))
- #pass
- else:
- write(u"""Failed: '%s'""" % uri)
- results.add((test, TYPE, RESULT["FailingRun"]))
- result = 1
- return result
-
-class ParserTestCase(unittest.TestCase):
- backend = 'default'
- path = 'store'
-
- def setUp(self):
- self.manifest = manifest = Graph(backend=self.backend)
- manifest.open(self.path)
- manifest.load("http://www.w3.org/2000/10/rdf-tests/rdfcore/Manifest.rdf")
-
- def tearDown(self):
- self.manifest.close()
-
- def testNegative(self):
- manifest = self.manifest
- num_failed = total = 0
- negs = list(manifest.subjects(TYPE, TEST["NegativeParserTest"]))
- negs.sort()
- for neg in negs:
- status = first(manifest.objects(neg, TEST["status"]))
- if status==Literal("APPROVED"):
- result = _testNegative(neg, manifest)
- total += 1
- num_failed += result
- self.assertEquals(num_failed, 0, "Failed: %s of %s." % (num_failed, total))
-
- def testPositive(self):
- manifest = self.manifest
- uris = list(manifest.subjects(TYPE, TEST["PositiveParserTest"]))
- uris.sort()
- num_failed = total = 0
- for uri in uris:
- status = first(manifest.objects(uri, TEST["status"]))
- if status==Literal("APPROVED"):
- result = _testPositive(uri, manifest)
- test = BNode()
- results.add((test, RESULT["test"], uri))
- results.add((test, RESULT["system"], system))
- if not result:
- results.add((test, TYPE, RESULT["PassingRun"]))
- else:
- results.add((test, TYPE, RESULT["FailingRun"]))
- total += 1
- num_failed += result
- self.assertEquals(num_failed, 0, "Failed: %s of %s." % (num_failed, total))
-
-RESULT = Namespace("http://www.w3.org/2002/03owlt/resultsOntology#")
-FOAF = Namespace("http://xmlns.com/foaf/0.1/")
-
-from rdflib.constants import RDFS_LABEL, RDFS_COMMENT
-results = Graph()
-
-system = BNode("system")
-results.add((system, FOAF["homepage"], URIRef("http://rdflib.net/")))
-results.add((system, RDFS_LABEL, Literal("RDFLib")))
-results.add((system, RDFS_COMMENT, Literal("")))
-
-
-if __name__ == "__main__":
- manifest = Graph()
- manifest.load("http://www.w3.org/2000/10/rdf-tests/rdfcore/Manifest.rdf")
- import sys, getopt
- try:
- optlist, args = getopt.getopt(sys.argv[1:], 'h:', ["help"])
- except getopt.GetoptError, msg:
- write(msg)
- usage()
-
- try:
- argv = sys.argv
- for arg in sys.argv[1:]:
- verbose = 1
- case = URIRef(arg)
- write(u"Testing: %s" % case)
- if (case, TYPE, TEST["PositiveParserTest"]) in manifest:
- result = _testPositive(case, manifest)
- write(u"Positive test %s" % ["PASSED", "FAILED"][result])
- elif (case, TYPE, TEST["NegativeParserTest"]) in manifest:
- result = _testNegative(case, manifest)
- write(u"Negative test %s" % ["PASSED", "FAILED"][result])
- else:
- write(u"%s not ??" % case)
-
- if len(argv)<=1:
- unittest.main()
- finally:
- results.save("results.rdf")
+import unittest + +from rdflib import URIRef, BNode, Literal +from rdflib.Namespace import Namespace +from rdflib.exceptions import ParserError +from rdflib.constants import TYPE + +from rdflib import Graph +from rdflib.util import first + + +verbose = 0 + +from encodings.utf_8 import StreamWriter + +import sys +sw = StreamWriter(sys.stdout) +def write(msg): + sw.write(msg+"\n") + #sys.stdout.write(msg+"\n") + +class TestStore(Graph): + def __init__(self, expected): + super(TestStore, self).__init__() + self.expected = expected + + def add(self, (s, p, o)): + if not isinstance(s, BNode) and not isinstance(o, BNode): + if not (s, p, o) in self.expected: + m = u"Triple not in expected result: %s, %s, %s" % (s.n3(), p.n3(), o.n3()) + if verbose: write(m) + #raise Exception(m) + super(TestStore, self).add((s, p, o)) + + +TEST = Namespace("http://www.w3.org/2000/10/rdf-tests/rdfcore/testSchema#") + +import os +def resolve(rel): + return "http://www.w3.org/2000/10/rdf-tests/rdfcore/" + rel + +def _testPositive(uri, manifest): + if verbose: write(u"TESTING: %s" % uri) + result = 0 # 1=failed, 0=passed + inDoc = first(manifest.objects(uri, TEST["inputDocument"])) + outDoc = first(manifest.objects(uri, TEST["outputDocument"])) + expected = Graph() + if outDoc[-3:]==".nt": + format = "nt" + else: + format = "xml" + expected.load(outDoc, format=format) + store = TestStore(expected) + if inDoc[-3:]==".nt": + format = "nt" + else: + format = "xml" + + try: + store.load(inDoc, format=format) + except ParserError, pe: + write("Failed '") + write(inDoc) + write("' failed with") + raise pe + try: + write(type(pe)) + except: + write("sorry could not dump out error.") + result = 1 + else: + if not store.isomorphic(expected): + write(u"""Failed: '%s'""" % uri) +# print """ In:\n""" +# for s, p, o in store: +# print "%s %s %s." % (s.n3(), p.n3(), o.n3()) +# print """ Out:\n""" +# for s, p, o in expected: +# print "%s %s %s." % (s.n3(), p.n3(), o.n3()) + + result += 1 + + if verbose: + write(""" In:\n""") + for s, p, o in store: + msg = u"%s %s %s." % (s.n3(), p.n3(), o.n3()) + write(msg) + write(""" Out:\n""") + for s, p, o in expected: + write(u"%s %s %s." % (s.n3(), p.n3(), o.n3())) + + return result + +def _testNegative(uri, manifest): + if verbose: write(u"TESTING: %s" % uri) + result = 0 # 1=failed, 0=passed + inDoc = first(manifest.objects(uri, TEST["inputDocument"])) + store = Graph() + + test = BNode() + results.add((test, RESULT["test"], uri)) + results.add((test, RESULT["system"], system)) + + try: + if inDoc[-3:]==".nt": + format = "nt" + else: + format = "xml" + store.load(inDoc, format=format) + except ParserError, pe: + results.add((test, TYPE, RESULT["PassingRun"])) + #pass + else: + write(u"""Failed: '%s'""" % uri) + results.add((test, TYPE, RESULT["FailingRun"])) + result = 1 + return result + +class ParserTestCase(unittest.TestCase): + backend = 'default' + path = 'store' + + def setUp(self): + self.manifest = manifest = Graph(backend=self.backend) + manifest.open(self.path) + manifest.load("http://www.w3.org/2000/10/rdf-tests/rdfcore/Manifest.rdf") + + def tearDown(self): + self.manifest.close() + + def testNegative(self): + manifest = self.manifest + num_failed = total = 0 + negs = list(manifest.subjects(TYPE, TEST["NegativeParserTest"])) + negs.sort() + for neg in negs: + status = first(manifest.objects(neg, TEST["status"])) + if status==Literal("APPROVED"): + result = _testNegative(neg, manifest) + total += 1 + num_failed += result + self.assertEquals(num_failed, 0, "Failed: %s of %s." % (num_failed, total)) + + def testPositive(self): + manifest = self.manifest + uris = list(manifest.subjects(TYPE, TEST["PositiveParserTest"])) + uris.sort() + num_failed = total = 0 + for uri in uris: + status = first(manifest.objects(uri, TEST["status"])) + if status==Literal("APPROVED"): + result = _testPositive(uri, manifest) + test = BNode() + results.add((test, RESULT["test"], uri)) + results.add((test, RESULT["system"], system)) + if not result: + results.add((test, TYPE, RESULT["PassingRun"])) + else: + results.add((test, TYPE, RESULT["FailingRun"])) + total += 1 + num_failed += result + self.assertEquals(num_failed, 0, "Failed: %s of %s." % (num_failed, total)) + +RESULT = Namespace("http://www.w3.org/2002/03owlt/resultsOntology#") +FOAF = Namespace("http://xmlns.com/foaf/0.1/") + +from rdflib.constants import RDFS_LABEL, RDFS_COMMENT +results = Graph() + +system = BNode("system") +results.add((system, FOAF["homepage"], URIRef("http://rdflib.net/"))) +results.add((system, RDFS_LABEL, Literal("RDFLib"))) +results.add((system, RDFS_COMMENT, Literal(""))) + + +if __name__ == "__main__": + manifest = Graph() + manifest.load("http://www.w3.org/2000/10/rdf-tests/rdfcore/Manifest.rdf") + import sys, getopt + try: + optlist, args = getopt.getopt(sys.argv[1:], 'h:', ["help"]) + except getopt.GetoptError, msg: + write(msg) + usage() + + try: + argv = sys.argv + for arg in sys.argv[1:]: + verbose = 1 + case = URIRef(arg) + write(u"Testing: %s" % case) + if (case, TYPE, TEST["PositiveParserTest"]) in manifest: + result = _testPositive(case, manifest) + write(u"Positive test %s" % ["PASSED", "FAILED"][result]) + elif (case, TYPE, TEST["NegativeParserTest"]) in manifest: + result = _testNegative(case, manifest) + write(u"Negative test %s" % ["PASSED", "FAILED"][result]) + else: + write(u"%s not ??" % case) + + if len(argv)<=1: + unittest.main() + finally: + results.save("results.rdf") diff --git a/test/rdf.py b/test/rdf.py index 624b1833..97eb9b38 100644 --- a/test/rdf.py +++ b/test/rdf.py @@ -1,54 +1,54 @@ -import unittest
-
-from rdflib import *
-from rdflib import RDF
-from rdflib.StringInputSource import StringInputSource
-
-FOAF = Namespace("http://xmlns.com/foaf/0.1/")
-
-
-rdfxml = """\
-<?xml version="1.0" encoding="utf-8"?>
-<rdf:RDF
- xmlns:xml='http://www.w3.org/XML/1998/namespace'
- xmlns:foaf='http://xmlns.com/foaf/0.1/'
- xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'
- xmlns:dc='http://http://purl.org/dc/elements/1.1/'
- xmlns:rdfs='http://www.w3.org/2000/01/rdf-schema#'
->
- <foaf:Person>
- <foaf:name>Donna Fales</foaf:name>
- <foaf:nick>donna</foaf:nick>
- </foaf:Person>
-</rdf:RDF>"""
-
-class RDFTestCase(unittest.TestCase):
- backend = 'default'
- path = 'store'
-
- def setUp(self):
- self.store = Graph(backend=self.backend)
- self.store.open(self.path)
- self.store.bind("dc", "http://http://purl.org/dc/elements/1.1/")
- self.store.bind("foaf", "http://xmlns.com/foaf/0.1/")
-
- def tearDown(self):
- self.store.close()
-
- def addDonna(self):
- self.donna = donna = BNode()
- self.store.add((donna, RDF.type, FOAF["Person"]))
- self.store.add((donna, FOAF["nick"], Literal("donna")))
- self.store.add((donna, FOAF["name"], Literal("Donna Fales")))
-
- def testRDFXML(self):
- self.addDonna()
- g = Graph()
- g.parse(StringInputSource(self.store.serialize(format="pretty-xml")))
- self.assertEquals(self.store.isomorphic(g), True)
-
-def test_suite():
- return unittest.makeSuite(RDFTestCase)
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
+import unittest + +from rdflib import * +from rdflib import RDF +from rdflib.StringInputSource import StringInputSource + +FOAF = Namespace("http://xmlns.com/foaf/0.1/") + + +rdfxml = """\ +<?xml version="1.0" encoding="utf-8"?> +<rdf:RDF + xmlns:xml='http://www.w3.org/XML/1998/namespace' + xmlns:foaf='http://xmlns.com/foaf/0.1/' + xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#' + xmlns:dc='http://http://purl.org/dc/elements/1.1/' + xmlns:rdfs='http://www.w3.org/2000/01/rdf-schema#' +> + <foaf:Person> + <foaf:name>Donna Fales</foaf:name> + <foaf:nick>donna</foaf:nick> + </foaf:Person> +</rdf:RDF>""" + +class RDFTestCase(unittest.TestCase): + backend = 'default' + path = 'store' + + def setUp(self): + self.store = Graph(backend=self.backend) + self.store.open(self.path) + self.store.bind("dc", "http://http://purl.org/dc/elements/1.1/") + self.store.bind("foaf", "http://xmlns.com/foaf/0.1/") + + def tearDown(self): + self.store.close() + + def addDonna(self): + self.donna = donna = BNode() + self.store.add((donna, RDF.type, FOAF["Person"])) + self.store.add((donna, FOAF["nick"], Literal("donna"))) + self.store.add((donna, FOAF["name"], Literal("Donna Fales"))) + + def testRDFXML(self): + self.addDonna() + g = Graph() + g.parse(StringInputSource(self.store.serialize(format="pretty-xml"))) + self.assertEquals(self.store.isomorphic(g), True) + +def test_suite(): + return unittest.makeSuite(RDFTestCase) + +if __name__ == '__main__': + unittest.main(defaultTest='test_suite') diff --git a/test/sparql/ConstructTests/Test10_21.py b/test/sparql/ConstructTests/Test10_21.py index 03dea9bc..8210f3bc 100755 --- a/test/sparql/ConstructTests/Test10_21.py +++ b/test/sparql/ConstructTests/Test10_21.py @@ -1,47 +1,47 @@ -#!/d/Bin/Python/python.exe
-# -*- coding: utf-8 -*-
-#
-#
-# $Date: 2005/04/02 07:30:02 $, by $Author: ivan $, $Revision: 1.1 $
-#
-
-from testSPARQL import ns_rdf
-from testSPARQL import ns_rdfs
-from testSPARQL import ns_dc
-from testSPARQL import ns_dc0
-from testSPARQL import ns_foaf
-from testSPARQL import ns_ns
-from testSPARQL import ns_book
-from testSPARQL import ns_vcard
-from testSPARQL import ns_person
-
-from rdflib.Literal import Literal
-from rdflib.sparql.sparqlOperators import lt, ge
-import datetime
-from rdflib.sparql import GraphPattern
-
-thresholdDate = datetime.date(2005,01,01)
-
-rdfData = """<?xml version="1.0" encoding="UTF-8"?>
-<rdf:RDF
- xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:foaf="http://xmlns.com/foaf/0.1/"
- xmlns:ns = "http://example.org/ns#"
->
- <rdf:Description>
- <foaf:name>Alice</foaf:name>
- <foaf:mbox rdf:resource="mailto:alice@example.com"/>
- </rdf:Description>
-</rdf:RDF>
-"""
-
-select = []
-pattern = GraphPattern([("?x",ns_foaf["name"],"?name")])
-optional = []
-construct = GraphPattern([(ns_person["Alice"],ns_vcard["FN"],"?name")])
-tripleStore = None
-
-
-
+#!/d/Bin/Python/python.exe +# -*- coding: utf-8 -*- +# +# +# $Date: 2005/04/02 07:30:02 $, by $Author: ivan $, $Revision: 1.1 $ +# + +from testSPARQL import ns_rdf +from testSPARQL import ns_rdfs +from testSPARQL import ns_dc +from testSPARQL import ns_dc0 +from testSPARQL import ns_foaf +from testSPARQL import ns_ns +from testSPARQL import ns_book +from testSPARQL import ns_vcard +from testSPARQL import ns_person + +from rdflib.Literal import Literal +from rdflib.sparql.sparqlOperators import lt, ge +import datetime +from rdflib.sparql import GraphPattern + +thresholdDate = datetime.date(2005,01,01) + +rdfData = """<?xml version="1.0" encoding="UTF-8"?> +<rdf:RDF + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:foaf="http://xmlns.com/foaf/0.1/" + xmlns:ns = "http://example.org/ns#" +> + <rdf:Description> + <foaf:name>Alice</foaf:name> + <foaf:mbox rdf:resource="mailto:alice@example.com"/> + </rdf:Description> +</rdf:RDF> +""" + +select = [] +pattern = GraphPattern([("?x",ns_foaf["name"],"?name")]) +optional = [] +construct = GraphPattern([(ns_person["Alice"],ns_vcard["FN"],"?name")]) +tripleStore = None + + + diff --git a/test/sparql/ConstructTests/Test10_22.py b/test/sparql/ConstructTests/Test10_22.py index 9222eca9..d38185fd 100755 --- a/test/sparql/ConstructTests/Test10_22.py +++ b/test/sparql/ConstructTests/Test10_22.py @@ -1,49 +1,49 @@ -#!/d/Bin/Python/python.exe
-# -*- coding: utf-8 -*-
-#
-#
-# $Date: 2005/04/02 07:30:02 $, by $Author: ivan $, $Revision: 1.1 $
-#
-
-from testSPARQL import ns_rdf
-from testSPARQL import ns_rdfs
-from testSPARQL import ns_dc
-from testSPARQL import ns_dc0
-from testSPARQL import ns_foaf
-from testSPARQL import ns_ns
-from testSPARQL import ns_book
-from testSPARQL import ns_vcard
-from testSPARQL import ns_person
-
-from rdflib.Literal import Literal
-from rdflib.sparql.sparqlOperators import lt, ge
-import datetime
-from rdflib.sparql import GraphPattern
-
-thresholdDate = datetime.date(2005,01,01)
-rdfData = """<?xml version="1.0" encoding="UTF-8"?>
-<rdf:RDF
- xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:foaf="http://xmlns.com/foaf/0.1/"
- xmlns:ns = "http://example.org/ns#"
->
- <rdf:Description>
- <foaf:givenname>Alice</foaf:givenname>
- <foaf:family_name>Hacker</foaf:family_name>
- </rdf:Description>
- <rdf:Description>
- <foaf:givenname>Bob</foaf:givenname>
- <foaf:family_name>Hacker</foaf:family_name>
- </rdf:Description>
-</rdf:RDF>
-"""
-select = []
-pattern = GraphPattern([("?x",ns_foaf["givenname"],"?name"),("?x",ns_foaf["family_name"],"?fname")])
-optional = []
-construct = GraphPattern([("_:v1", ns_vcard["N"],"_:x"),("_:x",ns_vcard["givenName"],"?name"),("_:x",ns_vcard["familyName"],"?fname")])
-tripleStore = None
-
-
-
+#!/d/Bin/Python/python.exe +# -*- coding: utf-8 -*- +# +# +# $Date: 2005/04/02 07:30:02 $, by $Author: ivan $, $Revision: 1.1 $ +# + +from testSPARQL import ns_rdf +from testSPARQL import ns_rdfs +from testSPARQL import ns_dc +from testSPARQL import ns_dc0 +from testSPARQL import ns_foaf +from testSPARQL import ns_ns +from testSPARQL import ns_book +from testSPARQL import ns_vcard +from testSPARQL import ns_person + +from rdflib.Literal import Literal +from rdflib.sparql.sparqlOperators import lt, ge +import datetime +from rdflib.sparql import GraphPattern + +thresholdDate = datetime.date(2005,01,01) +rdfData = """<?xml version="1.0" encoding="UTF-8"?> +<rdf:RDF + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:foaf="http://xmlns.com/foaf/0.1/" + xmlns:ns = "http://example.org/ns#" +> + <rdf:Description> + <foaf:givenname>Alice</foaf:givenname> + <foaf:family_name>Hacker</foaf:family_name> + </rdf:Description> + <rdf:Description> + <foaf:givenname>Bob</foaf:givenname> + <foaf:family_name>Hacker</foaf:family_name> + </rdf:Description> +</rdf:RDF> +""" +select = [] +pattern = GraphPattern([("?x",ns_foaf["givenname"],"?name"),("?x",ns_foaf["family_name"],"?fname")]) +optional = [] +construct = GraphPattern([("_:v1", ns_vcard["N"],"_:x"),("_:x",ns_vcard["givenName"],"?name"),("_:x",ns_vcard["familyName"],"?fname")]) +tripleStore = None + + + diff --git a/test/sparql/ConstructTests/Test10_23.py b/test/sparql/ConstructTests/Test10_23.py index eb2ad907..858947ad 100755 --- a/test/sparql/ConstructTests/Test10_23.py +++ b/test/sparql/ConstructTests/Test10_23.py @@ -1,50 +1,50 @@ -#!/d/Bin/Python/python.exe
-# -*- coding: utf-8 -*-
-#
-#
-# $Date: 2005/04/02 07:30:02 $, by $Author: ivan $, $Revision: 1.1 $
-#
-
-from testSPARQL import ns_rdf
-from testSPARQL import ns_rdfs
-from testSPARQL import ns_dc
-from testSPARQL import ns_dc0
-from testSPARQL import ns_foaf
-from testSPARQL import ns_ns
-from testSPARQL import ns_book
-from testSPARQL import ns_vcard
-from testSPARQL import ns_person
-
-from rdflib.Literal import Literal
-from rdflib.sparql.sparqlOperators import lt, ge
-import datetime
-from rdflib.sparql import GraphPattern
-
-thresholdDate = datetime.date(2005,01,01)
-rdfData = """<?xml version="1.0" encoding="UTF-8"?>
-<rdf:RDF
- xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:foaf="http://xmlns.com/foaf/0.1/"
- xmlns:ns = "http://example.org/ns#"
->
- <rdf:Description>
- <foaf:name>Alice</foaf:name>
- <foaf:mbox rdf:resource="mailto:alice@example.com"/>
- </rdf:Description>
- <rdf:Description>
- <foaf:name>Bob</foaf:name>
- <foaf:mbox rdf:resource="mailto:bob@example.org"/>
- </rdf:Description>
-</rdf:RDF>
-"""
-
-select = []
-pattern = GraphPattern([("?x",ns_foaf["name"],"?name")])
-optional = []
-construct = None
-tripleStore = None
-
-
-
+#!/d/Bin/Python/python.exe +# -*- coding: utf-8 -*- +# +# +# $Date: 2005/04/02 07:30:02 $, by $Author: ivan $, $Revision: 1.1 $ +# + +from testSPARQL import ns_rdf +from testSPARQL import ns_rdfs +from testSPARQL import ns_dc +from testSPARQL import ns_dc0 +from testSPARQL import ns_foaf +from testSPARQL import ns_ns +from testSPARQL import ns_book +from testSPARQL import ns_vcard +from testSPARQL import ns_person + +from rdflib.Literal import Literal +from rdflib.sparql.sparqlOperators import lt, ge +import datetime +from rdflib.sparql import GraphPattern + +thresholdDate = datetime.date(2005,01,01) +rdfData = """<?xml version="1.0" encoding="UTF-8"?> +<rdf:RDF + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:foaf="http://xmlns.com/foaf/0.1/" + xmlns:ns = "http://example.org/ns#" +> + <rdf:Description> + <foaf:name>Alice</foaf:name> + <foaf:mbox rdf:resource="mailto:alice@example.com"/> + </rdf:Description> + <rdf:Description> + <foaf:name>Bob</foaf:name> + <foaf:mbox rdf:resource="mailto:bob@example.org"/> + </rdf:Description> +</rdf:RDF> +""" + +select = [] +pattern = GraphPattern([("?x",ns_foaf["name"],"?name")]) +optional = [] +construct = None +tripleStore = None + + + diff --git a/test/sparql/ConstructTests/constuctTest.py b/test/sparql/ConstructTests/constuctTest.py index 715daec2..fdd75d7a 100755 --- a/test/sparql/ConstructTests/constuctTest.py +++ b/test/sparql/ConstructTests/constuctTest.py @@ -1,99 +1,99 @@ -#!/d/Bin/Python/python.exe
-# -*- coding: utf-8 -*-
-#
-#
-# $Date: 2005/04/02 07:30:02 $, by $Author: ivan $, $Revision: 1.1 $
-#
-"""
-
-"""
-import sys, os, time, datetime, imp, sys, StringIO
-sys.path.insert(0,"../")
-
-from testSPARQL import ns_rdf
-from testSPARQL import ns_rdfs
-from testSPARQL import ns_dc
-from testSPARQL import ns_dc0
-from testSPARQL import ns_foaf
-from testSPARQL import ns_vcard
-from testSPARQL import ns_person
-
-from rdflib.sparql import sparqlGraph, retrieveRDFFiles
-from rdflib.FileInputSource import FileInputSource
-
-tests = {
- 1021: "Test10_21",
- 1022: "Test10_22",
- 1023: "Test10_23",
-}
-
-Debug = False
-
-
-
-def run(modName) :
- # Import the python module
- defs = None
- (fl,realpath,descr) = imp.find_module(modName,["."])
- mod = imp.load_module(modName,fl,realpath,descr)
- defs = mod.__dict__
-
- ##################################################
- # Three ways of identifying the RDF data:
- # 1. A Triple Store generated in the module
- graph = None
- try :
- graph = defs["graph"]
- except :
- pass
- # 2. A reference to a set of RDF Files
- fils = None
- try :
- fils = defs["datafiles"]
- except :
- pass
- # 3. Directly in the test module as a string
- rdfData = None
- try :
- rdfData = defs["rdfData"]
- except :
- pass
-
- # Get the final of the triple store...
- if graph == None :
- if rdfData == None :
- graph = retrieveRDFFiles(fils)
- else :
- stream = FileInputSource(StringIO.StringIO(rdfData))
- graph = sparqlGraph.SPARQLGraph()
- graph.parse(stream,format="xml")
-
- ###############################################
- # Retrive the query data
- pattern = defs["pattern"]
- optPattern = defs["optional"]
- construct = defs["construct"]
-
-
- ###############################################
- print "\n============= Test Module: %s =============" % modName
-
- results = graph.queryObject(pattern,optPattern)
- graph = results.construct(construct)
- graph.save("output.rdf")
-
- print "=== generated RDF file (output.rdf):\n"
- for l in file("output.rdf") :
- sys.stdout.write(l)
-
-if __name__ == '__main__' :
- if len(sys.argv) == 1 :
- print "Usage: %s modname1 modname2 ..." % sys.argv[0]
- else :
- for mod in sys.argv[1:] :
- if mod.endswith(".py") :
- run(mod[0:-3])
- else :
- run(mod)
-
-
+#!/d/Bin/Python/python.exe +# -*- coding: utf-8 -*- +# +# +# $Date: 2005/04/02 07:30:02 $, by $Author: ivan $, $Revision: 1.1 $ +# +""" + +""" +import sys, os, time, datetime, imp, sys, StringIO +sys.path.insert(0,"../") + +from testSPARQL import ns_rdf +from testSPARQL import ns_rdfs +from testSPARQL import ns_dc +from testSPARQL import ns_dc0 +from testSPARQL import ns_foaf +from testSPARQL import ns_vcard +from testSPARQL import ns_person + +from rdflib.sparql import sparqlGraph, retrieveRDFFiles +from rdflib.FileInputSource import FileInputSource + +tests = { + 1021: "Test10_21", + 1022: "Test10_22", + 1023: "Test10_23", +} + +Debug = False + + + +def run(modName) : + # Import the python module + defs = None + (fl,realpath,descr) = imp.find_module(modName,["."]) + mod = imp.load_module(modName,fl,realpath,descr) + defs = mod.__dict__ + + ################################################## + # Three ways of identifying the RDF data: + # 1. A Triple Store generated in the module + graph = None + try : + graph = defs["graph"] + except : + pass + # 2. A reference to a set of RDF Files + fils = None + try : + fils = defs["datafiles"] + except : + pass + # 3. Directly in the test module as a string + rdfData = None + try : + rdfData = defs["rdfData"] + except : + pass + + # Get the final of the triple store... + if graph == None : + if rdfData == None : + graph = retrieveRDFFiles(fils) + else : + stream = FileInputSource(StringIO.StringIO(rdfData)) + graph = sparqlGraph.SPARQLGraph() + graph.parse(stream,format="xml") + + ############################################### + # Retrive the query data + pattern = defs["pattern"] + optPattern = defs["optional"] + construct = defs["construct"] + + + ############################################### + print "\n============= Test Module: %s =============" % modName + + results = graph.queryObject(pattern,optPattern) + graph = results.construct(construct) + graph.save("output.rdf") + + print "=== generated RDF file (output.rdf):\n" + for l in file("output.rdf") : + sys.stdout.write(l) + +if __name__ == '__main__' : + if len(sys.argv) == 1 : + print "Usage: %s modname1 modname2 ..." % sys.argv[0] + else : + for mod in sys.argv[1:] : + if mod.endswith(".py") : + run(mod[0:-3]) + else : + run(mod) + + diff --git a/test/sparql/QueryTests/Test1.py b/test/sparql/QueryTests/Test1.py index f84b3866..abd4c149 100755 --- a/test/sparql/QueryTests/Test1.py +++ b/test/sparql/QueryTests/Test1.py @@ -1,42 +1,42 @@ -#!/d/Bin/Python/python.exe
-# -*- coding: utf-8 -*-
-#
-#
-# $Date: 2005/04/02 07:29:46 $, by $Author: ivan $, $Revision: 1.1 $
-#
-
-from testSPARQL import ns_rdf
-from testSPARQL import ns_rdfs
-from testSPARQL import ns_dc
-from testSPARQL import ns_dc0
-from testSPARQL import ns_foaf
-
-from rdflib.sparql import GraphPattern
-
-
-# Careful to keep the <?xml declaration at the very beginning, otherwise the parser will fail...
-rdfData ="""<?xml version="1.0" encoding="UTF-8"?>
-<rdf:RDF
- xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:foaf="http://xmlns.com/foaf/0.1/"
->
- <rdf:Description>
- <foaf:name>Johny Lee Outlaw</foaf:name>
- <foaf:mbox rdf:resource="mailto:jlow@example.com"/>
- </rdf:Description>
-</rdf:RDF>
-"""
-
-select = ["?mbox","?junk"]
-pattern = GraphPattern([("?x",ns_foaf["name"],"Johny Lee Outlaw"),("?x",ns_foaf["mbox"],"?mbox")])
-optional = None
-tripleStore = None
-expected = '''
-?mbox: mailto:jlow@example.com
-?junk: None
-'''
-
-
-
+#!/d/Bin/Python/python.exe +# -*- coding: utf-8 -*- +# +# +# $Date: 2005/04/02 07:29:46 $, by $Author: ivan $, $Revision: 1.1 $ +# + +from testSPARQL import ns_rdf +from testSPARQL import ns_rdfs +from testSPARQL import ns_dc +from testSPARQL import ns_dc0 +from testSPARQL import ns_foaf + +from rdflib.sparql import GraphPattern + + +# Careful to keep the <?xml declaration at the very beginning, otherwise the parser will fail... +rdfData ="""<?xml version="1.0" encoding="UTF-8"?> +<rdf:RDF + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:foaf="http://xmlns.com/foaf/0.1/" +> + <rdf:Description> + <foaf:name>Johny Lee Outlaw</foaf:name> + <foaf:mbox rdf:resource="mailto:jlow@example.com"/> + </rdf:Description> +</rdf:RDF> +""" + +select = ["?mbox","?junk"] +pattern = GraphPattern([("?x",ns_foaf["name"],"Johny Lee Outlaw"),("?x",ns_foaf["mbox"],"?mbox")]) +optional = None +tripleStore = None +expected = ''' +?mbox: mailto:jlow@example.com +?junk: None +''' + + + diff --git a/test/sparql/QueryTests/Test11_3.py b/test/sparql/QueryTests/Test11_3.py index e2eca1ea..0ae06419 100755 --- a/test/sparql/QueryTests/Test11_3.py +++ b/test/sparql/QueryTests/Test11_3.py @@ -1,67 +1,67 @@ -#!/d/Bin/Python/python.exe
-# -*- coding: utf-8 -*-
-#
-#
-# $Date: 2005/04/02 07:29:46 $, by $Author: ivan $, $Revision: 1.1 $
-#
-"""
- Datatype test. Note that this is not 100% kosher. The problem is that the Literal of rdflib does not check the
- datatypes. In theory, if the data contains:
-
- x ns:p 42.
-
- instead of:
-
- x ns:p 42^^http://www.w3.org/2001/XMLSchema#integer
-
- the query should return no results, because the first object is of datatype string. However, Literal does not
- implement this...
-
-"""
-
-rdfData ="""<?xml version="1.0" encoding="UTF-8"?>
-<rdf:RDF
- xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:foaf="http://xmlns.com/foaf/0.1/"
- xmlns:ns = "http://example.org/ns#"
->
- <rdf:Description>
- <foaf:name>Alice</foaf:name>
- <foaf:mbox rdf:resource="mailto:alice@work.example"/>
- </rdf:Description>
- <rdf:Description>
- <foaf:name>Bob</foaf:name>
- <foaf:mbox>bob@work.example</foaf:mbox>
- </rdf:Description>
-</rdf:RDF>
-"""
-
-
-
-from testSPARQL import ns_rdf
-from testSPARQL import ns_rdfs
-from testSPARQL import ns_dc
-from testSPARQL import ns_foaf
-from testSPARQL import ns_ns
-from testSPARQL import ns_book
-
-from rdflib.Literal import Literal
-from rdflib.sparql import GraphPattern
-
-from rdflib.sparql.sparqlOperators import isURI
-
-
-select = ["?name", "?mbox"]
-pattern = GraphPattern([("?x", ns_foaf["name"],"?name"),("?x",ns_foaf["mbox"],"?mbox")])
-pattern.addConstraint(isURI("?mbox"))
-optional = []
-tripleStore = None
-expected = '''
- ?name: Alice
- ?mbox: mailto:alice@work.example
-'''
-
-
-
+#!/d/Bin/Python/python.exe +# -*- coding: utf-8 -*- +# +# +# $Date: 2005/04/02 07:29:46 $, by $Author: ivan $, $Revision: 1.1 $ +# +""" + Datatype test. Note that this is not 100% kosher. The problem is that the Literal of rdflib does not check the + datatypes. In theory, if the data contains: + + x ns:p 42. + + instead of: + + x ns:p 42^^http://www.w3.org/2001/XMLSchema#integer + + the query should return no results, because the first object is of datatype string. However, Literal does not + implement this... + +""" + +rdfData ="""<?xml version="1.0" encoding="UTF-8"?> +<rdf:RDF + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:foaf="http://xmlns.com/foaf/0.1/" + xmlns:ns = "http://example.org/ns#" +> + <rdf:Description> + <foaf:name>Alice</foaf:name> + <foaf:mbox rdf:resource="mailto:alice@work.example"/> + </rdf:Description> + <rdf:Description> + <foaf:name>Bob</foaf:name> + <foaf:mbox>bob@work.example</foaf:mbox> + </rdf:Description> +</rdf:RDF> +""" + + + +from testSPARQL import ns_rdf +from testSPARQL import ns_rdfs +from testSPARQL import ns_dc +from testSPARQL import ns_foaf +from testSPARQL import ns_ns +from testSPARQL import ns_book + +from rdflib.Literal import Literal +from rdflib.sparql import GraphPattern + +from rdflib.sparql.sparqlOperators import isURI + + +select = ["?name", "?mbox"] +pattern = GraphPattern([("?x", ns_foaf["name"],"?name"),("?x",ns_foaf["mbox"],"?mbox")]) +pattern.addConstraint(isURI("?mbox")) +optional = [] +tripleStore = None +expected = ''' + ?name: Alice + ?mbox: mailto:alice@work.example +''' + + + diff --git a/test/sparql/QueryTests/Test2_5.py b/test/sparql/QueryTests/Test2_5.py index fb956f05..e86074c2 100755 --- a/test/sparql/QueryTests/Test2_5.py +++ b/test/sparql/QueryTests/Test2_5.py @@ -1,62 +1,62 @@ -#!/d/Bin/Python/python.exe
-# -*- coding: utf-8 -*-
-#
-#
-# $Date: 2005/04/02 07:29:46 $, by $Author: ivan $, $Revision: 1.1 $
-#
-"""
- Datatype test. Note that this is not 100% kosher. The problem is that the Literal of rdflib does not check the
- datatypes. In theory, if the data contains:
-
- x ns:p 42.
-
- instead of:
-
- x ns:p 42^^http://www.w3.org/2001/XMLSchema#integer
-
- the query should return no results, because the first object is of datatype string. However, Literal does not
- implement this...
-
-"""
-
-from testSPARQL import ns_rdf
-from testSPARQL import ns_rdfs
-from testSPARQL import ns_dc
-from testSPARQL import ns_foaf
-from testSPARQL import ns_ns
-from testSPARQL import ns_book
-
-from rdflib.Literal import Literal
-from rdflib.sparql import GraphPattern
-rdfData ="""<?xml version="1.0" encoding="UTF-8"?>
-<rdf:RDF
- xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:foaf="http://xmlns.com/foaf/0.1/"
- xmlns:ns = "http://example.org/ns#"
->
- <rdf:Description>
- <foaf:name>Johny Lee Outlaw</foaf:name>
- <foaf:mbox rdf:resource="mailto:jlow@example.com"/>
- </rdf:Description>
- <rdf:Description>
- <foaf:name>Peter Goodguy</foaf:name>
- <foaf:mbox rdf:resource="mailto:peter@example.org"/>
- </rdf:Description>
-</rdf:RDF>
-"""
-
-select = ["?name", "?mbox"]
-pattern = GraphPattern([("?x", ns_foaf["name"],"?name"),("?x",ns_foaf["mbox"],"?mbox")])
-optional = []
-tripleStore = None
-expected = '''
- ?name: Johny Lee Outlaw
- ?mbox: mailto:jlow@example.com
-
- ?name: Peter Goodguy
- ?mbox: mailto:peter@example.org
-'''
-
-
+#!/d/Bin/Python/python.exe +# -*- coding: utf-8 -*- +# +# +# $Date: 2005/04/02 07:29:46 $, by $Author: ivan $, $Revision: 1.1 $ +# +""" + Datatype test. Note that this is not 100% kosher. The problem is that the Literal of rdflib does not check the + datatypes. In theory, if the data contains: + + x ns:p 42. + + instead of: + + x ns:p 42^^http://www.w3.org/2001/XMLSchema#integer + + the query should return no results, because the first object is of datatype string. However, Literal does not + implement this... + +""" + +from testSPARQL import ns_rdf +from testSPARQL import ns_rdfs +from testSPARQL import ns_dc +from testSPARQL import ns_foaf +from testSPARQL import ns_ns +from testSPARQL import ns_book + +from rdflib.Literal import Literal +from rdflib.sparql import GraphPattern +rdfData ="""<?xml version="1.0" encoding="UTF-8"?> +<rdf:RDF + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:foaf="http://xmlns.com/foaf/0.1/" + xmlns:ns = "http://example.org/ns#" +> + <rdf:Description> + <foaf:name>Johny Lee Outlaw</foaf:name> + <foaf:mbox rdf:resource="mailto:jlow@example.com"/> + </rdf:Description> + <rdf:Description> + <foaf:name>Peter Goodguy</foaf:name> + <foaf:mbox rdf:resource="mailto:peter@example.org"/> + </rdf:Description> +</rdf:RDF> +""" + +select = ["?name", "?mbox"] +pattern = GraphPattern([("?x", ns_foaf["name"],"?name"),("?x",ns_foaf["mbox"],"?mbox")]) +optional = [] +tripleStore = None +expected = ''' + ?name: Johny Lee Outlaw + ?mbox: mailto:jlow@example.com + + ?name: Peter Goodguy + ?mbox: mailto:peter@example.org +''' + + diff --git a/test/sparql/QueryTests/Test2_6.py b/test/sparql/QueryTests/Test2_6.py index f3fa7825..5da6d2f1 100755 --- a/test/sparql/QueryTests/Test2_6.py +++ b/test/sparql/QueryTests/Test2_6.py @@ -1,63 +1,63 @@ -#!/d/Bin/Python/python.exe
-# -*- coding: utf-8 -*-
-#
-#
-# $Date: 2005/04/02 07:29:46 $, by $Author: ivan $, $Revision: 1.1 $
-#
-"""
- Datatype test. Note that this is not 100% kosher. The problem is that the Literal of rdflib does not check the
- datatypes. In theory, if the data contains:
-
- x ns:p 42.
-
- instead of:
-
- x ns:p 42^^http://www.w3.org/2001/XMLSchema#integer
-
- the query should return no results, because the first object is of datatype string. However, Literal does not
- implement this...
-
-"""
-rdfData ="""<?xml version="1.0" encoding="UTF-8"?>
-<rdf:RDF
- xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:foaf="http://xmlns.com/foaf/0.1/"
- xmlns:ns = "http://example.org/ns#"
->
- <rdf:Description>
- <foaf:name>Alice</foaf:name>
- <foaf:mbox rdf:resource="mailto:jlow@example.com"/>
- </rdf:Description>
- <rdf:Description>
- <foaf:name>Bob</foaf:name>
- <foaf:mbox rdf:resource="mailto:peter@example.org"/>
- </rdf:Description>
-</rdf:RDF>
-"""
-
-from testSPARQL import ns_rdf
-from testSPARQL import ns_rdfs
-from testSPARQL import ns_dc
-from testSPARQL import ns_foaf
-from testSPARQL import ns_ns
-from testSPARQL import ns_book
-
-from rdflib.Literal import Literal
-
-from rdflib.sparql import GraphPattern
-
-select = ["?x", "?name"]
-pattern = GraphPattern([("?x", ns_foaf["name"],"?name")])
-optional = []
-tripleStore = None
-expected = '''
- ?x: (some bnode)
- ?name: Alice
-
- ?x: (some bnode)
- ?name: Bob
-'''
-
-
+#!/d/Bin/Python/python.exe +# -*- coding: utf-8 -*- +# +# +# $Date: 2005/04/02 07:29:46 $, by $Author: ivan $, $Revision: 1.1 $ +# +""" + Datatype test. Note that this is not 100% kosher. The problem is that the Literal of rdflib does not check the + datatypes. In theory, if the data contains: + + x ns:p 42. + + instead of: + + x ns:p 42^^http://www.w3.org/2001/XMLSchema#integer + + the query should return no results, because the first object is of datatype string. However, Literal does not + implement this... + +""" +rdfData ="""<?xml version="1.0" encoding="UTF-8"?> +<rdf:RDF + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:foaf="http://xmlns.com/foaf/0.1/" + xmlns:ns = "http://example.org/ns#" +> + <rdf:Description> + <foaf:name>Alice</foaf:name> + <foaf:mbox rdf:resource="mailto:jlow@example.com"/> + </rdf:Description> + <rdf:Description> + <foaf:name>Bob</foaf:name> + <foaf:mbox rdf:resource="mailto:peter@example.org"/> + </rdf:Description> +</rdf:RDF> +""" + +from testSPARQL import ns_rdf +from testSPARQL import ns_rdfs +from testSPARQL import ns_dc +from testSPARQL import ns_foaf +from testSPARQL import ns_ns +from testSPARQL import ns_book + +from rdflib.Literal import Literal + +from rdflib.sparql import GraphPattern + +select = ["?x", "?name"] +pattern = GraphPattern([("?x", ns_foaf["name"],"?name")]) +optional = [] +tripleStore = None +expected = ''' + ?x: (some bnode) + ?name: Alice + + ?x: (some bnode) + ?name: Bob +''' + + diff --git a/test/sparql/QueryTests/Test3_1_1.py b/test/sparql/QueryTests/Test3_1_1.py index b27d4aaa..4495197a 100755 --- a/test/sparql/QueryTests/Test3_1_1.py +++ b/test/sparql/QueryTests/Test3_1_1.py @@ -1,57 +1,57 @@ -#!/d/Bin/Python/python.exe
-# -*- coding: utf-8 -*-
-#
-#
-# $Date: 2005/04/02 07:29:46 $, by $Author: ivan $, $Revision: 1.1 $
-#
-"""
- Datatype test. Note that this is not 100% kosher. The problem is that the Literal of rdflib does not check the
- datatypes. In theory, if the data contains:
-
- x ns:p 42.
-
- instead of:
-
- x ns:p 42^^http://www.w3.org/2001/XMLSchema#integer
-
- the query should return no results, because the first object is of datatype string. However, Literal does not
- implement this...
-
-"""
-rdfData ="""<?xml version="1.0" encoding="UTF-8"?>
-<rdf:RDF
- xmlns:rdfs ="http://www.w3.org/2000/01/rdf-schema#"
- xmlns:rdf ="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:dc ="http://purl.org/dc/elements/1.1/"
- xmlns:foaf ="http://xmlns.com/foaf/0.1/"
- xmlns:ns ="http://example.org/ns#"
- xmlns:dt ="http://example.org/datatype#"
->
- <rdf:Description>
- <ns:p rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">42</ns:p>
- <ns:p rdf:datatype="http://example.org/datatype#specialDatatype">abc</ns:p>
- <ns:p>2005-02-27</ns:p>
- <ns:p xml:lang="en">cat</ns:p>
- </rdf:Description>
-</rdf:RDF>
-"""
-
-from testSPARQL import ns_rdf
-from testSPARQL import ns_rdfs
-from testSPARQL import ns_dc
-from testSPARQL import ns_foaf
-from testSPARQL import ns_ns
-
-from rdflib.Literal import Literal
-import datetime
-from rdflib.sparql import GraphPattern
-
-select = ["?v"]
-pattern = GraphPattern([("?v","?p",42)])
-optional = []
-tripleStore = None
-expected = '''
-?v : (some bnode id)
-'''
-
-
+#!/d/Bin/Python/python.exe +# -*- coding: utf-8 -*- +# +# +# $Date: 2005/04/02 07:29:46 $, by $Author: ivan $, $Revision: 1.1 $ +# +""" + Datatype test. Note that this is not 100% kosher. The problem is that the Literal of rdflib does not check the + datatypes. In theory, if the data contains: + + x ns:p 42. + + instead of: + + x ns:p 42^^http://www.w3.org/2001/XMLSchema#integer + + the query should return no results, because the first object is of datatype string. However, Literal does not + implement this... + +""" +rdfData ="""<?xml version="1.0" encoding="UTF-8"?> +<rdf:RDF + xmlns:rdfs ="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf ="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:dc ="http://purl.org/dc/elements/1.1/" + xmlns:foaf ="http://xmlns.com/foaf/0.1/" + xmlns:ns ="http://example.org/ns#" + xmlns:dt ="http://example.org/datatype#" +> + <rdf:Description> + <ns:p rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">42</ns:p> + <ns:p rdf:datatype="http://example.org/datatype#specialDatatype">abc</ns:p> + <ns:p>2005-02-27</ns:p> + <ns:p xml:lang="en">cat</ns:p> + </rdf:Description> +</rdf:RDF> +""" + +from testSPARQL import ns_rdf +from testSPARQL import ns_rdfs +from testSPARQL import ns_dc +from testSPARQL import ns_foaf +from testSPARQL import ns_ns + +from rdflib.Literal import Literal +import datetime +from rdflib.sparql import GraphPattern + +select = ["?v"] +pattern = GraphPattern([("?v","?p",42)]) +optional = [] +tripleStore = None +expected = ''' +?v : (some bnode id) +''' + + diff --git a/test/sparql/QueryTests/Test3_1_2.py b/test/sparql/QueryTests/Test3_1_2.py index 5f2f2e62..957bc14a 100755 --- a/test/sparql/QueryTests/Test3_1_2.py +++ b/test/sparql/QueryTests/Test3_1_2.py @@ -1,61 +1,61 @@ -#!/d/Bin/Python/python.exe
-# -*- coding: utf-8 -*-
-#
-#
-# $Date: 2005/04/02 07:29:46 $, by $Author: ivan $, $Revision: 1.1 $
-#
-"""
- Datatype test. Note that this is not 100% kosher. The problem is that the Literal of rdflib does not check the
- datatypes. In theory, if the data contains:
-
- x ns:p 42.
-
- instead of:
-
- x ns:p 42^^http://www.w3.org/2001/XMLSchema#integer
-
- the query should return no results, because the first object is of datatype string. However, Literal does not
- implement this...
-
-"""
-rdfData ="""<?xml version="1.0" encoding="UTF-8"?>
-<rdf:RDF
- xmlns:rdfs ="http://www.w3.org/2000/01/rdf-schema#"
- xmlns:rdf ="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:dc ="http://purl.org/dc/elements/1.1/"
- xmlns:foaf ="http://xmlns.com/foaf/0.1/"
- xmlns:ns ="http://example.org/ns#"
- xmlns:dt ="http://example.org/datatype#"
->
- <rdf:Description>
- <ns:p rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">42</ns:p>
- <ns:p rdf:datatype="http://example.org/datatype#specialDatatype">abc</ns:p>
- <ns:p>2005-02-27</ns:p>
- <ns:p xml:lang="en">cat</ns:p>
- </rdf:Description>
-</rdf:RDF>
-
-
-"""
-
-from testSPARQL import ns_rdf
-from testSPARQL import ns_rdfs
-from testSPARQL import ns_dc
-from testSPARQL import ns_foaf
-from testSPARQL import ns_ns
-
-from rdflib.Literal import Literal
-import datetime
-from rdflib.sparql import GraphPattern
-
-select = ["?v"]
-#pattern = GraphPattern([("?v","?p",Literal("abc",datatype="http://example.org/datatype#specialDatatype"))])
-pattern = GraphPattern([("?v","?p","abc")])
-optional = []
-tripleStore = None
-expected = '''
-EMPTY
-'''
-
-
-
+#!/d/Bin/Python/python.exe +# -*- coding: utf-8 -*- +# +# +# $Date: 2005/04/02 07:29:46 $, by $Author: ivan $, $Revision: 1.1 $ +# +""" + Datatype test. Note that this is not 100% kosher. The problem is that the Literal of rdflib does not check the + datatypes. In theory, if the data contains: + + x ns:p 42. + + instead of: + + x ns:p 42^^http://www.w3.org/2001/XMLSchema#integer + + the query should return no results, because the first object is of datatype string. However, Literal does not + implement this... + +""" +rdfData ="""<?xml version="1.0" encoding="UTF-8"?> +<rdf:RDF + xmlns:rdfs ="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf ="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:dc ="http://purl.org/dc/elements/1.1/" + xmlns:foaf ="http://xmlns.com/foaf/0.1/" + xmlns:ns ="http://example.org/ns#" + xmlns:dt ="http://example.org/datatype#" +> + <rdf:Description> + <ns:p rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">42</ns:p> + <ns:p rdf:datatype="http://example.org/datatype#specialDatatype">abc</ns:p> + <ns:p>2005-02-27</ns:p> + <ns:p xml:lang="en">cat</ns:p> + </rdf:Description> +</rdf:RDF> + + +""" + +from testSPARQL import ns_rdf +from testSPARQL import ns_rdfs +from testSPARQL import ns_dc +from testSPARQL import ns_foaf +from testSPARQL import ns_ns + +from rdflib.Literal import Literal +import datetime +from rdflib.sparql import GraphPattern + +select = ["?v"] +#pattern = GraphPattern([("?v","?p",Literal("abc",datatype="http://example.org/datatype#specialDatatype"))]) +pattern = GraphPattern([("?v","?p","abc")]) +optional = [] +tripleStore = None +expected = ''' +EMPTY +''' + + + diff --git a/test/sparql/QueryTests/Test3_1_3.py b/test/sparql/QueryTests/Test3_1_3.py index 224715d5..6f8b9ae2 100755 --- a/test/sparql/QueryTests/Test3_1_3.py +++ b/test/sparql/QueryTests/Test3_1_3.py @@ -1,58 +1,58 @@ -#!/d/Bin/Python/python.exe
-# -*- coding: utf-8 -*-
-#
-#
-# $Date: 2005/04/02 07:29:46 $, by $Author: ivan $, $Revision: 1.1 $
-#
-"""
- Datatype test. Note that this is not 100% kosher. The problem is that the Literal of rdflib does not check the
- datatypes. In theory, if the data contains:
-
- x ns:p 42.
-
- instead of:
-
- x ns:p 42^^http://www.w3.org/2001/XMLSchema#integer
-
- the query should return no results, because the first object is of datatype string. However, Literal does not
- implement this...
-
-"""
-from testSPARQL import ns_rdf
-from testSPARQL import ns_rdfs
-from testSPARQL import ns_dc
-from testSPARQL import ns_foaf
-from testSPARQL import ns_ns
-
-rdfData ="""<?xml version="1.0" encoding="UTF-8"?>
-<rdf:RDF
- xmlns:rdfs ="http://www.w3.org/2000/01/rdf-schema#"
- xmlns:rdf ="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:dc ="http://purl.org/dc/elements/1.1/"
- xmlns:foaf ="http://xmlns.com/foaf/0.1/"
- xmlns:ns ="http://example.org/ns#"
- xmlns:dt ="http://example.org/datatype#"
->
- <rdf:Description>
- <ns:p rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">42</ns:p>
- <ns:p rdf:datatype="http://example.org/datatype#specialDatatype">abc</ns:p>
- <ns:p>2005-02-27</ns:p>
- <ns:p xml:lang="en">cat</ns:p>
- </rdf:Description>
-</rdf:RDF>
-"""
-
-from rdflib.Literal import Literal
-import datetime
-from rdflib.sparql import GraphPattern
-
-select = ["?v"]
-pattern = GraphPattern([("?v","?p","cat")])
-optional = []
-tripleStore = None
-expected = '''
-EMPTY
-'''
-
-
-
+#!/d/Bin/Python/python.exe +# -*- coding: utf-8 -*- +# +# +# $Date: 2005/04/02 07:29:46 $, by $Author: ivan $, $Revision: 1.1 $ +# +""" + Datatype test. Note that this is not 100% kosher. The problem is that the Literal of rdflib does not check the + datatypes. In theory, if the data contains: + + x ns:p 42. + + instead of: + + x ns:p 42^^http://www.w3.org/2001/XMLSchema#integer + + the query should return no results, because the first object is of datatype string. However, Literal does not + implement this... + +""" +from testSPARQL import ns_rdf +from testSPARQL import ns_rdfs +from testSPARQL import ns_dc +from testSPARQL import ns_foaf +from testSPARQL import ns_ns + +rdfData ="""<?xml version="1.0" encoding="UTF-8"?> +<rdf:RDF + xmlns:rdfs ="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf ="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:dc ="http://purl.org/dc/elements/1.1/" + xmlns:foaf ="http://xmlns.com/foaf/0.1/" + xmlns:ns ="http://example.org/ns#" + xmlns:dt ="http://example.org/datatype#" +> + <rdf:Description> + <ns:p rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">42</ns:p> + <ns:p rdf:datatype="http://example.org/datatype#specialDatatype">abc</ns:p> + <ns:p>2005-02-27</ns:p> + <ns:p xml:lang="en">cat</ns:p> + </rdf:Description> +</rdf:RDF> +""" + +from rdflib.Literal import Literal +import datetime +from rdflib.sparql import GraphPattern + +select = ["?v"] +pattern = GraphPattern([("?v","?p","cat")]) +optional = [] +tripleStore = None +expected = ''' +EMPTY +''' + + + diff --git a/test/sparql/QueryTests/Test3_1_4.py b/test/sparql/QueryTests/Test3_1_4.py index 6bfbadd8..c5783b74 100755 --- a/test/sparql/QueryTests/Test3_1_4.py +++ b/test/sparql/QueryTests/Test3_1_4.py @@ -1,57 +1,57 @@ -#!/d/Bin/Python/python.exe
-# -*- coding: utf-8 -*-
-#
-#
-# $Date: 2005/04/02 07:29:46 $, by $Author: ivan $, $Revision: 1.1 $
-#
-"""
- Datatype test. Note that this is not 100% kosher. The problem is that the Literal of rdflib does not check the
- datatypes. In theory, if the data contains:
-
- x ns:p 42.
-
- instead of:
-
- x ns:p 42^^http://www.w3.org/2001/XMLSchema#integer
-
- the query should return no results, because the first object is of datatype string. However, Literal does not
- implement this...
-
-"""
-rdfData ="""<?xml version="1.0" encoding="UTF-8"?>
-<rdf:RDF
- xmlns:rdfs ="http://www.w3.org/2000/01/rdf-schema#"
- xmlns:rdf ="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:dc ="http://purl.org/dc/elements/1.1/"
- xmlns:foaf ="http://xmlns.com/foaf/0.1/"
- xmlns:ns ="http://example.org/ns#"
- xmlns:dt ="http://example.org/datatype#"
->
- <rdf:Description>
- <ns:p rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">42</ns:p>
- <ns:p rdf:datatype="http://example.org/datatype#specialDatatype">abc</ns:p>
- <ns:p>2005-02-27</ns:p>
- <ns:p xml:lang="en">cat</ns:p>
- </rdf:Description>
-</rdf:RDF>
-"""
-from testSPARQL import ns_rdf
-from testSPARQL import ns_rdfs
-from testSPARQL import ns_dc
-from testSPARQL import ns_foaf
-from testSPARQL import ns_ns
-
-from rdflib.Literal import Literal
-import datetime
-from rdflib.sparql import GraphPattern
-
-select = ["?v"]
-pattern = GraphPattern([("?v","?p",Literal("cat",lang="en"))])
-optional = []
-tripleStore = None
-expected = '''
-?v : (some Bnode id)
-'''
-
-
-
+#!/d/Bin/Python/python.exe +# -*- coding: utf-8 -*- +# +# +# $Date: 2005/04/02 07:29:46 $, by $Author: ivan $, $Revision: 1.1 $ +# +""" + Datatype test. Note that this is not 100% kosher. The problem is that the Literal of rdflib does not check the + datatypes. In theory, if the data contains: + + x ns:p 42. + + instead of: + + x ns:p 42^^http://www.w3.org/2001/XMLSchema#integer + + the query should return no results, because the first object is of datatype string. However, Literal does not + implement this... + +""" +rdfData ="""<?xml version="1.0" encoding="UTF-8"?> +<rdf:RDF + xmlns:rdfs ="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf ="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:dc ="http://purl.org/dc/elements/1.1/" + xmlns:foaf ="http://xmlns.com/foaf/0.1/" + xmlns:ns ="http://example.org/ns#" + xmlns:dt ="http://example.org/datatype#" +> + <rdf:Description> + <ns:p rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">42</ns:p> + <ns:p rdf:datatype="http://example.org/datatype#specialDatatype">abc</ns:p> + <ns:p>2005-02-27</ns:p> + <ns:p xml:lang="en">cat</ns:p> + </rdf:Description> +</rdf:RDF> +""" +from testSPARQL import ns_rdf +from testSPARQL import ns_rdfs +from testSPARQL import ns_dc +from testSPARQL import ns_foaf +from testSPARQL import ns_ns + +from rdflib.Literal import Literal +import datetime +from rdflib.sparql import GraphPattern + +select = ["?v"] +pattern = GraphPattern([("?v","?p",Literal("cat",lang="en"))]) +optional = [] +tripleStore = None +expected = ''' +?v : (some Bnode id) +''' + + + diff --git a/test/sparql/QueryTests/Test3_2.py b/test/sparql/QueryTests/Test3_2.py index 65dd1ffd..aad4cf69 100755 --- a/test/sparql/QueryTests/Test3_2.py +++ b/test/sparql/QueryTests/Test3_2.py @@ -1,60 +1,60 @@ -#!/d/Bin/Python/python.exe
-# -*- coding: utf-8 -*-
-#
-#
-# $Date: 2005/04/02 07:29:46 $, by $Author: ivan $, $Revision: 1.1 $
-#
-
-from testSPARQL import ns_rdf
-from testSPARQL import ns_rdfs
-from testSPARQL import ns_dc
-from testSPARQL import ns_foaf
-from testSPARQL import ns_ns
-from testSPARQL import ns_book
-
-from rdflib.Literal import Literal
-from rdflib.sparql.sparqlOperators import lt, ge
-import datetime
-from rdflib.sparql import GraphPattern
-
-thresholdDate = datetime.date(2005,01,01)
-rdfData ="""<?xml version="1.0" encoding="UTF-8"?>
-<rdf:RDF
- xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:foaf="http://xmlns.com/foaf/0.1/"
- xmlns:ns = "http://example.org/ns#"
- xmlns:book = "http://example.org/book"
->
- <rdf:Description rdf:ID="book1">
- <dc:title>SPARQL Tutorial</dc:title>
- <ns:price rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">42</ns:price>
- </rdf:Description>
- <rdf:Description rdf:ID="book2">
- <dc:title>The Semantic Web</dc:title>
- <ns:price rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">23</ns:price>
- </rdf:Description>
- <rdf:Description rdf:ID="book3">
- <dc:title>The Semantic Web Old</dc:title>
- <dc:date rdf:datatype="http://www.w3.org/2001/XMLSchema#date">2000-03-12</dc:date>
- </rdf:Description>
- <rdf:Description rdf:ID="book4">
- <dc:title>The Semantic Web New</dc:title>
- <dc:date rdf:datatype="http://www.w3.org/2001/XMLSchema#date">2005-03-02</dc:date>
- </rdf:Description>
-</rdf:RDF>
-"""
-
-select = ["?title", "?price"]
-pattern = GraphPattern([("?x", ns_dc["title"],"?title"),("?x",ns_ns["price"],"?price")])
-pattern.addConstraint(lt("?price",30))
-optional = []
-tripleStore = None
-expected = '''
- ?title: The Semantic Web
- ?price: 23
-'''
-
-
-
+#!/d/Bin/Python/python.exe +# -*- coding: utf-8 -*- +# +# +# $Date: 2005/04/02 07:29:46 $, by $Author: ivan $, $Revision: 1.1 $ +# + +from testSPARQL import ns_rdf +from testSPARQL import ns_rdfs +from testSPARQL import ns_dc +from testSPARQL import ns_foaf +from testSPARQL import ns_ns +from testSPARQL import ns_book + +from rdflib.Literal import Literal +from rdflib.sparql.sparqlOperators import lt, ge +import datetime +from rdflib.sparql import GraphPattern + +thresholdDate = datetime.date(2005,01,01) +rdfData ="""<?xml version="1.0" encoding="UTF-8"?> +<rdf:RDF + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:foaf="http://xmlns.com/foaf/0.1/" + xmlns:ns = "http://example.org/ns#" + xmlns:book = "http://example.org/book" +> + <rdf:Description rdf:ID="book1"> + <dc:title>SPARQL Tutorial</dc:title> + <ns:price rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">42</ns:price> + </rdf:Description> + <rdf:Description rdf:ID="book2"> + <dc:title>The Semantic Web</dc:title> + <ns:price rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">23</ns:price> + </rdf:Description> + <rdf:Description rdf:ID="book3"> + <dc:title>The Semantic Web Old</dc:title> + <dc:date rdf:datatype="http://www.w3.org/2001/XMLSchema#date">2000-03-12</dc:date> + </rdf:Description> + <rdf:Description rdf:ID="book4"> + <dc:title>The Semantic Web New</dc:title> + <dc:date rdf:datatype="http://www.w3.org/2001/XMLSchema#date">2005-03-02</dc:date> + </rdf:Description> +</rdf:RDF> +""" + +select = ["?title", "?price"] +pattern = GraphPattern([("?x", ns_dc["title"],"?title"),("?x",ns_ns["price"],"?price")]) +pattern.addConstraint(lt("?price",30)) +optional = [] +tripleStore = None +expected = ''' + ?title: The Semantic Web + ?price: 23 +''' + + + diff --git a/test/sparql/QueryTests/Test5_1.py b/test/sparql/QueryTests/Test5_1.py index 89331e25..5e164af9 100755 --- a/test/sparql/QueryTests/Test5_1.py +++ b/test/sparql/QueryTests/Test5_1.py @@ -1,64 +1,64 @@ -#!/d/Bin/Python/python.exe
-# -*- coding: utf-8 -*-
-#
-#
-# $Date: 2005/04/02 07:29:46 $, by $Author: ivan $, $Revision: 1.1 $
-#
-"""
- Datatype test. Note that this is not 100% kosher. The problem is that the Literal of rdflib does not check the
- datatypes. In theory, if the data contains:
-
- x ns:p 42.
-
- instead of:
-
- x ns:p 42^^http://www.w3.org/2001/XMLSchema#integer
-
- the query should return no results, because the first object is of datatype string. However, Literal does not
- implement this...
-
-"""
-
-from testSPARQL import ns_rdf
-from testSPARQL import ns_rdfs
-from testSPARQL import ns_dc
-from testSPARQL import ns_foaf
-from testSPARQL import ns_ns
-from testSPARQL import ns_book
-
-from rdflib.Literal import Literal
-from rdflib.sparql import GraphPattern
-
-rdfData ="""<?xml version="1.0" encoding="UTF-8"?>
-<rdf:RDF
- xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:foaf="http://xmlns.com/foaf/0.1/"
- xmlns:ns = "http://example.org/ns#"
->
- <foaf:Person>
- <foaf:name>Alice</foaf:name>
- <foaf:mbox rdf:resource="mailto:alice@work.example"/>
- </foaf:Person>
- <foaf:Person>
- <foaf:name>Bob</foaf:name>
- </foaf:Person>
-</rdf:RDF>
-"""
-
-select = ["?name", "?mbox"]
-pattern = GraphPattern([("?x", ns_foaf["name"],"?name")])
-#optional = None
-optional = GraphPattern([("?x",ns_foaf["mbox"],"?mbox")])
-tripleStore = None
-expected = '''
- ?name: Alice
- ?mbox: mailto:alice@work.example
-
- ?name: Bob
- ?mbox: None
-'''
-
-
-
+#!/d/Bin/Python/python.exe +# -*- coding: utf-8 -*- +# +# +# $Date: 2005/04/02 07:29:46 $, by $Author: ivan $, $Revision: 1.1 $ +# +""" + Datatype test. Note that this is not 100% kosher. The problem is that the Literal of rdflib does not check the + datatypes. In theory, if the data contains: + + x ns:p 42. + + instead of: + + x ns:p 42^^http://www.w3.org/2001/XMLSchema#integer + + the query should return no results, because the first object is of datatype string. However, Literal does not + implement this... + +""" + +from testSPARQL import ns_rdf +from testSPARQL import ns_rdfs +from testSPARQL import ns_dc +from testSPARQL import ns_foaf +from testSPARQL import ns_ns +from testSPARQL import ns_book + +from rdflib.Literal import Literal +from rdflib.sparql import GraphPattern + +rdfData ="""<?xml version="1.0" encoding="UTF-8"?> +<rdf:RDF + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:foaf="http://xmlns.com/foaf/0.1/" + xmlns:ns = "http://example.org/ns#" +> + <foaf:Person> + <foaf:name>Alice</foaf:name> + <foaf:mbox rdf:resource="mailto:alice@work.example"/> + </foaf:Person> + <foaf:Person> + <foaf:name>Bob</foaf:name> + </foaf:Person> +</rdf:RDF> +""" + +select = ["?name", "?mbox"] +pattern = GraphPattern([("?x", ns_foaf["name"],"?name")]) +#optional = None +optional = GraphPattern([("?x",ns_foaf["mbox"],"?mbox")]) +tripleStore = None +expected = ''' + ?name: Alice + ?mbox: mailto:alice@work.example + + ?name: Bob + ?mbox: None +''' + + + diff --git a/test/sparql/QueryTests/Test5_2.py b/test/sparql/QueryTests/Test5_2.py index b8a32cb5..387f1970 100755 --- a/test/sparql/QueryTests/Test5_2.py +++ b/test/sparql/QueryTests/Test5_2.py @@ -1,56 +1,56 @@ -#!/d/Bin/Python/python.exe
-# -*- coding: utf-8 -*-
-#
-#
-# $Date: 2005/04/02 07:29:46 $, by $Author: ivan $, $Revision: 1.1 $
-#
-
-from testSPARQL import ns_rdf
-from testSPARQL import ns_rdfs
-from testSPARQL import ns_dc
-from testSPARQL import ns_foaf
-from testSPARQL import ns_ns
-from testSPARQL import ns_book
-
-from rdflib.Literal import Literal
-from rdflib.sparql.sparqlOperators import lt, ge
-import datetime
-from rdflib.sparql import GraphPattern
-
-thresholdDate = datetime.date(2005,01,01)
-
-rdfData ="""<?xml version="1.0" encoding="UTF-8"?>
-<rdf:RDF
- xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:foaf="http://xmlns.com/foaf/0.1/"
- xmlns:ns = "http://example.org/ns#"
- xmlns:book = "http://example.org/book"
->
- <rdf:Description rdf:ID="book1">
- <dc:title>SPARQL Tutorial</dc:title>
- <ns:price rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">42</ns:price>
- </rdf:Description>
- <rdf:Description rdf:ID="book2">
- <dc:title>The Semantic Web</dc:title>
- <ns:price rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">23</ns:price>
- </rdf:Description>
-</rdf:RDF>
-"""
-
-select = ["?title", "?price"]
-pattern = GraphPattern([("?x", ns_dc["title"],"?title")])
-optional = GraphPattern([("?x",ns_ns["price"],"?price")])
-optional.addConstraint(lt("?price",30))
-tripleStore = None
-expected = '''
- ?title: SPARQL Tutorial
- ?price: None
-
- ?title: The Semantic Web
- ?price: 23
-'''
-
-
-
+#!/d/Bin/Python/python.exe +# -*- coding: utf-8 -*- +# +# +# $Date: 2005/04/02 07:29:46 $, by $Author: ivan $, $Revision: 1.1 $ +# + +from testSPARQL import ns_rdf +from testSPARQL import ns_rdfs +from testSPARQL import ns_dc +from testSPARQL import ns_foaf +from testSPARQL import ns_ns +from testSPARQL import ns_book + +from rdflib.Literal import Literal +from rdflib.sparql.sparqlOperators import lt, ge +import datetime +from rdflib.sparql import GraphPattern + +thresholdDate = datetime.date(2005,01,01) + +rdfData ="""<?xml version="1.0" encoding="UTF-8"?> +<rdf:RDF + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:foaf="http://xmlns.com/foaf/0.1/" + xmlns:ns = "http://example.org/ns#" + xmlns:book = "http://example.org/book" +> + <rdf:Description rdf:ID="book1"> + <dc:title>SPARQL Tutorial</dc:title> + <ns:price rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">42</ns:price> + </rdf:Description> + <rdf:Description rdf:ID="book2"> + <dc:title>The Semantic Web</dc:title> + <ns:price rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">23</ns:price> + </rdf:Description> +</rdf:RDF> +""" + +select = ["?title", "?price"] +pattern = GraphPattern([("?x", ns_dc["title"],"?title")]) +optional = GraphPattern([("?x",ns_ns["price"],"?price")]) +optional.addConstraint(lt("?price",30)) +tripleStore = None +expected = ''' + ?title: SPARQL Tutorial + ?price: None + + ?title: The Semantic Web + ?price: 23 +''' + + + diff --git a/test/sparql/QueryTests/Test5_3.py b/test/sparql/QueryTests/Test5_3.py index 6389c352..dcbe5254 100755 --- a/test/sparql/QueryTests/Test5_3.py +++ b/test/sparql/QueryTests/Test5_3.py @@ -1,71 +1,71 @@ -#!/d/Bin/Python/python.exe
-# -*- coding: utf-8 -*-
-#
-#
-# $Date: 2005/04/02 07:29:46 $, by $Author: ivan $, $Revision: 1.1 $
-#
-"""
- Datatype test. Note that this is not 100% kosher. The problem is that the Literal of rdflib does not check the
- datatypes. In theory, if the data contains:
-
- x ns:p 42.
-
- instead of:
-
- x ns:p 42^^http://www.w3.org/2001/XMLSchema#integer
-
- the query should return no results, because the first object is of datatype string. However, Literal does not
- implement this...
-
-"""
-
-from testSPARQL import ns_rdf
-from testSPARQL import ns_rdfs
-from testSPARQL import ns_dc
-from testSPARQL import ns_foaf
-from testSPARQL import ns_ns
-from testSPARQL import ns_book
-
-from rdflib.Literal import Literal
-from rdflib.sparql import GraphPattern
-
-
-rdfData ="""<?xml version="1.0" encoding="UTF-8"?>
-<rdf:RDF
- xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:foaf="http://xmlns.com/foaf/0.1/"
- xmlns:ns = "http://example.org/ns#"
->
- <foaf:Person>
- <foaf:name>Alice</foaf:name>
- <foaf:homepage rdf:resource="http://work.example.org"/>
- </foaf:Person>
- <foaf:Person>
- <foaf:name>Bob</foaf:name>
- <foaf:mbox rdf:resource="mailto:bob@work.example"/>
- </foaf:Person>
-</rdf:RDF>
-"""
-
-select = ["?name", "?mbox", "?hpage"]
-pattern = GraphPattern([("?x", ns_foaf["name"],"?name")])
-#optional = None
-optional = [
- GraphPattern([("?x",ns_foaf["mbox"],"?mbox")]),
- GraphPattern([("?x",ns_foaf["homepage"],"?hpage")])
-]
-tripleStore = None
-expected = '''
- ?name: Alice
- ?mbox: None
- ?hpage: http://work.example.org
-
- ?name: Bob
- ?mbox: mailto:bob@work.example
- ?hpage: None
-'''
-
-
-
+#!/d/Bin/Python/python.exe +# -*- coding: utf-8 -*- +# +# +# $Date: 2005/04/02 07:29:46 $, by $Author: ivan $, $Revision: 1.1 $ +# +""" + Datatype test. Note that this is not 100% kosher. The problem is that the Literal of rdflib does not check the + datatypes. In theory, if the data contains: + + x ns:p 42. + + instead of: + + x ns:p 42^^http://www.w3.org/2001/XMLSchema#integer + + the query should return no results, because the first object is of datatype string. However, Literal does not + implement this... + +""" + +from testSPARQL import ns_rdf +from testSPARQL import ns_rdfs +from testSPARQL import ns_dc +from testSPARQL import ns_foaf +from testSPARQL import ns_ns +from testSPARQL import ns_book + +from rdflib.Literal import Literal +from rdflib.sparql import GraphPattern + + +rdfData ="""<?xml version="1.0" encoding="UTF-8"?> +<rdf:RDF + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:foaf="http://xmlns.com/foaf/0.1/" + xmlns:ns = "http://example.org/ns#" +> + <foaf:Person> + <foaf:name>Alice</foaf:name> + <foaf:homepage rdf:resource="http://work.example.org"/> + </foaf:Person> + <foaf:Person> + <foaf:name>Bob</foaf:name> + <foaf:mbox rdf:resource="mailto:bob@work.example"/> + </foaf:Person> +</rdf:RDF> +""" + +select = ["?name", "?mbox", "?hpage"] +pattern = GraphPattern([("?x", ns_foaf["name"],"?name")]) +#optional = None +optional = [ + GraphPattern([("?x",ns_foaf["mbox"],"?mbox")]), + GraphPattern([("?x",ns_foaf["homepage"],"?hpage")]) +] +tripleStore = None +expected = ''' + ?name: Alice + ?mbox: None + ?hpage: http://work.example.org + + ?name: Bob + ?mbox: mailto:bob@work.example + ?hpage: None +''' + + + diff --git a/test/sparql/QueryTests/Test6_11.py b/test/sparql/QueryTests/Test6_11.py index dfff94b9..00e3788e 100755 --- a/test/sparql/QueryTests/Test6_11.py +++ b/test/sparql/QueryTests/Test6_11.py @@ -1,57 +1,57 @@ -#!/d/Bin/Python/python.exe
-# -*- coding: utf-8 -*-
-#
-#
-# $Date: 2005/04/02 07:29:46 $, by $Author: ivan $, $Revision: 1.1 $
-#
-
-from testSPARQL import ns_rdf
-from testSPARQL import ns_rdfs
-from testSPARQL import ns_dc
-from testSPARQL import ns_dc0
-from testSPARQL import ns_foaf
-from testSPARQL import ns_ns
-from testSPARQL import ns_book
-
-from rdflib.Literal import Literal
-from rdflib.sparql.sparqlOperators import lt, ge
-import datetime
-from rdflib.sparql import GraphPattern
-
-thresholdDate = datetime.date(2005,01,01)
-
-rdfData ="""<?xml version="1.0" encoding="UTF-8"?>
-<rdf:RDF
- xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:dc0="http://purl.org/dc/elements/1.0/"
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:foaf="http://xmlns.com/foaf/0.1/"
- xmlns:ns = "http://example.org/ns#"
- xmlns:book = "http://example.org/book"
->
- <rdf:Description rdf:ID="book2">
- <dc0:title>SPARQL Query Language Tutorial</dc0:title>
- <dc0:creator>Alice</dc0:creator>
- </rdf:Description>
- <rdf:Description rdf:ID="book1">
- <dc:title>SPARQL Protocol Tutorial</dc:title>
- <dc:creator>Bob</dc:creator>
- </rdf:Description>
-</rdf:RDF>
-"""
-
-select = ["?title"]
-patt1 = GraphPattern([("?book",ns_dc0["title"],"?title")])
-patt2 = GraphPattern([("?book",ns_dc["title"],"?title")])
-pattern = [patt1,patt2]
-optional = []
-tripleStore = None
-expected = '''
- ?title: SPARQL Query Language Tutorial
-
- ?title: SPARQL Protocol Tutorial
-'''
-
-
-
+#!/d/Bin/Python/python.exe +# -*- coding: utf-8 -*- +# +# +# $Date: 2005/04/02 07:29:46 $, by $Author: ivan $, $Revision: 1.1 $ +# + +from testSPARQL import ns_rdf +from testSPARQL import ns_rdfs +from testSPARQL import ns_dc +from testSPARQL import ns_dc0 +from testSPARQL import ns_foaf +from testSPARQL import ns_ns +from testSPARQL import ns_book + +from rdflib.Literal import Literal +from rdflib.sparql.sparqlOperators import lt, ge +import datetime +from rdflib.sparql import GraphPattern + +thresholdDate = datetime.date(2005,01,01) + +rdfData ="""<?xml version="1.0" encoding="UTF-8"?> +<rdf:RDF + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:dc0="http://purl.org/dc/elements/1.0/" + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:foaf="http://xmlns.com/foaf/0.1/" + xmlns:ns = "http://example.org/ns#" + xmlns:book = "http://example.org/book" +> + <rdf:Description rdf:ID="book2"> + <dc0:title>SPARQL Query Language Tutorial</dc0:title> + <dc0:creator>Alice</dc0:creator> + </rdf:Description> + <rdf:Description rdf:ID="book1"> + <dc:title>SPARQL Protocol Tutorial</dc:title> + <dc:creator>Bob</dc:creator> + </rdf:Description> +</rdf:RDF> +""" + +select = ["?title"] +patt1 = GraphPattern([("?book",ns_dc0["title"],"?title")]) +patt2 = GraphPattern([("?book",ns_dc["title"],"?title")]) +pattern = [patt1,patt2] +optional = [] +tripleStore = None +expected = ''' + ?title: SPARQL Query Language Tutorial + + ?title: SPARQL Protocol Tutorial +''' + + + diff --git a/test/sparql/QueryTests/Test6_12.py b/test/sparql/QueryTests/Test6_12.py index cc695c2b..5a92d07a 100755 --- a/test/sparql/QueryTests/Test6_12.py +++ b/test/sparql/QueryTests/Test6_12.py @@ -1,60 +1,60 @@ -#!/d/Bin/Python/python.exe
-# -*- coding: utf-8 -*-
-#
-#
-# $Date: 2005/04/02 07:29:46 $, by $Author: ivan $, $Revision: 1.1 $
-#
-
-from testSPARQL import ns_rdf
-from testSPARQL import ns_rdfs
-from testSPARQL import ns_dc
-from testSPARQL import ns_dc0
-from testSPARQL import ns_foaf
-from testSPARQL import ns_ns
-from testSPARQL import ns_book
-
-from rdflib.Literal import Literal
-from rdflib.sparql.sparqlOperators import lt, ge
-import datetime
-from rdflib.sparql import GraphPattern
-
-thresholdDate = datetime.date(2005,01,01)
-
-
-rdfData ="""<?xml version="1.0" encoding="UTF-8"?>
-<rdf:RDF
- xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:dc0="http://purl.org/dc/elements/1.0/"
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:foaf="http://xmlns.com/foaf/0.1/"
- xmlns:ns = "http://example.org/ns#"
- xmlns:book = "http://example.org/book"
->
- <rdf:Description rdf:ID="book2">
- <dc0:title>SPARQL Query Language Tutorial</dc0:title>
- <dc0:creator>Alice</dc0:creator>
- </rdf:Description>
- <rdf:Description rdf:ID="book1">
- <dc:title>SPARQL Protocol Tutorial</dc:title>
- <dc:creator>Bob</dc:creator>
- </rdf:Description>
-</rdf:RDF>
-"""
-
-select = ["?x","?y"]
-patt1 = GraphPattern([("?book",ns_dc0["title"],"?x")])
-patt2 = GraphPattern([("?book",ns_dc["title"],"?y")])
-pattern = [patt1,patt2]
-optional = []
-tripleStore = None
-expected = '''
- ?x: SPARQL Query Language Tutorial
- ?y: None
-
- ?x: None
- ?y: SPARQL Protocol Tutorial
-'''
-
-
-
+#!/d/Bin/Python/python.exe +# -*- coding: utf-8 -*- +# +# +# $Date: 2005/04/02 07:29:46 $, by $Author: ivan $, $Revision: 1.1 $ +# + +from testSPARQL import ns_rdf +from testSPARQL import ns_rdfs +from testSPARQL import ns_dc +from testSPARQL import ns_dc0 +from testSPARQL import ns_foaf +from testSPARQL import ns_ns +from testSPARQL import ns_book + +from rdflib.Literal import Literal +from rdflib.sparql.sparqlOperators import lt, ge +import datetime +from rdflib.sparql import GraphPattern + +thresholdDate = datetime.date(2005,01,01) + + +rdfData ="""<?xml version="1.0" encoding="UTF-8"?> +<rdf:RDF + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:dc0="http://purl.org/dc/elements/1.0/" + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:foaf="http://xmlns.com/foaf/0.1/" + xmlns:ns = "http://example.org/ns#" + xmlns:book = "http://example.org/book" +> + <rdf:Description rdf:ID="book2"> + <dc0:title>SPARQL Query Language Tutorial</dc0:title> + <dc0:creator>Alice</dc0:creator> + </rdf:Description> + <rdf:Description rdf:ID="book1"> + <dc:title>SPARQL Protocol Tutorial</dc:title> + <dc:creator>Bob</dc:creator> + </rdf:Description> +</rdf:RDF> +""" + +select = ["?x","?y"] +patt1 = GraphPattern([("?book",ns_dc0["title"],"?x")]) +patt2 = GraphPattern([("?book",ns_dc["title"],"?y")]) +pattern = [patt1,patt2] +optional = [] +tripleStore = None +expected = ''' + ?x: SPARQL Query Language Tutorial + ?y: None + + ?x: None + ?y: SPARQL Protocol Tutorial +''' + + + diff --git a/test/sparql/QueryTests/queryTest.py b/test/sparql/QueryTests/queryTest.py index 1ab4f412..35e2e267 100755 --- a/test/sparql/QueryTests/queryTest.py +++ b/test/sparql/QueryTests/queryTest.py @@ -1,103 +1,103 @@ -#!/d/Bin/Python/python.exe
-# -*- coding: utf-8 -*-
-#
-#
-# $Date: 2005/04/02 07:29:46 $, by $Author: ivan $, $Revision: 1.1 $
-#
-"""
-
-"""
-import sys, os, time, datetime, imp, sys, StringIO
-
-sys.path.insert(0,"../")
-
-from rdflib import sparql
-from rdflib.sparql import sparqlGraph, retrieveRDFFiles
-from testSPARQL import ns_rdf
-from testSPARQL import ns_rdfs
-from testSPARQL import ns_dc
-from testSPARQL import ns_dc0
-from testSPARQL import ns_foaf
-from rdflib.FileInputSource import FileInputSource
-
-def run(modName) :
- # Import the python module
- defs = None
- (fl,realpath,descr) = imp.find_module(modName,["."])
- mod = imp.load_module(modName,fl,realpath,descr)
- defs = mod.__dict__
-
- ##################################################
- # Three ways of identifying the RDF data:
- # 1. A Triple Store generated in the module
- tripleStore = None
- try :
- tripleStore = defs["tripleStore"]
- except :
- pass
- # 2. A reference to a set of RDF Files
- fils = None
- try :
- fils = defs["datafiles"]
- except :
- pass
- # 3. Directly in the test module as a string
- rdfData = None
- try :
- rdfData = defs["rdfData"]
- except :
- pass
-
- # Get the final of the triple store...
- if tripleStore == None :
- if rdfData == None :
- tripleStore = retrieveRDFFiles(fils)
- else :
- stream = StringIO.StringIO(rdfData)
- tripleStore = sparqlGraph.SPARQLGraph()
- tripleStore.parse(FileInputSource(stream),format="xml")
-
- ###############################################
- # Retrive the query data
- pattern = defs["pattern"]
- optPattern = defs["optional"]
- select = defs["select"]
-
-
- ###############################################
- print "\n============= Test Module: %s =============" % modName
- # better test modules describe their expected results...
- try :
- expected = defs["expected"]
- print "expected: %s" % expected
- print "=======\n"
- except :
- pass
-
- # Run the query and print the results
- results = tripleStore.query(select,pattern,optPattern)
- num = len(results)
- print "Number of hits: %d" % num
- print
- for i in range(0,num) :
- hit = results[i]
- if len(select) == 1 :
- print "%s: %s" % (select[0],hit)
- else :
- for j in range(0,len(select)) :
- var = select[j]
- val = hit[j]
- print "%s: %s" % (var,val)
- print
-
-if __name__ == '__main__' :
- if len(sys.argv) == 1 :
- print "Usage: %s modname1 modname2 ..." % sys.argv[0]
- else :
- for mod in sys.argv[1:] :
- if mod.endswith(".py") :
- run(mod[0:-3])
- else :
- run(mod)
-
-
+#!/d/Bin/Python/python.exe +# -*- coding: utf-8 -*- +# +# +# $Date: 2005/04/02 07:29:46 $, by $Author: ivan $, $Revision: 1.1 $ +# +""" + +""" +import sys, os, time, datetime, imp, sys, StringIO + +sys.path.insert(0,"../") + +from rdflib import sparql +from rdflib.sparql import sparqlGraph, retrieveRDFFiles +from testSPARQL import ns_rdf +from testSPARQL import ns_rdfs +from testSPARQL import ns_dc +from testSPARQL import ns_dc0 +from testSPARQL import ns_foaf +from rdflib.FileInputSource import FileInputSource + +def run(modName) : + # Import the python module + defs = None + (fl,realpath,descr) = imp.find_module(modName,["."]) + mod = imp.load_module(modName,fl,realpath,descr) + defs = mod.__dict__ + + ################################################## + # Three ways of identifying the RDF data: + # 1. A Triple Store generated in the module + tripleStore = None + try : + tripleStore = defs["tripleStore"] + except : + pass + # 2. A reference to a set of RDF Files + fils = None + try : + fils = defs["datafiles"] + except : + pass + # 3. Directly in the test module as a string + rdfData = None + try : + rdfData = defs["rdfData"] + except : + pass + + # Get the final of the triple store... + if tripleStore == None : + if rdfData == None : + tripleStore = retrieveRDFFiles(fils) + else : + stream = StringIO.StringIO(rdfData) + tripleStore = sparqlGraph.SPARQLGraph() + tripleStore.parse(FileInputSource(stream),format="xml") + + ############################################### + # Retrive the query data + pattern = defs["pattern"] + optPattern = defs["optional"] + select = defs["select"] + + + ############################################### + print "\n============= Test Module: %s =============" % modName + # better test modules describe their expected results... + try : + expected = defs["expected"] + print "expected: %s" % expected + print "=======\n" + except : + pass + + # Run the query and print the results + results = tripleStore.query(select,pattern,optPattern) + num = len(results) + print "Number of hits: %d" % num + print + for i in range(0,num) : + hit = results[i] + if len(select) == 1 : + print "%s: %s" % (select[0],hit) + else : + for j in range(0,len(select)) : + var = select[j] + val = hit[j] + print "%s: %s" % (var,val) + print + +if __name__ == '__main__' : + if len(sys.argv) == 1 : + print "Usage: %s modname1 modname2 ..." % sys.argv[0] + else : + for mod in sys.argv[1:] : + if mod.endswith(".py") : + run(mod[0:-3]) + else : + run(mod) + + diff --git a/test/sparql/README b/test/sparql/README index d6e8a493..b202dc69 100755 --- a/test/sparql/README +++ b/test/sparql/README @@ -1,20 +1,20 @@ -There are two classes of tests (for now): query and construct, each in its own directory. The structure is identical.
-
-Each test is in a different python file (usually Test***.py, where *** refer to the chapter
-in the SPARQL document). The test is run by the queryTest (resp. constructTest) script.
-This script does a run-time import of the test file, getting the variables in the Test files,
-construct and runs the sparql query and displays the result.
-
-Each test file has an identical structure: it is a bunch of (python) declaration:
-
-- the rdf data itself ("rdfData")
- it is also possible to refer to an array of external files using the
- variable "datafiles", but the rdfData takes precedence. If files are used,
- either set rdfData to None, or do not set it at all
-- the 'where' and 'optional' clauses, set as GraphPatterns
-- the 'select' tuple (if applicable)
-- the 'construct' pattern (if applicable)
-- for the query case, the expected result should be added in the form of a string
-
-Looking at the current examples, the structure is pretty straightforward.
-
+There are two classes of tests (for now): query and construct, each in its own directory. The structure is identical. + +Each test is in a different python file (usually Test***.py, where *** refer to the chapter +in the SPARQL document). The test is run by the queryTest (resp. constructTest) script. +This script does a run-time import of the test file, getting the variables in the Test files, +construct and runs the sparql query and displays the result. + +Each test file has an identical structure: it is a bunch of (python) declaration: + +- the rdf data itself ("rdfData") + it is also possible to refer to an array of external files using the + variable "datafiles", but the rdfData takes precedence. If files are used, + either set rdfData to None, or do not set it at all +- the 'where' and 'optional' clauses, set as GraphPatterns +- the 'select' tuple (if applicable) +- the 'construct' pattern (if applicable) +- for the query case, the expected result should be added in the form of a string + +Looking at the current examples, the structure is pretty straightforward. + diff --git a/test/sparql/testSPARQL.py b/test/sparql/testSPARQL.py index e5808837..b6900ec2 100755 --- a/test/sparql/testSPARQL.py +++ b/test/sparql/testSPARQL.py @@ -1,32 +1,32 @@ -#!/d/Bin/Python/python.exe
-# -*- coding: utf-8 -*-
-#
-#
-# $Date: 2005/04/02 07:29:30 $, by $Author: ivan $, $Revision: 1.1 $
-#
-"""
-
-"""
-import sys, os, time, datetime
-
-from rdflib.sparql import ns_rdf as ns_rdf
-from rdflib.sparql import ns_rdfs as ns_rdfs
-from rdflib.sparql import ns_dc as ns_dc
-from rdflib.sparql import ns_owl as ns_owl
-
-from rdflib.sparql import type_integer
-from rdflib.sparql import type_double
-from rdflib.sparql import type_float
-from rdflib.sparql import type_decimal
-from rdflib.sparql import type_dateTime
-
-from rdflib.Namespace import Namespace
-
-ns_foaf = Namespace("http://xmlns.com/foaf/0.1/")
-ns_ns = Namespace("http://example.org/ns#")
-ns_book = Namespace("http://example.org/book")
-ns_person = Namespace("http://example.org/person#")
-ns_dt = Namespace("http://example.org/datatype#")
-ns_dc0 = Namespace("http://purl.org/dc/elements/1.0/")
-ns_vcard = Namespace("http://www.w3.org/2001/vcard-rdf/3.0#")
-
+#!/d/Bin/Python/python.exe +# -*- coding: utf-8 -*- +# +# +# $Date: 2005/04/02 07:29:30 $, by $Author: ivan $, $Revision: 1.1 $ +# +""" + +""" +import sys, os, time, datetime + +from rdflib.sparql import ns_rdf as ns_rdf +from rdflib.sparql import ns_rdfs as ns_rdfs +from rdflib.sparql import ns_dc as ns_dc +from rdflib.sparql import ns_owl as ns_owl + +from rdflib.sparql import type_integer +from rdflib.sparql import type_double +from rdflib.sparql import type_float +from rdflib.sparql import type_decimal +from rdflib.sparql import type_dateTime + +from rdflib.Namespace import Namespace + +ns_foaf = Namespace("http://xmlns.com/foaf/0.1/") +ns_ns = Namespace("http://example.org/ns#") +ns_book = Namespace("http://example.org/book") +ns_person = Namespace("http://example.org/person#") +ns_dt = Namespace("http://example.org/datatype#") +ns_dc0 = Namespace("http://purl.org/dc/elements/1.0/") +ns_vcard = Namespace("http://www.w3.org/2001/vcard-rdf/3.0#") + diff --git a/test/sparqlgrammar.py b/test/sparqlgrammar.py index ea7a9b70..cca255cb 100644 --- a/test/sparqlgrammar.py +++ b/test/sparqlgrammar.py @@ -1,17 +1,17 @@ -import unittest
-
-from rdflib import *
-
-class SPARQLGrammarTestCase(unittest.TestCase):
-
- def setUp(self):
- self.p = parser.SPARQLGrammar()
-
- def test_VAR_(self):
- self.p._VAR_.parseString('?bob') == ['?bob']
-
- def testURI(self):
- self.p.URI.parseString('<dc:title>') == ['?bob']
-
-if __name__ == '__main__':
- unittest.main()
+import unittest + +from rdflib import * + +class SPARQLGrammarTestCase(unittest.TestCase): + + def setUp(self): + self.p = parser.SPARQLGrammar() + + def test_VAR_(self): + self.p._VAR_.parseString('?bob') == ['?bob'] + + def testURI(self): + self.p.URI.parseString('<dc:title>') == ['?bob'] + +if __name__ == '__main__': + unittest.main() diff --git a/test/triple_store.py b/test/triple_store.py index 4ef26078..dfe1ca58 100644 --- a/test/triple_store.py +++ b/test/triple_store.py @@ -1,34 +1,34 @@ -import unittest
-
-from rdflib import Graph, URIRef, BNode, Literal, RDFS
-
-
-class GraphTest(unittest.TestCase):
- backend = 'default'
- path = 'store'
-
- def setUp(self):
- self.store = Graph(backend=self.backend)
- self.store.open(self.path)
- self.remove_me = (BNode(), RDFS.label, Literal("remove_me"))
- self.store.add(self.remove_me)
-
- def tearDown(self):
- self.store.close()
-
- def testAdd(self):
- subject = BNode()
- self.store.add((subject, RDFS.label, Literal("foo")))
-
- def testRemove(self):
- self.store.remove(self.remove_me)
- self.store.remove((None, None, None))
-
- def testTriples(self):
- for s, p, o in self.store:
- pass
-
-if __name__ == "__main__":
- unittest.main()
-
-
+import unittest + +from rdflib import Graph, URIRef, BNode, Literal, RDFS + + +class GraphTest(unittest.TestCase): + backend = 'default' + path = 'store' + + def setUp(self): + self.store = Graph(backend=self.backend) + self.store.open(self.path) + self.remove_me = (BNode(), RDFS.label, Literal("remove_me")) + self.store.add(self.remove_me) + + def tearDown(self): + self.store.close() + + def testAdd(self): + subject = BNode() + self.store.add((subject, RDFS.label, Literal("foo"))) + + def testRemove(self): + self.store.remove(self.remove_me) + self.store.remove((None, None, None)) + + def testTriples(self): + for s, p, o in self.store: + pass + +if __name__ == "__main__": + unittest.main() + + diff --git a/test/type_check.py b/test/type_check.py index 56c118a1..df005287 100644 --- a/test/type_check.py +++ b/test/type_check.py @@ -1,33 +1,33 @@ -import unittest
-
-from rdflib import Graph
-from rdflib.exceptions import SubjectTypeError
-from rdflib.exceptions import PredicateTypeError
-from rdflib.exceptions import ObjectTypeError
-from rdflib.URIRef import URIRef
-
-foo = URIRef("foo")
-
-
-class TypeCheckCase(unittest.TestCase):
- backend = 'default'
- path = 'store'
-
- def setUp(self):
- self.store = Graph(backend=self.backend)
- self.store.open(self.path)
-
- def tearDown(self):
- self.store.close()
-
- def testSubjectTypeCheck(self):
- self.assertRaises(SubjectTypeError,
- self.store.add, (None, foo, foo))
-
- def testPredicateTypeCheck(self):
- self.assertRaises(PredicateTypeError,
- self.store.add, (foo, None, foo))
-
- def testObjectTypeCheck(self):
- self.assertRaises(ObjectTypeError,
- self.store.add, (foo, foo, None))
+import unittest + +from rdflib import Graph +from rdflib.exceptions import SubjectTypeError +from rdflib.exceptions import PredicateTypeError +from rdflib.exceptions import ObjectTypeError +from rdflib.URIRef import URIRef + +foo = URIRef("foo") + + +class TypeCheckCase(unittest.TestCase): + backend = 'default' + path = 'store' + + def setUp(self): + self.store = Graph(backend=self.backend) + self.store.open(self.path) + + def tearDown(self): + self.store.close() + + def testSubjectTypeCheck(self): + self.assertRaises(SubjectTypeError, + self.store.add, (None, foo, foo)) + + def testPredicateTypeCheck(self): + self.assertRaises(PredicateTypeError, + self.store.add, (foo, None, foo)) + + def testObjectTypeCheck(self): + self.assertRaises(ObjectTypeError, + self.store.add, (foo, foo, None)) diff --git a/test/util.py b/test/util.py index 327e5751..ada88f23 100644 --- a/test/util.py +++ b/test/util.py @@ -1,19 +1,19 @@ -import unittest
-
-from rdflib import *
-from rdflib.store.NodePickler import NodePickler
-
-
-class UtilTestCase(unittest.TestCase):
-
- def test_to_bits_from_bits_round_trip(self):
- np = NodePickler()
-
- a = Literal(u'''A test with a \\n (backslash n), "\u00a9" , and newline \n and a second line.
-''')
- b = np.loads(np.dumps(a))
- self.assertEquals(a, b)
-
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
+import unittest + +from rdflib import * +from rdflib.store.NodePickler import NodePickler + + +class UtilTestCase(unittest.TestCase): + + def test_to_bits_from_bits_round_trip(self): + np = NodePickler() + + a = Literal(u'''A test with a \\n (backslash n), "\u00a9" , and newline \n and a second line. +''') + b = np.loads(np.dumps(a)) + self.assertEquals(a, b) + + +if __name__ == '__main__': + unittest.main(defaultTest='test_suite') |