Hello community,
here is the log from the commit of package python-requests-cache for
openSUSE:Leap:15.2 checked in at 2020-03-02 13:22:10
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Leap:15.2/python-requests-cache (Old)
and /work/SRC/openSUSE:Leap:15.2/.python-requests-cache.new.26092 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-requests-cache"
Mon Mar 2 13:22:10 2020 rev:11 rq:777089 version:0.5.2
Changes:
--------
---
/work/SRC/openSUSE:Leap:15.2/python-requests-cache/python-requests-cache.changes
2020-01-15 15:52:39.191570729 +0100
+++
/work/SRC/openSUSE:Leap:15.2/.python-requests-cache.new.26092/python-requests-cache.changes
2020-03-02 13:22:11.194258691 +0100
@@ -1,0 +2,22 @@
+Tue Sep 10 10:50:37 UTC 2019 - Tomáš Chvátal <[email protected]>
+
+- Update to 0.5.2:
+ * Fix DeprecationWarning from collections #140
+
+-------------------------------------------------------------------
+Tue May 7 12:27:11 UTC 2019 - [email protected]
+
+- version update to 0.5.0
+ * Add gridfs support, thanks to @chengguangnan
+ * Add dynamodb support, thanks to @ar90n
+ * Add response filter #104, thanks to @christopher-dG
+ * Fix bulk_commit #78
+ * Fix remove_expired_responses missed in __init__.py #93
+ * Fix deprecation warnings #122, thanks to mbarkhau
+
+-------------------------------------------------------------------
+Tue Dec 4 12:53:42 UTC 2018 - Matej Cepl <[email protected]>
+
+- Remove superfluous devel dependency for noarch package
+
+-------------------------------------------------------------------
Old:
----
requests-cache-0.4.13.tar.gz
New:
----
requests-cache-0.5.2.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-requests-cache.spec ++++++
--- /var/tmp/diff_new_pack.W5Tgtw/_old 2020-03-02 13:22:11.778259852 +0100
+++ /var/tmp/diff_new_pack.W5Tgtw/_new 2020-03-02 13:22:11.782259860 +0100
@@ -1,7 +1,7 @@
#
# spec file for package python-requests-cache
#
-# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -12,27 +12,25 @@
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
-# Please submit bugfixes or comments via http://bugs.opensuse.org/
+# Please submit bugfixes or comments via https://bugs.opensuse.org/
+#
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
-
Name: python-requests-cache
-Version: 0.4.13
+Version: 0.5.2
Release: 0
-License: BSD-2-Clause
Summary: Persistent cache for requests library
-Url: https://github.com/reclosedev/requests-cache
+License: BSD-2-Clause
Group: Development/Languages/Python
+URL: https://github.com/reclosedev/requests-cache
Source:
https://files.pythonhosted.org/packages/source/r/requests-cache/requests-cache-%{version}.tar.gz
-BuildRequires: %{python_module devel}
-BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module requests >= 1.1.0}
+BuildRequires: %{python_module setuptools}
+BuildRequires: fdupes
BuildRequires: python-rpm-macros
Requires: python-requests >= 1.1.0
-BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildArch: noarch
-
%python_subpackages
%description
@@ -53,17 +51,18 @@
%setup -q -n requests-cache-%{version}
%build
-%{python_build}
+%python_build
%install
-%{python_install}
+%python_install
+%python_expand %fdupes %{buildroot}%{$python_sitelib}
%check
%python_exec setup.py test
%files %{python_files}
-%defattr(-,root,root,-)
-%doc README.rst LICENSE
+%license LICENSE
+%doc README.rst
%{python_sitelib}/*
%changelog
++++++ requests-cache-0.4.13.tar.gz -> requests-cache-0.5.2.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/requests-cache-0.4.13/HISTORY.rst
new/requests-cache-0.5.2/HISTORY.rst
--- old/requests-cache-0.4.13/HISTORY.rst 2016-12-23 10:35:51.000000000
+0100
+++ new/requests-cache-0.5.2/HISTORY.rst 2019-08-14 15:57:48.000000000
+0200
@@ -2,6 +2,32 @@
History
-------
+0.5.2 (2019-08-14)
+++++++++++++++++++
+
+* Fix DeprecationWarning from collections #140
+
+
+0.5.1 (2019-08-13)
+++++++++++++++++++
+
+* Remove Python 2.6 Testing from travis #133
+* Fix DeprecationWarning from collections #131
+* vacuum the sqlite database after clearing a table #134
+* Fix handling of unpickle errors #128
+
+
+0.5.0 (2019-04-18)
+++++++++++++++++++
+Project is now added to https://www.codeshelter.co/
+
+* Add gridfs support, thanks to @chengguangnan
+* Add dynamodb support, thanks to @ar90n
+* Add response filter #104, thanks to @christopher-dG
+* Fix bulk_commit #78
+* Fix remove_expired_responses missed in __init__.py #93
+* Fix deprecation warnings #122, thanks to mbarkhau
+
0.4.13 (2016-12-23)
+++++++++++++++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/requests-cache-0.4.13/PKG-INFO
new/requests-cache-0.5.2/PKG-INFO
--- old/requests-cache-0.4.13/PKG-INFO 2016-12-23 10:36:39.000000000 +0100
+++ new/requests-cache-0.5.2/PKG-INFO 2019-08-14 15:58:37.000000000 +0200
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: requests-cache
-Version: 0.4.13
+Version: 0.5.2
Summary: Persistent cache for requests library
Home-page: https://github.com/reclosedev/requests-cache
Author: Roman Haritonov
@@ -19,6 +19,10 @@
.. image::
https://coveralls.io/repos/reclosedev/requests-cache/badge.svg?branch=master&service=github
:target:
https://coveralls.io/github/reclosedev/requests-cache?branch=master
+ .. image:: https://www.codeshelter.co/static/badges/badge-flat.svg
+ :target: https://www.codeshelter.co/
+ :alt: Code Shelter
+
Usage example
-------------
@@ -69,6 +73,32 @@
History
-------
+ 0.5.2 (2019-08-14)
+ ++++++++++++++++++
+
+ * Fix DeprecationWarning from collections #140
+
+
+ 0.5.1 (2019-08-13)
+ ++++++++++++++++++
+
+ * Remove Python 2.6 Testing from travis #133
+ * Fix DeprecationWarning from collections #131
+ * vacuum the sqlite database after clearing a table #134
+ * Fix handling of unpickle errors #128
+
+
+ 0.5.0 (2019-04-18)
+ ++++++++++++++++++
+ Project is now added to https://www.codeshelter.co/
+
+ * Add gridfs support, thanks to @chengguangnan
+ * Add dynamodb support, thanks to @ar90n
+ * Add response filter #104, thanks to @christopher-dG
+ * Fix bulk_commit #78
+ * Fix remove_expired_responses missed in __init__.py #93
+ * Fix deprecation warnings #122, thanks to mbarkhau
+
0.4.13 (2016-12-23)
+++++++++++++++++++
@@ -215,6 +245,5 @@
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Programming Language :: Python
-Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/requests-cache-0.4.13/README.rst
new/requests-cache-0.5.2/README.rst
--- old/requests-cache-0.4.13/README.rst 2016-12-23 10:28:59.000000000
+0100
+++ new/requests-cache-0.5.2/README.rst 2019-06-25 15:30:48.000000000 +0200
@@ -11,6 +11,10 @@
.. image::
https://coveralls.io/repos/reclosedev/requests-cache/badge.svg?branch=master&service=github
:target:
https://coveralls.io/github/reclosedev/requests-cache?branch=master
+.. image:: https://www.codeshelter.co/static/badges/badge-flat.svg
+ :target: https://www.codeshelter.co/
+ :alt: Code Shelter
+
Usage example
-------------
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/requests-cache-0.4.13/docs/user_guide.rst
new/requests-cache-0.5.2/docs/user_guide.rst
--- old/requests-cache-0.4.13/docs/user_guide.rst 2016-12-23
10:28:59.000000000 +0100
+++ new/requests-cache-0.5.2/docs/user_guide.rst 2019-04-13
10:14:31.000000000 +0200
@@ -152,7 +152,7 @@
expire_after = timedelta(hours=1)
requests_cache.install_cache(expire_after=expire_after)
...
- requests_cache.remove_expired_responses()
+ requests_cache.core.remove_expired_responses()
# or
remove_old_entries.get_cache().remove_old_entries(datetime.utcnow() -
expire_after)
# when used as session
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/requests-cache-0.4.13/requests_cache/__init__.py
new/requests-cache-0.5.2/requests_cache/__init__.py
--- old/requests-cache-0.4.13/requests_cache/__init__.py 2016-12-23
10:35:51.000000000 +0100
+++ new/requests-cache-0.5.2/requests_cache/__init__.py 2019-08-14
15:56:56.000000000 +0200
@@ -23,9 +23,9 @@
:license: BSD, see LICENSE for more details.
"""
__docformat__ = 'restructuredtext'
-__version__ = '0.4.13'
+__version__ = '0.5.2'
-from .core import(
+from .core import (
CachedSession, install_cache, uninstall_cache,
- disabled, enabled, get_cache, clear, configure
+ disabled, enabled, get_cache, clear, configure, remove_expired_responses
)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/requests-cache-0.4.13/requests_cache/backends/__init__.py
new/requests-cache-0.5.2/requests_cache/backends/__init__.py
--- old/requests-cache-0.4.13/requests_cache/backends/__init__.py
2016-12-23 10:28:59.000000000 +0100
+++ new/requests-cache-0.5.2/requests_cache/backends/__init__.py
2019-04-13 10:14:31.000000000 +0200
@@ -17,7 +17,8 @@
_backend_dependencies = {
'sqlite': 'sqlite3',
'mongo': 'pymongo',
- 'redis': 'redis'
+ 'redis': 'redis',
+ 'dynamodb': 'dynamodb'
}
try:
@@ -33,12 +34,24 @@
except ImportError:
MongoCache = None
+
+try:
+ from .gridfs import GridFSCache
+ registry['gridfs'] = GridFSCache
+except ImportError:
+ GridFSCache = None
+
try:
from .redis import RedisCache
registry['redis'] = RedisCache
except ImportError:
RedisCache = None
+try:
+ from .dynamodb import DynamoDbCache
+ registry['dynamodb'] = DynamoDbCache
+except ImportError:
+ DynamoDbCache = None
def create_backend(backend_name, cache_name, options):
if isinstance(backend_name, BaseCache):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/requests-cache-0.4.13/requests_cache/backends/dynamodb.py
new/requests-cache-0.5.2/requests_cache/backends/dynamodb.py
--- old/requests-cache-0.4.13/requests_cache/backends/dynamodb.py
1970-01-01 01:00:00.000000000 +0100
+++ new/requests-cache-0.5.2/requests_cache/backends/dynamodb.py
2019-04-13 10:14:31.000000000 +0200
@@ -0,0 +1,30 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+"""
+ requests_cache.backends.dynamodb
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ ``dynamodb`` cache backend
+"""
+from .base import BaseCache
+from .storage.dynamodbdict import DynamoDbDict
+
+
+class DynamoDbCache(BaseCache):
+ """ ``dynamodb`` cache backend.
+ """
+ def __init__(self, table_name='requests-cache', **options):
+ """
+ :param namespace: dynamodb table name (default: ``'requests-cache'``)
+ :param connection: (optional) ``boto3.resource('dynamodb')``
+ """
+ super(DynamoDbCache, self).__init__(**options)
+ self.responses = DynamoDbDict(table_name, 'responses',
+ options.get('connection'),
+ options.get('endpont_url'),
+ options.get('region_name'),
+ options.get('read_capacity_units'),
+ options.get('write_capacity_units'))
+ self.keys_map = DynamoDbDict(table_name,
+ 'urls',
+ self.responses.connection)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/requests-cache-0.4.13/requests_cache/backends/gridfs.py
new/requests-cache-0.5.2/requests_cache/backends/gridfs.py
--- old/requests-cache-0.4.13/requests_cache/backends/gridfs.py 1970-01-01
01:00:00.000000000 +0100
+++ new/requests-cache-0.5.2/requests_cache/backends/gridfs.py 2019-04-13
10:14:31.000000000 +0200
@@ -0,0 +1,34 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+"""
+ requests_cache.backends.gridfs
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ ``gridfs`` cache backend
+
+ Use MongoDB GridFS to support documents greater than 16MB.
+
+ Usage:
+ requests_cache.install_cache(backend='gridfs')
+
+ Or:
+ from pymongo import MongoClient
+ requests_cache.install_cache(backend='gridfs',
connection=MongoClient('another-host.local'))
+"""
+from .base import BaseCache
+from .storage.mongodict import MongoDict
+from .storage.gridfspickledict import GridFSPickleDict
+
+
+class GridFSCache(BaseCache):
+ """ ``gridfs`` cache backend.
+ """
+ def __init__(self, db_name, **options):
+ """
+ :param db_name: database name
+ :param connection: (optional) ``pymongo.Connection``
+ """
+ super(GridFSCache, self).__init__(**options)
+ self.responses = GridFSPickleDict(db_name, options.get('connection'))
+ self.keys_map = MongoDict(db_name, 'http_redirects',
self.responses.connection)
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/requests-cache-0.4.13/requests_cache/backends/storage/dbdict.py
new/requests-cache-0.5.2/requests_cache/backends/storage/dbdict.py
--- old/requests-cache-0.4.13/requests_cache/backends/storage/dbdict.py
2016-12-23 10:28:59.000000000 +0100
+++ new/requests-cache-0.5.2/requests_cache/backends/storage/dbdict.py
2019-06-25 15:31:01.000000000 +0200
@@ -6,7 +6,11 @@
Dictionary-like objects for saving large data sets to `sqlite` database
"""
-from collections import MutableMapping
+try:
+ from collections.abc import MutableMapping
+except ImportError:
+ from collections import MutableMapping
+
import sqlite3 as sqlite
from contextlib import contextmanager
try:
@@ -48,7 +52,7 @@
self.table_name = table_name
self.fast_save = fast_save
- #: Transactions can be commited if this property is set to `True`
+ #: Transactions can be committed if this property is set to `True`
self.can_commit = True
@@ -108,8 +112,9 @@
finally:
self._bulk_commit = False
self.can_commit = True
- self._pending_connection.close()
- self._pending_connection = None
+ if self._pending_connection is not None:
+ self._pending_connection.close()
+ self._pending_connection = None
def __getitem__(self, key):
with self.connection() as con:
@@ -147,6 +152,7 @@
con.execute("drop table `%s`" % self.table_name)
con.execute("create table `%s` (key PRIMARY KEY, value)" %
self.table_name)
+ con.execute("vacuum")
def __str__(self):
return str(dict(self.items()))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/requests-cache-0.4.13/requests_cache/backends/storage/dynamodbdict.py
new/requests-cache-0.5.2/requests_cache/backends/storage/dynamodbdict.py
--- old/requests-cache-0.4.13/requests_cache/backends/storage/dynamodbdict.py
1970-01-01 01:00:00.000000000 +0100
+++ new/requests-cache-0.5.2/requests_cache/backends/storage/dynamodbdict.py
2019-08-14 15:56:14.000000000 +0200
@@ -0,0 +1,140 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+"""
+ requests_cache.backends.dynamodbdict
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ Dictionary-like objects for saving large data sets to ``dynamodb``
key-store
+"""
+try:
+ from collections.abc import MutableMapping
+except ImportError:
+ from collections import MutableMapping
+try:
+ import cPickle as pickle
+except ImportError:
+ import pickle
+import boto3
+from boto3.dynamodb.conditions import Key, Attr
+from botocore.exceptions import ClientError
+
+
+class DynamoDbDict(MutableMapping):
+ """ DynamoDbDict - a dictionary-like interface for ``dynamodb`` key-stores
+ """
+
+ def __init__(self, table_name, namespace='dynamodb_dict_data',
+ connection=None,
+ endpoint_url=None,
+ region_name='us-east-1',
+ read_capacity_units=1,
+ write_capacity_units=1):
+
+ """
+ The actual key name on the dynamodb server will be
+ ``namespace``:``namespace_name``
+
+ In order to deal with how dynamodb stores data/keys,
+ everything, i.e. keys and data, must be pickled.
+
+ :param table_name: table name to use
+ :param namespace_name: name of the hash map stored in dynamodb
+ (default: dynamodb_dict_data)
+ :param connection: ``boto3.resource('dynamodb')`` instance.
+ If it's ``None`` (default), a new connection with
+ default options will be created
+ :param endpoint_url: url of dynamodb server.
+
+ """
+ self._self_key = namespace
+ if connection is not None:
+ self.connection = connection
+ else:
+ self.connection = boto3.resource('dynamodb',
+ endpoint_url=endpoint_url,
+ region_name=region_name)
+ try:
+ self.connection.create_table(
+ AttributeDefinitions=[
+ {
+ 'AttributeName': 'namespace',
+ 'AttributeType': 'S',
+ },
+ {
+ 'AttributeName': 'key',
+ 'AttributeType': 'S',
+ }
+ ],
+ TableName=table_name,
+ KeySchema=[
+ {
+ 'AttributeName': 'namespace',
+ 'KeyType': 'HASH'
+ },
+ {
+ 'AttributeName': 'key',
+ 'KeyType': 'RANGE'
+ }
+ ],
+ ProvisionedThroughput={
+ 'ReadCapacityUnits': read_capacity_units,
+ 'WriteCapacityUnits': write_capacity_units
+ }
+ )
+ except ClientError:
+ pass
+ self._table = self.connection.Table(table_name)
+ self._table.wait_until_exists()
+
+ def __getitem__(self, key):
+ composite_key = {'namespace': self._self_key, 'key': str(key)}
+ result = self._table.get_item(Key=composite_key)
+ if not 'Item' in result:
+ raise KeyError
+ return pickle.loads(result['Item']['value'].value)
+
+ def __setitem__(self, key, item):
+ item = {'namespace': self._self_key,
+ 'key': str(key),
+ 'value': pickle.dumps(item)}
+ self._table.put_item(Item=item)
+
+ def __delitem__(self, key):
+ composite_key = {'namespace': self._self_key, 'key': str(key)}
+ response = self._table.delete_item(Key=composite_key,
+ ReturnValues='ALL_OLD')
+ if not 'Attributes' in response:
+ raise KeyError
+
+ def __len__(self):
+ return self.__count_table()
+
+ def __iter__(self):
+ response = self.__scan_table()
+ for v in response['Items']:
+ yield pickle.loads(v['value'].value)
+
+ def clear(self):
+ response = self.__scan_table()
+ for v in response['Items']:
+ composite_key = {'namespace': v['namespace'], 'key': v['key']}
+ self._table.delete_item(Key=composite_key)
+
+ def __str__(self):
+ return str(dict(self.items()))
+
+ def __scan_table(self):
+ expression_attribute_values = {':Namespace': self._self_key}
+ expression_attribute_names = {'#N': 'namespace'}
+ key_condition_expression = '#N = :Namespace'
+ return
self._table.query(ExpressionAttributeValues=expression_attribute_values,
+
ExpressionAttributeNames=expression_attribute_names,
+
KeyConditionExpression=key_condition_expression)
+ def __count_table(self):
+ expression_attribute_values = {':Namespace': self._self_key}
+ expression_attribute_names = {'#N': 'namespace'}
+ key_condition_expression = '#N = :Namespace'
+ return self._table.query(Select='COUNT',
+
ExpressionAttributeValues=expression_attribute_values,
+
ExpressionAttributeNames=expression_attribute_names,
+
KeyConditionExpression=key_condition_expression)['Count']
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/requests-cache-0.4.13/requests_cache/backends/storage/gridfspickledict.py
new/requests-cache-0.5.2/requests_cache/backends/storage/gridfspickledict.py
---
old/requests-cache-0.4.13/requests_cache/backends/storage/gridfspickledict.py
1970-01-01 01:00:00.000000000 +0100
+++
new/requests-cache-0.5.2/requests_cache/backends/storage/gridfspickledict.py
2019-08-14 15:56:14.000000000 +0200
@@ -0,0 +1,73 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+"""
+ requests_cache.backends.mongodict
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ Dictionary-like objects for saving large data sets to ``mongodb`` database
+"""
+
+try:
+ from collections.abc import MutableMapping
+except ImportError:
+ from collections import MutableMapping
+try:
+ import cPickle as pickle
+except ImportError:
+ import pickle
+
+# Use PyMongo 3 if present
+try:
+ from pymongo import MongoClient
+except ImportError:
+ from pymongo import Connection as MongoClient
+
+from gridfs import GridFS
+
+class GridFSPickleDict(MutableMapping):
+ """ MongoDict - a dictionary-like interface for ``mongo`` database
+ """
+ def __init__(self, db_name, connection=None):
+ """
+ :param db_name: database name (be careful with production databases)
+ :param connection: ``pymongo.Connection`` instance. If it's ``None``
+ (default) new connection with default options will
+ be created
+ """
+ if connection is not None:
+ self.connection = connection
+ else:
+ self.connection = MongoClient()
+
+ self.db = self.connection[db_name]
+ self.fs = GridFS(self.db)
+
+ def __getitem__(self, key):
+ result = self.fs.find_one({'_id': key})
+ if result is None:
+ raise KeyError
+ return pickle.loads(bytes(result.read()))
+
+ def __setitem__(self, key, item):
+ self.__delitem__(key)
+ self.fs.put(pickle.dumps(item), **{'_id': key})
+
+ def __delitem__(self, key):
+ res = self.fs.find_one({'_id': key})
+ if res is not None:
+ self.fs.delete(res._id)
+
+ def __len__(self):
+ return self.db['fs.files'].count()
+
+ def __iter__(self):
+ for d in self.fs.find():
+ yield d._id
+
+ def clear(self):
+ self.db['fs.files'].drop()
+ self.db['fs.chunks'].drop()
+
+ def __str__(self):
+ return str(dict(self.items()))
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/requests-cache-0.4.13/requests_cache/backends/storage/mongodict.py
new/requests-cache-0.5.2/requests_cache/backends/storage/mongodict.py
--- old/requests-cache-0.4.13/requests_cache/backends/storage/mongodict.py
2016-12-23 10:28:59.000000000 +0100
+++ new/requests-cache-0.5.2/requests_cache/backends/storage/mongodict.py
2019-06-25 15:31:01.000000000 +0200
@@ -7,7 +7,11 @@
Dictionary-like objects for saving large data sets to ``mongodb`` database
"""
-from collections import MutableMapping
+try:
+ from collections.abc import MutableMapping
+except ImportError:
+ from collections import MutableMapping
+
try:
import cPickle as pickle
except ImportError:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/requests-cache-0.4.13/requests_cache/backends/storage/redisdict.py
new/requests-cache-0.5.2/requests_cache/backends/storage/redisdict.py
--- old/requests-cache-0.4.13/requests_cache/backends/storage/redisdict.py
2016-12-23 10:28:59.000000000 +0100
+++ new/requests-cache-0.5.2/requests_cache/backends/storage/redisdict.py
2019-08-14 15:56:14.000000000 +0200
@@ -6,7 +6,10 @@
Dictionary-like objects for saving large data sets to ``redis`` key-store
"""
-from collections import MutableMapping
+try:
+ from collections.abc import MutableMapping
+except ImportError:
+ from collections import MutableMapping
try:
import cPickle as pickle
except ImportError:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/requests-cache-0.4.13/requests_cache/compat.py
new/requests-cache-0.5.2/requests_cache/compat.py
--- old/requests-cache-0.4.13/requests_cache/compat.py 2016-12-23
10:28:59.000000000 +0100
+++ new/requests-cache-0.5.2/requests_cache/compat.py 2019-06-25
15:43:06.000000000 +0200
@@ -3,8 +3,6 @@
"""
pythoncompat
"""
-
-
import sys
# -------
@@ -89,7 +87,6 @@
basestring = basestring
-
elif is_py3:
from urllib.parse import urlparse, urlunparse, urljoin, urlsplit,
urlencode, quote, unquote, parse_qsl
from urllib.request import parse_http_list
@@ -100,4 +97,3 @@
str = str
bytes = bytes
basestring = (str,bytes)
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/requests-cache-0.4.13/requests_cache/core.py
new/requests-cache-0.5.2/requests_cache/core.py
--- old/requests-cache-0.4.13/requests_cache/core.py 2016-12-23
10:28:59.000000000 +0100
+++ new/requests-cache-0.5.2/requests_cache/core.py 2019-06-25
15:44:58.000000000 +0200
@@ -34,13 +34,14 @@
def __init__(self, cache_name='cache', backend=None, expire_after=None,
allowable_codes=(200,), allowable_methods=('GET',),
- old_data_on_error=False, **backend_options):
+ filter_fn=lambda r: True, old_data_on_error=False,
+ **backend_options):
"""
:param cache_name: for ``sqlite`` backend: cache file will start with
this prefix,
e.g ``cache.sqlite``
for ``mongodb``: it's used as database name
-
+
for ``redis``: it's used as the namespace. This
means all keys
are prefixed with ``'cache_name:'``
:param backend: cache backend name e.g ``'sqlite'``, ``'mongodb'``,
``'redis'``, ``'memory'``.
@@ -54,8 +55,12 @@
:type allowable_codes: tuple
:param allowable_methods: cache only requests of this methods
(default: 'GET')
:type allowable_methods: tuple
+ :param filter_fn: function to apply to each response; the response is
only cached if
+ this returns `True`. Note that this function does
not not modify
+ the cached response in any way.
+ :type filter_fn: function
:kwarg backend_options: options for chosen backend. See corresponding
- :ref:`sqlite <backends_sqlite>`, :ref:`mongo
<backends_mongo>`
+ :ref:`sqlite <backends_sqlite>`, :ref:`mongo
<backends_mongo>`
and :ref:`redis <backends_redis>` backends API
documentation
:param include_get_headers: If `True` headers will be part of cache
key.
E.g. after get('some_link',
headers={'Accept':'application/json'})
@@ -74,6 +79,7 @@
self._cache_allowable_codes = allowable_codes
self._cache_allowable_methods = allowable_methods
+ self._filter_fn = filter_fn
self._return_old_data_on_error = old_data_on_error
self._is_cache_disabled = False
super(CachedSession, self).__init__()
@@ -94,7 +100,11 @@
response.from_cache = False
return response
- response, timestamp = self.cache.get_response_and_time(cache_key)
+ try:
+ response, timestamp = self.cache.get_response_and_time(cache_key)
+ except (ImportError, TypeError):
+ return send_request_and_cache_response()
+
if response is None:
return send_request_and_cache_response()
@@ -129,6 +139,14 @@
return response
main_key = self.cache.create_key(response.request)
+
+ # If self._return_old_data_on_error is set,
+ # responses won't always have the from_cache attribute.
+ if (hasattr(response, "from_cache") and not response.from_cache
+ and self._filter_fn(response) is not True):
+ self.cache.delete(main_key)
+ return response
+
for r in response.history:
self.cache.add_key_mapping(
self.cache.create_key(r.request), main_key
@@ -170,7 +188,8 @@
def install_cache(cache_name='cache', backend=None, expire_after=None,
allowable_codes=(200,), allowable_methods=('GET',),
- session_factory=CachedSession, **backend_options):
+ filter_fn=lambda r: True, session_factory=CachedSession,
+ **backend_options):
"""
Installs cache for all ``Requests`` requests by monkey-patching ``Session``
@@ -189,6 +208,7 @@
expire_after=expire_after,
allowable_codes=allowable_codes,
allowable_methods=allowable_methods,
+ filter_fn=filter_fn,
**backend_options
)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/requests-cache-0.4.13/requests_cache.egg-info/PKG-INFO
new/requests-cache-0.5.2/requests_cache.egg-info/PKG-INFO
--- old/requests-cache-0.4.13/requests_cache.egg-info/PKG-INFO 2016-12-23
10:36:39.000000000 +0100
+++ new/requests-cache-0.5.2/requests_cache.egg-info/PKG-INFO 2019-08-14
15:58:37.000000000 +0200
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: requests-cache
-Version: 0.4.13
+Version: 0.5.2
Summary: Persistent cache for requests library
Home-page: https://github.com/reclosedev/requests-cache
Author: Roman Haritonov
@@ -19,6 +19,10 @@
.. image::
https://coveralls.io/repos/reclosedev/requests-cache/badge.svg?branch=master&service=github
:target:
https://coveralls.io/github/reclosedev/requests-cache?branch=master
+ .. image:: https://www.codeshelter.co/static/badges/badge-flat.svg
+ :target: https://www.codeshelter.co/
+ :alt: Code Shelter
+
Usage example
-------------
@@ -69,6 +73,32 @@
History
-------
+ 0.5.2 (2019-08-14)
+ ++++++++++++++++++
+
+ * Fix DeprecationWarning from collections #140
+
+
+ 0.5.1 (2019-08-13)
+ ++++++++++++++++++
+
+ * Remove Python 2.6 Testing from travis #133
+ * Fix DeprecationWarning from collections #131
+ * vacuum the sqlite database after clearing a table #134
+ * Fix handling of unpickle errors #128
+
+
+ 0.5.0 (2019-04-18)
+ ++++++++++++++++++
+ Project is now added to https://www.codeshelter.co/
+
+ * Add gridfs support, thanks to @chengguangnan
+ * Add dynamodb support, thanks to @ar90n
+ * Add response filter #104, thanks to @christopher-dG
+ * Fix bulk_commit #78
+ * Fix remove_expired_responses missed in __init__.py #93
+ * Fix deprecation warnings #122, thanks to mbarkhau
+
0.4.13 (2016-12-23)
+++++++++++++++++++
@@ -215,6 +245,5 @@
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Programming Language :: Python
-Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/requests-cache-0.4.13/requests_cache.egg-info/SOURCES.txt
new/requests-cache-0.5.2/requests_cache.egg-info/SOURCES.txt
--- old/requests-cache-0.4.13/requests_cache.egg-info/SOURCES.txt
2016-12-23 10:36:39.000000000 +0100
+++ new/requests-cache-0.5.2/requests_cache.egg-info/SOURCES.txt
2019-08-14 15:58:37.000000000 +0200
@@ -25,17 +25,23 @@
requests_cache.egg-info/top_level.txt
requests_cache/backends/__init__.py
requests_cache/backends/base.py
+requests_cache/backends/dynamodb.py
+requests_cache/backends/gridfs.py
requests_cache/backends/mongo.py
requests_cache/backends/redis.py
requests_cache/backends/sqlite.py
requests_cache/backends/storage/__init__.py
requests_cache/backends/storage/dbdict.py
+requests_cache/backends/storage/dynamodbdict.py
+requests_cache/backends/storage/gridfspickledict.py
requests_cache/backends/storage/mongodict.py
requests_cache/backends/storage/redisdict.py
tests/__init__.py
tests/test_cache.py
tests/test_custom_dict.py
tests/test_dbdict.py
+tests/test_dynamodbdict.py
+tests/test_gridfsdict.py
tests/test_mongodict.py
tests/test_monkey_patch.py
tests/test_redisdict.py
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/requests-cache-0.4.13/requests_cache.egg-info/requires.txt
new/requests-cache-0.5.2/requests_cache.egg-info/requires.txt
--- old/requests-cache-0.4.13/requests_cache.egg-info/requires.txt
2016-12-23 10:36:39.000000000 +0100
+++ new/requests-cache-0.5.2/requests_cache.egg-info/requires.txt
2019-08-14 15:58:37.000000000 +0200
@@ -1 +1 @@
-requests>=1.1.0
\ No newline at end of file
+requests>=1.1.0
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/requests-cache-0.4.13/setup.cfg
new/requests-cache-0.5.2/setup.cfg
--- old/requests-cache-0.4.13/setup.cfg 2016-12-23 10:36:39.000000000 +0100
+++ new/requests-cache-0.5.2/setup.cfg 2019-08-14 15:58:37.000000000 +0200
@@ -4,5 +4,4 @@
[egg_info]
tag_build =
tag_date = 0
-tag_svn_revision = 0
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/requests-cache-0.4.13/setup.py
new/requests-cache-0.5.2/setup.py
--- old/requests-cache-0.4.13/setup.py 2016-12-23 10:35:51.000000000 +0100
+++ new/requests-cache-0.5.2/setup.py 2019-08-14 15:56:56.000000000 +0200
@@ -20,7 +20,7 @@
packages=['requests_cache',
'requests_cache.backends',
'requests_cache.backends.storage'],
- version='0.4.13',
+ version='0.5.2',
description='Persistent cache for requests library',
author='Roman Haritonov',
author_email='[email protected]',
@@ -35,7 +35,6 @@
'Intended Audience :: Developers',
'Topic :: Software Development :: Libraries :: Python Modules',
'Programming Language :: Python',
- 'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
],
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/requests-cache-0.4.13/tests/test_cache.py
new/requests-cache-0.5.2/tests/test_cache.py
--- old/requests-cache-0.4.13/tests/test_cache.py 2016-12-23
10:28:59.000000000 +0100
+++ new/requests-cache-0.5.2/tests/test_cache.py 2019-06-25
15:43:16.000000000 +0200
@@ -230,6 +230,7 @@
r = self.s.get(httpbin('get'), params=p)
self.assert_(self.s.cache.has_url( httpbin('get?arg1=value1')))
+ @unittest.skipIf(sys.version_info < (2, 7), "No https in 2.6")
def test_https_support(self):
n = 10
delay = 1
@@ -466,6 +467,17 @@
self.assertEqual(len(s.cache.keys_map), 0)
self.assertIn(ok_url, list(s.cache.responses.values())[0][0].url)
+ def test_cache_unpickle_errors(self):
+ url = httpbin('get?q=1')
+ self.assertFalse(self.s.get(url).from_cache)
+ with
mock.patch("requests_cache.backends.base.BaseCache.restore_response",
side_effect=TypeError):
+ resp = self.s.get(url)
+ self.assertFalse(resp.from_cache)
+ self.assertEquals(resp.json()["args"]["q"], "1")
+ resp = self.s.get(url)
+ self.assertTrue(resp.from_cache)
+ self.assertEquals(resp.json()["args"]["q"], "1")
+
if __name__ == '__main__':
unittest.main()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/requests-cache-0.4.13/tests/test_dbdict.py
new/requests-cache-0.5.2/tests/test_dbdict.py
--- old/requests-cache-0.4.13/tests/test_dbdict.py 2016-12-23
10:28:59.000000000 +0100
+++ new/requests-cache-0.5.2/tests/test_dbdict.py 2019-04-13
10:14:31.000000000 +0200
@@ -18,6 +18,8 @@
def test_bulk_commit(self):
d = DbDict(self.NAMESPACE, self.TABLES[0])
+ with d.bulk_commit():
+ pass
d.clear()
n = 1000
with d.bulk_commit():
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/requests-cache-0.4.13/tests/test_dynamodbdict.py
new/requests-cache-0.5.2/tests/test_dynamodbdict.py
--- old/requests-cache-0.4.13/tests/test_dynamodbdict.py 1970-01-01
01:00:00.000000000 +0100
+++ new/requests-cache-0.5.2/tests/test_dynamodbdict.py 2019-04-13
10:14:31.000000000 +0200
@@ -0,0 +1,29 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# Path hack
+import os, sys
+sys.path.insert(0, os.path.abspath('..'))
+
+try:
+ import unittest2 as unittest
+except ImportError:
+ import unittest
+
+from tests.test_custom_dict import BaseCustomDictTestCase
+try:
+ from requests_cache.backends.storage.dynamodbdict import DynamoDbDict
+except ImportError:
+ print("DynamoDb not installed")
+else:
+
+ class WrapDynamoDbDict(DynamoDbDict):
+ def __init__(self, namespace, collection_name='dynamodb_dict_data',
**options):
+ options['endpoint_url'] = os.environ['DYNAMODB_ENDPOINT_URL'] if
'DYNAMODB_ENDPOINT_URL' in os.environ else None
+ super(WrapDynamoDbDict,self).__init__( namespace, collection_name,
**options)
+
+ class DynamoDbDictTestCase(BaseCustomDictTestCase, unittest.TestCase):
+ dict_class = WrapDynamoDbDict
+ pickled_dict_class = WrapDynamoDbDict
+
+ if __name__ == '__main__':
+ unittest.main()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/requests-cache-0.4.13/tests/test_gridfsdict.py
new/requests-cache-0.5.2/tests/test_gridfsdict.py
--- old/requests-cache-0.4.13/tests/test_gridfsdict.py 1970-01-01
01:00:00.000000000 +0100
+++ new/requests-cache-0.5.2/tests/test_gridfsdict.py 2019-04-13
10:14:31.000000000 +0200
@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# Path hack
+import os, sys
+sys.path.insert(0, os.path.abspath('..'))
+
+try:
+ import unittest2 as unittest
+except ImportError:
+ import unittest
+
+from tests.test_custom_dict import BaseCustomDictTestCase
+try:
+ from requests_cache.backends.storage.mongodict import MongoDict
+ from requests_cache.backends.storage.gridfspickledict import
GridFSPickleDict
+
+except ImportError:
+ print("pymongo not installed")
+else:
+ class MongoDictTestCase(BaseCustomDictTestCase, unittest.TestCase):
+ dict_class = MongoDict
+ pickled_dict_class = GridFSPickleDict
+
+ if __name__ == '__main__':
+ unittest.main()