Skip to content

Commit

Permalink
Lots of cleanup and prep work for Python 3.7-3.10 Django 2.1+
Browse files Browse the repository at this point in the history
  • Loading branch information
rh0dium committed Dec 21, 2020
1 parent aa448bd commit 087c982
Show file tree
Hide file tree
Showing 101 changed files with 946 additions and 749 deletions.
10 changes: 10 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[run]
branch = True
omit =
*/migrations/*

[report]
fail_under = 70
omit =
*/migrations/*
*/test*
119 changes: 105 additions & 14 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,16 +1,107 @@
*.pyc
*.pyo
# Created by .ignore support plugin (hsz.mobi)
### Python template
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
.DS_Store
Thumbs.db
*.orig
dist
build
django_datatable_view.egg-info
.tm_properties
.python-version
local_settings.py
db.sqlite3
appengine
docs/_build
.idea
.venv/

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/

.DS_Store
32 changes: 32 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
repos:
- repo: git://github.com/pre-commit/pre-commit-hooks
rev: v1.4.0
hooks:
- id: check-added-large-files
args: ['--maxkb=500']
- id: check-byte-order-marker
- id: check-case-conflict
- id: check-merge-conflict
- id: check-symlinks
- id: detect-private-key
- id: flake8
files: datatableview
exclude: tests/*
args: ['--config=tox.ini']
- id: fix-encoding-pragma
- id: end-of-file-fixer
exclude: .idea/*
- id: trailing-whitespace
exclude: .idea/*
- id: mixed-line-ending
exclude: .idea/*
- id: double-quote-string-fixer
exclude: .idea/*
- id: check-json
files: .gitignore
- repo: https://github.com/pre-commit/mirrors-isort
rev: v4.3.16 # Use the revision sha / tag you want to point at
hooks:
- id: isort
files: datatableview
args: ['--recursive', '--diff']
55 changes: 27 additions & 28 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
sudo: false
dist: xenial

language: python

sudo: false

git:
depth: 1
quiet: true

cache: pip

python:
- "2.7"
- "3.4"
- "3.5"
- "3.6"
# - "3.7"
env:
- DJANGO=1.11.16
- DJANGO=2.0.9
- DJANGO=2.1.2
- "3.7"
- "3.8"
- "3.9"
- "3.10-dev"

install:
- pip install -q Django==$DJANGO
# - pip install pep8
# - pip install pyflakes
- pip install -q -e .
# before_script:
# - "pep8 --exclude=migrations --ignore=E501,E225 datatableview"
# - pyflakes datatableview
script:
- python datatableview/tests/example_project/manage.py test

matrix:
exclude:
- python: "2.7"
env: DJANGO=2.0.9
- python: "2.7"
env: DJANGO=2.1.2
- python: "3.4"
env: DJANGO=2.1.2
- 'pip install tox-travis pyyaml python-coveralls'

script: tox

notifications:
slack:
rooms:
- pivotalenergy:SvNSkVaLVlZeu82utL37wSvy#travis

after_success:
- coveralls
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ class MyDatatableView(DatatableView):
def get_json_response_object(self, object_list, *args, **kwargs):
data = super(MyDatatableView, self).get_json_response_object(object_list, *args, **kwargs)

# Keep customizations JSON-compatible! :)
# Keep customizations JSON-compatible! :)
data.update({
'special_arg': self.kwargs['special_arg'],
})
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,4 @@
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
6 changes: 5 additions & 1 deletion datatableview/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@

__name__ = 'datatableview'
__author__ = 'Autumn Valenta'
__version_info__ = (0, 9, 0)
__version_info__ = (1, 0, 0)
__version__ = '.'.join(map(str, __version_info__))
__date__ = '2013/11/14 2:00:00 PM'
__credits__ = ['Autumn Valenta', 'Steven Klass']
__license__ = 'See the file LICENSE.txt for licensing information.'

__all__ = ['Datatable', 'ValuesDatatable', 'LegacyDatatable', 'Column', 'TextColumn',
'DateColumn', 'DateTimeColumn', 'BooleanColumn', 'IntegerColumn', 'FloatColumn',
'DisplayColumn', 'CompoundColumn', 'CheckBoxSelectColumn', 'SkipRecord']
9 changes: 5 additions & 4 deletions datatableview/cache.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import inspect
import hashlib
import logging
Expand Down Expand Up @@ -42,11 +43,11 @@ class cache_types(object):

cache = caches[CACHE_BACKEND]


hash_slice = None
if CACHE_KEY_HASH:
hash_slice = slice(None, CACHE_KEY_HASH_LENGTH)


def _hash_key_component(s):
return hashlib.sha1(s.encode('utf-8')).hexdigest()[hash_slice]

Expand Down Expand Up @@ -93,7 +94,7 @@ def get_cache_key(datatable_class, view=None, user=None, **kwargs):
kwargs_id = _hash_key_component(kwargs_id)
cache_key += '__kwargs_%s' % (kwargs_id,)

log.debug("Cache key derived for %r: %r (from kwargs %r)", datatable_class, cache_key, values)
log.debug('Cache key derived for %r: %r (from kwargs %r)', datatable_class, cache_key, values)

return cache_key

Expand All @@ -102,12 +103,12 @@ def get_cached_data(datatable, **kwargs):
""" Returns the cached object list under the appropriate key, or None if not set. """
cache_key = '%s%s' % (CACHE_PREFIX, datatable.get_cache_key(**kwargs))
data = cache.get(cache_key)
log.debug("Reading data from cache at %r: %r", cache_key, data)
log.debug('Reading data from cache at %r: %r', cache_key, data)
return data


def cache_data(datatable, data, **kwargs):
""" Stores the object list in the cache under the appropriate key. """
cache_key = '%s%s' % (CACHE_PREFIX, datatable.get_cache_key(**kwargs))
log.debug("Setting data to cache at %r: %r", cache_key, data)
log.debug('Setting data to cache at %r: %r', cache_key, data)
cache.set(cache_key, data)
Loading

0 comments on commit 087c982

Please sign in to comment.