From 849727da17b127058c0c96279f26cb95ea77baa1 Mon Sep 17 00:00:00 2001 From: Philip Bauer Date: Thu, 22 Jan 2015 15:55:34 +0100 Subject: [PATCH] make code-analysis happy Conflicts: plone/app/contenttypes/tests/test_setup.py --- plone/app/contenttypes/browser/file.py | 1 + plone/app/contenttypes/migration/__init__.py | 1 + plone/app/contenttypes/migration/browser.py | 6 +++--- plone/app/contenttypes/migration/dxmigration.py | 2 -- plone/app/contenttypes/migration/migration.py | 5 +++-- plone/app/contenttypes/migration/topics.py | 5 +---- plone/app/contenttypes/migration/utils.py | 3 +++ plone/app/contenttypes/migration/vocabularies.py | 3 ++- plone/app/contenttypes/testing.py | 9 +++++---- plone/app/contenttypes/tests/test_migration.py | 9 +++++---- plone/app/contenttypes/tests/test_migration_topic.py | 7 ++++--- 11 files changed, 28 insertions(+), 23 deletions(-) diff --git a/plone/app/contenttypes/browser/file.py b/plone/app/contenttypes/browser/file.py index ad371074a..a63349812 100644 --- a/plone/app/contenttypes/browser/file.py +++ b/plone/app/contenttypes/browser/file.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from plone.app.contenttypes.browser.utils import Utils diff --git a/plone/app/contenttypes/migration/__init__.py b/plone/app/contenttypes/migration/__init__.py index 311a3e7aa..1ed467b00 100644 --- a/plone/app/contenttypes/migration/__init__.py +++ b/plone/app/contenttypes/migration/__init__.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytz diff --git a/plone/app/contenttypes/migration/browser.py b/plone/app/contenttypes/migration/browser.py index 2f6191f3e..4b9beff51 100644 --- a/plone/app/contenttypes/migration/browser.py +++ b/plone/app/contenttypes/migration/browser.py @@ -516,7 +516,8 @@ class FolderishCollection(Container): - my.package.content.FolderishCollection + my.package.content.FolderishCollection + """ @@ -528,7 +529,7 @@ class FolderishCollection(Container): behavior = 'plone.app.contenttypes.behaviors.collection.ICollection' if fti and behavior in fti.behaviors: logger.warn("You are trying to migrate topic to collection. " - "Instead you need a type 'Collection'.") + "Instead you need a type 'Collection'.") def has_contentleadimage(self): return HAS_CONTENTLEADIMAGE @@ -540,7 +541,6 @@ def installed_types(self): results['installed_without_behavior'] = [] results['not_installed'] = [] behavior = 'plone.app.contenttypes.behaviors.leadimage.ILeadImage' - portal_types = getToolByName(self.context, 'portal_types') for type_name in DEFAULT_TYPES: fti = queryUtility(IDexterityFTI, name=type_name) if fti: diff --git a/plone/app/contenttypes/migration/dxmigration.py b/plone/app/contenttypes/migration/dxmigration.py index 419b02809..4af24e4b3 100644 --- a/plone/app/contenttypes/migration/dxmigration.py +++ b/plone/app/contenttypes/migration/dxmigration.py @@ -6,8 +6,6 @@ from plone.app.contenttypes.interfaces import IEvent from plone.app.contenttypes.migration import datetime_fixer from plone.app.contenttypes.migration.utils import HAS_MULTILINGUAL -from plone.dexterity.content import Container -from plone.dexterity.content import Item from plone.dexterity.interfaces import IDexterityContent from plone.dexterity.interfaces import IDexterityFTI from plone.event.utils import default_timezone diff --git a/plone/app/contenttypes/migration/migration.py b/plone/app/contenttypes/migration/migration.py index d4af8e5ec..5c171c51c 100644 --- a/plone/app/contenttypes/migration/migration.py +++ b/plone/app/contenttypes/migration/migration.py @@ -63,7 +63,7 @@ def migrate_portlets(src_obj, dst_obj): """ # also take custom portlet managers into account - managers = [reg.name for reg in getSiteManager().registeredUtilities() \ + managers = [reg.name for reg in getSiteManager().registeredUtilities() if reg.provided == IPortletManager] # faster, but no custom managers # managers = [u'plone.leftcolumn', u'plone.rightcolumn'] @@ -86,7 +86,8 @@ def migrate_portlets(src_obj, dst_obj): if not hasattr(assignment, '__Broken_state__'): add_portlet(dst_obj, assignment, key, manager) else: - logger.warn(u'skipping broken portlet assignment {0} for manager {1}'.format(key, manager)) + logger.warn(u'skipping broken portlet assignment {0} ' + 'for manager {1}'.format(key, manager)) def refs(obj): diff --git a/plone/app/contenttypes/migration/topics.py b/plone/app/contenttypes/migration/topics.py index fa0aa36a2..7d8825cfd 100644 --- a/plone/app/contenttypes/migration/topics.py +++ b/plone/app/contenttypes/migration/topics.py @@ -9,7 +9,6 @@ """ from DateTime import DateTime -from Products.CMFCore.interfaces._content import IFolderish from Products.CMFCore.utils import getToolByName from Products.contentmigration.inplace import InplaceCMFFolderMigrator from Products.contentmigration.inplace import InplaceCMFItemMigrator @@ -30,8 +29,8 @@ INVALID_OPERATION = 'Invalid operation %s for criterion: %s' -# Converters +# Converters class CriterionConverter(object): # Last part of the code for the dotted operation method, @@ -536,7 +535,6 @@ def migrate_criteria(self): if self._collection_query is not None: adapted.query = self._collection_query - def migrate_atctmetadata(self): field = self.old.getField('excludeFromNav') self.new.exclude_from_nav = field.get(self.old) @@ -649,7 +647,6 @@ def migrate_criteria(self): if self._collection_query is not None: adapted.query = self._collection_query - def migrate_atctmetadata(self): field = self.old.getField('excludeFromNav') self.new.exclude_from_nav = field.get(self.old) diff --git a/plone/app/contenttypes/migration/utils.py b/plone/app/contenttypes/migration/utils.py index 20ae0d447..89813be60 100644 --- a/plone/app/contenttypes/migration/utils.py +++ b/plone/app/contenttypes/migration/utils.py @@ -129,6 +129,7 @@ def add_portlet(context, assignment, portlet_key, columnName): IPortletAssignmentMapping) assignmentmapping[portlet_key] = assignment + def move_comments(source_object, target_object): """Move comments by copying the annotation to the target and then removing the comments from the source (not the annotation). @@ -146,6 +147,7 @@ def move_comments(source_object, target_object): del source_conversation[comment.comment_id] del source_annotations[DISCUSSION_KEY] + def copy_contentrules(source_object, target_object): """Copy contentrules. """ @@ -160,6 +162,7 @@ def copy_contentrules(source_object, target_object): for rule_id in source_assignable: assign_rule(target_object, rule_id) + def migrate_leadimage(source_object, target_object): """ Migrate images added using collective.contentleadimage to the ILeadImage-behavior of plone.app.contenttypes if it is enabled. diff --git a/plone/app/contenttypes/migration/vocabularies.py b/plone/app/contenttypes/migration/vocabularies.py index 4b14d1d64..279c46b24 100644 --- a/plone/app/contenttypes/migration/vocabularies.py +++ b/plone/app/contenttypes/migration/vocabularies.py @@ -225,6 +225,7 @@ def __call__(self, context): return SimpleVocabulary( [SimpleVocabulary.createTerm( class_name, class_name, - '{0} ({1})'.format(class_name, list_of_class_names[class_name])) + '{0} ({1})'.format( + class_name, list_of_class_names[class_name])) for class_name in list_of_class_names.keys()] ) diff --git a/plone/app/contenttypes/testing.py b/plone/app/contenttypes/testing.py index bc0bb91db..d312241a0 100644 --- a/plone/app/contenttypes/testing.py +++ b/plone/app/contenttypes/testing.py @@ -45,12 +45,13 @@ def setUpZope(self, app, configurationContext): def setUpPloneSite(self, portal): applyProfile(portal, 'plone.app.contenttypes:default') - # install and enable referenceablebehavior on Documents to be able to test - # controlpanel to enable plone.app.linkintegrity checks + # install and enable referenceablebehavior on Documents to be able to + # test controlpanel to enable plone.app.linkintegrity checks # XXX Disabled as it is causing test errors in comments # see https://github.com/plone/Products.CMFPlone/issues/255 - #applyProfile(portal, 'plone.app.referenceablebehavior:default') - #portal.portal_types.Document.behaviors += ('plone.app.referenceablebehavior.referenceable.IReferenceable',) + # applyProfile(portal, 'plone.app.referenceablebehavior:default') + # portal.portal_types.Document.behaviors += \ + # ('plone.app.referenceablebehavior.referenceable.IReferenceable',) mtr = portal.mimetypes_registry mime_doc = mtr.lookup('application/msword')[0] diff --git a/plone/app/contenttypes/tests/test_migration.py b/plone/app/contenttypes/tests/test_migration.py index f21cb2a47..b399f99da 100644 --- a/plone/app/contenttypes/tests/test_migration.py +++ b/plone/app/contenttypes/tests/test_migration.py @@ -1293,7 +1293,6 @@ def test_migration_view_confirmation(self): results = migration_view() self.assertIn('@@migrate_from_atct?migrate=1', results) - def test_portlets_are_migrated(self): """add portlets and see if they're still available on the migrated content including portlet settings. @@ -1350,7 +1349,7 @@ def get_portlets(context, columnName): # add a portlet to the folder portlet2 = StaticAssignment(u"Sample Folder Portlet", - "

Do I get migrated?

") + "

Do I get migrated?

") add_portlet(at_folder, portlet2, 'static-portlet', u'plone.rightcolumn') @@ -1473,14 +1472,16 @@ def test_dxmigration_migrate_item_to_container_add_object_inside(self): migrate_base_class_to_new_class migrate_base_class_to_new_class(self.portal.item) self.portal.item.invokeFactory('Document', 'doc') - self.assertEqual(len(self.portal.item.folderlistingFolderContents()), 1) + self.assertEqual( + len(self.portal.item.folderlistingFolderContents()), 1) def test_dxmigration_migrate_list_of_objects_with_changed_base_class(self): """Check list of objects with changed classes.""" from plone.app.contenttypes.migration.dxmigration import \ list_of_objects_with_changed_base_class # We have already one changed object - objects = [i for i in list_of_objects_with_changed_base_class(self.portal)] + objects = [i for i in + list_of_objects_with_changed_base_class(self.portal)] self.assertEqual(len(objects), 1) def test_dxmigration_migrate_list_of_changed_base_class_names(self): diff --git a/plone/app/contenttypes/tests/test_migration_topic.py b/plone/app/contenttypes/tests/test_migration_topic.py index 0a07c00e8..d2aae89b5 100644 --- a/plone/app/contenttypes/tests/test_migration_topic.py +++ b/plone/app/contenttypes/tests/test_migration_topic.py @@ -17,8 +17,8 @@ @implementer(ICollection) class FolderishCollection(Container): - """Test subclass for folderish ``Collections``. - """ + """Test subclass for folderish ``Collections``. + """ class MigrateTopicsIntegrationTest(unittest.TestCase): @@ -102,7 +102,8 @@ def test_migrate_nested_topic(self): # the content_meta_type attribute when klass has changed fti._updateProperty( 'klass', - 'plone.app.contenttypes.tests.test_migration_topic.FolderishCollection') + 'plone.app.contenttypes.tests.test_migration_topic.' + 'FolderishCollection') fti._updateProperty('allowed_content_types', ['Document', 'Folder']) fti._updateProperty('filter_content_types', False) self.run_migration()