Skip to content

Commit 803d591

Browse files
committed
Merge 0d43e7a into ad05ff8
2 parents ad05ff8 + 0d43e7a commit 803d591

File tree

6 files changed

+32
-66
lines changed

6 files changed

+32
-66
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
- repo: git@github.com:pre-commit/pre-commit-hooks
2-
sha: 29bf11d13689a0a9a895c41eb3591c7e942d377d
2+
sha: e306ff3b7d0d9a6fc7d128ef9ca2e0b6e6e76e8f
33
hooks:
44
- id: trailing-whitespace
55
- id: end-of-file-fixer
@@ -13,13 +13,13 @@
1313
args:
1414
- requirements-dev.txt
1515
- repo: git://github.com/FalconSocial/pre-commit-mirrors-pep257
16-
sha: 67c970e89857fdcebcd59ace94950a3331985a3b
16+
sha: ebb1b1bb080b0c960bcf37cf81d09185cec4fc6d
1717
hooks:
1818
- id: pep257
1919
args:
2020
- --explain
2121
- --ignore=D100,D101,D102,D103,D104,D105,D203
2222
- repo: git://github.com/FalconSocial/pre-commit-python-sorter
23-
sha: 934072fb29303aaa64bead610be042049e9db488
23+
sha: ec01d99f48a0dabb2ebbb2675139e2cc0fe2aa93
2424
hooks:
2525
- id: python-import-sorter

.travis.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
11
language: python
22
sudo: false
3-
cache:
4-
- pip
3+
cache: pip
54
python:
65
- "2.7"
7-
- "3.3"
86
- "3.4"
97
- "3.5"
10-
- "pypy"
11-
- "pypy3"
128
env:
139
matrix:
14-
- DJANGO="Django<1.8,>=1.7"
1510
- DJANGO="Django<1.9,>=1.8"
11+
- DJANGO="Django<1.10,>=1.9"
1612
- DJANGO="-e git+https://github.com/django/django.git@master#egg=Django"
1713
matrix:
1814
fast_finish: true
1915
allow_failures:
20-
- python: "3.5"
2116
- env: DJANGO="-e git+https://github.com/django/django.git@master#egg=Django"
2217
install:
2318
- pip install --upgrade pip
@@ -28,6 +23,6 @@ script:
2823
- isort --check-only --recursive --diff .
2924
- flake8 --jobs=2 .
3025
- pep257 --verbose --explain --source --count stdimage
31-
- coverage run --source=stdimage runtests.py
26+
- coverage run --source=stdimage -m 'pytest'
3227
after_success:
3328
- coveralls

README.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ Django Standarized Image Field
2929
Django Field that implement the following features:
3030

3131
* Django-Storages compatible (S3)
32-
* Python 2, 3 and PyPy support
3332
* Resize images to different sizes
3433
* Access thumbnails on model level, no template tags required
3534
* Preserves original image

setup.py

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,6 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
3-
from setuptools import Command, find_packages, setup
4-
5-
6-
class PyTest(Command):
7-
user_options = []
8-
9-
def initialize_options(self):
10-
pass
11-
12-
def finalize_options(self):
13-
pass
14-
15-
def run(self):
16-
import sys
17-
import subprocess
18-
19-
errno = subprocess.call([sys.executable, 'runtests.py'])
20-
raise SystemExit(errno)
21-
3+
from setuptools import find_packages, setup
224

235
setup(
246
name='django-stdimage',
@@ -39,13 +21,13 @@ def run(self):
3921
'Programming Language :: Python',
4022
'Topic :: Software Development',
4123
'Programming Language :: Python :: 2',
42-
'Programming Language :: Python :: 2.6',
4324
'Programming Language :: Python :: 2.7',
4425
'Programming Language :: Python :: 3',
45-
'Programming Language :: Python :: 3.2',
46-
'Programming Language :: Python :: 3.3',
4726
'Programming Language :: Python :: 3.4',
48-
'Programming Language :: Python :: Implementation :: PyPy',
27+
'Programming Language :: Python :: 3.5',
28+
'Framework :: Django',
29+
'Framework :: Django :: 1.8',
30+
'Framework :: Django :: 1.9',
4931
],
5032
packages=find_packages(exclude=[
5133
"*.tests", "*.tests.*", "tests.*", "tests", ".egg-info"
@@ -55,5 +37,4 @@ def run(self):
5537
'pillow>=2.5',
5638
'progressbar2>=3.0.0',
5739
],
58-
cmdclass={'test': PyTest},
5940
)

stdimage/management/commands/rendervariations.py

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@
77
from multiprocessing import Pool, cpu_count
88

99
import progressbar
10+
from django.apps import apps
1011
from django.core.management import BaseCommand
11-
from django.db.models import get_model
1212

1313
from stdimage.utils import render_variations
1414

15-
is_pypy = '__pypy__' in sys.builtin_module_names
1615
BAR = None
1716

1817

@@ -38,7 +37,7 @@ def handle(self, *args, **options):
3837
replace = options.get('replace')
3938
for route in args:
4039
app_label, model_name, field_name = route.rsplit('.')
41-
model_class = get_model(app_label, model_name)
40+
model_class = apps.get_model(app_label, model_name)
4241
field = model_class._meta.get_field(field_name)
4342

4443
queryset = model_class._default_manager \
@@ -47,13 +46,10 @@ def handle(self, *args, **options):
4746
images = queryset.values_list(field_name, flat=True).iterator()
4847
count = queryset.count()
4948

50-
if is_pypy: # pypy doesn't handle multiprocessing to well
51-
self.render_linear(field, images, count, replace)
52-
else:
53-
self.render_in_parallel(field, images, count, replace)
49+
self.render(field, images, count, replace)
5450

5551
@staticmethod
56-
def render_in_parallel(field, images, count, replace):
52+
def render(field, images, count, replace):
5753
pool = Pool(
5854
initializer=init_progressbar,
5955
initargs=[count]
@@ -72,22 +68,6 @@ def render_in_parallel(field, images, count, replace):
7268
pool.close()
7369
pool.join()
7470

75-
@staticmethod
76-
def render_linear(field, images, count, replace):
77-
init_progressbar(count)
78-
args_list = [
79-
dict(
80-
file_name=file_name,
81-
variations=field.variations,
82-
replace=replace,
83-
storage=field.storage
84-
)
85-
for file_name in images
86-
]
87-
for args in args_list:
88-
render_variations(**args)
89-
finish_progressbar()
90-
9171

9272
def init_progressbar(count):
9373
global BAR

tests/test_models.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class UUID4Monkey(object):
1313

1414
uuid.__dict__['uuid4'] = lambda: UUID4Monkey()
1515

16+
import django # NoQA
1617
from django.conf import settings # NoQA
1718
from django.core.files import File # NoQA
1819
from django.test import TestCase # NoQA
@@ -174,9 +175,14 @@ def test_pre_save_delete_callback_clear(self):
174175
AdminDeleteModel.objects.create(
175176
image=self.fixtures['100.gif']
176177
)
177-
self.client.post('/admin/tests/admindeletemodel/1/', {
178-
'image-clear': 'checked',
179-
})
178+
if django.VERSION >= (1, 9):
179+
self.client.post('/admin/tests/admindeletemodel/1/change/', {
180+
'image-clear': 'checked',
181+
})
182+
else:
183+
self.client.post('/admin/tests/admindeletemodel/1/', {
184+
'image-clear': 'checked',
185+
})
180186
self.assertFalse(
181187
os.path.exists(os.path.join(IMG_DIR, 'image.gif'))
182188
)
@@ -185,9 +191,14 @@ def test_pre_save_delete_callback_new(self):
185191
AdminDeleteModel.objects.create(
186192
image=self.fixtures['100.gif']
187193
)
188-
self.client.post('/admin/tests/admindeletemodel/1/', {
189-
'image': self.fixtures['600x400.jpg'],
190-
})
194+
if django.VERSION >= (1, 9):
195+
self.client.post('/admin/tests/admindeletemodel/1/change/', {
196+
'image': self.fixtures['600x400.jpg'],
197+
})
198+
else:
199+
self.client.post('/admin/tests/admindeletemodel/1/', {
200+
'image': self.fixtures['600x400.jpg'],
201+
})
191202
self.assertFalse(
192203
os.path.exists(os.path.join(IMG_DIR, 'image.gif'))
193204
)

0 commit comments

Comments
 (0)