diff --git a/setup.py b/setup.py
index a42bdc1a..4e2a2d8e 100644
--- a/setup.py
+++ b/setup.py
@@ -49,13 +49,13 @@ def read(*pathnames):
python_requires=">=3.8",
install_requires=[
"setuptools",
+ "plone.base",
"plone.supermodel",
"plone.api >= 1.5",
"plone.app.registry",
"plone.app.dexterity",
"plone.synchronize",
"lxml",
- "six >= 1.12",
],
extras_require={
"dev": [
diff --git a/src/collective/taxonomy/__init__.py b/src/collective/taxonomy/__init__.py
index 832c1efa..336acb8b 100644
--- a/src/collective/taxonomy/__init__.py
+++ b/src/collective/taxonomy/__init__.py
@@ -1,5 +1,3 @@
-# -*- coding: utf-8 -*-
-
PATH_SEPARATOR = "\u241F"
LEGACY_PATH_SEPARATOR = "/"
PRETTY_PATH_SEPARATOR = " ยป "
diff --git a/src/collective/taxonomy/behavior.py b/src/collective/taxonomy/behavior.py
index a2e05902..85aabd0e 100644
--- a/src/collective/taxonomy/behavior.py
+++ b/src/collective/taxonomy/behavior.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from collective.taxonomy import generated
from collective.taxonomy.i18n import CollectiveTaxonomyMessageFactory as _
from collective.taxonomy.indexer import TaxonomyIndexer
@@ -7,6 +6,7 @@
from plone.autoform.interfaces import IFormFieldProvider
from plone.autoform.interfaces import WIDGETS_KEY
from plone.autoform.interfaces import WRITE_PERMISSIONS_KEY
+from plone.base.utils import safe_text
from plone.behavior.interfaces import IBehavior
from plone.dexterity.interfaces import IDexterityContent
from plone.indexer.interfaces import IIndexer
@@ -18,7 +18,6 @@
from plone.supermodel.model import Schema
from plone.supermodel.model import SchemaClass
from Products.CMFCore.utils import getToolByName
-from Products.CMFPlone.utils import safe_unicode
from Products.PluginIndexes.KeywordIndex.KeywordIndex import KeywordIndex
from Products.ZCatalog.Catalog import CatalogError
from Products.ZCatalog.interfaces import IZCatalog
@@ -107,7 +106,7 @@ def removeIndex(self):
catalog.delIndex(self.field_name)
except CatalogError:
logging.info(
- "Could not delete index {0} .. something is not right.".format(
+ "Could not delete index {} .. something is not right.".format(
self.field_name
)
)
@@ -119,9 +118,9 @@ def activateSearchable(self):
def add(name, value):
registry.records[prefix + "." + name] = value
- add("title", Record(field.TextLine(), safe_unicode(self.field_title)))
+ add("title", Record(field.TextLine(), safe_text(self.field_title)))
add("enabled", Record(field.Bool(), True))
- add("group", Record(field.TextLine(), safe_unicode("Taxonomy")))
+ add("group", Record(field.TextLine(), safe_text("Taxonomy")))
add(
"operations",
Record(
@@ -130,11 +129,11 @@ def add(name, value):
),
)
add(
- "vocabulary", Record(field.TextLine(), safe_unicode(self.vocabulary_name))
+ "vocabulary", Record(field.TextLine(), safe_text(self.vocabulary_name))
) # noqa: E501
add("fetch_vocabulary", Record(field.Bool(), True))
add("sortable", Record(field.Bool(), False))
- add("description", Record(field.Text(), safe_unicode("")))
+ add("description", Record(field.Text(), safe_text("")))
def addIndex(self):
context = getSite()
@@ -152,7 +151,7 @@ def addIndex(self):
catalog.addIndex(self.field_name, idx_object)
except CatalogError:
logging.info(
- "Index {0} already exists, we hope it is proper configured".format(
+ "Index {} already exists, we hope it is proper configured".format(
self.field_name
) # noqa: E501
)
@@ -163,7 +162,7 @@ def addMetadata(self):
catalog.addColumn(self.field_name)
except CatalogError:
logging.info(
- "Column {0} already exists".format(self.field_name)
+ "Column {} already exists".format(self.field_name)
) # noqa: E501
def unregisterInterface(self):
@@ -195,15 +194,15 @@ def generateInterface(self):
if hasattr(self, "is_single_select") and self.is_single_select:
select_field = schema.Choice(
- title=_(safe_unicode(self.field_title)),
- description=_(safe_unicode(self.field_description)),
+ title=_(safe_text(self.field_title)),
+ description=_(safe_text(self.field_description)),
required=self.is_required,
vocabulary=self.vocabulary_name,
)
else:
select_field = schema.List(
- title=_(safe_unicode(self.field_title)),
- description=_(safe_unicode(self.field_description)),
+ title=_(safe_text(self.field_title)),
+ description=_(safe_text(self.field_description)),
required=self.is_required,
min_length=self.is_required and 1 or 0,
value_type=schema.Choice(
diff --git a/src/collective/taxonomy/browser.py b/src/collective/taxonomy/browser.py
index b2ae276d..89cfa0a3 100644
--- a/src/collective/taxonomy/browser.py
+++ b/src/collective/taxonomy/browser.py
@@ -2,8 +2,8 @@
from plone import api
from plone.app.contenttypes.browser.collection import CollectionView
from plone.app.vocabularies.metadatafields import get_field_label
+from plone.base.utils import safe_callable
from plone.behavior.interfaces import IBehavior
-from Products.CMFPlone.utils import safe_callable
from Products.Five.browser import BrowserView
from zope.component import getSiteManager
from zope.component import queryUtility
@@ -53,7 +53,7 @@ def translate(self, msgid, domain="", target_language=None):
class VocabularyTuplesView(BrowserView):
def __init__(self, context, request, vocabulary):
- super(VocabularyTuplesView, self).__init__(context, request)
+ super().__init__(context, request)
self.vocabulary = vocabulary
def __call__(self, target_language=None):
diff --git a/src/collective/taxonomy/collectionfilter.py b/src/collective/taxonomy/collectionfilter.py
index eaf13f24..55120a72 100644
--- a/src/collective/taxonomy/collectionfilter.py
+++ b/src/collective/taxonomy/collectionfilter.py
@@ -41,7 +41,7 @@ def groupby_modifier(groupby):
behavior = sm.queryUtility(IBehavior, name=taxonomy[1].getGeneratedName())
taxonomy_field_prefix = behavior.field_prefix
taxonomy_shortname = taxonomy[1].getShortName()
- taxonomy_index_name = "{0}{1}".format(taxonomy_field_prefix, taxonomy_shortname)
+ taxonomy_index_name = "{}{}".format(taxonomy_field_prefix, taxonomy_shortname)
groupby._groupby[taxonomy_index_name] = {
"index": taxonomy_index_name,
"metadata": taxonomy_index_name,
diff --git a/src/collective/taxonomy/configure.zcml b/src/collective/taxonomy/configure.zcml
index daf1080d..f5498093 100644
--- a/src/collective/taxonomy/configure.zcml
+++ b/src/collective/taxonomy/configure.zcml
@@ -98,13 +98,13 @@
0:
self.request.RESPONSE.redirect(
- "{0}/@@taxonomy-edit?form.widgets.taxonomy={1}".format(
+ "{}/@@taxonomy-edit?form.widgets.taxonomy={}".format(
self.context.portal_url(), data.get("taxonomies")[0]
)
)
@@ -81,7 +80,7 @@ def handle_edit_taxonomy_data_action(self, action):
data, errors = self.extractData()
if len(data.get("taxonomies", [])) > 0:
self.request.RESPONSE.redirect(
- "{0}/@@taxonomy-edit-data?taxonomy={1}".format(
+ "{}/@@taxonomy-edit-data?taxonomy={}".format(
self.context.portal_url(), data.get("taxonomies")[0]
)
)
@@ -123,7 +122,7 @@ def handle_export_action(self, action):
if len(taxonomies) > 0:
return self.request.RESPONSE.redirect(
- "{0}/@@taxonomy-export?taxonomies={1}".format(
+ "{}/@@taxonomy-export?taxonomies={}".format(
self.context.portal_url(), ",".join(taxonomies)
)
) # noqa
@@ -218,7 +217,7 @@ def handleAdd(self, action):
def handleCancel(self, action):
api.portal.show_message(_("Add cancelled"), request=self.request)
self.request.response.redirect(
- "{0}/@@taxonomy-settings".format(self.context.absolute_url())
+ "{}/@@taxonomy-settings".format(self.context.absolute_url())
)
@@ -256,20 +255,20 @@ def handleApply(self, action):
api.portal.show_message(_("Changes saved"), request=self.request)
self.request.response.redirect(
- "{0}/@@taxonomy-settings".format(self.context.absolute_url())
+ "{}/@@taxonomy-settings".format(self.context.absolute_url())
)
@button.buttonAndHandler(_("Cancel"), name="cancel")
def handleCancel(self, action):
api.portal.show_message(_("Edit cancelled"), request=self.request)
self.request.response.redirect(
- "{0}/@@taxonomy-settings".format(self.context.absolute_url())
+ "{}/@@taxonomy-settings".format(self.context.absolute_url())
)
@adapter(IPloneSiteRoot)
@implementer(ITaxonomyForm)
-class TaxonomyEditFormAdapter(object):
+class TaxonomyEditFormAdapter:
purge = False
def __init__(self, context, name=None):
diff --git a/src/collective/taxonomy/exportimport.py b/src/collective/taxonomy/exportimport.py
index e65e7c41..e0b98a35 100644
--- a/src/collective/taxonomy/exportimport.py
+++ b/src/collective/taxonomy/exportimport.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from collective.taxonomy.factory import registerTaxonomy
from collective.taxonomy.interfaces import ITaxonomy
from collective.taxonomy.vdex import ExportVdex
@@ -6,10 +5,10 @@
from io import BytesIO
from io import StringIO
from lxml.etree import fromstring
+from plone.base.utils import safe_text
from plone.behavior.interfaces import IBehavior
-from six.moves import configparser
-import six
+import configparser
def parseConfigFile(data):
@@ -95,7 +94,7 @@ def exportTaxonomy(context):
for name in ["title", "description", "default_language"]:
value = getattr(taxonomy, name, None)
if value:
- config.set("taxonomy", name, six.ensure_text(value))
+ config.set("taxonomy", name, safe_text(value))
for name in [
"field_title",
@@ -106,17 +105,14 @@ def exportTaxonomy(context):
]:
value = getattr(behavior, name, None)
if value is not None:
- config.set("taxonomy", name, six.ensure_text(value))
+ config.set("taxonomy", name, safe_text(value))
for name in ["is_single_select", "is_required"]:
value = getattr(behavior, name, None)
if value:
config.set("taxonomy", name, str(value).lower())
- if six.PY3:
- filehandle = StringIO()
- else:
- filehandle = BytesIO()
+ filehandle = StringIO()
config.write(filehandle)
context.writeDataFile(
"taxonomies/" + short_name + ".cfg", filehandle.getvalue(), "text/plain"
@@ -124,7 +120,7 @@ def exportTaxonomy(context):
context.writeDataFile("taxonomies/" + short_name + ".xml", body, "text/xml")
-class TaxonomyImportExportAdapter(object):
+class TaxonomyImportExportAdapter:
IMSVDEX_NS = "http://www.imsglobal.org/xsd/imsvdex_v1p0"
def __init__(self, context):
diff --git a/src/collective/taxonomy/generated.py b/src/collective/taxonomy/generated.py
index 76c6caea..b9e94f7c 100644
--- a/src/collective/taxonomy/generated.py
+++ b/src/collective/taxonomy/generated.py
@@ -8,7 +8,7 @@
import sys
-class Wrapper(object):
+class Wrapper:
__name__ = __name__
lock = RLock()
diff --git a/src/collective/taxonomy/indexer.py b/src/collective/taxonomy/indexer.py
index ff281d9b..008cc01a 100644
--- a/src/collective/taxonomy/indexer.py
+++ b/src/collective/taxonomy/indexer.py
@@ -3,21 +3,20 @@
from collections.abc import Iterable
from collective.taxonomy.interfaces import ITaxonomy
from plone import api
+from plone.base.interfaces import IPloneSiteRoot
from plone.dexterity.interfaces import IDexterityContent
from plone.indexer.interfaces import IIndexer
-from Products.CMFPlone.interfaces import IPloneSiteRoot
from Products.ZCatalog.interfaces import IZCatalog
from zope.component import adapter
from zope.interface import implementer
import logging
-import six
logger = logging.getLogger("collective.taxonomy")
-class TaxonomyIndexerWrapper(object):
+class TaxonomyIndexerWrapper:
def __init__(self, field_name, utility_name, context, catalog):
self.context = context
self.catalog = catalog
@@ -42,9 +41,7 @@ def __call__(self):
found = []
stored_element = getattr(self.context, self.field_name)
- if not isinstance(stored_element, Iterable) or isinstance(
- stored_element, six.string_types
- ):
+ if not isinstance(stored_element, Iterable) or isinstance(stored_element, str):
stored_element = [stored_element]
for language, data in utility.data.items():
@@ -73,7 +70,7 @@ def __call__(self):
@adapter(IDexterityContent, IZCatalog)
@implementer(IIndexer)
-class TaxonomyIndexer(object):
+class TaxonomyIndexer:
__name__ = "TaxonomyIndexer"
def __init__(self, field_name, utility_name):
diff --git a/src/collective/taxonomy/interfaces.py b/src/collective/taxonomy/interfaces.py
index b019f512..a881e344 100644
--- a/src/collective/taxonomy/interfaces.py
+++ b/src/collective/taxonomy/interfaces.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from .i18n import CollectiveTaxonomyMessageFactory as _
from plone import api
from plone.namedfile.field import NamedBlobFile
diff --git a/src/collective/taxonomy/jsonimpl.py b/src/collective/taxonomy/jsonimpl.py
index 36e60fe7..2655d1bf 100644
--- a/src/collective/taxonomy/jsonimpl.py
+++ b/src/collective/taxonomy/jsonimpl.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from BTrees.OOBTree import OOBTree
from collective.taxonomy import PATH_SEPARATOR
from collective.taxonomy.i18n import CollectiveTaxonomyMessageFactory as _
@@ -97,7 +96,6 @@ def get_resource_url(self):
class ImportJson(BrowserView):
-
"""Update taxonomy using json data."""
def __call__(self):
diff --git a/src/collective/taxonomy/restapi/__init__.py b/src/collective/taxonomy/restapi/__init__.py
index 40a96afc..e69de29b 100644
--- a/src/collective/taxonomy/restapi/__init__.py
+++ b/src/collective/taxonomy/restapi/__init__.py
@@ -1 +0,0 @@
-# -*- coding: utf-8 -*-
diff --git a/src/collective/taxonomy/restapi/serializers/__init__.py b/src/collective/taxonomy/restapi/serializers/__init__.py
index 40a96afc..e69de29b 100644
--- a/src/collective/taxonomy/restapi/serializers/__init__.py
+++ b/src/collective/taxonomy/restapi/serializers/__init__.py
@@ -1 +0,0 @@
-# -*- coding: utf-8 -*-
diff --git a/src/collective/taxonomy/restapi/serializers/taxonomy.py b/src/collective/taxonomy/restapi/serializers/taxonomy.py
index c97ed3cd..2945a0a4 100644
--- a/src/collective/taxonomy/restapi/serializers/taxonomy.py
+++ b/src/collective/taxonomy/restapi/serializers/taxonomy.py
@@ -1,5 +1,6 @@
""" RestAPI Taxonomy serializer
"""
+
from collective.taxonomy import PATH_SEPARATOR
from collective.taxonomy.interfaces import ITaxonomy
from plone.api import portal
@@ -11,7 +12,7 @@
@implementer(ISerializeToJson)
@adapter(ITaxonomy, Interface)
-class TaxonomySerializer(object):
+class TaxonomySerializer:
"""Taxnomy serializer"""
def __init__(self, context, request):
diff --git a/src/collective/taxonomy/restapi/services/__init__.py b/src/collective/taxonomy/restapi/services/__init__.py
index 40a96afc..e69de29b 100644
--- a/src/collective/taxonomy/restapi/services/__init__.py
+++ b/src/collective/taxonomy/restapi/services/__init__.py
@@ -1 +0,0 @@
-# -*- coding: utf-8 -*-
diff --git a/src/collective/taxonomy/restapi/services/controlpanel/__init__.py b/src/collective/taxonomy/restapi/services/controlpanel/__init__.py
index 40a96afc..e69de29b 100644
--- a/src/collective/taxonomy/restapi/services/controlpanel/__init__.py
+++ b/src/collective/taxonomy/restapi/services/controlpanel/__init__.py
@@ -1 +0,0 @@
-# -*- coding: utf-8 -*-
diff --git a/src/collective/taxonomy/restapi/services/controlpanel/controlpanel.py b/src/collective/taxonomy/restapi/services/controlpanel/controlpanel.py
index 6aec6f9c..9d7d4216 100644
--- a/src/collective/taxonomy/restapi/services/controlpanel/controlpanel.py
+++ b/src/collective/taxonomy/restapi/services/controlpanel/controlpanel.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from collective.taxonomy.i18n import CollectiveTaxonomyMessageFactory as _
from collective.taxonomy.interfaces import IBrowserLayer
from collective.taxonomy.interfaces import ITaxonomyControlPanel
diff --git a/src/collective/taxonomy/restapi/services/taxonomy/__init__.py b/src/collective/taxonomy/restapi/services/taxonomy/__init__.py
index 40a96afc..e69de29b 100644
--- a/src/collective/taxonomy/restapi/services/taxonomy/__init__.py
+++ b/src/collective/taxonomy/restapi/services/taxonomy/__init__.py
@@ -1 +0,0 @@
-# -*- coding: utf-8 -*-
diff --git a/src/collective/taxonomy/restapi/services/taxonomy/add.py b/src/collective/taxonomy/restapi/services/taxonomy/add.py
index 91e8b714..22aeaff8 100644
--- a/src/collective/taxonomy/restapi/services/taxonomy/add.py
+++ b/src/collective/taxonomy/restapi/services/taxonomy/add.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from collective.taxonomy.exportimport import TaxonomyImportExportAdapter
from collective.taxonomy.factory import registerTaxonomy
from collective.taxonomy.interfaces import ITaxonomyForm
diff --git a/src/collective/taxonomy/restapi/services/taxonomy/configure.zcml b/src/collective/taxonomy/restapi/services/taxonomy/configure.zcml
index cacdfaf9..4d2f161a 100644
--- a/src/collective/taxonomy/restapi/services/taxonomy/configure.zcml
+++ b/src/collective/taxonomy/restapi/services/taxonomy/configure.zcml
@@ -7,16 +7,16 @@
method="GET"
accept="application/json,application/schema+json"
factory=".get.TaxonomyGet"
- for="Products.CMFPlone.interfaces.IPloneSiteRoot"
+ for="plone.base.interfaces.IPloneSiteRoot"
permission="zope2.View"
name="@taxonomy"
/>
-
@@ -24,7 +24,7 @@
@@ -32,16 +32,16 @@
-
+
+ />
diff --git a/src/collective/taxonomy/restapi/services/taxonomy/delete.py b/src/collective/taxonomy/restapi/services/taxonomy/delete.py
index 3c2cdfb3..646d0e60 100644
--- a/src/collective/taxonomy/restapi/services/taxonomy/delete.py
+++ b/src/collective/taxonomy/restapi/services/taxonomy/delete.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from collective.taxonomy.i18n import CollectiveTaxonomyMessageFactory as _
from collective.taxonomy.interfaces import ITaxonomy
from plone.restapi.services import Service
diff --git a/src/collective/taxonomy/restapi/services/taxonomy/get.py b/src/collective/taxonomy/restapi/services/taxonomy/get.py
index 1a62c7a6..e533a777 100644
--- a/src/collective/taxonomy/restapi/services/taxonomy/get.py
+++ b/src/collective/taxonomy/restapi/services/taxonomy/get.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from collective.taxonomy.interfaces import ITaxonomy
from collective.taxonomy.restapi.utils import get_all_taxonomies
from collective.taxonomy.vdex import TreeExport
diff --git a/src/collective/taxonomy/restapi/services/taxonomy/schema.py b/src/collective/taxonomy/restapi/services/taxonomy/schema.py
index 81d9fc00..930aa274 100644
--- a/src/collective/taxonomy/restapi/services/taxonomy/schema.py
+++ b/src/collective/taxonomy/restapi/services/taxonomy/schema.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from collective.taxonomy.interfaces import ITaxonomyForm
from plone.restapi.serializer.controlpanels import get_jsonschema_for_controlpanel
from plone.restapi.serializer.converters import json_compatible
diff --git a/src/collective/taxonomy/restapi/services/taxonomy/update.py b/src/collective/taxonomy/restapi/services/taxonomy/update.py
index 9be9d7e1..c500c5cd 100644
--- a/src/collective/taxonomy/restapi/services/taxonomy/update.py
+++ b/src/collective/taxonomy/restapi/services/taxonomy/update.py
@@ -1,5 +1,6 @@
""" RestAPI PATCH
"""
+
from BTrees.OOBTree import OOBTree
from collective.taxonomy import PATH_SEPARATOR
from collective.taxonomy.controlpanel import TaxonomyEditFormAdapter
diff --git a/src/collective/taxonomy/restapi/utils.py b/src/collective/taxonomy/restapi/utils.py
index ed9d0536..2ebcd72b 100644
--- a/src/collective/taxonomy/restapi/utils.py
+++ b/src/collective/taxonomy/restapi/utils.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from collective.taxonomy.interfaces import ITaxonomy
from plone.restapi.interfaces import ISerializeToJson
from zope.component import getMultiAdapter
diff --git a/src/collective/taxonomy/testing.py b/src/collective/taxonomy/testing.py
index 55c40b89..99310bbb 100644
--- a/src/collective/taxonomy/testing.py
+++ b/src/collective/taxonomy/testing.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from plone.app.robotframework.testing import REMOTE_LIBRARY_BUNDLE_FIXTURE
from plone.app.testing import applyProfile
from plone.app.testing import FunctionalTesting
diff --git a/src/collective/taxonomy/tests/test_behavior.py b/src/collective/taxonomy/tests/test_behavior.py
index 7dc737f8..fcb6debf 100644
--- a/src/collective/taxonomy/tests/test_behavior.py
+++ b/src/collective/taxonomy/tests/test_behavior.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from collective.taxonomy.interfaces import ITaxonomy
from collective.taxonomy.testing import INTEGRATION_TESTING
from plone import api
diff --git a/src/collective/taxonomy/tests/test_controlpanel.py b/src/collective/taxonomy/tests/test_controlpanel.py
index 2d406e47..cd015b84 100644
--- a/src/collective/taxonomy/tests/test_controlpanel.py
+++ b/src/collective/taxonomy/tests/test_controlpanel.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from collective.taxonomy.testing import FUNCTIONAL_TESTING
from plone import api
from plone.app.testing import applyProfile
@@ -29,7 +28,7 @@ def setUp(self):
self.browser.handleErrors = False
self.browser.addHeader(
"Authorization",
- "Basic {0}:{1}".format(SITE_OWNER_NAME, SITE_OWNER_PASSWORD),
+ "Basic {}:{}".format(SITE_OWNER_NAME, SITE_OWNER_PASSWORD),
)
commit()
@@ -45,9 +44,9 @@ def test_add_vocabulary(self):
self.assertIn('id="TaxonomySettings"', self.browser.contents)
self.browser.getControl("Add").click()
self.browser.getControl(name="form.widgets.taxonomy").value = "foobar"
- self.browser.getControl(
- name="form.widgets.field_title"
- ).value = "Foo Bar Vocabulary"
+ self.browser.getControl(name="form.widgets.field_title").value = (
+ "Foo Bar Vocabulary"
+ )
self.browser.getControl(name="form.widgets.default_language:list").value = [
"en"
]
@@ -64,9 +63,9 @@ def test_edit_vocabulary(self):
self.browser.getForm(id="TaxonomySettings").submit(
name="form.buttons.edit-taxonomy"
)
- self.browser.getControl(
- name="form.widgets.field_title"
- ).value = "Edited Test Vocabulary"
+ self.browser.getControl(name="form.widgets.field_title").value = (
+ "Edited Test Vocabulary"
+ )
self.browser.getForm(id="form").submit("Save")
self.assertIn(
'Edited Test Vocabulary', self.browser.contents
diff --git a/src/collective/taxonomy/tests/test_controlpanel_restapi.py b/src/collective/taxonomy/tests/test_controlpanel_restapi.py
index 1d2dd173..27429bbd 100644
--- a/src/collective/taxonomy/tests/test_controlpanel_restapi.py
+++ b/src/collective/taxonomy/tests/test_controlpanel_restapi.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from collective.taxonomy.testing import FUNCTIONAL_TESTING
from plone.app.testing import applyProfile
from plone.app.testing import setRoles
diff --git a/src/collective/taxonomy/tests/test_indexer.py b/src/collective/taxonomy/tests/test_indexer.py
index 01a06f55..dc7e1af2 100644
--- a/src/collective/taxonomy/tests/test_indexer.py
+++ b/src/collective/taxonomy/tests/test_indexer.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from collective.taxonomy.interfaces import ITaxonomy
from collective.taxonomy.testing import INTEGRATION_TESTING
from plone import api
@@ -19,7 +18,6 @@
class TestIndexer(unittest.TestCase):
-
"""Test JSON views."""
layer = INTEGRATION_TESTING
diff --git a/src/collective/taxonomy/tests/test_json.py b/src/collective/taxonomy/tests/test_json.py
index c55ccf6b..0213f1f5 100644
--- a/src/collective/taxonomy/tests/test_json.py
+++ b/src/collective/taxonomy/tests/test_json.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from collective.taxonomy.testing import INTEGRATION_TESTING
from plone.app.testing import setRoles
from plone.app.testing import TEST_USER_ID
@@ -6,18 +5,16 @@
from plone.app.testing.interfaces import TEST_USER_NAME
import json
-import six
import unittest
class TestJson(unittest.TestCase):
-
"""Test JSON views."""
layer = INTEGRATION_TESTING
def setUp(self):
- super(TestJson, self).setUp()
+ super().setUp()
self.portal = self.layer["portal"]
self.request = self.layer["request"]
setRoles(self.portal, TEST_USER_ID, ["Manager"])
@@ -105,15 +102,13 @@ def test_generate_json(self):
)
-@unittest.skipIf(six.PY2, "Those tests run just for Python 3")
class TestEditDataJson(unittest.TestCase):
-
"""Test Edit Data JSON view."""
layer = INTEGRATION_TESTING
def setUp(self):
- super(TestEditDataJson, self).setUp()
+ super().setUp()
self.portal = self.layer["portal"]
self.request = self.layer["request"]
setRoles(self.portal, TEST_USER_ID, ["Manager"])
diff --git a/src/collective/taxonomy/tests/test_setup.py b/src/collective/taxonomy/tests/test_setup.py
index 888afebd..4697e17b 100644
--- a/src/collective/taxonomy/tests/test_setup.py
+++ b/src/collective/taxonomy/tests/test_setup.py
@@ -1,32 +1,15 @@
-# -*- coding: utf-8 -*-
"""Setup tests for this package."""
+
from collective.taxonomy.testing import INTEGRATION_TESTING
from plone import api
from plone.app.testing import setRoles
from plone.app.testing import TEST_USER_ID
+from plone.base.utils import get_installer
from Products.CMFCore.utils import getToolByName
import unittest
-no_get_installer = False
-
-try:
- from Products.CMFPlone.utils import get_installer
-except Exception:
- # Quick shim for 5.1 api change
-
- class get_installer(object):
- def __init__(self, portal, request):
- self.installer = getToolByName(portal, "portal_quickinstaller")
-
- def is_product_installed(self, name):
- return self.installer.isProductInstalled(name)
-
- def uninstall_product(self, name):
- return self.installer.uninstallProducts([name])
-
-
class TestSetup(unittest.TestCase):
"""Test that collective.taxonomy is properly installed."""
diff --git a/src/collective/taxonomy/tests/test_taxonomy_endpoint.py b/src/collective/taxonomy/tests/test_taxonomy_endpoint.py
index 25b15620..302a4da4 100644
--- a/src/collective/taxonomy/tests/test_taxonomy_endpoint.py
+++ b/src/collective/taxonomy/tests/test_taxonomy_endpoint.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from collective.taxonomy.testing import FUNCTIONAL_TESTING
from plone.app.testing import applyProfile
from plone.app.testing import setRoles
@@ -170,4 +169,4 @@ def test_get_AddTaxonomy_Schema(self):
fields = [x.get("fields") for x in response["fieldsets"]]
self.assertIn("field_title", fields[0])
self.assertIn("taxonomy", fields[0])
- self.assertNotEquals(response["properties"], {})
+ self.assertNotEqual(response["properties"], {})
diff --git a/src/collective/taxonomy/tests/test_traverser.py b/src/collective/taxonomy/tests/test_traverser.py
index 8945e90f..7524d146 100644
--- a/src/collective/taxonomy/tests/test_traverser.py
+++ b/src/collective/taxonomy/tests/test_traverser.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from collective.taxonomy.browser import VocabularyTuplesView
from collective.taxonomy.testing import INTEGRATION_TESTING
from collective.taxonomy.vocabulary import Vocabulary
diff --git a/src/collective/taxonomy/tests/test_utility.py b/src/collective/taxonomy/tests/test_utility.py
index 7d22ddcb..00855117 100644
--- a/src/collective/taxonomy/tests/test_utility.py
+++ b/src/collective/taxonomy/tests/test_utility.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from collective.taxonomy.interfaces import ITaxonomy
from collective.taxonomy.testing import INTEGRATION_TESTING
from zope.component import queryUtility
diff --git a/src/collective/taxonomy/utility.py b/src/collective/taxonomy/utility.py
index 5f8f4bdb..94eea8ce 100644
--- a/src/collective/taxonomy/utility.py
+++ b/src/collective/taxonomy/utility.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from BTrees.IOBTree import IOBTree
from BTrees.OOBTree import OOBTree
from collective.taxonomy import generated
@@ -267,7 +266,7 @@ def fix(path):
seen = set()
for key, value in items:
if key in seen:
- logger.warning("Duplicate key entry: %r" % (key,))
+ logger.warning("Duplicate key entry: {!r}".format(key))
seen.add(key)
update = key in tree
diff --git a/src/collective/taxonomy/vdex.py b/src/collective/taxonomy/vdex.py
index 5fcb4a14..fb89fe3c 100644
--- a/src/collective/taxonomy/vdex.py
+++ b/src/collective/taxonomy/vdex.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from collections import OrderedDict
from collective.taxonomy import PATH_SEPARATOR
from lxml import etree
@@ -8,7 +7,7 @@
LANG_SEPARATOR = "|"
-class ImportVdex(object):
+class ImportVdex:
"""Helper class for import"""
def __init__(self, tree, ns):
@@ -42,7 +41,7 @@ def recurse(self, tree, available_languages=set(), parent_language=None):
for node in tree.findall("./{%s}term" % self.ns):
identifier = node.find("./{%s}termIdentifier" % self.ns)
langstrings = node.findall(
- "./{%s}caption/{%s}langstring" % (self.ns, self.ns)
+ "./{{{}}}caption/{{{}}}langstring".format(self.ns, self.ns)
)
for i in langstrings:
if not parent_language or parent_language == i.attrib["language"]:
@@ -62,7 +61,7 @@ def recurse(self, tree, available_languages=set(), parent_language=None):
return result
-class TreeExport(object):
+class TreeExport:
def __init__(self, taxonomy):
self.taxonomy = taxonomy
diff --git a/src/collective/taxonomy/vocabulary.py b/src/collective/taxonomy/vocabulary.py
index 3635ad77..05eaa34e 100644
--- a/src/collective/taxonomy/vocabulary.py
+++ b/src/collective/taxonomy/vocabulary.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from collections import OrderedDict
from collective.taxonomy import LEGACY_PATH_SEPARATOR
from collective.taxonomy import NODE
@@ -22,11 +21,11 @@ class Node(OrderedDict):
def __init__(self, term):
self.term = term
- super(Node, self).__init__()
+ super().__init__()
@implementer(IVocabularyFactory)
-class TaxonomyVocabulary(object):
+class TaxonomyVocabulary:
# Vocabulary for generating a list of existing taxonomies
def __call__(self, adapter):
@@ -41,7 +40,7 @@ def __call__(self, adapter):
@implementer(IVocabularyTokenized)
-class Vocabulary(object):
+class Vocabulary:
"""Vocabulary, generated by the ITaxonomy utility"""
def __init__(self, name, data, inv_data, order, version):
@@ -172,7 +171,7 @@ def add(path, value):
@implementer(IVocabularyFactory)
-class PermissionsVocabulary(object):
+class PermissionsVocabulary:
def __call__(self, context):
result = []
sm = getSite().getSiteManager()
@@ -189,7 +188,7 @@ def __call__(self, context):
@implementer(IVocabularyFactory)
-class LanguagesVocabulary(object):
+class LanguagesVocabulary:
"""Languages vocabulary."""
def __call__(self, context):
diff --git a/src/collective/taxonomy/widget.py b/src/collective/taxonomy/widget.py
index f7d06b20..f068b92c 100644
--- a/src/collective/taxonomy/widget.py
+++ b/src/collective/taxonomy/widget.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from collective.taxonomy.interfaces import ITaxonomySelectWidget
from plone.memoize import ram
from z3c.form import interfaces
@@ -14,7 +13,7 @@ def _items_cachekey(fun, self):
# try to get modified time of taxonomy utility
try:
mtime = self.terms.terms.data._p_mtime
- key = "{0}-{1}".format(self.field.__name__, mtime)
+ key = "{}-{}".format(self.field.__name__, mtime)
return key
except AttributeError:
# XXX: this happens with newly created taxonomies
@@ -31,7 +30,7 @@ def _get_items(self):
def update(self):
"""See z3c.form.interfaces.IWidget."""
- super(TaxonomySelectWidget, self).update()
+ super().update()
self.items = self._get_items()
self.selectedItems = [
self.getItem(self.terms.getTermByToken(token), count)