Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Imports are Python3 compatible #34

Merged
merged 2 commits into from
Jan 28, 2018
Merged
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
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ New features:

Bug fixes:

- *add item here*
- Imports are Python3 compatible
[ale-rt]


2.0.6 (2016-12-19)
Expand Down
12 changes: 8 additions & 4 deletions src/plone/app/imaging/monkey.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
# -*- coding: utf-8 -*-
from Acquisition import aq_base
from cStringIO import StringIO
from logging import getLogger
from plone.app.imaging.interfaces import IImageScaleHandler
from plone.app.imaging.utils import getAllowedSizes, getQuality
from plone.app.imaging.utils import getAllowedSizes
from plone.app.imaging.utils import getQuality
from Products.Archetypes.Field import ImageField
from Products.Archetypes.utils import shasattr
from Products.ATContentTypes.content.image import ATImageSchema
from Products.ATContentTypes.content.newsitem import ATNewsItemSchema
from six import StringIO

import six


logger = getLogger(__name__)

Expand All @@ -29,7 +33,7 @@ def getAvailableSizes(self, instance):
sizes = getattr(aq_base(self), 'sizes', None)
if isinstance(sizes, dict):
return sizes
elif isinstance(sizes, basestring):
elif isinstance(sizes, six.string_types):
assert(shasattr(instance, sizes))
method = getattr(instance, sizes)
data = method()
Expand Down Expand Up @@ -60,7 +64,7 @@ def scale(self, data, w, h, default_format='PNG'):
""" use our quality setting as pil_quality """
pil_quality = getQuality()

#make sure we have valid int's
# make sure we have valid int's
size = int(w), int(h)

original_file = StringIO(data)
Expand Down
11 changes: 6 additions & 5 deletions src/plone/app/imaging/tests/base.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# -*- coding: utf-8 -*-
from plone.app.testing.bbb import PloneTestCase
from plone.testing.z2 import Browser
from os.path import dirname
from os.path import join
from plone.app.imaging import testing
from StringIO import StringIO
from os.path import dirname, join
from plone.app.testing import TEST_USER_NAME
from plone.app.testing import TEST_USER_PASSWORD
from zope.component import queryUtility
from plone.app.testing.bbb import PloneTestCase
from plone.registry.interfaces import IRegistry
from plone.testing.z2 import Browser
from Products.CMFPlone.interfaces.controlpanel import IImagingSchema
from six import StringIO
from zope.component import queryUtility


def getSettings():
Expand Down
11 changes: 6 additions & 5 deletions src/plone/app/imaging/tests/test_scaling.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# -*- coding: utf-8 -*-
from plone.app.imaging.tests.base import ImagingTestCase
from PIL.Image import open
from six import StringIO
from plone.app.imaging.tests.base import getSettings
from plone.app.imaging.tests.base import ImagingFunctionalTestCase
from plone.app.imaging.traverse import ImageTraverser
from plone.app.imaging.tests.base import ImagingTestCase
from plone.app.imaging.traverse import DefaultImageScaleHandler
from StringIO import StringIO
from PIL.Image import open
from plone.app.imaging.traverse import ImageTraverser

import transaction
from plone.app.imaging.tests.base import getSettings


class TraverseCounterMixin:
Expand Down
5 changes: 4 additions & 1 deletion src/plone/app/imaging/traverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
from zope.globalrequest import getRequest


import six


class ImageTraverser(DefaultPublishTraverse):
""" traversal adapter for scaled down versions of image content """
adapts(IBaseObject, IRequest)
Expand Down Expand Up @@ -57,7 +60,7 @@ def getScale(self, instance, scale):
if data is not None:
self.storeScale(instance, scale, **data)
image = self.retrieveScale(instance, scale=scale)
if image is not None and not isinstance(image, basestring):
if image is not None and not isinstance(image, six.string_types):
return image
return None

Expand Down