Skip to content

Commit

Permalink
Merge pull request #14 from plone/cleanup
Browse files Browse the repository at this point in the history
Cleanup
  • Loading branch information
gforcada committed Feb 5, 2016
2 parents ef3df6d + 1e2a0e4 commit ec17664
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 17 deletions.
4 changes: 2 additions & 2 deletions plone/app/contentlisting/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ def __init__(self, brain):
self.request = aq_get(brain, 'REQUEST')

def __repr__(self):
return "<plone.app.contentlisting.catalog."\
"CatalogContentListingObject instance at {0}>".format(
return '<plone.app.contentlisting.catalog.'\
'CatalogContentListingObject instance at {0}>'.format(
self.getPath()
)

Expand Down
8 changes: 4 additions & 4 deletions plone/app/contentlisting/contentlisting.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from plone.i18n.normalizer.interfaces import IIDNormalizer
from plone.registry.interfaces import IRegistry
from Products.CMFPlone.interfaces import INavigationSchema
from zope.interface import implementer
from zope.component import getUtility
from zope.component import queryUtility
from zope.interface import implementer


@implementer(IContentListing)
Expand Down Expand Up @@ -105,13 +105,13 @@ def __eq__(self, other):
def ContentTypeClass(self):
"""A normalised type name that identifies the object in listings.
used for CSS styling"""
return "contenttype-" + queryUtility(IIDNormalizer).normalize(
return 'contenttype-' + queryUtility(IIDNormalizer).normalize(
self.PortalType())

def ReviewStateClass(self):
"""A normalised review state string for CSS styling use in listings.
"""
return "state-" + queryUtility(IIDNormalizer).normalize(
return 'state-' + queryUtility(IIDNormalizer).normalize(
self.review_state())

def appendViewAction(self):
Expand All @@ -121,7 +121,7 @@ def appendViewAction(self):
registry = getUtility(IRegistry)
types = registry.get('plone.types_use_view_action_in_listings', [])
if self.portal_type in types:
return "/view"
return '/view'
return ''

def isVisibleInNav(self):
Expand Down
6 changes: 3 additions & 3 deletions plone/app/contentlisting/realobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ def __init__(self, obj):
self.request = aq_get(obj, 'REQUEST')

def __repr__(self):
return "<plone.app.contentlisting.realobject."\
"RealContentListingObject instance at {0}>".format(
return '<plone.app.contentlisting.realobject.'\
'RealContentListingObject instance at {0}>'.format(
self.getPath()
)

Expand Down Expand Up @@ -66,7 +66,7 @@ def uuid(self):

def review_state(self):
obj = self.getObject()
wftool = getToolByName(obj, "portal_workflow")
wftool = getToolByName(obj, 'portal_workflow')
return wftool.getInfoFor(obj, 'review_state')

def Type(self):
Expand Down
5 changes: 3 additions & 2 deletions plone/app/contentlisting/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from plone.app.testing import TEST_USER_ID
from Products.CMFCore.utils import getToolByName
from zope.configuration import xmlconfig

import unittest2 as unittest


Expand All @@ -26,11 +27,11 @@ def setUpZope(self, app, configurationContext):
CONTENTLISTING_FIXTURE = ContentListingLayer()
CONTENTLISTING_INTEGRATION_TESTING = IntegrationTesting(
bases=(CONTENTLISTING_FIXTURE, ),
name="ContentListing:Integration"
name='ContentListing:Integration'
)
CONTENTLISTING_FUNCTIONAL_TESTING = FunctionalTesting(
bases=(CONTENTLISTING_FIXTURE, ),
name="ContentListing:Functional"
name='ContentListing:Functional'
)


Expand Down
4 changes: 3 additions & 1 deletion plone/app/contentlisting/tests/test_integration_doctest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from .base import ContentlistingFunctionalTestCase
# -*- coding: utf-8 -*-
from plone.app.contentlisting.tests.base import ContentlistingFunctionalTestCase # noqa
from Testing import ZopeTestCase as ztc

import doctest
import unittest

Expand Down
9 changes: 4 additions & 5 deletions plone/app/contentlisting/tests/test_integration_unit.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
from plone.app.contentlisting.interfaces import IContentListing
from plone.app.contentlisting.interfaces import IContentListingObject
from plone.app.contentlisting.tests.base import \
ContentlistingFunctionalTestCase
from plone.app.contentlisting.tests.base import ContentlistingFunctionalTestCase # noqa
from plone.app.testing import setRoles
from plone.app.testing import TEST_USER_ID
from plone.batching.interfaces import IBatch
Expand Down Expand Up @@ -87,7 +86,7 @@ def test_special_getattr_from_brain(self):

def test_special_getattr_from_object(self):
# Asking for an attribute not in the contentlistingobject, should
# defer lookup to the brain"""
# defer lookup to the brain
self.assertEqual(self.item.absolute_url(), '')
self.assertEqual(
repr(self.item.getDataOrigin()),
Expand Down Expand Up @@ -116,7 +115,7 @@ def test_item_getSize(self):
self.assertEqual(self.item.getSize().upper(), '0 KB')

def test_item_reviewState(self):
wftool = getToolByName(self.realitem, "portal_workflow")
wftool = getToolByName(self.realitem, 'portal_workflow')
wf = wftool.getInfoFor(self.realitem, 'review_state')
self.assertEqual(self.item.review_state(), wf)

Expand Down Expand Up @@ -196,7 +195,7 @@ def test_item_getURL(self):
self.assertEqual(self.item.getURL(), self.realitem.absolute_url())

def test_item_reviewState(self):
wftool = getToolByName(self.realitem, "portal_workflow")
wftool = getToolByName(self.realitem, 'portal_workflow')
wf = wftool.getInfoFor(self.realitem, 'review_state')
self.assertEqual(self.item.review_state(), wf)

Expand Down

1 comment on commit ec17664

@jenkins-plone-org
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gforcada Jenkins CI reporting about code analysis
See the full report here: http://jenkins.plone.org/job/package-plone.app.contentlisting/5//violations

plone/app/contentlisting/catalog.py:42:12: P002 found "hasattr", consider replacing it
plone/app/contentlisting/catalog.py:44:14: P002 found "hasattr", consider replacing it
plone/app/contentlisting/catalog.py:84:12: P002 found "hasattr", consider replacing it
plone/app/contentlisting/catalog.py:185:12: P002 found "hasattr", consider replacing it
plone/app/contentlisting/contentlisting.py:130:12: P002 found "hasattr", consider replacing it
plone/app/contentlisting/realobject.py:36:12: P002 found "hasattr", consider replacing it

You can run that yourself using buildout.coredev experimental/qa.cfg config file.

Please sign in to comment.