diff --git a/src/codesyntax/distributions/__init__.py b/src/codesyntax/distributions/__init__.py index af0e3a5..d608635 100644 --- a/src/codesyntax/distributions/__init__.py +++ b/src/codesyntax/distributions/__init__.py @@ -3,4 +3,4 @@ from zope.i18nmessageid import MessageFactory -_ = MessageFactory('codesyntax.distributions') +_ = MessageFactory("codesyntax.distributions") diff --git a/src/codesyntax/distributions/handlers/multilingual.py b/src/codesyntax/distributions/handlers/multilingual.py index 1fb053a..9f1e8b3 100644 --- a/src/codesyntax/distributions/handlers/multilingual.py +++ b/src/codesyntax/distributions/handlers/multilingual.py @@ -31,9 +31,7 @@ def post_handler(distribution: Distribution, site, answers: dict): content_types = ["News Item", "Event", "Document", "Collection"] for content_type in content_types: request = getRequest() - context = queryMultiAdapter( - (site, request), name="dexterity-types" - ) + context = queryMultiAdapter((site, request), name="dexterity-types") context = context.publishTraverse(request, content_type) behaviors = queryMultiAdapter((context, getRequest()), name="behaviors") diff --git a/src/codesyntax/distributions/locales/update.py b/src/codesyntax/distributions/locales/update.py index 61016e3..c525fd1 100644 --- a/src/codesyntax/distributions/locales/update.py +++ b/src/codesyntax/distributions/locales/update.py @@ -5,12 +5,12 @@ import subprocess -domain = 'codesyntax.distributions' -os.chdir(pkg_resources.resource_filename(domain, '')) -os.chdir('../../../') -target_path = 'src/codesyntax/distributions/' -locale_path = target_path + 'locales/' -i18ndude = './bin/i18ndude' +domain = "codesyntax.distributions" +os.chdir(pkg_resources.resource_filename(domain, "")) +os.chdir("../../../") +target_path = "src/codesyntax/distributions/" +locale_path = target_path + "locales/" +i18ndude = "./bin/i18ndude" # ignore node_modules files resulting in errors excludes = '"*.html *json-schema*.xml"' @@ -18,15 +18,15 @@ def locale_folder_setup(): os.chdir(locale_path) - languages = [d for d in os.listdir('.') if os.path.isdir(d)] + languages = [d for d in os.listdir(".") if os.path.isdir(d)] for lang in languages: folder = os.listdir(lang) - if 'LC_MESSAGES' in folder: + if "LC_MESSAGES" in folder: continue else: - lc_messages_path = lang + '/LC_MESSAGES/' + lc_messages_path = lang + "/LC_MESSAGES/" os.mkdir(lc_messages_path) - cmd = 'msginit --locale={0} --input={1}.pot --output={2}/LC_MESSAGES/{3}.po'.format( # NOQA: E501 + cmd = "msginit --locale={0} --input={1}.pot --output={2}/LC_MESSAGES/{3}.po".format( # NOQA: E501 lang, domain, lang, @@ -37,11 +37,11 @@ def locale_folder_setup(): shell=True, ) - os.chdir('../../../../') + os.chdir("../../../../") def _rebuild(): - cmd = '{i18ndude} rebuild-pot --pot {locale_path}/{domain}.pot --exclude {excludes} --create {domain} {target_path}'.format( # NOQA: E501 + cmd = "{i18ndude} rebuild-pot --pot {locale_path}/{domain}.pot --exclude {excludes} --create {domain} {target_path}".format( # NOQA: E501 i18ndude=i18ndude, locale_path=locale_path, domain=domain, @@ -55,7 +55,7 @@ def _rebuild(): def _sync(): - cmd = '{0} sync --pot {1}/{2}.pot {3}*/LC_MESSAGES/{4}.po'.format( + cmd = "{0} sync --pot {1}/{2}.pot {3}*/LC_MESSAGES/{4}.po".format( i18ndude, locale_path, domain, diff --git a/src/codesyntax/distributions/setuphandlers.py b/src/codesyntax/distributions/setuphandlers.py index c968e21..893dd25 100644 --- a/src/codesyntax/distributions/setuphandlers.py +++ b/src/codesyntax/distributions/setuphandlers.py @@ -5,7 +5,6 @@ @implementer(INonInstallable) class HiddenProfiles(object): - def getNonInstallableProfiles(self): """Hide uninstall profile from site-creation and quickinstaller.""" return [ diff --git a/src/codesyntax/distributions/tests/test_robot.py b/src/codesyntax/distributions/tests/test_robot.py index c12a151..a834461 100644 --- a/src/codesyntax/distributions/tests/test_robot.py +++ b/src/codesyntax/distributions/tests/test_robot.py @@ -1,5 +1,7 @@ # -*- coding: utf-8 -*- -from codesyntax.distributions.testing import CODESYNTAX_DISTRIBUTIONS_ACCEPTANCE_TESTING # noqa: E501 +from codesyntax.distributions.testing import ( + CODESYNTAX_DISTRIBUTIONS_ACCEPTANCE_TESTING, +) # noqa: E501 from plone.app.testing import ROBOT_TEST_LEVEL from plone.testing import layered @@ -11,18 +13,21 @@ def test_suite(): suite = unittest.TestSuite() current_dir = os.path.abspath(os.path.dirname(__file__)) - robot_dir = os.path.join(current_dir, 'robot') + robot_dir = os.path.join(current_dir, "robot") robot_tests = [ - os.path.join('robot', doc) for doc in os.listdir(robot_dir) - if doc.endswith('.robot') and doc.startswith('test_') + os.path.join("robot", doc) + for doc in os.listdir(robot_dir) + if doc.endswith(".robot") and doc.startswith("test_") ] for robot_test in robot_tests: robottestsuite = robotsuite.RobotTestSuite(robot_test) robottestsuite.level = ROBOT_TEST_LEVEL - suite.addTests([ - layered( - robottestsuite, - layer=CODESYNTAX_DISTRIBUTIONS_ACCEPTANCE_TESTING, - ), - ]) + suite.addTests( + [ + layered( + robottestsuite, + layer=CODESYNTAX_DISTRIBUTIONS_ACCEPTANCE_TESTING, + ), + ] + ) return suite diff --git a/src/codesyntax/distributions/tests/test_setup.py b/src/codesyntax/distributions/tests/test_setup.py index 0a557be..5346bdb 100644 --- a/src/codesyntax/distributions/tests/test_setup.py +++ b/src/codesyntax/distributions/tests/test_setup.py @@ -3,7 +3,9 @@ from plone import api from plone.app.testing import setRoles from plone.app.testing import TEST_USER_ID -from codesyntax.distributions.testing import CODESYNTAX_DISTRIBUTIONS_INTEGRATION_TESTING # noqa: E501 +from codesyntax.distributions.testing import ( + CODESYNTAX_DISTRIBUTIONS_INTEGRATION_TESTING, +) # noqa: E501 import unittest @@ -21,25 +23,22 @@ class TestSetup(unittest.TestCase): def setUp(self): """Custom shared utility setup for tests.""" - self.portal = self.layer['portal'] + self.portal = self.layer["portal"] if get_installer: - self.installer = get_installer(self.portal, self.layer['request']) + self.installer = get_installer(self.portal, self.layer["request"]) else: - self.installer = api.portal.get_tool('portal_quickinstaller') + self.installer = api.portal.get_tool("portal_quickinstaller") def test_product_installed(self): """Test if codesyntax.distributions is installed.""" - self.assertTrue(self.installer.is_product_installed( - 'codesyntax.distributions')) + self.assertTrue(self.installer.is_product_installed("codesyntax.distributions")) def test_browserlayer(self): """Test that ICodesyntaxDistributionsLayer is registered.""" - from codesyntax.distributions.interfaces import ( - ICodesyntaxDistributionsLayer) + from codesyntax.distributions.interfaces import ICodesyntaxDistributionsLayer from plone.browserlayer import utils - self.assertIn( - ICodesyntaxDistributionsLayer, - utils.registered_layers()) + + self.assertIn(ICodesyntaxDistributionsLayer, utils.registered_layers()) class TestUninstall(unittest.TestCase): @@ -47,24 +46,25 @@ class TestUninstall(unittest.TestCase): layer = CODESYNTAX_DISTRIBUTIONS_INTEGRATION_TESTING def setUp(self): - self.portal = self.layer['portal'] + self.portal = self.layer["portal"] if get_installer: - self.installer = get_installer(self.portal, self.layer['request']) + self.installer = get_installer(self.portal, self.layer["request"]) else: - self.installer = api.portal.get_tool('portal_quickinstaller') + self.installer = api.portal.get_tool("portal_quickinstaller") roles_before = api.user.get_roles(TEST_USER_ID) - setRoles(self.portal, TEST_USER_ID, ['Manager']) - self.installer.uninstall_product('codesyntax.distributions') + setRoles(self.portal, TEST_USER_ID, ["Manager"]) + self.installer.uninstall_product("codesyntax.distributions") setRoles(self.portal, TEST_USER_ID, roles_before) def test_product_uninstalled(self): """Test if codesyntax.distributions is cleanly uninstalled.""" - self.assertFalse(self.installer.is_product_installed( - 'codesyntax.distributions')) + self.assertFalse( + self.installer.is_product_installed("codesyntax.distributions") + ) def test_browserlayer_removed(self): """Test that ICodesyntaxDistributionsLayer is removed.""" - from codesyntax.distributions.interfaces import \ - ICodesyntaxDistributionsLayer + from codesyntax.distributions.interfaces import ICodesyntaxDistributionsLayer from plone.browserlayer import utils + self.assertNotIn(ICodesyntaxDistributionsLayer, utils.registered_layers())