Skip to content

Commit f3fa83c

Browse files
authored
Merge pull request #191 from hugovk/update-versions
Update Python versions
2 parents a3f55b7 + 1c8839d commit f3fa83c

File tree

8 files changed

+13
-23
lines changed

8 files changed

+13
-23
lines changed

cachecontrol/adapter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
class CacheControlAdapter(HTTPAdapter):
13-
invalidating_methods = set(['PUT', 'DELETE'])
13+
invalidating_methods = {'PUT', 'DELETE'}
1414

1515
def __init__(self, cache=None,
1616
cache_etags=True,

cachecontrol/caches/redis_cache.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,6 @@
44
from cachecontrol.cache import BaseCache
55

66

7-
def total_seconds(td):
8-
"""Python 2.6 compatability"""
9-
if hasattr(td, 'total_seconds'):
10-
return int(td.total_seconds())
11-
12-
ms = td.microseconds
13-
secs = (td.seconds + td.days * 24 * 3600)
14-
return int((ms + secs * 10**6) / 10**6)
15-
16-
177
class RedisCache(BaseCache):
188

199
def __init__(self, conn):
@@ -27,7 +17,7 @@ def set(self, key, value, expires=None):
2717
self.conn.set(key, value)
2818
else:
2919
expires = expires - datetime.utcnow()
30-
self.conn.setex(key, total_seconds(expires), value)
20+
self.conn.setex(key, int(expires.total_seconds()), value)
3121

3222
def delete(self, key):
3323
self.conn.delete(key)

cachecontrol/heuristics.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,8 @@ class LastModified(BaseHeuristic):
100100
http://lxr.mozilla.org/mozilla-release/source/netwerk/protocol/http/nsHttpResponseHead.cpp#397
101101
Unlike mozilla we limit this to 24-hr.
102102
"""
103-
cacheable_by_default_statuses = set([
104-
200, 203, 204, 206, 300, 301, 404, 405, 410, 414, 501
105-
])
103+
cacheable_by_default_statuses = {200, 203, 204, 206, 300, 301, 404, 405,
104+
410, 414, 501}
106105

107106
def update_headers(self, resp):
108107
headers = resp.headers

cachecontrol/serialize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def loads(self, request, data):
9595

9696
# Dispatch to the actual load method for the given version
9797
try:
98-
return getattr(self, "_loads_v{0}".format(ver))(request, data)
98+
return getattr(self, "_loads_v{}".format(ver))(request, data)
9999
except AttributeError:
100100
# This is a version we don't have a loads function for, so we'll
101101
# just treat it as a miss and return None

examples/benchmark.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
HOST = 'localhost'
1111
PORT = 8050
12-
URL = 'http://{0}:{1}/'.format(HOST, PORT)
12+
URL = 'http://{}:{}/'.format(HOST, PORT)
1313

1414

1515
class Server(object):

setup.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,18 @@
3030
'doesitcache = cachecontrol._cmd:main',
3131
]
3232
},
33+
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',
3334
classifiers=[
3435
'Development Status :: 4 - Beta',
3536
'Environment :: Web Environment',
3637
'License :: OSI Approved :: Apache Software License',
3738
'Operating System :: OS Independent',
38-
'Programming Language :: Python :: 2.6',
39+
'Programming Language :: Python :: 2',
3940
'Programming Language :: Python :: 2.7',
4041
'Programming Language :: Python :: 3',
41-
'Programming Language :: Python :: 3.2',
42-
'Programming Language :: Python :: 3.3',
4342
'Programming Language :: Python :: 3.4',
43+
'Programming Language :: Python :: 3.5',
44+
'Programming Language :: Python :: 3.6',
4445
'Topic :: Internet :: WWW/HTTP',
4546
],
4647
)

tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def vary_accept(self, env, start_response):
4848

4949
def update_etag_string(self):
5050
self.etag_count += 1
51-
self.etag_string = '"ETAG-{0}"'.format(self.etag_count)
51+
self.etag_string = '"ETAG-{}"'.format(self.etag_count)
5252

5353
def update_etag(self, env, start_response):
5454
self.update_etag_string()
@@ -155,7 +155,7 @@ def pytest_namespace():
155155
logger.removeHandler(logger.handlers[0])
156156

157157
cherrypy.server.start()
158-
return dict(server=cherrypy.server)
158+
return {'server': cherrypy.server}
159159

160160

161161
def pytest_unconfigure(config):

tests/test_storage_filecache.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def randomdata():
1919
key = ''.join(sample(string.ascii_lowercase, randint(2, 4)))
2020
val = ''.join(sample(string.ascii_lowercase + string.digits,
2121
randint(2, 10)))
22-
return '&{0}={1}'.format(key, val)
22+
return '&{}={}'.format(key, val)
2323

2424

2525
class TestStorageFileCache(object):

0 commit comments

Comments
 (0)