Skip to content

Commit

Permalink
use sixer
Browse files Browse the repository at this point in the history
  • Loading branch information
jensens committed Jan 25, 2018
1 parent a14968a commit f5f7c18
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 26 deletions.
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ New features:

Bug fixes:
- Imports are Python3 compatible
[ale-rt]
[ale-rt, jensens]

- Fix serialization of query variables for selector links in Zope 4.
[davisagli]
Expand Down
9 changes: 0 additions & 9 deletions src/plone/app/multilingual/_compat.py

This file was deleted.

2 changes: 1 addition & 1 deletion src/plone/app/multilingual/browser/helper_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def getClosestDestination(self):
if prefered in languages:
context = languages[prefered]
else:
context = languages[languages.keys()[0]]
context = languages[list(languages.keys())[0]]

checkPermission = getSecurityManager().checkPermission
chain = self.getParentChain(context)
Expand Down
4 changes: 2 additions & 2 deletions src/plone/app/multilingual/browser/migrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def step1andstep2(self):
'/'.join(content.getPhysicalPath()),
'/'.join(target_folder.getPhysicalPath()))
log = logger.info
except Exception, err:
except Exception as err:
info_str = "ERROR. Step 2: not possible to move " \
"object %s to folder %s. Error: %s" % (
'/'.join(content.getPhysicalPath()),
Expand Down Expand Up @@ -256,7 +256,7 @@ def step3(self):
info_str = "Moved object %s to language root folder "\
"%s" % (old_path, lang)
log = logger.info
except Exception, err:
except Exception as err:
info_str = "ERROR. Step 3: not possible to move "\
"object %s to root language folder %s. Error: %s"\
% (old_path, lang, err)
Expand Down
2 changes: 1 addition & 1 deletion src/plone/app/multilingual/browser/modify.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def __call__(self):
manager = ITranslationManager(context)
try:
manager.remove_translation(language)
except Exception, e:
except Exception as e:
messages = IStatusMessage(self.request)
messages.addStatusMessage(e, type='error')

Expand Down
7 changes: 5 additions & 2 deletions src/plone/app/multilingual/browser/selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,22 @@
from zope.component.hooks import getSite


import six


def addQuery(request, url, exclude=tuple(), **extras):
"""Adds the incoming GET query to the end of the url
so that is propagated through the redirect hoops
"""
formvariables = {}
for k, v in request.form.items():
if k not in exclude:
if isinstance(v, unicode):
if isinstance(v, six.text_type):
formvariables[k] = v.encode('utf-8')
else:
formvariables[k] = v
for k, v in extras.items():
if isinstance(v, unicode):
if isinstance(v, six.text_type):
formvariables[k] = v.encode('utf-8')
else:
formvariables[k] = v
Expand Down
4 changes: 2 additions & 2 deletions src/plone/app/multilingual/browser/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def linkTranslations(self):

try:
canonical = ITranslationManager(self.folders[self.defaultLanguage])
except TypeError, e:
except TypeError as e:
raise TypeError(str(e) + u' Are your folders ITranslatable?')

for language in self.languages:
Expand Down Expand Up @@ -234,7 +234,7 @@ def resetDefaultPage(self):

try:
target.manage_pasteObjects(objects)
except ValueError, exc:
except ValueError as exc:
# This portal_type may not be allowed. This should not be
# fatal, so we only log a warning.
logger.warn((u"Could not move default page '{0:s}' j"
Expand Down
11 changes: 6 additions & 5 deletions src/plone/app/multilingual/browser/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
from plone.uuid.interfaces import IUUID
from zope.component import getUtility
import json
import urllib

from six.moves import urllib


def google_translate(question, key, lang_target, lang_source):
Expand All @@ -27,19 +28,19 @@ def google_translate(question, key, lang_target, lang_source):
'target': lang_target,
'source': lang_source,
'q': temp_question}
params = urllib.urlencode(data)
params = urllib.parse.urlencode(data)

retorn = urllib.urlopen(url + '?' + params)
retorn = urllib.request.urlopen(url + '?' + params)
translated += json.loads(
retorn.read())['data']['translations'][0]['translatedText']

data = {'key': key,
'target': lang_target,
'source': lang_source,
'q': temp_question}
params = urllib.urlencode(data)
params = urllib.parse.urlencode(data)

retorn = urllib.urlopen(url + '?' + params)
retorn = urllib.request.urlopen(url + '?' + params)
translated += json.loads(
retorn.read())['data']['translations'][0]['translatedText']
return json.dumps({'data': translated})
Expand Down
3 changes: 2 additions & 1 deletion src/plone/app/multilingual/browser/viewlets.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
from plone.app.multilingual.interfaces import ITranslatable
from plone.app.multilingual.interfaces import ITranslationManager
from plone.memoize import ram
from urllib import quote_plus

from six.moves.urllib.parse import quote_plus


def _cache_until_catalog_change(fun, self):
Expand Down
2 changes: 1 addition & 1 deletion src/plone/app/multilingual/dx/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def get(self):

if len(result) >= 1:

orig_lang = result.keys()[0]
orig_lang = list(result.keys())[0]
obj = result[orig_lang]
name = self.field.__name__
# XXX
Expand Down
4 changes: 3 additions & 1 deletion src/plone/app/multilingual/tests/test_sitemap.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
from gzip import GzipFile
from plone.app.multilingual._compat import StringIO
from plone.app.multilingual.interfaces import IPloneAppMultilingualInstalled
from plone.app.multilingual.testing import PAM_FUNCTIONAL_TESTING
from plone.dexterity.utils import createContentInContainer
Expand All @@ -13,6 +12,9 @@
import unittest


from six import StringIO


# This class largely inspired by plone/app/layout/sitemap/tests/test_sitemap.py
class TestSitemap(unittest.TestCase):
layer = PAM_FUNCTIONAL_TESTING
Expand Down

0 comments on commit f5f7c18

Please sign in to comment.