Skip to content

Commit

Permalink
Merge pull request #13 from dipcode-software/feat/compat
Browse files Browse the repository at this point in the history
Added compat to python3
  • Loading branch information
srtab committed Sep 16, 2017
2 parents 08692d6 + db088db commit 20a5012
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 49 deletions.
47 changes: 42 additions & 5 deletions .travis.yml
@@ -1,9 +1,46 @@
sudo: false
language: python

python:
- 2.7
sudo: false
- "2.7"
- "3.4"
- "3.5"
- "3.6"

env:
matrix:
- django19
- django110
- django111
- djangomaster

matrix:
fast_finish: true
include:
- python: "3.4"
env: flake8
exclude:
- python: "2.7"
env: djangomaster
- python: "3.6"
env: django19
- python: "3.6"
env: django111
allow_failures:
- env: djangomaster

cache:
directories:
- $HOME/.cache/pip
- $TRAVIS_BUILD_DIR/.tox

install:
- pip install tox
- pip install --upgrade pip wheel setuptools
- pip install coveralls codacy-coverage tox-travis

script:
- tox -e flake8
- tox -e travis
- tox

after_success:
- coveralls
- python-codacy-coverage -r coverage.xml
8 changes: 6 additions & 2 deletions CHANGELOG.md
Expand Up @@ -4,9 +4,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## 0.1.1 - 2017-09-13
## [0.1.2] - 2017-09-16
### Added
- Support to python 3.4, 3.5 and 3.6 and django 1.9, 1.10 and 1.11.

## [0.1.1] - 2017-09-13
### Fixed
- Fix to interaction with models default queryset of the host project

## 0.1.0 - 2017-08-08
## [0.1.0] - 2017-08-08
- First release on PyPi
10 changes: 9 additions & 1 deletion README.rst
@@ -1,16 +1,21 @@
Django obfuscate
=================

|Build Status| |Coverage Status| |Codacy Badge| |BCH compliance|
|Build Status| |Coverage Status| |Codacy Badge| |BCH compliance| |Pypi|

Django app to obfuscate text data.

Table of contents:
* `Compatibility`_;
* `How to install`_;
* `Example usage`_;
* `Settings reference`_;
* `License`_.

Compatibility
-------------
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>`_

How to install
--------------

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

.. _Compatibility: #compatibility
.. _How to install: #how-to-install
.. _Example usage: #example-usage
.. _Settings reference: #settings-reference
Expand All @@ -136,3 +142,5 @@ projects and commercial products.
: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
.. |BCH compliance| image:: https://bettercodehub.com/edge/badge/dipcode-software/django-obfuscate?branch=master
:target: https://bettercodehub.com/
.. |Pypi| image:: https://img.shields.io/pypi/v/django-obfuscate.svg?style=flat
:target: https://pypi.python.org/pypi/django-obfuscate
2 changes: 1 addition & 1 deletion obfuscator/__init__.py
Expand Up @@ -4,4 +4,4 @@

default_app_config = 'obfuscator.apps.ObfuscatorConfig'

__version__ = '0.1.1'
__version__ = '0.1.2'
3 changes: 1 addition & 2 deletions obfuscator/management/commands/obfuscate.py
Expand Up @@ -47,8 +47,7 @@ def work(self, model_class, fields):
value = getattr(obj, field_name)
if value:
field = model_class._meta.get_field(field_name)
data[field_name] = utils.obfuscator(
field, value.encode('utf-8'))
data[field_name] = utils.obfuscator(field, value)
model_class._default_manager.filter(pk=obj.pk).update(**data)
self.psuccess("Finished offuscation")

Expand Down
4 changes: 2 additions & 2 deletions obfuscator/utils.py
Expand Up @@ -13,7 +13,7 @@ class ObfuscatorUtils(object):
def email(value, max_length, **kwargs):
""" """
username, domain = value.split('@')
username = hashlib.sha224(username).hexdigest()
username = hashlib.sha224(username.encode('utf-8')).hexdigest()
length = len(username) + len(domain) + 1
if length > max_length:
username = username[:(max_length - length)]
Expand All @@ -23,7 +23,7 @@ def email(value, max_length, **kwargs):
@staticmethod
def text(value, max_length=None, **kwargs):
""" """
hashed_value = hashlib.sha224(value).hexdigest()
hashed_value = hashlib.sha224(value.encode('utf-8')).hexdigest()
length = len(hashed_value)
if max_length and length > max_length:
hashed_value = hashed_value[:(max_length - length)]
Expand Down
3 changes: 0 additions & 3 deletions requirements.txt

This file was deleted.

2 changes: 0 additions & 2 deletions setup.cfg

This file was deleted.

11 changes: 8 additions & 3 deletions setup.py
Expand Up @@ -12,7 +12,7 @@
# Package meta-data.
VERSION = __import__("obfuscator").__version__
NAME = 'django-obfuscate'
DESCRIPTION = 'Django app to obfuscate data. '
DESCRIPTION = 'Django app to obfuscate text data.'
URL = 'https://github.com/dipcode-software/django-obfuscate'
EMAIL = 'team@dipcode.com'
AUTHOR = 'Dipcode'
Expand Down Expand Up @@ -49,9 +49,9 @@ def run(self):
except OSError:
pass

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

self.status('Uploading the package to {env} via Twine…'\
Expand Down Expand Up @@ -83,12 +83,17 @@ class DevelopmentPublishCommand(PublishCommand):
classifiers=[
'Environment :: Web Environment',
'Framework :: Django',
'Framework :: Django :: 1.9',
'Framework :: Django :: 1.10',
'Framework :: Django :: 1.11',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
],
cmdclass={
'publish_dev': DevelopmentPublishCommand,
Expand Down
42 changes: 14 additions & 28 deletions tox.ini
@@ -1,37 +1,23 @@
[tox]
skipsdist = True
envlist = py27,flake8
envlist =
py{27,34,35}-django{19,110,111},
py{35,36}-django{111,master}
flake8

[testenv]
deps = -r{toxinidir}/requirements.txt
commands = {envpython} runtests.py

[testenv:flake8]
deps = flake8
commands = flake8 {toxinidir}/obfuscator

[testenv:coverage]
basepython=python2.7
deps=
-r{toxinidir}/requirements.txt
coverage
setenv=
PYTHONWARNINGS=ignore
commands=
coverage run runtests.py {posargs:}
coverage report
coverage erase

[testenv:travis]
passenv = TRAVIS TRAVIS_JOB_ID TRAVIS_BRANCH
deps =
-r{toxinidir}/requirements.txt
coverage
coveralls
setenv =
PYTHONWARNINGS=ignore
commands =
mock >= 2.0.0
django19: Django>=1.9,<1.10
django110: Django>=1.10,<1.11
django111: Django>=1.11,<2.0
djangomaster: https://github.com/django/django/archive/master.tar.gz
commands=
coverage run runtests.py {posargs:}
coverage report
coverage xml
coveralls

[testenv:flake8]
deps = flake8
commands = flake8 {toxinidir}/obfuscator

0 comments on commit 20a5012

Please sign in to comment.