Skip to content

Commit db088db

Browse files
committed
Added compat to python3
1 parent 08692d6 commit db088db

File tree

10 files changed

+83
-49
lines changed

10 files changed

+83
-49
lines changed

.travis.yml

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,46 @@
1+
sudo: false
12
language: python
3+
24
python:
3-
- 2.7
4-
sudo: false
5+
- "2.7"
6+
- "3.4"
7+
- "3.5"
8+
- "3.6"
9+
10+
env:
11+
matrix:
12+
- django19
13+
- django110
14+
- django111
15+
- djangomaster
16+
17+
matrix:
18+
fast_finish: true
19+
include:
20+
- python: "3.4"
21+
env: flake8
22+
exclude:
23+
- python: "2.7"
24+
env: djangomaster
25+
- python: "3.6"
26+
env: django19
27+
- python: "3.6"
28+
env: django111
29+
allow_failures:
30+
- env: djangomaster
31+
32+
cache:
33+
directories:
34+
- $HOME/.cache/pip
35+
- $TRAVIS_BUILD_DIR/.tox
36+
537
install:
6-
- pip install tox
38+
- pip install --upgrade pip wheel setuptools
39+
- pip install coveralls codacy-coverage tox-travis
40+
741
script:
8-
- tox -e flake8
9-
- tox -e travis
42+
- tox
43+
44+
after_success:
45+
- coveralls
46+
- python-codacy-coverage -r coverage.xml

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7-
## 0.1.1 - 2017-09-13
7+
## [0.1.2] - 2017-09-16
8+
### Added
9+
- Support to python 3.4, 3.5 and 3.6 and django 1.9, 1.10 and 1.11.
10+
11+
## [0.1.1] - 2017-09-13
812
### Fixed
913
- Fix to interaction with models default queryset of the host project
1014

11-
## 0.1.0 - 2017-08-08
15+
## [0.1.0] - 2017-08-08
1216
- First release on PyPi

README.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
Django obfuscate
22
=================
33

4-
|Build Status| |Coverage Status| |Codacy Badge| |BCH compliance|
4+
|Build Status| |Coverage Status| |Codacy Badge| |BCH compliance| |Pypi|
55

66
Django app to obfuscate text data.
77

88
Table of contents:
9+
* `Compatibility`_;
910
* `How to install`_;
1011
* `Example usage`_;
1112
* `Settings reference`_;
1213
* `License`_.
1314

15+
Compatibility
16+
-------------
17+
Tested with python 2.7, 3.4, 3.5, 3.6 and Django 1.9, 1.10, 1.11: `Travis CI <https://travis-ci.org/dipcode-software/django-obfuscate>`_
18+
1419
How to install
1520
--------------
1621

@@ -123,6 +128,7 @@ License
123128
MIT license, see the LICENSE file. You can use obfuscator in open source
124129
projects and commercial products.
125130

131+
.. _Compatibility: #compatibility
126132
.. _How to install: #how-to-install
127133
.. _Example usage: #example-usage
128134
.. _Settings reference: #settings-reference
@@ -136,3 +142,5 @@ projects and commercial products.
136142
:target: https://www.codacy.com/app/srtabs/django-obfuscate?utm_source=github.com&utm_medium=referral&utm_content=dipcode-software/django-obfuscate&utm_campaign=Badge_Grade
137143
.. |BCH compliance| image:: https://bettercodehub.com/edge/badge/dipcode-software/django-obfuscate?branch=master
138144
:target: https://bettercodehub.com/
145+
.. |Pypi| image:: https://img.shields.io/pypi/v/django-obfuscate.svg?style=flat
146+
:target: https://pypi.python.org/pypi/django-obfuscate

obfuscator/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
default_app_config = 'obfuscator.apps.ObfuscatorConfig'
66

7-
__version__ = '0.1.1'
7+
__version__ = '0.1.2'

obfuscator/management/commands/obfuscate.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ def work(self, model_class, fields):
4747
value = getattr(obj, field_name)
4848
if value:
4949
field = model_class._meta.get_field(field_name)
50-
data[field_name] = utils.obfuscator(
51-
field, value.encode('utf-8'))
50+
data[field_name] = utils.obfuscator(field, value)
5251
model_class._default_manager.filter(pk=obj.pk).update(**data)
5352
self.psuccess("Finished offuscation")
5453

obfuscator/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class ObfuscatorUtils(object):
1313
def email(value, max_length, **kwargs):
1414
""" """
1515
username, domain = value.split('@')
16-
username = hashlib.sha224(username).hexdigest()
16+
username = hashlib.sha224(username.encode('utf-8')).hexdigest()
1717
length = len(username) + len(domain) + 1
1818
if length > max_length:
1919
username = username[:(max_length - length)]
@@ -23,7 +23,7 @@ def email(value, max_length, **kwargs):
2323
@staticmethod
2424
def text(value, max_length=None, **kwargs):
2525
""" """
26-
hashed_value = hashlib.sha224(value).hexdigest()
26+
hashed_value = hashlib.sha224(value.encode('utf-8')).hexdigest()
2727
length = len(hashed_value)
2828
if max_length and length > max_length:
2929
hashed_value = hashed_value[:(max_length - length)]

requirements.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

setup.cfg

Lines changed: 0 additions & 2 deletions
This file was deleted.

setup.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# Package meta-data.
1313
VERSION = __import__("obfuscator").__version__
1414
NAME = 'django-obfuscate'
15-
DESCRIPTION = 'Django app to obfuscate data. '
15+
DESCRIPTION = 'Django app to obfuscate text data.'
1616
URL = 'https://github.com/dipcode-software/django-obfuscate'
1717
1818
AUTHOR = 'Dipcode'
@@ -49,9 +49,9 @@ def run(self):
4949
except OSError:
5050
pass
5151

52-
self.status('Building Source and Wheel distribution…')
52+
self.status('Building Source and Wheel (universal) distribution…')
5353
os.system(
54-
'{0} setup.py sdist bdist_wheel '.format(sys.executable)
54+
'{0} setup.py sdist bdist_wheel --universal'.format(sys.executable)
5555
)
5656

5757
self.status('Uploading the package to {env} via Twine…'\
@@ -83,12 +83,17 @@ class DevelopmentPublishCommand(PublishCommand):
8383
classifiers=[
8484
'Environment :: Web Environment',
8585
'Framework :: Django',
86+
'Framework :: Django :: 1.9',
87+
'Framework :: Django :: 1.10',
8688
'Framework :: Django :: 1.11',
8789
'Intended Audience :: Developers',
8890
'License :: OSI Approved :: MIT License',
8991
'Operating System :: OS Independent',
9092
'Programming Language :: Python',
9193
'Programming Language :: Python :: 2.7',
94+
'Programming Language :: Python :: 3.4',
95+
'Programming Language :: Python :: 3.5',
96+
'Programming Language :: Python :: 3.6',
9297
],
9398
cmdclass={
9499
'publish_dev': DevelopmentPublishCommand,

tox.ini

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,23 @@
11
[tox]
22
skipsdist = True
3-
envlist = py27,flake8
3+
envlist =
4+
py{27,34,35}-django{19,110,111},
5+
py{35,36}-django{111,master}
6+
flake8
47

58
[testenv]
6-
deps = -r{toxinidir}/requirements.txt
7-
commands = {envpython} runtests.py
8-
9-
[testenv:flake8]
10-
deps = flake8
11-
commands = flake8 {toxinidir}/obfuscator
12-
13-
[testenv:coverage]
14-
basepython=python2.7
15-
deps=
16-
-r{toxinidir}/requirements.txt
17-
coverage
18-
setenv=
19-
PYTHONWARNINGS=ignore
20-
commands=
21-
coverage run runtests.py {posargs:}
22-
coverage report
23-
coverage erase
24-
25-
[testenv:travis]
26-
passenv = TRAVIS TRAVIS_JOB_ID TRAVIS_BRANCH
279
deps =
28-
-r{toxinidir}/requirements.txt
2910
coverage
30-
coveralls
31-
setenv =
32-
PYTHONWARNINGS=ignore
33-
commands =
11+
mock >= 2.0.0
12+
django19: Django>=1.9,<1.10
13+
django110: Django>=1.10,<1.11
14+
django111: Django>=1.11,<2.0
15+
djangomaster: https://github.com/django/django/archive/master.tar.gz
16+
commands=
3417
coverage run runtests.py {posargs:}
3518
coverage report
3619
coverage xml
37-
coveralls
20+
21+
[testenv:flake8]
22+
deps = flake8
23+
commands = flake8 {toxinidir}/obfuscator

0 commit comments

Comments
 (0)