Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
language: python
install: pip install tox-travis
script: tox

python:
- 2.7
install: pip install tox --use-mirrors
script: tox
- "2.7"
- "3.7"
3 changes: 3 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.. image:: https://travis-ci.org/supervacuo/django-memcachedkeys.svg?branch=python3
:target: https://travis-ci.org/supervacuo/django-memcachedkeys

=============================
django-memcachedkeys
=============================
Expand Down
6 changes: 4 additions & 2 deletions memcachedkeys/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from __future__ import unicode_literals

from memcachedkeys.pkgmeta import *
import re
from hashlib import md5


bad_key_chars = re.compile(ur'[\u0000-\u001f\s]+')
bad_key_chars = re.compile(r'[\u0000-\u001f\s]+')
MAX_LENGTH = 250


Expand All @@ -17,7 +19,7 @@ def make_key(key, key_prefix, version):
full_key = ':'.join([key_prefix, version_str, clean_key])

if clean_key != key or len(full_key) > MAX_LENGTH:
hashed_key = md5(key).hexdigest()
hashed_key = md5(key.encode('utf-8')).hexdigest()
abbrev_keylen = MAX_LENGTH - len(hashed_key) - len('::[]') - len(key_prefix) - len(version_str)
new_key = '%s[%s]' % (clean_key[:abbrev_keylen], hashed_key)
full_key = ':'.join([key_prefix, version_str, new_key])
Expand Down
2 changes: 1 addition & 1 deletion memcachedkeys/pkgmeta.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
)

globals().update(pkgmeta)
__all__ = pkgmeta.keys()
__all__ = list(pkgmeta.keys())
27 changes: 5 additions & 22 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,10 @@


pkgmeta = {}
execfile(os.path.join(os.path.dirname(__file__),
'memcachedkeys', 'pkgmeta.py'), pkgmeta)


class PyTest(TestCommand):
def finalize_options(self):
TestCommand.finalize_options(self)
self.test_args = ['tests', '-s']
self.test_suite = True

def run_tests(self):
import pytest
# Make sure this package's tests module gets priority.
sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))
errno = pytest.main(self.test_args)
sys.exit(errno)

pkgmeta_path = os.path.join(os.path.dirname(__file__), 'memcachedkeys', 'pkgmeta.py')
with open(pkgmeta_path) as f:
code = compile(f.read(), pkgmeta_path, 'exec')
exec(code, pkgmeta)

class LintCommand(Command):
"""
Expand Down Expand Up @@ -65,11 +52,8 @@ def distribution_files(self):
setup_requires=[
'flake8',
],
tests_require=[
'pytest-django',
],
install_requires=[
'Django>=1.2',
'Django>=1.11',
],
zip_safe=False,
keywords='django-memcachedkeys',
Expand All @@ -86,7 +70,6 @@ def distribution_files(self):
'Programming Language :: Python :: 3.3',
],
cmdclass={
'test': PyTest,
'lint': LintCommand,
},
)
12 changes: 10 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
[tox]
envlist = py27, py26
envlist =
py37-django{200,202},
{py27,py37}-django{110,111},

[testenv]
commands = python setup.py test
commands = pytest tests -s
deps =
pytest-django
django110: Django==1.10.8
django111: Django==1.11.26
django200: Django==2.0.13
django202: Django==2.2.7