Skip to content

Commit 23751ed

Browse files
committed
imported code from sourceforge (r180)
0 parents  commit 23751ed

40 files changed

+4173
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*~
2+
*.pyc

AUTHORS.txt

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Authors
3+
-------
4+
5+
Ivan Herman <[email protected]>
6+
Sergio Fernández <[email protected]>
7+
Carlos Tejo <[email protected]>
8+
9+
10+
Contributors
11+
------------
12+
13+
Obey Arthur Liu <[email protected]>, different patches
14+
Christopher Lenz <[email protected]>, feature to allow developers to choose the json module
15+
Pēteris Caune <[email protected]>, great feedback and patches
16+
Bogdan Benea <[email protected]>, patch for the query regular expresion
17+
William Waites <[email protected]>, patches for RDFLib3
18+
Christoph Burgmer <[email protected]>, patches for RDFLib3
19+
Thomas Kluyver <[email protected]>, patches for Python 3.x
20+
Diego Berrueta <[email protected]>, new function for printing results as table
21+
Olivier Berger <[email protected]>, patch regarding raw response for unknown formats
22+

ChangeLog.txt

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
SPARQLWrapper's changelog:
2+
-------------------------
3+
4+
YYYY-MM-DD 1.5.3 - Returing raw response in case of unknow content type returned
5+
- Fixed some issues with the last version of the SPARQL 1.1 Update Protocol
6+
7+
2012-08-28 1.5.2 - Implemented update operation according the latest SPARQL 1.1 Protocol drafts (i.e., switching to 'update' parameter)
8+
9+
2012-07-10 1.5.1 - Added the posibility to use two different endpoints for reading and writing operations
10+
- New print_results() function for users testing
11+
12+
2012-02-01 1.5.0 - Update handling 500's coming from SPARQL endpoint (feature request #3198363)
13+
- Added Python 3.x support (feature request 3022722)
14+
- Warning when returned format would be different than the requested one
15+
16+
2011-01-28 1.4.2 - Updated for working with RDFLib3 too (feature request #3117442)
17+
- fixed bug with prefixes' regex (#2320024)
18+
19+
2010-01-11 1.4.1 - Supporting keep-alive in SPARQLWrapper if urlgrabber is available (ticket #2929881)
20+
- fixed bugs (#2949834)
21+
22+
2009-12-14 1.4.0 - Added some suport for SPARUL
23+
- Improved HTTP related code
24+
- Many other minor bugs fixed
25+
26+
2009-09-23 1.3.2 - Remove pyxml dependecy. Instead, use xml.dom.minidom
27+
- Updated setup installation (added rdflib dependency)
28+
- Udpated example.py (added XML, N3 and RDF examples)
29+
30+
2009-09-11 1.3.1 - Remove simplejson dependency for python => 2.6 version
31+
- Added feature to choose the json module to use
32+
33+
2009-05-06 1.3.0 - Added a new method to add custom parameters (deprecated old way to do it)
34+
35+
2009-04-27 1.2.1 - Updated setup installation
36+
- Patched to work with JSON in Python>=2.6
37+
38+
2008-07-10 1.2.0 - Allowed non-standard extensions (such as SPARUL).
39+
- Exceptions fixed.
40+
- Added another example.
41+
42+
2008-03-24 1.1.0 - Renamed package name to SPARQLWrapper.
43+
- Added a basic catalog of exceptions.
44+
45+
2008-03-07 1.0.1 - Fixed some cosmetic things.
46+
47+
2008-02-14 1.0.0 - First stable release.
48+
- Main functionalities stabilized.
49+
- Project moved to SourceForge.
50+
51+
2007-07-06 0.2.0 - First public release of the library.
52+

LICENSE.txt

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
SPARQL Python Wrapper is released under the W3C� SOFTWARE NOTICE AND LICENSE.
2+
3+
This work (and included software, documentation such as READMEs, or other related items) is being provided by the copyright holders under the following license. By obtaining, using and/or copying this work, you (the licensee) agree that you have read, understood, and will comply with the following terms and conditions.
4+
5+
Permission to copy, modify, and distribute this software and its documentation, with or without modification, for any purpose and without fee or royalty is hereby granted, provided that you include the following on ALL copies of the software and documentation or portions thereof, including modifications:
6+
7+
1. The full text of this NOTICE in a location viewable to users of the redistributed or derivative work.
8+
2. Any pre-existing intellectual property disclaimers, notices, or terms and conditions. If none exist, the W3C Software Short Notice should be included (hypertext is preferred, text is permitted) within the body of any redistributed or derivative code.
9+
3. Notice of any changes or modifications to the files, including the date changes were made. (We recommend you provide URIs to the location from which the code is derived.)
10+
11+
THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
12+
13+
COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.
14+
15+
The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to the software without specific, written prior permission. Title to copyright in this software and any associated documentation will at all times remain with copyright holders.
16+
17+
See also http://www.w3.org/Consortium/Legal/copyright-software for further details
18+

MANIFEST.in

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include *.txt
2+
exclude Makefile

Makefile

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# SPARQLWrapper Makefile
2+
3+
NAME=SPARQLWrapper
4+
DESTDIR =
5+
DOCDIR=doc
6+
PYTHON=python
7+
8+
doc: clean
9+
mkdir -p $(DOCDIR)
10+
epydoc -v -n $(NAME) -o $(DOCDIR) --html SPARQLWrapper
11+
12+
clean:
13+
rm -rf $(DOCDIR)

README.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# SPARQL Endpoint interface to Python
2+
3+
The distribution contains:
4+
5+
* `SPARQLWrapper`: the Python library. You should copy the directory somewhere into your PYTHONPATH. Alternatively, you can also run the disutils scrips:
6+
7+
python setup.py install
8+
9+
* `test`: some unit tests
10+
11+
* `script`: some scripts to run the library against some SPARQL end-points.
12+
13+
* `scripts/sparql.py`: to run a SPARQL SELECT query stored in an external file. The URIs for the SPARQL services have to be updated for local use.
14+
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# -*- coding: utf-8 -*-
2+
3+
"""
4+
A simple implementation of a key case-insensitive dictionary.
5+
6+
@authors: U{Ivan Herman<http://www.ivan-herman.net>}, U{Sergio Fernández<http://www.wikier.org>}, U{Carlos Tejo Alonso<http://www.dayures.net>}
7+
@organization: U{World Wide Web Consortium<http://www.w3.org>} and U{Foundation CTIC<http://www.fundacionctic.org/>}.
8+
@license: U{W3C® SOFTWARE NOTICE AND LICENSE<href="http://www.w3.org/Consortium/Legal/copyright-software">}
9+
"""
10+
11+
class KeyCaseInsensitiveDict(dict):
12+
"""
13+
A simple implementation of a key case-insensitive dictionary
14+
"""
15+
16+
def __init__(self, d={}):
17+
for k, v in d.items():
18+
self[k] = v
19+
20+
def __setitem__(self, key, value):
21+
if (hasattr(key, "lower")):
22+
key = key.lower()
23+
dict.__setitem__(self, key, value)
24+
25+
def __getitem__(self, key):
26+
if (hasattr(key, "lower")):
27+
key = key.lower()
28+
return dict.__getitem__(self, key)
29+
30+
def __delitem__(self, key):
31+
if hasattr(key, "lower"):
32+
key = key.lower()
33+
dict.__delitem__(self, key)
34+

SPARQLWrapper/SPARQLExceptions.py

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# -*- coding: utf-8 -*-
2+
3+
"""
4+
5+
SPARQL Wrapper exceptions
6+
7+
@authors: U{Ivan Herman<http://www.ivan-herman.net>}, U{Sergio Fernández<http://www.wikier.org>}, U{Carlos Tejo Alonso<http://www.dayures.net>}
8+
@organization: U{World Wide Web Consortium<http://www.w3.org>} and U{Foundation CTIC<http://www.fundacionctic.org/>}.
9+
@license: U{W3C® SOFTWARE NOTICE AND LICENSE<href="http://www.w3.org/Consortium/Legal/copyright-software">}
10+
11+
"""
12+
13+
class SPARQLWrapperException(Exception):
14+
"""
15+
Base class for SPARQL Wrapper exceptions
16+
"""
17+
18+
msg = "an exception has occured"
19+
20+
def __init__(self, response=None):
21+
if (response):
22+
Exception.__init__(self, "%s: %s. \n\nResponse:\n%s" % (self.__class__.__name__, self.msg, response))
23+
else:
24+
Exception.__init__(self, "%s: %s." % (self.__class__.__name__, self.msg))
25+
26+
class EndPointInternalError(SPARQLWrapperException):
27+
"""
28+
Exception type for 500 Internal Server Error responses.
29+
"""
30+
31+
msg = "endpoint returned code 500 and response"
32+
33+
class QueryBadFormed(SPARQLWrapperException):
34+
"""
35+
Query Bad Formed exceptions
36+
"""
37+
38+
msg = "a bad request has been sent to the endpoint, probably the sparql query is bad formed"
39+
40+
class EndPointNotFound(SPARQLWrapperException):
41+
"""
42+
End Point Not Found exceptions
43+
"""
44+
45+
msg = "it was impossible to connect with the endpoint in that address, check if it is correct"
46+

SPARQLWrapper/SPARQLUtils.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# -*- coding: utf8 -*-
2+
3+
"""
4+
5+
SPARQL Wrapper Utils
6+
7+
@authors: U{Ivan Herman<http://www.ivan-herman.net>}, U{Sergio Fernández<http://www.wikier.org>}, U{Carlos Tejo Alonso<http://www.dayures.net>}
8+
@organization: U{World Wide Web Consortium<http://www.w3.org>} and U{Foundation CTIC<http://www.fundacionctic.org/>}.
9+
@license: U{W3C SOFTWARE NOTICE AND LICENSE<href="http://www.w3.org/Consortium/Legal/copyright-software">}
10+
11+
"""
12+
13+
import warnings
14+
15+
def deprecated(func):
16+
"""
17+
This is a decorator which can be used to mark functions
18+
as deprecated. It will result in a warning being emmitted
19+
when the function is used.
20+
@see: http://code.activestate.com/recipes/391367/
21+
"""
22+
def newFunc(*args, **kwargs):
23+
warnings.warn("Call to deprecated function %s." % func.__name__, category=DeprecationWarning, stacklevel=2)
24+
return func(*args, **kwargs)
25+
newFunc.__name__ = func.__name__
26+
newFunc.__doc__ = func.__doc__
27+
newFunc.__dict__.update(func.__dict__)
28+
return newFunc
29+

0 commit comments

Comments
 (0)