Skip to content

Commit

Permalink
Dropped python 3.5 and below.
Browse files Browse the repository at this point in the history
  • Loading branch information
akornatskyy committed Nov 14, 2020
1 parent 8455ee7 commit 9ecce38
Show file tree
Hide file tree
Showing 17 changed files with 42 additions and 159 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ services:

matrix:
include:
- python: 2.7
env: TOXENV=py27
- python: 3.6
env: TOXENV=py36
- python: 3.7
env: TOXENV=py37
- python: 3.8
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ Resources:
## Install

[wheezy.caching](https://pypi.org/project/wheezy.caching/) requires
[python](http://www.python.org) version 2.4 to 2.7 or 3.2+. It is
independent of operating system. You can install it from
[python](http://www.python.org) version 3.6+. It is independent of operating
system. You can install it from
[pypi](https://pypi.org/project/wheezy.caching/) site:

```sh
Expand Down
5 changes: 2 additions & 3 deletions doc/gettingstarted.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ Getting Started
Install
-------

:ref:`wheezy.caching` requires `python`_ version 2.4 to 2.7 or 3.2+.
It is operating system independent. You can install it from the `pypi`_
site::
:ref:`wheezy.caching` requires `python`_ version 3.6+. It is operating system
independent. You can install it from the `pypi`_ site::

$ pip install wheezy.caching

Expand Down
35 changes: 0 additions & 35 deletions requirements/dev-py2.txt

This file was deleted.

File renamed without changes.
12 changes: 2 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
[os.path.join(p, "*.py")],
exclude=os.path.join(p, "__init__.py"),
nthreads=2,
compiler_directives={"language_level": 3},
quiet=True,
)
except ImportError:
Expand All @@ -32,6 +33,7 @@
setup(
name="wheezy.caching",
version=VERSION,
python_requires=">=3.6",
description="A lightweight caching library",
long_description=README,
long_description_content_type="text/markdown",
Expand All @@ -45,16 +47,6 @@
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.4",
"Programming Language :: Python :: 2.5",
"Programming Language :: Python :: 2.6",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.2",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
Expand Down
59 changes: 0 additions & 59 deletions src/wheezy/caching/comp.py

This file was deleted.

11 changes: 5 additions & 6 deletions src/wheezy/caching/dependency.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
""" ``dependency`` module.
"""

from wheezy.caching.comp import itervalues, xrange
from wheezy.caching.utils import total_seconds


Expand Down Expand Up @@ -37,7 +36,7 @@ def next_keys(self, master_key, n):
"""
last_id = self.cache.incr(master_key, n, self.namespace, 0)
return [
master_key + str(i) for i in xrange(last_id - n + 1, last_id + 1)
master_key + str(i) for i in range(last_id - n + 1, last_id + 1)
]

def add(self, master_key, key):
Expand All @@ -56,8 +55,8 @@ def get_keys(self, master_key):
n = self.cache.get(master_key, self.namespace)
if n is None:
return []
keys = [master_key + str(i) for i in xrange(1, n + 1)]
keys.extend(itervalues(self.cache.get_multi(keys, self.namespace)))
keys = [master_key + str(i) for i in range(1, n + 1)]
keys.extend(self.cache.get_multi(keys, self.namespace).values())
keys.append(master_key)
return keys

Expand All @@ -69,9 +68,9 @@ def get_multi_keys(self, master_keys):
keys = [
master_key + str(i)
for master_key, n in numbers.items()
for i in xrange(1, n + 1)
for i in range(1, n + 1)
]
keys.extend(itervalues(self.cache.get_multi(keys, self.namespace)))
keys.extend(self.cache.get_multi(keys, self.namespace).values())
keys.extend(master_keys)
return keys

Expand Down
12 changes: 5 additions & 7 deletions src/wheezy/caching/encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

from base64 import b64encode

from wheezy.caching.comp import string_type

BASE64_ALTCHARS = "-_".encode("latin1")


Expand Down Expand Up @@ -32,7 +30,7 @@ def encode_keys(mapping, key_encode):

def string_encode(key):
"""Encodes ``key`` with UTF-8 encoding."""
if isinstance(key, string_type):
if isinstance(key, str):
return key.encode("UTF-8")
else:
return key # pragma: nocover
Expand All @@ -41,11 +39,11 @@ def string_encode(key):
def base64_encode(key):
"""Encodes ``key`` with base64 encoding.
>>> result = base64_encode(string_type('my key'))
>>> result = base64_encode('my key')
>>> result == 'bXkga2V5'.encode('latin1')
True
"""
if isinstance(key, string_type):
if isinstance(key, str):
key = key.encode("UTF-8")
return b64encode(key, BASE64_ALTCHARS)

Expand All @@ -63,7 +61,7 @@ def hash_encode(hash_factory):
>>> try:
... from hashlib import sha1
... key_encode = hash_encode(sha1)
... r = base64_encode(key_encode(string_type('my key')))
... r = base64_encode(key_encode('my key'))
... assert r == 'RigVwkWdSuGyFu7au08PzUMloU8='.encode('latin1')
... except ImportError: # Python2.4
... pass
Expand All @@ -72,7 +70,7 @@ def hash_encode(hash_factory):

def key_encode(key):
h = hash_factory()
if isinstance(key, string_type):
if isinstance(key, str):
key = key.encode("UTF-8")
h.update(key)
return h.digest()
Expand Down
4 changes: 1 addition & 3 deletions src/wheezy/caching/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
"""

from hashlib import sha1
from logging import Handler

from wheezy.caching.comp import __import__
from wheezy.caching.encoding import hash_encode
from wheezy.caching.utils import total_seconds

Handler = __import__("logging", None, None, ["Handler"]).Handler


class OnePassHandler(Handler):
"""One pass logging handler is used to proxy a message to inner
Expand Down
5 changes: 2 additions & 3 deletions src/wheezy/caching/memcache.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
""" ``memcache`` module.
"""

from wheezy.caching.comp import __import__, list_map
from wheezy.caching.encoding import encode_keys, string_encode

try:
Client = __import__("memcache", None, None, ["Client"]).Client
from memcache import Client
except ImportError: # pragma: nocover
Client = None
import warnings
Expand Down Expand Up @@ -80,7 +79,7 @@ def get_multi(self, keys, namespace=None):
This is the recommended way to do bulk loads.
"""
key_encode = self.key_encode
encoded_keys = list_map(key_encode, keys)
encoded_keys = list(map(key_encode, keys))
mapping = self.client.get_multi(encoded_keys)
if mapping:
key_mapping = dict(zip(encoded_keys, keys))
Expand Down
9 changes: 4 additions & 5 deletions src/wheezy/caching/memory.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
""" ``memory`` module.
"""

from _thread import allocate_lock
from time import time as unixtime

from wheezy.caching.comp import allocate_lock, iteritems, xrange


def expires(now, time):
"""
Expand Down Expand Up @@ -54,7 +53,7 @@ def find_expired(bucket_items, now):
[('k2', 2), ('k3', 3)]
"""
expired_keys = []
for i in xrange(len(bucket_items) - 1, -1, -1):
for i in range(len(bucket_items) - 1, -1, -1):
key, expires = bucket_items[i]
if expires < now:
expired_keys.append(key)
Expand Down Expand Up @@ -82,7 +81,7 @@ def __init__(self, buckets=60, bucket_interval=15):
self.items = {}
self.lock = allocate_lock()
self.expire_buckets = [
(allocate_lock(), []) for i in xrange(0, buckets)
(allocate_lock(), []) for i in range(0, buckets)
]
self.last_expire_bucket_id = -1

Expand Down Expand Up @@ -432,7 +431,7 @@ def store_multi(self, mapping, time=0, op=0):
succeeded = []
self.lock.acquire(1)
try:
for key, value in iteritems(mapping):
for key, value in mapping.items():
try:
entry = items[key]
if entry.expires < now:
Expand Down
12 changes: 7 additions & 5 deletions src/wheezy/caching/patterns.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
""" ``patterns`` module.
"""

from inspect import getargspec
from inspect import getfullargspec
from time import sleep, time

from wheezy.caching.dependency import CacheDependency
Expand Down Expand Up @@ -254,7 +254,7 @@ def get_multi_account(account_ids):
assert make_key

def decorate(func):
argnames = getargspec(func)[0]
argnames = getfullargspec(func)[0]
if argnames and argnames[0] in ("self", "cls", "klass"):
assert len(argnames) == 2

Expand Down Expand Up @@ -349,7 +349,7 @@ def get_or_create_wrapper(*args, **kwargs):

def adapt(self, func, make_key=None):
if make_key:
argnames = getargspec(func)[0]
argnames = getfullargspec(func)[0]
if argnames and argnames[0] in ("self", "cls", "klass"):
return lambda ignore, *args, **kwargs: make_key(
*args, **kwargs
Expand Down Expand Up @@ -426,7 +426,7 @@ def key_format(func, key_prefix):
>>> key_format(list_items, 'repo')
'repo-list_items:%r:%r'
"""
argnames = getargspec(func)[0]
argnames = getfullargspec(func)[0]
n = len(argnames)
if n and argnames[0] in ("self", "cls", "klass"):
n -= 1
Expand Down Expand Up @@ -473,7 +473,9 @@ def key_list_items(self, locale='en', sort_order=1):
"""

def build(func):
argnames, varargs, kwargs, defaults = getargspec(func)
spec = getfullargspec(func)
argnames = spec.args
defaults = spec.defaults
if defaults:
n = len(defaults)
defaults = dict(zip(argnames[-n:], defaults))
Expand Down
Loading

0 comments on commit 9ecce38

Please sign in to comment.