From 627f0a864676f211aacde5644b4172dcd45e448b Mon Sep 17 00:00:00 2001 From: Maurits van Rees Date: Mon, 20 Dec 2021 23:25:23 +0100 Subject: [PATCH] Get rid of Python 2 code. pyupgrade --py37-plus --- Products/CMFDynamicViewFTI/__init__.py | 1 - Products/CMFDynamicViewFTI/browser/__init__.py | 1 - Products/CMFDynamicViewFTI/browser/typeinfo.py | 3 +-- Products/CMFDynamicViewFTI/browserdefault.py | 7 +++---- Products/CMFDynamicViewFTI/content_for_tests.py | 1 - Products/CMFDynamicViewFTI/fti.py | 9 ++++----- Products/CMFDynamicViewFTI/interface.py | 1 - Products/CMFDynamicViewFTI/interfaces.py | 1 - Products/CMFDynamicViewFTI/permissions.py | 1 - Products/CMFDynamicViewFTI/tests/CMFDVFTITestCase.py | 1 - Products/CMFDynamicViewFTI/tests/__init__.py | 1 - Products/CMFDynamicViewFTI/tests/test_browserdefault.py | 3 +-- Products/CMFDynamicViewFTI/tests/test_fti.py | 3 +-- setup.py | 1 - 14 files changed, 10 insertions(+), 24 deletions(-) diff --git a/Products/CMFDynamicViewFTI/__init__.py b/Products/CMFDynamicViewFTI/__init__.py index 196c127..bba4fc4 100644 --- a/Products/CMFDynamicViewFTI/__init__.py +++ b/Products/CMFDynamicViewFTI/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from Products.CMFCore import utils as cmf_utils from Products.CMFCore.permissions import AddPortalContent from Products.CMFCore.permissions import AddPortalFolders diff --git a/Products/CMFDynamicViewFTI/browser/__init__.py b/Products/CMFDynamicViewFTI/browser/__init__.py index 9053d82..8b2a76f 100644 --- a/Products/CMFDynamicViewFTI/browser/__init__.py +++ b/Products/CMFDynamicViewFTI/browser/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Browser subpackage """ diff --git a/Products/CMFDynamicViewFTI/browser/typeinfo.py b/Products/CMFDynamicViewFTI/browser/typeinfo.py index 62f9140..9fced65 100644 --- a/Products/CMFDynamicViewFTI/browser/typeinfo.py +++ b/Products/CMFDynamicViewFTI/browser/typeinfo.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Add DynamicView FTI form (ZMI) """ @@ -13,4 +12,4 @@ class DVFactoryTypeInformationAddView(FactoryTypeInformationAddView): klass = DynamicViewTypeInformation - description = u'A dynamic view type information object defines a portal type.' + description = 'A dynamic view type information object defines a portal type.' diff --git a/Products/CMFDynamicViewFTI/browserdefault.py b/Products/CMFDynamicViewFTI/browserdefault.py index 8380824..c3e1bb3 100644 --- a/Products/CMFDynamicViewFTI/browserdefault.py +++ b/Products/CMFDynamicViewFTI/browserdefault.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """Mixin class for selectable views This module contains a mixin-class to support selecting default layout @@ -163,7 +162,7 @@ def setLayout(self, layout): # 'layout' should be one of the list returned by getAvailableLayouts(), # but it is not enforced. If a default page has been set with # setDefaultPage(), it is turned off by calling setDefaultPage(None). - if not (layout and isinstance(layout, six.string_types)): + if not (layout and isinstance(layout, str)): raise ValueError( "layout must be a non empty string, got %s(%s)" % (layout, type(layout)) @@ -179,7 +178,7 @@ def setLayout(self, layout): if getattr(aq_base(self), 'layout', _marker) is not _marker: # Archetypes remains? clean up old = self.layout - if old and not isinstance(old, six.string_types): + if old and not isinstance(old, str): raise RuntimeError( "layout attribute exists on %s and is no string: %s" % (self, type(old)) @@ -216,7 +215,7 @@ def getAvailableLayouts(self): spec = (providedBy(self), providedBy(self.REQUEST)) gsm = getSiteManager() for mid in method_ids: - if not isinstance(mid, six.string_types): + if not isinstance(mid, str): mid = mid.decode() factory = gsm.adapters.lookup(spec, Interface, mid) if factory is not None: diff --git a/Products/CMFDynamicViewFTI/content_for_tests.py b/Products/CMFDynamicViewFTI/content_for_tests.py index db6fc89..be1e028 100644 --- a/Products/CMFDynamicViewFTI/content_for_tests.py +++ b/Products/CMFDynamicViewFTI/content_for_tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from Products.CMFCore.PortalFolder import PortalFolder from Products.CMFCore.PortalContent import PortalContent from Products.CMFDynamicViewFTI.browserdefault import BrowserDefaultMixin diff --git a/Products/CMFDynamicViewFTI/fti.py b/Products/CMFDynamicViewFTI/fti.py index 3997a6e..404f95b 100644 --- a/Products/CMFDynamicViewFTI/fti.py +++ b/Products/CMFDynamicViewFTI/fti.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from AccessControl import ClassSecurityInfo from Acquisition import aq_base from AccessControl.class_init import InitializeClass @@ -108,7 +107,7 @@ def manage_changeProperties(self, **kw): if not view_methods: self.view_methods = view_methods = (default_view, ) if default_view and default_view not in view_methods: - raise ValueError("%s not in %s" % (default_view, view_methods)) + raise ValueError(f"{default_view} not in {view_methods}") @security.protected(View) def getDefaultViewMethod(self, context): @@ -119,7 +118,7 @@ def getDefaultViewMethod(self, context): def getAvailableViewMethods(self, context): # Get a list of registered view methods. methods = self.view_methods - if isinstance(methods, six.string_types): + if isinstance(methods, str): methods = (methods, ) return tuple(methods) @@ -139,7 +138,7 @@ def getViewMethod( layout = layout() if not layout: return default - if not isinstance(layout, six.string_types): + if not isinstance(layout, str): raise TypeError( "layout of %s must be a string, got %s" % (repr(context), type(layout)) @@ -223,7 +222,7 @@ def queryMethodID(self, alias, default=None, context=None): default=default, context=context ) - if not isinstance(methodTarget, six.string_types): + if not isinstance(methodTarget, str): # nothing to do, method_id is probably None return methodTarget diff --git a/Products/CMFDynamicViewFTI/interface.py b/Products/CMFDynamicViewFTI/interface.py index 309af6a..1805e3d 100644 --- a/Products/CMFDynamicViewFTI/interface.py +++ b/Products/CMFDynamicViewFTI/interface.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # BBB module will be removed at some point. We will still need it as long as # we plan to support Plone 4.3.x from Products.CMFDynamicViewFTI.interfaces import * diff --git a/Products/CMFDynamicViewFTI/interfaces.py b/Products/CMFDynamicViewFTI/interfaces.py index 6f0b3af..452394e 100644 --- a/Products/CMFDynamicViewFTI/interfaces.py +++ b/Products/CMFDynamicViewFTI/interfaces.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from Products.CMFCore.interfaces import ITypeInformation from zope.interface import Interface diff --git a/Products/CMFDynamicViewFTI/permissions.py b/Products/CMFDynamicViewFTI/permissions.py index fd86b13..19d7400 100644 --- a/Products/CMFDynamicViewFTI/permissions.py +++ b/Products/CMFDynamicViewFTI/permissions.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from AccessControl.Permission import addPermission ModifyViewTemplate = "Modify view template" diff --git a/Products/CMFDynamicViewFTI/tests/CMFDVFTITestCase.py b/Products/CMFDynamicViewFTI/tests/CMFDVFTITestCase.py index 9d8ac08..be0f462 100644 --- a/Products/CMFDynamicViewFTI/tests/CMFDVFTITestCase.py +++ b/Products/CMFDynamicViewFTI/tests/CMFDVFTITestCase.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from plone.app import testing from plone.app.testing import PLONE_FIXTURE from plone.app.testing import PloneSandboxLayer diff --git a/Products/CMFDynamicViewFTI/tests/__init__.py b/Products/CMFDynamicViewFTI/tests/__init__.py index 40a96af..e69de29 100644 --- a/Products/CMFDynamicViewFTI/tests/__init__.py +++ b/Products/CMFDynamicViewFTI/tests/__init__.py @@ -1 +0,0 @@ -# -*- coding: utf-8 -*- diff --git a/Products/CMFDynamicViewFTI/tests/test_browserdefault.py b/Products/CMFDynamicViewFTI/tests/test_browserdefault.py index d94d9fb..cff3bd2 100644 --- a/Products/CMFDynamicViewFTI/tests/test_browserdefault.py +++ b/Products/CMFDynamicViewFTI/tests/test_browserdefault.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from Products.CMFCore.utils import getToolByName from Products.CMFDynamicViewFTI.browserdefault import BrowserDefaultMixin from Products.CMFDynamicViewFTI.interfaces import IBrowserDefault @@ -34,7 +33,7 @@ def test_extendsInterface(self): class TestAvailableLayouts(CMFDVFTITestCase.CMFDVFTITestCase): def setUp(self): - super(TestAvailableLayouts, self).setUp() + super().setUp() self.dfolder = DummyFolder() self.dfolder.fti = self.types['DynFolder'] diff --git a/Products/CMFDynamicViewFTI/tests/test_fti.py b/Products/CMFDynamicViewFTI/tests/test_fti.py index a8e4a51..bc366f9 100644 --- a/Products/CMFDynamicViewFTI/tests/test_fti.py +++ b/Products/CMFDynamicViewFTI/tests/test_fti.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from plone.app.testing import TEST_USER_NAME from plone.app.testing import TEST_USER_PASSWORD from Products.CMFCore.interfaces import ITypeInformation @@ -215,7 +214,7 @@ class TestEmptyLayoutBug(CMFDVFTITestCase.CMFDVFTITestCase): # Finally, here is why we did all this... def setUp(self): - super(TestEmptyLayoutBug, self).setUp() + super().setUp() # Make a DynFolder self.folder.invokeFactory('DynFolder', id='dynfolder') self.dynfolder = self.folder.dynfolder diff --git a/setup.py b/setup.py index 086333e..9c401a7 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from setuptools import find_packages from setuptools import setup