Hello community, here is the log from the commit of package python-SPARQLWrapper for openSUSE:Factory checked in at 2016-09-17 14:37:33 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-SPARQLWrapper (Old) and /work/SRC/openSUSE:Factory/.python-SPARQLWrapper.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-SPARQLWrapper" Changes: -------- --- /work/SRC/openSUSE:Factory/python-SPARQLWrapper/python-SPARQLWrapper.changes 2016-02-22 08:55:51.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.python-SPARQLWrapper.new/python-SPARQLWrapper.changes 2016-09-17 14:37:35.000000000 +0200 @@ -1,0 +2,22 @@ +Mon Sep 12 12:47:10 UTC 2016 - apla...@suse.com + +- update to version 1.7.6 + * Removed wrong response encoding (issue #70) + * Authorization header bug when using Python 3 (issue #71) +- additional changes from version 1.7.5 + * Removed pip dependency on setup (issue #69) +- additional changes from version 1.7.4 + * Fixed packaging (issue #66) +- additional changes from version 1.7.3 + * Finally fixed the keepalive issue in all Pyhon versions (issue #65) + * Removed old JSON layer in favor of the native json module +- additional changes from version 1.7.2 + * Moved to the new keepalive package (issues #53 and #61) +- additional changes from version 1.7.1 + * Fixed build in Python 3.x (issue #57) +- additional changes from version 1.7.0 + * Added support to HTTP Digest Auth Support (issue #45) + * Improved print_results showing language tag (xml:lang) and datatype + * Updated to RDFLib 4.x + +------------------------------------------------------------------- Old: ---- SPARQLWrapper-1.6.4.tar.gz New: ---- SPARQLWrapper-1.7.6.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-SPARQLWrapper.spec ++++++ --- /var/tmp/diff_new_pack.XsgUHP/_old 2016-09-17 14:37:36.000000000 +0200 +++ /var/tmp/diff_new_pack.XsgUHP/_new 2016-09-17 14:37:36.000000000 +0200 @@ -17,16 +17,19 @@ Name: python-SPARQLWrapper -Version: 1.6.4 +Version: 1.7.6 Release: 0 Summary: SPARQL Endpoint interface to Python License: W3C Group: Development/Languages/Python Url: http://sparql-wrapper.sourceforge.net/ -Source: https://pypi.python.org/packages/source/S/SPARQLWrapper/SPARQLWrapper-%{version}.tar.gz +Source: https://pypi.io/packages/source/S/SPARQLWrapper/SPARQLWrapper-%{version}.tar.gz BuildRequires: python-devel BuildRequires: python-setuptools -Requires: python-rdflib +Requires: python-rdflib >= 4.0 +# TODO(aplanas) python-keepalive is in the requirements.txt file, but +# the tests pass without this package. +# Requires: python-keepalive >= 0.5 BuildRoot: %{_tmppath}/%{name}-%{version}-build %if 0%{?suse_version} && 0%{?suse_version} <= 1110 BuildRequires: python-simplejson ++++++ SPARQLWrapper-1.6.4.tar.gz -> SPARQLWrapper-1.7.6.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SPARQLWrapper-1.6.4/AUTHORS.md new/SPARQLWrapper-1.7.6/AUTHORS.md --- old/SPARQLWrapper-1.6.4/AUTHORS.md 2014-08-26 13:44:16.000000000 +0200 +++ new/SPARQLWrapper-1.7.6/AUTHORS.md 2015-12-18 10:20:55.000000000 +0100 @@ -19,3 +19,8 @@ * Benjamin Cogrel ([@bcogrel](http://github.com/bcogrel)): standard query types * Urs Holzer ([@uholzer](http://github.com/uholzer)): features, patches and testing * Alf Lervåg ([@alf](http://github.com/alf)): setup patch +* Nolan Nichols ([@nicholsn](http://github.com/nicholsn)): http disgest auth support +* Kevin Turner ([@keturn](https://github.com/keturn)): `SmartWrapper.Value.__repr__()` implementation +* Marcelo Jorge Vieira ([@marcelometal](https://github.com/marcelometal)): typos +* Trevor Andersen ([@trevorandersen](https://github.com/trevorandersen): patches for Python 3.x + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SPARQLWrapper-1.6.4/MANIFEST.in new/SPARQLWrapper-1.7.6/MANIFEST.in --- old/SPARQLWrapper-1.6.4/MANIFEST.in 2014-08-26 11:07:11.000000000 +0200 +++ new/SPARQLWrapper-1.7.6/MANIFEST.in 2015-11-05 14:54:35.000000000 +0100 @@ -2,3 +2,4 @@ exclude Makefile include test/*.py include scripts/*.py +include requirements.txt diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SPARQLWrapper-1.6.4/PKG-INFO new/SPARQLWrapper-1.7.6/PKG-INFO --- old/SPARQLWrapper-1.6.4/PKG-INFO 2014-08-26 14:55:08.000000000 +0200 +++ new/SPARQLWrapper-1.7.6/PKG-INFO 2015-12-18 10:23:21.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: SPARQLWrapper -Version: 1.6.4 +Version: 1.7.6 Summary: SPARQL Endpoint interface to Python Home-page: http://rdflib.github.io/sparqlwrapper Author: Ivan Herman, Sergio Fernández, Carlos Tejo Alonso, Alexey Zakhlestin @@ -8,7 +8,7 @@ License: W3C SOFTWARE NOTICE AND LICENSE Download-URL: https://github.com/RDFLib/sparqlwrapper/releases Description: This is a wrapper around a SPARQL service. It helps in creating the query URI and, possibly, convert the result into a more manageable format. -Keywords: python SPARQL +Keywords: python sparql rdf rdflib Platform: any Classifier: Development Status :: 5 - Production/Stable Classifier: Intended Audience :: Developers @@ -16,4 +16,3 @@ Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 3 -Requires: rdflib diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SPARQLWrapper-1.6.4/README.md new/SPARQLWrapper-1.7.6/README.md --- old/SPARQLWrapper-1.6.4/README.md 2014-08-26 11:07:11.000000000 +0200 +++ new/SPARQLWrapper-1.7.6/README.md 2015-11-05 14:54:35.000000000 +0100 @@ -1,14 +1,15 @@ # SPARQL Endpoint interface to Python [![Build Status](https://secure.travis-ci.org/RDFLib/sparqlwrapper.svg?branch=master)](https://travis-ci.org/RDFLib/sparqlwrapper) +[![PyPi version](https://badge.fury.io/py/SPARQLWrapper.svg)](https://pypi.python.org/pypi/SPARQLWrapper) The distribution contains: -* `SPARQLWrapper`: the Python library. You should copy the directory somewhere into your PYTHONPATH. Alternatively, you can also run the disutils scrips: +* `SPARQLWrapper`: the Python library. You should copy the directory somewhere into your `PYTHONPATH`. Alternatively, you can also run the distutils scripts: python setup.py install -* `test`: some unit tests +* `test`: some unit and integrations tests -* `script`: some scripts to run the library against some SPARQL end-points. +* `script`: some scripts to run the library against some SPARQL endpoints. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SPARQLWrapper-1.6.4/SPARQLWrapper/SmartWrapper.py new/SPARQLWrapper-1.7.6/SPARQLWrapper/SmartWrapper.py --- old/SPARQLWrapper-1.6.4/SPARQLWrapper/SmartWrapper.py 2014-08-26 11:07:11.000000000 +0200 +++ new/SPARQLWrapper-1.7.6/SPARQLWrapper/SmartWrapper.py 2015-11-05 14:54:35.000000000 +0100 @@ -61,6 +61,10 @@ except : pass + def __repr__(self): + cls = self.__class__.__name__ + return "%s(%s:%r)" % (cls, self.type, self.value) + ###################################################################################### diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SPARQLWrapper-1.6.4/SPARQLWrapper/Wrapper.py new/SPARQLWrapper-1.7.6/SPARQLWrapper/Wrapper.py --- old/SPARQLWrapper-1.6.4/SPARQLWrapper/Wrapper.py 2014-08-26 11:07:11.000000000 +0200 +++ new/SPARQLWrapper-1.7.6/SPARQLWrapper/Wrapper.py 2015-12-18 10:18:26.000000000 +0100 @@ -32,7 +32,7 @@ import sys import warnings -import jsonlayer +import json from KeyCaseInsensitiveDict import KeyCaseInsensitiveDict from SPARQLExceptions import QueryBadFormed, EndPointNotFound, EndPointInternalError from SPARQLUtils import deprecated @@ -42,7 +42,7 @@ JSON = "json" JSONLD = "json-ld" XML = "xml" -TURTLE = "n3" +TURTLE = "turtle" N3 = "n3" RDF = "rdf" _allowedFormats = [JSON, XML, TURTLE, N3, RDF] @@ -52,6 +52,11 @@ GET = "GET" _allowedRequests = [POST, GET] +# Possible HTTP Authentication methods +BASIC = "BASIC" +DIGEST = "DIGEST" +_allowedAuth = [BASIC, DIGEST] + # Possible SPARQL/SPARUL query type SELECT = "SELECT" CONSTRUCT = "CONSTRUCT" @@ -155,6 +160,7 @@ self.agent = agent self.user = None self.passwd = None + self.http_auth = BASIC self._defaultGraph = defaultGraph if returnFormat in _allowedFormats: @@ -314,6 +320,20 @@ self.user = user self.passwd = passwd + def setHTTPAuth(self, auth): + """ + Set the HTTP Authentication type (Basic or Digest) + @param auth: auth type + @type auth: string + """ + if not isinstance(auth, str): + raise TypeError('setHTTPAuth takes a string') + elif auth.upper() in _allowedAuth: + self.http_auth = auth.upper() + else: + valid_types = ", ".join(_allowedAuth) + raise ValueError("Value should be one of {0}".format(valid_types)) + def setQuery(self, query): """ Set the SPARQL query text. Note: no check is done on the validity of the query @@ -377,15 +397,15 @@ def setUseKeepAlive(self): """Make urllib2 use keep-alive. - @raise ImportError: when could not be imported urlgrabber.keepalive.HTTPHandler + @raise ImportError: when could not be imported keepalive.HTTPHandler """ try: - from urlgrabber.keepalive import HTTPHandler + from keepalive import HTTPHandler keepalive_handler = HTTPHandler() opener = urllib2.build_opener(keepalive_handler) urllib2.install_opener(opener) except ImportError: - warnings.warn("urlgrabber not installed in the system. The execution of this method has no effect.") + warnings.warn("keepalive support not available, so the execution of this method has no effect") def isSparqlUpdateRequest(self): """ Returns TRUE if SPARQLWrapper is configured for executing SPARQL Update request @@ -485,8 +505,20 @@ request.add_header("User-Agent", self.agent) request.add_header("Accept", self._getAcceptHeader()) if self.user and self.passwd: - credentials = "%s:%s" % (self.user, self.passwd) - request.add_header("Authorization", "Basic %s" % base64.encodestring(credentials.encode('utf-8'))) + if self.http_auth == BASIC: + credentials = "%s:%s" % (self.user, self.passwd) + request.add_header("Authorization", "Basic %s" % base64.b64encode(credentials.encode('utf-8')).decode('utf-8')) + elif self.http_auth == DIGEST: + realm = "SPARQL" + pwd_mgr = urllib2.HTTPPasswordMgr() + pwd_mgr.add_password(realm, uri, self.user, self.passwd) + opener = urllib2.build_opener() + opener.add_handler(urllib2.HTTPDigestAuthHandler(pwd_mgr)) + urllib2.install_opener(opener) + else: + valid_types = ", ".join(_allowedAuth) + raise NotImplementedError("Expecting one of: {0}, but received: {1}".format(valid_types, + self.http_auth)) return request @@ -599,20 +631,6 @@ """Method for the standard iterator.""" return self.response.next() - @staticmethod - def setJSONModule(module): - """Set the Python module for encoding JSON data. If not an allowed value, the setting is ignored. - JSON modules supported: - - ``simplejson``: http://code.google.com/p/simplejson/ - - ``cjson``: http://pypi.python.org/pypi/python-cjson - - ``json``: This is the version of ``simplejson`` that is bundled with the - Python standard library since version 2.6 - (see http://docs.python.org/library/json.html) - @param module: Possible values: are L{simplejson}, L{cjson}, L{json}. All other cases raise a ValueError exception. - @type module: string - """ - jsonlayer.use(module) - def _convertJSON(self): """ Convert a JSON result into a Python dict. This method can be overwritten in a subclass @@ -620,7 +638,7 @@ @return: converted result @rtype: Python dictionary """ - return jsonlayer.decode(self.response.read().decode("utf-8")) + return json.loads(self.response.read().decode("utf-8")) def _convertXML(self): """ @@ -725,7 +743,8 @@ for result in results["results"]["bindings"] : index = 0 for var in results["head"]["vars"] : - print result[var]["value"].ljust(width[index]),"|", + result = self.__get_prettyprint_string_sparql_var_result(result[var]) + print result.ljust(width[index]),"|", index += 1 print @@ -736,6 +755,17 @@ for result in results["results"]["bindings"] : index = 0 for var in results["head"]["vars"] : - width[index] = max(width[index], len(result[var]["value"])) + result = self.__get_prettyprint_string_sparql_var_result(result[var]) + width[index] = max(width[index], len(result)) index =+ 1 return width + + def __get_prettyprint_string_sparql_var_result(self, result): + value = result["value"] + lang = result.get("xml:lang", None) + datatype = result.get("datatype",None) + if lang is not None: + value+="@"+lang + if datatype is not None: + value+=" ["+datatype+"]" + return value diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SPARQLWrapper-1.6.4/SPARQLWrapper/__init__.py new/SPARQLWrapper-1.7.6/SPARQLWrapper/__init__.py --- old/SPARQLWrapper-1.6.4/SPARQLWrapper/__init__.py 2014-08-26 14:53:58.000000000 +0200 +++ new/SPARQLWrapper-1.7.6/SPARQLWrapper/__init__.py 2015-12-18 10:22:39.000000000 +0100 @@ -163,7 +163,7 @@ @requires: U{RDFLib<http://rdflib.net>} package. """ -__version__ = "1.6.4" +__version__ = "1.7.6" """The version of SPARQLWrapper""" __authors__ = "Ivan Herman, Sergio Fernández, Carlos Tejo Alonso, Alexey Zakhlestin" @@ -178,7 +178,7 @@ __contact__ = "rdflib-...@googlegroups.com" """Mail list to contact to other people RDFLib and SPARQLWrappers folks and developers""" -__date__ = "2014-08-26" +__date__ = "2015-12-18" """Last update""" __agent__ = "sparqlwrapper %s (rdflib.github.io/sparqlwrapper)" % __version__ @@ -189,6 +189,6 @@ from Wrapper import GET, POST from Wrapper import SELECT, CONSTRUCT, ASK, DESCRIBE, INSERT, DELETE from Wrapper import URLENCODED, POSTDIRECTLY +from Wrapper import BASIC, DIGEST from SmartWrapper import SPARQLWrapper2 - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SPARQLWrapper-1.6.4/SPARQLWrapper/jsonlayer.py new/SPARQLWrapper-1.7.6/SPARQLWrapper/jsonlayer.py --- old/SPARQLWrapper-1.6.4/SPARQLWrapper/jsonlayer.py 2014-08-26 11:07:11.000000000 +0200 +++ new/SPARQLWrapper-1.7.6/SPARQLWrapper/jsonlayer.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,164 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright (C) 2009 Christopher Lenz -# All rights reserved. -# - -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: - -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. 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. -# 3. The name of the author may not be used to endorse or promote -# products derived from this software without specific prior -# written permission. - -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. - -"""Thin abstraction layer over the different available modules for decoding -and encoding JSON data. - -This module currently supports the following JSON modules: - - ``simplejson``: http://code.google.com/p/simplejson/ - - ``cjson``: http://pypi.python.org/pypi/python-cjson - - ``json``: This is the version of ``simplejson`` that is bundled with the - Python standard library since version 2.6 - (see http://docs.python.org/library/json.html) - -The default behavior is to use ``simplejson`` if installed, and otherwise -fallback to the standard library module. To explicitly tell SPARQLWrapper -which module to use, invoke the `use()` function with the module name:: - - import jsonlayer - jsonlayer.use('cjson') - -In addition to choosing one of the above modules, you can also configure -SPARQLWrapper to use custom decoding and encoding functions:: - - import jsonlayer - jsonlayer.use(decode=my_decode, encode=my_encode) - -""" - -__all__ = ['decode', 'encode', 'use'] - -_initialized = False -_using = None -_decode = None -_encode = None - - -def decode(string): - """Decode the given JSON string. - - :param string: the JSON string to decode - :type string: basestring - :return: the corresponding Python data structure - :rtype: object - """ - if not _initialized: - _initialize() - return _decode(string) - - -def encode(obj): - """Encode the given object as a JSON string. - - :param obj: the Python data structure to encode - :type obj: object - :return: the corresponding JSON string - :rtype: basestring - """ - if not _initialized: - _initialize() - return _encode(obj) - - -def use(module=None, decode=None, encode=None): - """Set the JSON library that should be used, either by specifying a known - module name, or by providing a decode and encode function. - - The modules "simplejson", "cjson", and "json" are currently supported for - the ``module`` parameter. - - If provided, the ``decode`` parameter must be a callable that accepts a - JSON string and returns a corresponding Python data structure. The - ``encode`` callable must accept a Python data structure and return the - corresponding JSON string. Exceptions raised by decoding and encoding - should be propagated up unaltered. - - :param module: the name of the JSON library module to use, or the module object itself - :type module: str or module - :param decode: a function for decoding JSON strings - :type decode: callable - :param encode: a function for encoding objects as JSON strings - :type encode: callable - """ - global _decode, _encode, _initialized, _using - if module is not None: - if not isinstance(module, basestring): - module = module.__name__ - if module not in ('cjson', 'json', 'simplejson'): - raise ValueError('Unsupported JSON module %s' % module) - _using = module - _initialized = False - else: - assert decode is not None and encode is not None - _using = 'custom' - _decode = decode - _encode = encode - _initialized = True - - -def _initialize(): - global _initialized - - def _init_simplejson(): - global _decode, _encode - import simplejson - _decode = lambda string, loads=simplejson.loads: loads(string) - _encode = lambda obj, dumps=simplejson.dumps: \ - dumps(obj, allow_nan=False, ensure_ascii=False) - - def _init_cjson(): - global _decode, _encode - import cjson - _decode = lambda string, decode=cjson.decode: decode(string) - _encode = lambda obj, encode=cjson.encode: encode(obj) - - def _init_stdlib(): - global _decode, _encode - json = __import__('json', {}, {}) - _decode = lambda string, loads=json.loads: loads(string) - _encode = lambda obj, dumps=json.dumps: \ - dumps(obj, allow_nan=False, ensure_ascii=False) - - if _using == 'simplejson': - _init_simplejson() - elif _using == 'cjson': - _init_cjson() - elif _using == 'json': - _init_stdlib() - elif _using != 'custom': - try: - _init_simplejson() - except ImportError: - _init_stdlib() - _initialized = True - - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SPARQLWrapper-1.6.4/SPARQLWrapper.egg-info/PKG-INFO new/SPARQLWrapper-1.7.6/SPARQLWrapper.egg-info/PKG-INFO --- old/SPARQLWrapper-1.6.4/SPARQLWrapper.egg-info/PKG-INFO 2014-08-26 14:54:57.000000000 +0200 +++ new/SPARQLWrapper-1.7.6/SPARQLWrapper.egg-info/PKG-INFO 2015-12-18 10:23:16.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: SPARQLWrapper -Version: 1.6.4 +Version: 1.7.6 Summary: SPARQL Endpoint interface to Python Home-page: http://rdflib.github.io/sparqlwrapper Author: Ivan Herman, Sergio Fernández, Carlos Tejo Alonso, Alexey Zakhlestin @@ -8,7 +8,7 @@ License: W3C SOFTWARE NOTICE AND LICENSE Download-URL: https://github.com/RDFLib/sparqlwrapper/releases Description: This is a wrapper around a SPARQL service. It helps in creating the query URI and, possibly, convert the result into a more manageable format. -Keywords: python SPARQL +Keywords: python sparql rdf rdflib Platform: any Classifier: Development Status :: 5 - Production/Stable Classifier: Intended Audience :: Developers @@ -16,4 +16,3 @@ Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 3 -Requires: rdflib diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SPARQLWrapper-1.6.4/SPARQLWrapper.egg-info/SOURCES.txt new/SPARQLWrapper-1.7.6/SPARQLWrapper.egg-info/SOURCES.txt --- old/SPARQLWrapper-1.6.4/SPARQLWrapper.egg-info/SOURCES.txt 2014-08-26 14:54:57.000000000 +0200 +++ new/SPARQLWrapper-1.7.6/SPARQLWrapper.egg-info/SOURCES.txt 2015-12-18 10:23:16.000000000 +0100 @@ -2,7 +2,7 @@ MANAGEMENT.md MANIFEST.in README.md -setup.cfg +requirements.txt setup.py SPARQLWrapper/KeyCaseInsensitiveDict.py SPARQLWrapper/SPARQLExceptions.py @@ -10,7 +10,6 @@ SPARQLWrapper/SmartWrapper.py SPARQLWrapper/Wrapper.py SPARQLWrapper/__init__.py -SPARQLWrapper/jsonlayer.py SPARQLWrapper.egg-info/PKG-INFO SPARQLWrapper.egg-info/SOURCES.txt SPARQLWrapper.egg-info/dependency_links.txt diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SPARQLWrapper-1.6.4/SPARQLWrapper.egg-info/requires.txt new/SPARQLWrapper-1.7.6/SPARQLWrapper.egg-info/requires.txt --- old/SPARQLWrapper-1.6.4/SPARQLWrapper.egg-info/requires.txt 2014-08-26 14:54:57.000000000 +0200 +++ new/SPARQLWrapper-1.7.6/SPARQLWrapper.egg-info/requires.txt 2015-12-18 10:23:16.000000000 +0100 @@ -1 +1,2 @@ -rdflib >= 2.4.2 \ No newline at end of file +rdflib>=4.0 +keepalive>=0.5 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SPARQLWrapper-1.6.4/requirements.txt new/SPARQLWrapper-1.7.6/requirements.txt --- old/SPARQLWrapper-1.6.4/requirements.txt 1970-01-01 01:00:00.000000000 +0100 +++ new/SPARQLWrapper-1.7.6/requirements.txt 2015-11-27 18:48:08.000000000 +0100 @@ -0,0 +1,2 @@ +rdflib>=4.0 +keepalive>=0.5 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SPARQLWrapper-1.6.4/setup.py new/SPARQLWrapper-1.7.6/setup.py --- old/SPARQLWrapper-1.6.4/setup.py 2014-08-26 13:43:26.000000000 +0200 +++ new/SPARQLWrapper-1.7.6/setup.py 2015-11-19 14:12:26.000000000 +0100 @@ -8,28 +8,15 @@ except: pass -from setuptools import setup, find_packages +from setuptools import setup try: import six py3 = six.PY3 except: - py3 = sys.version_info[0] >= 3 + py3 = sys.version_info[0] >= 3 -# grouping requires -_requires = [] -_install_requires = [] - -# rdflib -_requires.append('rdflib') -_install_requires.append('rdflib >= 2.4.2') - -# simplejson -if sys.version_info[0:2] < (2, 6): - _requires.append('simplejson') - _install_requires.append('simplejson == 2.0.9') - -# metainformation +# metadata if py3: import re _version_re = re.compile(r'__version__\s*=\s*"(.*)"') @@ -51,21 +38,25 @@ authors = SPARQLWrapper.__authors__ url = SPARQLWrapper.__url__ -# actual setup configuration + +# requirements +with open('requirements.txt', 'r') as f: + _install_requires = [line.rstrip('\n') for line in f] + + setup( name = 'SPARQLWrapper', version = version, description = 'SPARQL Endpoint interface to Python', long_description = 'This is a wrapper around a SPARQL service. It helps in creating the query URI and, possibly, convert the result into a more manageable format.', - license = 'W3C SOFTWARE NOTICE AND LICENSE', # should be removed by PEP 314 + license = 'W3C SOFTWARE NOTICE AND LICENSE', author = authors, author_email = "ivan at ivan-herman net, sergio at wikier org, carlos.tejo at gmail com, indeyets at gmail com", url = url, download_url = 'https://github.com/RDFLib/sparqlwrapper/releases', - platforms = ['any'], # should be removed by PEP 314 + platforms = ['any'], packages = ['SPARQLWrapper'], - requires = _requires, # used by distutils to create metadata PKG-INFO - install_requires = _install_requires, # used by setuptools to install the dependencies + install_requires = _install_requires, classifiers = [ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', @@ -74,8 +65,6 @@ 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 3', ], - keywords = 'python SPARQL', - use_2to3 = True, - #requires_python = '>=2.5', # Future in PEP 345 - #scripts = ['ez_setup.py'] + keywords = 'python sparql rdf rdflib', + use_2to3 = True ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SPARQLWrapper-1.6.4/test/dbpedia.py new/SPARQLWrapper-1.7.6/test/dbpedia.py --- old/SPARQLWrapper-1.6.4/test/dbpedia.py 2014-08-26 11:07:11.000000000 +0200 +++ new/SPARQLWrapper-1.7.6/test/dbpedia.py 2015-11-05 14:54:35.000000000 +0100 @@ -44,14 +44,14 @@ PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> """ -selectQuery = """ +selectQuery = """ SELECT ?label WHERE { <http://dbpedia.org/resource/Asturias> rdfs:label ?label . } """ -constructQuery = """ +constructQuery = """ CONSTRUCT { _:v rdfs:label ?label . _:v rdfs:comment "this is only a mock node to test library" @@ -238,6 +238,16 @@ # def testQueryManyPrefixes(self): # result = self.__generic(queryManyPrefixes, XML, GET) + def testKeepAlive(self): + sparql = SPARQLWrapper(endpoint) + sparql.setQuery('SELECT * WHERE {?s ?p ?o} LIMIT 10') + sparql.setReturnFormat(JSON) + sparql.setMethod(GET) + sparql.setUseKeepAlive() + + sparql.query() + sparql.query() + if __name__ == "__main__": unittest.main() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SPARQLWrapper-1.6.4/test/wrapper_test.py new/SPARQLWrapper-1.7.6/test/wrapper_test.py --- old/SPARQLWrapper-1.6.4/test/wrapper_test.py 2014-08-26 11:07:11.000000000 +0200 +++ new/SPARQLWrapper-1.7.6/test/wrapper_test.py 2015-12-18 10:18:26.000000000 +0100 @@ -7,6 +7,7 @@ logging.basicConfig() import unittest +import urllib2 from urlparse import urlparse from urllib2 import Request @@ -25,6 +26,7 @@ from SPARQLWrapper import SPARQLWrapper from SPARQLWrapper import XML, GET, POST, JSON, JSONLD, N3, TURTLE, RDF, SELECT, INSERT from SPARQLWrapper import URLENCODED, POSTDIRECTLY +from SPARQLWrapper import BASIC, DIGEST from SPARQLWrapper.Wrapper import QueryResult, QueryBadFormed, EndPointNotFound, EndPointInternalError @@ -63,13 +65,32 @@ raise TypeError # DONE +class TestCase(unittest.TestCase): + + def assertIsInstance(self, obj, cls, msg=None, *args, **kwargs): + """Python < v2.7 compatibility. Assert 'obj' is instance of 'cls'""" + try: + f = super(TestCase, self).assertIsInstance + except AttributeError: + self.assertTrue(isinstance(obj, cls), *args, **kwargs) + else: + f(obj, cls, *args, **kwargs) + + def assertIsNone(self, obj, msg=None, *args, **kwargs): + """Python < v2.7 compatibility. Assert 'obj' is None""" + try: + f = super(TestCase, self).assertIsNone + except AttributeError: + self.assertEqual(obj, None, *args, **kwargs) + else: + f(obj, *args, **kwargs) -class SPARQLWrapper_Test(unittest.TestCase): + +class SPARQLWrapper_Test(TestCase): @staticmethod def _get_request(wrapper): - request = wrapper.query().response.request # possible due to mock above - return request + return wrapper.query().response.request # possible due to mock above @staticmethod def _get_parameters_from_request(request): @@ -208,7 +229,30 @@ self.wrapper.setCredentials('login', 'password') request = self._get_request(self.wrapper) self.assertTrue(request.has_header('Authorization')) - # TODO: test for header-value using some external decoder implementation + + # expected header for login:password + # should succeed for python 3 since pull request #72 + self.assertEqual("Basic bG9naW46cGFzc3dvcmQ=", request.get_header('Authorization')) + + def testSetHTTPAuth(self): + self.assertRaises(TypeError, self.wrapper.setHTTPAuth, 123) + + self.wrapper.setCredentials('login', 'password') + request = self._get_request(self.wrapper) + self.assertTrue(request.has_header('Authorization')) + self.assertIsNone(urllib2._opener) + + self.wrapper.setHTTPAuth(DIGEST) + self.assertIsNone(urllib2._opener) + request = self._get_request(self.wrapper) + self.assertFalse(request.has_header('Authorization')) + self.assertEqual(self.wrapper.http_auth, DIGEST) + self.assertIsInstance(urllib2._opener, urllib2.OpenerDirector) + + self.assertRaises(ValueError, self.wrapper.setHTTPAuth, 'OAuth') + + self.wrapper.http_auth = "OAuth" + self.assertRaises(NotImplementedError, self._get_request, self.wrapper) def testSetQuery(self): self.wrapper.setQuery('PREFIX example: <http://example.org/INSERT/> SELECT * WHERE {?s ?p ?v}') @@ -447,6 +491,7 @@ class QueryResult_Test(unittest.TestCase): + def testConstructor(self): qr = QueryResult('result') self.assertEqual('result', qr.response) @@ -543,6 +588,6 @@ self.assertEqual(1, _mime_vs_type("application/rdf+xml", JSON)) self.assertEqual(1, _mime_vs_type("application/rdf+xml", N3)) + if __name__ == "__main__": unittest.main() -