Skip to content

Commit

Permalink
pyupgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
jensens committed Aug 25, 2022
1 parent 894ee62 commit 2f9c1c5
Show file tree
Hide file tree
Showing 19 changed files with 43 additions and 68 deletions.
1 change: 0 additions & 1 deletion plone/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# -*- coding: utf-8 -*-
__import__("pkg_resources").declare_namespace(__name__)
1 change: 0 additions & 1 deletion plone/outputfilters/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
def apply_filters(filters, data):
by_order = lambda x: x.order
filters = sorted(filters, key=by_order)
Expand Down
1 change: 0 additions & 1 deletion plone/outputfilters/browser/captioned_image.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from Products.Five import BrowserView
from zope.cachedescriptors.property import Lazy as lazy_property

Expand Down
1 change: 0 additions & 1 deletion plone/outputfilters/browser/resolveuid.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from Acquisition import aq_base
from Products.CMFCore.utils import getToolByName
from zExceptions import NotFound
Expand Down
3 changes: 1 addition & 2 deletions plone/outputfilters/filters/example.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# -*- coding: utf-8 -*-
from plone.outputfilters.interfaces import IFilter
from zope.interface import implementer

import re


@implementer(IFilter)
class EmDashAdder(object):
class EmDashAdder:
order = 1000

def __init__(self, context, request):
Expand Down
4 changes: 2 additions & 2 deletions plone/outputfilters/filters/picture_variants.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


@implementer(IFilter)
class PictureVariantsFilter(object):
class PictureVariantsFilter:
"""Converts img tags with a data-picturevariant attribute into picture/source tag's with srcset definitions."""

order = 700
Expand All @@ -39,7 +39,7 @@ def __call__(self, data):
picture_variants_config = get_picture_variants().get(picture_variant_name)
if not picture_variants_config:
logger.warn(
"Could not find the given picture_variant_name {0}, leave tag untouched!".format(
"Could not find the given picture_variant_name {}, leave tag untouched!".format(
picture_variant_name
)
)
Expand Down
61 changes: 29 additions & 32 deletions plone/outputfilters/filters/resolveuid_and_caption.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from Acquisition import aq_acquire
from Acquisition import aq_base
from Acquisition import aq_inner
Expand All @@ -11,10 +10,10 @@
from plone.registry.interfaces import IRegistry
from Products.CMFCore.interfaces import IContentish
from Products.CMFPlone.utils import safe_unicode
from six.moves.urllib.parse import unquote
from six.moves.urllib.parse import urljoin
from six.moves.urllib.parse import urlsplit
from six.moves.urllib.parse import urlunsplit
from urllib.parse import unquote
from urllib.parse import urljoin
from urllib.parse import urlsplit
from urllib.parse import urlunsplit
from zExceptions import NotFound
from ZODB.POSException import ConflictError
from zope.cachedescriptors.property import Lazy as lazy_property
Expand Down Expand Up @@ -45,7 +44,7 @@ class IResolveUidsEnabler(Interface):


@implementer(IImageCaptioningEnabler)
class ImageCaptioningEnabler(object):
class ImageCaptioningEnabler:
@property
def available(self):
name = "plone.image_captioning"
Expand All @@ -56,7 +55,7 @@ def available(self):


@implementer(IResolveUidsEnabler)
class ResolveUidsAlwaysEnabled(object):
class ResolveUidsAlwaysEnabled:
available = True


Expand All @@ -66,32 +65,30 @@ def tag(img, **attributes):


@implementer(IFilter)
class ResolveUIDAndCaptionFilter(object):
class ResolveUIDAndCaptionFilter:
"""Parser to convert UUID links and captioned images"""

singleton_tags = set(
[
"area",
"base",
"basefont",
"br",
"col",
"command",
"embed",
"frame",
"hr",
"img",
"input",
"isindex",
"keygen",
"link",
"meta",
"param",
"source",
"track",
"wbr",
]
)
singleton_tags = {
"area",
"base",
"basefont",
"br",
"col",
"command",
"embed",
"frame",
"hr",
"img",
"input",
"isindex",
"keygen",
"link",
"meta",
"param",
"source",
"track",
"wbr",
}

def __init__(self, context=None, request=None):
self.current_status = None
Expand Down Expand Up @@ -253,7 +250,7 @@ def __call__(self, data):
else:
del captioned.img["class"]
elem.replace_with(captioned)
return six.text_type(soup)
return str(soup)

def resolve_scale_data(self, url):
"""return scale url, width and height"""
Expand Down
1 change: 0 additions & 1 deletion plone/outputfilters/interfaces.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from zope import schema
from zope.interface import Interface

Expand Down
1 change: 0 additions & 1 deletion plone/outputfilters/mimetype.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from Products.MimetypesRegistry.MimeTypeItem import MimeTypeItem


Expand Down
1 change: 0 additions & 1 deletion plone/outputfilters/setuphandlers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from plone.outputfilters.mimetype import text_plone_outputfilters_html
from plone.outputfilters.transforms.html_to_plone_outputfilters_html import (
html_to_plone_outputfilters_html,
Expand Down
3 changes: 1 addition & 2 deletions plone/outputfilters/testing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from plone.app.contenttypes.testing import PLONE_APP_CONTENTTYPES_FIXTURE
from plone.app.testing import applyProfile
from plone.app.testing import FunctionalTesting
Expand All @@ -13,7 +12,7 @@


@implementer(IImageCaptioningEnabler)
class DummyImageCaptioningEnabler(object):
class DummyImageCaptioningEnabler:

available = True

Expand Down
3 changes: 1 addition & 2 deletions plone/outputfilters/tests/test_apply_filters.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# -*- coding: utf-8 -*-
from plone.outputfilters import apply_filters

import unittest


class DummyFilter(object):
class DummyFilter:
order = 500

def is_enabled(self):
Expand Down
8 changes: 1 addition & 7 deletions plone/outputfilters/tests/test_docs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from plone.outputfilters.testing import PLONE_OUTPUTFILTERS_FUNCTIONAL_TESTING
from plone.testing import layered

Expand All @@ -12,12 +11,7 @@
doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE | doctest.REPORT_ONLY_FIRST_FAILURE
)

if six.PY3:
normal_testfiles = ["../README.rst"]
else:
normal_testfiles = [
"./README_py2.rst",
]
normal_testfiles = ["../README.rst"]


def test_suite():
Expand Down
5 changes: 2 additions & 3 deletions plone/outputfilters/tests/test_picture_variants.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from doctest import _ellipsis_match
from doctest import OutputChecker
from doctest import REPORT_NDIFF
Expand Down Expand Up @@ -83,7 +82,7 @@ def _assertTransformsTo(self, input, expected):
self.assertTrue(_ellipsis_match(normalized_expected, normalized_out))
except AssertionError:

class wrapper(object):
class wrapper:
want = expected

raise AssertionError(
Expand Down Expand Up @@ -166,7 +165,7 @@ def test_parsing_long_doc(self):
startTime = time.time()
res = self.parser(text)
executionTime = time.time() - startTime
print("\n\nimage srcset parsing time: {}\n".format(executionTime))
print(f"\n\nimage srcset parsing time: {executionTime}\n")
self.assertTrue(res)

text_out = """<h1>Welcome!</h1>
Expand Down
11 changes: 5 additions & 6 deletions plone/outputfilters/tests/test_resolveuid_and_caption.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from doctest import _ellipsis_match
from doctest import OutputChecker
from doctest import REPORT_NDIFF
Expand Down Expand Up @@ -88,7 +87,7 @@ def _assertTransformsTo(self, input, expected, parsing=True):
self.assertTrue(_ellipsis_match(normalized_expected, normalized_out))
except AssertionError:

class wrapper(object):
class wrapper:
want = expected

raise AssertionError(
Expand Down Expand Up @@ -186,7 +185,7 @@ def test_parsing_long_doc(self):
startTime = time.time()
res = self.parser(text)
executionTime = time.time() - startTime
print("\n\nresolve_uid_and_caption parsing time: {}\n".format(executionTime))
print(f"\n\nresolve_uid_and_caption parsing time: {executionTime}\n")
self.assertTrue(res)

def test_parsing_preserves_newlines(self):
Expand All @@ -212,10 +211,10 @@ def test_resolve_uids_in_links(self):
text = """<html>
<head></head>
<body>
<a class="internal-link" href="resolveuid/%s">Some link</a>
<a class="internal-link" href="resolveuid/%s#named-anchor">Some anchored link</a>
<a class="internal-link" href="resolveuid/{}">Some link</a>
<a class="internal-link" href="resolveuid/{}#named-anchor">Some anchored link</a>
</body>
</html>""" % (
</html>""".format(
self.UID,
self.UID,
)
Expand Down
1 change: 0 additions & 1 deletion plone/outputfilters/tests/test_transforms.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from plone.app.testing import setRoles
from plone.app.testing import TEST_USER_ID
from plone.outputfilters.testing import PLONE_OUTPUTFILTERS_INTEGRATION_TESTING
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from plone.outputfilters import apply_filters
from plone.outputfilters.interfaces import IFilter
from Products.PortalTransforms.interfaces import ITransform
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# -*- coding: utf-8 -*-
from Products.PortalTransforms.interfaces import ITransform
from zope.interface import implementer


@implementer(ITransform)
class plone_outputfilters_html_to_html(object):
class plone_outputfilters_html_to_html:

__name__ = "plone_outputfilters_html_to_html"
inputs = ("text/x-plone-outputfilters-html",)
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from setuptools import find_packages
from setuptools import setup

Expand Down

0 comments on commit 2f9c1c5

Please sign in to comment.