Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Sep 22, 2020. It is now read-only.
Closed
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
10 changes: 10 additions & 0 deletions 10 .frigg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,19 @@ tasks:
- tox -e flake8
- tox -e isort
- tox -e py34-pillow
- tox -e py27-pillow
- tox -e py34-pgmagick
- tox -e py27-pgmagick
- tox -e py34-wand
- tox -e py27-wand
- tox -e py34-django17
- tox -e py27-django17
- tox -e py34-django18
- tox -e py27-django18
- tox -e py34-redis
- tox -e py27-redis
- flake8
- isort -rc -c thumbnails tests
- coverage combine && coverage report && coverage xml
- tox -e docs

Expand Down
5 changes: 4 additions & 1 deletion 5 CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Changes since last release
~~~~~~~~~~~~~~~~~~~~~~~~~~
Nothing yet.

0.6.0
~~~~~
- Reintroduce support for Python 2

0.5.0
~~~~~
Expand Down
1 change: 1 addition & 0 deletions 1 setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def _read_long_description():
classifiers=[
'Development Status :: 4 - Beta',
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.4',
]
)
8 changes: 8 additions & 0 deletions 8 tests/compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-
import six

if six.PY3:
from unittest import mock # noqa

elif six.PY2:
import mock # noqa
2 changes: 1 addition & 1 deletion 2 tests/test_cache_backends.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
import unittest
from unittest import mock

from thumbnails.cache_backends import (BaseCacheBackend, DjangoCacheBackend, RedisCacheBackend,
SimpleCacheBackend)
from thumbnails.images import Thumbnail

from .compat import mock
from .utils import has_installed


Expand Down
19 changes: 19 additions & 0 deletions 19 tests/test_compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
import os
import shutil
import unittest

from thumbnails.compat import makedirs


class CompatTestCase(unittest.TestCase):

def test_makedirs(self):
path = os.path.join(os.getcwd(), 'makedirs-test/folders')
makedirs(path, exist_ok=True)
makedirs(path, exist_ok=True)

with self.assertRaises(OSError):
makedirs(path)

shutil.rmtree(os.path.dirname(path))
2 changes: 1 addition & 1 deletion 2 tests/test_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
import os
import unittest
from copy import deepcopy
from unittest import mock

from thumbnails.conf.wrapper import SettingsWrapper

from .compat import mock
from .utils import has_installed


Expand Down
2 changes: 1 addition & 1 deletion 2 tests/test_engines.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import hashlib
import os
import unittest
from unittest import mock

from PIL import Image

Expand All @@ -11,6 +10,7 @@
from thumbnails.errors import ThumbnailError
from thumbnails.images import SourceFile, Thumbnail

from .compat import mock
from .utils import is_tox_env


Expand Down
4 changes: 2 additions & 2 deletions 4 tests/test_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
import hashlib
import os
import unittest
from io import BytesIO
from unittest import mock

from PIL import Image

from thumbnails.compat import BytesIO
from thumbnails.conf import settings
from thumbnails.images import SourceFile, Thumbnail

from . import data
from .compat import mock
from .utils import has_installed


Expand Down
2 changes: 1 addition & 1 deletion 2 tests/test_init.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
import unittest
from unittest import mock

from thumbnails import get_thumbnail
from thumbnails.conf import settings
from thumbnails.images import Thumbnail

from .compat import mock
from .utils import override_settings


Expand Down
2 changes: 1 addition & 1 deletion 2 tests/test_templatetags.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
import unittest
from unittest import mock

from thumbnails import settings

from .compat import mock
from .utils import has_installed

try:
Expand Down
19 changes: 19 additions & 0 deletions 19 thumbnails/compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
import errno

import six

BytesIO = six.BytesIO
StringIO = six.StringIO

if six.PY3:
from os import makedirs
else:
from os import makedirs as os_makedirs

def makedirs(name, mode=0o777, exist_ok=False):
try:
os_makedirs(name, mode)
except OSError as e:
if e.errno != errno.EEXIST or not exist_ok:
raise
6 changes: 4 additions & 2 deletions 6 thumbnails/conf/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import json
import os

from thumbnails.compat import makedirs

from . import defaults


Expand All @@ -27,8 +29,8 @@ def __init__(self):
pass

if not os.path.exists(self.THUMBNAIL_PATH):
os.makedirs(os.path.dirname(self.THUMBNAIL_PATH), exist_ok=True)
os.makedirs(self.THUMBNAIL_PATH, exist_ok=True)
makedirs(os.path.dirname(self.THUMBNAIL_PATH), exist_ok=True)
makedirs(self.THUMBNAIL_PATH, exist_ok=True)

def __getattr__(self, key):
value = self.defaults.get(key, 'unknown setting')
Expand Down
2 changes: 1 addition & 1 deletion 2 thumbnails/engines/pillow_engine.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from io import BytesIO

from thumbnails.compat import BytesIO
from thumbnails.errors import ThumbnailError

from .base import BaseThumbnailEngine
Expand Down
2 changes: 1 addition & 1 deletion 2 thumbnails/images.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# -*- coding: utf-8 -*-
import base64
import os
from io import BytesIO

import requests

from thumbnails.compat import BytesIO
from thumbnails.conf import settings
from thumbnails.helpers import get_engine, get_storage_backend

Expand Down
6 changes: 3 additions & 3 deletions 6 thumbnails/storage_backends.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# -*- coding: utf-8 -*-
import codecs
import os
from io import BytesIO

from thumbnails import helpers

from .compat import BytesIO, makedirs
from .conf import settings


Expand Down Expand Up @@ -51,7 +51,7 @@ class FilesystemStorageBackend(BaseStorageBackend):
def __init__(self):
super(FilesystemStorageBackend, self).__init__()
if not os.path.exists(self.location):
os.makedirs(self.location, exist_ok=True)
makedirs(self.location, exist_ok=True)

def _open(self, name, mode='rb', encoding=None, errors='strict'):
return codecs.open(name, mode=mode, encoding=encoding, errors=errors)
Expand All @@ -61,7 +61,7 @@ def _exists(self, name):

def _save(self, name, data):
if not os.path.exists(os.path.dirname(name)):
os.makedirs(os.path.dirname(name), exist_ok=True)
makedirs(os.path.dirname(name), exist_ok=True)

with open(name, 'wb') as f:
f.write(data)
Expand Down
6 changes: 3 additions & 3 deletions 6 tox.ini
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[tox]
envlist =
flake8,isort,
{py34}-{pillow,wand,pgmagick},
{py34}-{django17,django18,redis},
docs
{py27,py34}-{pillow,wand,pgmagick},
{py27,py34}-{django17,django18,redis},
py34-docs
skipsdist = True

[testenv]
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.