Skip to content

Commit

Permalink
autopep8 -ir
Browse files Browse the repository at this point in the history
  • Loading branch information
jensens committed Apr 23, 2016
1 parent fbf3674 commit dffd910
Show file tree
Hide file tree
Showing 14 changed files with 51 additions and 31 deletions.
3 changes: 2 additions & 1 deletion plone/app/layout/analytics/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ def update(self):
def render(self):
"""render the webstats snippet"""
registry = getUtility(IRegistry)
site_settings = registry.forInterface(ISiteSchema, prefix="plone", check=False)
site_settings = registry.forInterface(
ISiteSchema, prefix="plone", check=False)
try:
if site_settings.webstats_js:
return site_settings.webstats_js
Expand Down
12 changes: 6 additions & 6 deletions plone/app/layout/dashboard/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ class DashboardView(BrowserView):
interface.implements(IDashboard)

def __call__(self):
self.request.set('disable_border',1)
self.request.set('disable_plone.leftcolumn',1)
self.request.set('disable_plone.rightcolumn',1)
self.request.set('disable_border', 1)
self.request.set('disable_plone.leftcolumn', 1)
self.request.set('disable_plone.rightcolumn', 1)
if self.can_edit() and self.empty():
message = _(u"info_empty_dashboard",
default=u"Your dashboard is currently empty. Click the"
" <em>edit</em> tab to assign some personal"
" portlets.")
default=u"Your dashboard is currently empty. Click the"
" <em>edit</em> tab to assign some personal"
" portlets.")
IStatusMessage(self.request).add(message)
return self.index()

Expand Down
3 changes: 2 additions & 1 deletion plone/app/layout/globals/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ def view_url(self):
view_url = self.object_url()
portal_type = getattr(aq_base(self.context), 'portal_type', None)
registry = getUtility(IRegistry)
use_view_action = registry.get('plone.types_use_view_action_in_listings', [])
use_view_action = registry.get(
'plone.types_use_view_action_in_listings', [])
if portal_type in use_view_action:
view_url = view_url + '/view'
return view_url
Expand Down
12 changes: 8 additions & 4 deletions plone/app/layout/globals/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ def icons_visible(self):
anon = membership.isAnonymousUser()

registry = getUtility(IRegistry)
settings = registry.forInterface(ISiteSchema, prefix="plone", check=False)
settings = registry.forInterface(
ISiteSchema, prefix="plone", check=False)
icon_visibility = settings.icon_visibility

if icon_visibility == 'enabled':
Expand All @@ -105,7 +106,8 @@ def thumb_visible(self):
membership = getToolByName(context, "portal_membership")
anon = membership.isAnonymousUser()
registry = getUtility(IRegistry)
settings = registry.forInterface(ISiteSchema, prefix="plone", check=False)
settings = registry.forInterface(
ISiteSchema, prefix="plone", check=False)
thumb_visibility = settings.thumb_visibility

if thumb_visibility == 'enabled':
Expand Down Expand Up @@ -222,10 +224,12 @@ def bodyClass(self, template, view):
else:
user = membership.getAuthenticatedMember()
for role in user.getRolesInContext(self.context):
body_classes.append('userrole-' + role.lower().replace(' ', '-'))
body_classes.append(
'userrole-' + role.lower().replace(' ', '-'))

registry = getUtility(IRegistry)
settings = registry.forInterface(ISiteSchema, prefix='plone', check=False)
settings = registry.forInterface(
ISiteSchema, prefix='plone', check=False)

# toolbar classes
try:
Expand Down
3 changes: 2 additions & 1 deletion plone/app/layout/globals/portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ def portal(self):
@memoize_contextless
def portal_title(self):
registry = getUtility(IRegistry)
settings = registry.forInterface(ISiteSchema, prefix="plone", check=False)
settings = registry.forInterface(
ISiteSchema, prefix="plone", check=False)
return settings.site_title

@memoize_contextless
Expand Down
4 changes: 2 additions & 2 deletions plone/app/layout/globals/tests/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ def test_is_locked(self):
self.assertEqual(self.dview.is_locked(), False)
ILockable(self.folder.d1).lock()
self.logout()
# The object is not "locked" if it was locked by the
# current user
# The object is not "locked" if it was locked by the
# current user
del self.app.REQUEST.__annotations__
self.assertEqual(self.dview.is_locked(), True)

Expand Down
1 change: 0 additions & 1 deletion plone/app/layout/globals/tests/test_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
# Used in tests



class IZero(Interface):
''' Test interface zero
'''
Expand Down
3 changes: 2 additions & 1 deletion plone/app/layout/links/viewlets.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ def update(self):
continue
obj = uuidToObject(uid)
if obj is None and uid[0] == '/':
obj = portal.restrictedTraverse(uid.lstrip('/'), None)
obj = portal.restrictedTraverse(
uid.lstrip('/'), None)
if obj is not None:
self.rsslinks.extend(self.getRssLinks(obj))
self.rsslinks.extend(self.getRssLinks(portal))
Expand Down
8 changes: 4 additions & 4 deletions plone/app/layout/navigation/navtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,12 @@ def buildFolderTree(context, obj=None, query={},
if navtreeLevel > 1:
navtreeContextPath = pathQuery['query']
navtreeContextPathElements = navtreeContextPath[
len(portalPath)+1:].split('/')
len(portalPath) + 1:].split('/')
# Short-circuit if we won't be able to find this path
if len(navtreeContextPathElements) < (navtreeLevel - 1):
return {'children': []}
rootPath = portalPath + '/' + '/'.join(
navtreeContextPathElements[:navtreeLevel-1])
navtreeContextPathElements[:navtreeLevel - 1])
else:
rootPath = portalPath
else:
Expand Down Expand Up @@ -315,7 +315,7 @@ def insertElement(itemPaths, item, forceInsert=False):
# context. Note that we use an unrestricted query: things we don't normally
# have permission to see will be included in the tree.
if strategy.showAllParents and objPath is not None:
objSubPathElements = objPath[len(rootPath)+1:].split('/')
objSubPathElements = objPath[len(rootPath) + 1:].split('/')
parentPaths = []

haveNode = (itemPaths.get(rootPath, {}).get('item', None) is None)
Expand All @@ -324,7 +324,7 @@ def insertElement(itemPaths, item, forceInsert=False):

parentPath = rootPath
for i in range(len(objSubPathElements)):
nodePath = rootPath + '/' + '/'.join(objSubPathElements[:i+1])
nodePath = rootPath + '/' + '/'.join(objSubPathElements[:i + 1])
node = itemPaths.get(nodePath, None)

# If we don't have this node, we'll have to get it, if we have it
Expand Down
5 changes: 3 additions & 2 deletions plone/app/layout/viewlets/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ def update(self):

def selectedTabs(self, default_tab='index_html', portal_tabs=()):
portal = getToolByName(self.context, 'portal_url').getPortalObject()
plone_url = getNavigationRootObject(self.context, portal).absolute_url()
plone_url = getNavigationRootObject(
self.context, portal).absolute_url()
plone_url_len = len(plone_url)
request = self.request
valid_actions = []
Expand Down Expand Up @@ -258,7 +259,7 @@ def update(self):
'href': action['url'],
'id': 'personaltools-{}'.format(action['id']),
'target': 'link_target' in action and action['link_target'] or None,
}
}
modal = action.get('modal')
if modal:
info['class'] = 'pat-plone-modal'
Expand Down
9 changes: 6 additions & 3 deletions plone/app/layout/viewlets/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ def get_translations(self):
cts = []
if ITranslatable.providedBy(self.context):
t_langs = translated_languages(self.context)
context_translations = ITranslationManager(self.context).get_translations()
context_translations = ITranslationManager(
self.context).get_translations()
for lang in t_langs:
cts.append(dict(lang_native=lang.title,
url=context_translations[lang.value].absolute_url()))
Expand Down Expand Up @@ -282,7 +283,8 @@ def get_translations(self):
cts = []
if ITranslatable.providedBy(self.context):
t_langs = translated_languages(self.context)
context_translations = ITranslationManager(self.context).get_translations()
context_translations = ITranslationManager(
self.context).get_translations()
for lang in t_langs:
cts.append(dict(lang_native=lang.title,
url=context_translations[lang.value].absolute_url()))
Expand Down Expand Up @@ -438,7 +440,8 @@ def revisionHistory(self):
portal_diff = getToolByName(context, "portal_diff", None)
can_diff = portal_diff is not None \
and len(portal_diff.getDiffForPortalType(context.portal_type)) > 0
can_revert = _checkPermission('CMFEditions: Revert to previous versions', context)
can_revert = _checkPermission(
'CMFEditions: Revert to previous versions', context)

def morphVersionDataToHistoryFormat(vdata, version_id):
meta = vdata["metadata"]["sys_metadata"]
Expand Down
2 changes: 2 additions & 0 deletions plone/app/layout/viewlets/tests/test_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class TestDocumentBylineViewletView(ViewletsTestCase):
"""
Test the document by line viewlet
"""

def afterSetUp(self):
self.folder.invokeFactory('Document', 'doc1', title='Document 1')
self.context = self.folder['doc1']
Expand Down Expand Up @@ -98,6 +99,7 @@ class TestHistoryBylineViewletView(ViewletsTestCase):
"""
Test the document by line viewlet
"""

def afterSetUp(self):
self.folder.invokeFactory('Document', 'doc1', title='Document 1')
self.context = self.folder['doc1']
Expand Down
11 changes: 8 additions & 3 deletions plone/app/layout/viewlets/tests/test_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class TestWorkflowHistoryViewlet(ViewletsTestCase):
"""
Test the workflow history viewlet
"""

def afterSetUp(self):
# add document, perform transition, set history for non-existent
# member and also None (anonymous)
Expand Down Expand Up @@ -67,6 +68,7 @@ class TestContentHistoryViewlet(ViewletsTestCase):
"""
Test the workflow history viewlet
"""

def afterSetUp(self):
# add document, perform transition, set history for non-existent
# member and also None (anonymous)
Expand Down Expand Up @@ -97,7 +99,8 @@ def test_revisionHistory(self):
viewlet.update()
history = viewlet.revisionHistory()
self.assertTrue(
'http://nohost/plone/Members/test_user_1_/d1/@@history?one=1&two=0' in history[0]['diff_previous_url']
'http://nohost/plone/Members/test_user_1_/d1/@@history?one=1&two=0' in history[
0]['diff_previous_url']
)

# check diff link does not appear if content is not diffable
Expand All @@ -108,7 +111,8 @@ def test_revisionHistory(self):
self.assertFalse('diff_previous_url' in history[0])

def test_revertAbility(self):
# check revert URL is generated only if the user has the appropriate permission
# check revert URL is generated only if the user has the appropriate
# permission
repo_tool = self.portal.portal_repository
request = self.app.REQUEST
context = getattr(self.folder, 'd1')
Expand All @@ -123,7 +127,8 @@ def test_revertAbility(self):
self.assertTrue(
'http://nohost/plone/Members/test_user_1_/d1/revertversion' in history[0]['revert_url']) # noqa

self.portal.manage_permission('CMFEditions: Revert to previous versions', [], False)
self.portal.manage_permission(
'CMFEditions: Revert to previous versions', [], False)

viewlet.update()
history = viewlet.revisionHistory()
Expand Down
6 changes: 4 additions & 2 deletions plone/app/layout/viewlets/toolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ def portal_state(self):
return getMultiAdapter((self.context, self.request), name='plone_portal_state')

def get_personal_bar(self):
viewlet = PersonalBarViewlet(self.context, self.request, self.__parent__, self)
viewlet = PersonalBarViewlet(
self.context, self.request, self.__parent__, self)
viewlet.update()
return viewlet

def get_toolbar_logo(self):
registry = getUtility(IRegistry)
settings = registry.forInterface(ISiteSchema, prefix='plone', check=False)
settings = registry.forInterface(
ISiteSchema, prefix='plone', check=False)
portal_url = self.portal_state.portal_url()
try:
logo = settings.toolbar_logo
Expand Down

0 comments on commit dffd910

Please sign in to comment.