Skip to content

Commit

Permalink
Fix code analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
hvelarde committed Feb 8, 2018
1 parent 2fd111b commit ef15464
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 51 deletions.
9 changes: 3 additions & 6 deletions sc/social/like/browser/canonicalurl.py
Expand Up @@ -24,8 +24,7 @@ class ICanonicalURLUpdater(model.Schema):
default=u'The canonical domain will be used to construct the canonical URL (<code>og:url</code> property) of portal objects. '
u'Use the domain name of your site (e.g. <strong>http://www.example.org</strong> or <strong>https://www.example.org</strong>). '
u'Facebook will use the canonical URL to ensure that all actions such as likes and shares aggregate at the same URL rather than spreading across multiple versions of a page. '
u'Check <a href="https://pypi.python.org/pypi/sc.social.like">package documentation</a> for more information on how to use this feature.'
),
u'Check <a href="https://pypi.python.org/pypi/sc.social.like">package documentation</a> for more information on how to use this feature.'),
required=True,
constraint=validate_canonical_domain,
)
Expand All @@ -35,8 +34,7 @@ class ICanonicalURLUpdater(model.Schema):
description=_(
u'help_published_before',
default=u'Objects published before this date will be updated using the canonical domain defined in this form; '
u'objects published on or after this date will be updated using the canonical domain defined in the control panel configlet.'
),
u'objects published on or after this date will be updated using the canonical domain defined in the control panel configlet.'),
required=True,
)

Expand All @@ -48,8 +46,7 @@ class CanonicalURLUpdater(form.Form):
label = _(u'Canonical URL updater form')
description = _(
u'This form will update the canonical URL of all Dexterity-based '
u'objects in the catalog providing the Social Media behavior.'
)
u'objects in the catalog providing the Social Media behavior.')
ignoreContext = True

@property
Expand Down
2 changes: 1 addition & 1 deletion sc/social/like/browser/viewlets.py
Expand Up @@ -92,7 +92,7 @@ def enabled(self):
# If using folder_full_view or all_content, we add metadata
# in order to proper display share buttons for
# contained content types
if template in ('all_content', 'folder_full_view',):
if template in ('all_content', 'folder_full_view'):
return True
return self.helper.enabled(self.view)

Expand Down
36 changes: 13 additions & 23 deletions sc/social/like/interfaces.py
Expand Up @@ -72,7 +72,7 @@ class ISocialLikeSettings(model.Schema):
required=True,
default=DEFAULT_ENABLED_CONTENT_TYPES,
value_type=schema.Choice(
vocabulary='plone.app.vocabularies.ReallyUserFriendlyTypes')
vocabulary='plone.app.vocabularies.ReallyUserFriendlyTypes'),
)

plugins_enabled = schema.Tuple(
Expand All @@ -83,7 +83,7 @@ class ISocialLikeSettings(model.Schema):
),
required=False,
default=DEFAULT_PLUGINS_ENABLED,
value_type=schema.Choice(vocabulary='sc.social.likes.plugins')
value_type=schema.Choice(vocabulary='sc.social.likes.plugins'),
)

validation_enabled = schema.Bool(
Expand All @@ -92,8 +92,7 @@ class ISocialLikeSettings(model.Schema):
u'help_validation_enabled',
default=u'Enables validation to check if content follows social networks sharing best practices. '
u'The validation includes title, description and lead image fields. '
u'This feature is only available for Dexterity-based content types.'
),
u'This feature is only available for Dexterity-based content types.'),
default=True,
)

Expand All @@ -116,8 +115,7 @@ class ISocialLikeSettings(model.Schema):
u'widgets , instead simple links will be used.\n'
u'This will limits user experience and features '
u'(like the share count) but will enhance users privacy: '
u'no 3rd party cookies will be sent to users.'
),
u'no 3rd party cookies will be sent to users.'),
default=False,
)

Expand All @@ -137,8 +135,7 @@ class ISocialLikeSettings(model.Schema):
default=u'The canonical domain will be used to construct the canonical URL (<code>og:url</code> property) of portal objects. '
u'Use the domain name of your site (e.g. <strong>http://www.example.org</strong> or <strong>https://www.example.org</strong>). '
u'Facebook will use the canonical URL to ensure that all actions such as likes and shares aggregate at the same URL rather than spreading across multiple versions of a page. '
u'Check <a href="https://pypi.python.org/pypi/sc.social.like">package documentation</a> for more information on how to use this feature.'
),
u'Check <a href="https://pypi.python.org/pypi/sc.social.like">package documentation</a> for more information on how to use this feature.'),
required=True,
constraint=validate_canonical_domain,
)
Expand All @@ -149,8 +146,7 @@ class ISocialLikeSettings(model.Schema):
description=_(
u'help_fallback_image',
default=u'Content without a lead image will use this image as fallback (<code>og:image</code> property). '
u'There could be a delay of up to 2 minutes when replacing this image.'
),
u'There could be a delay of up to 2 minutes when replacing this image.'),
required=False,
constraint=validate_og_fallback_image,
)
Expand All @@ -164,7 +160,7 @@ class ISocialLikeSettings(model.Schema):
'facebook_app_id',
'fbbuttons',
'fbshowlikes',
'facebook_prefetch_enabled'
'facebook_prefetch_enabled',
],
)

Expand All @@ -174,8 +170,7 @@ class ISocialLikeSettings(model.Schema):
u'help_verb_display',
default=u'The verb to display in the Facebook button. '
u'Currently only "like" and "recommend" are '
u'supported.',
),
u'supported.'),
required=True,
default=u'like',
vocabulary=FacebookVerbsVocabulary,
Expand All @@ -186,8 +181,7 @@ class ISocialLikeSettings(model.Schema):
description=_(
u'help_admins',
default=u'A comma-separated list of either the '
u'Facebook IDs of page administrators.',
),
u'Facebook IDs of page administrators.'),
required=False,
default='',
)
Expand All @@ -197,8 +191,7 @@ class ISocialLikeSettings(model.Schema):
description=_(
u'help_appid',
default=u'A Facebook Platform application ID.\n'
u'This is required when \"Do not track users\" option is enabled.',
),
u'This is required when \"Do not track users\" option is enabled.'),
required=False,
default='',
)
Expand All @@ -219,8 +212,7 @@ class ISocialLikeSettings(model.Schema):
description=_(
u'help_show_likes',
default=u'If enabled, the Facebook button will show the number of '
u'Facebook users who have already liked this page.'
),
u'Facebook users who have already liked this page.'),
default=True,
)

Expand All @@ -232,8 +224,7 @@ class ISocialLikeSettings(model.Schema):
u'crawler scrape and cache metadata every time a new '
u'piece content is published and every time published '
u'content is edited. '
u'This will keep the metadata updated on Facebook always.'
),
u'This will keep the metadata updated on Facebook always.'),
default=False,
)

Expand All @@ -244,8 +235,7 @@ class ISocialLikeSettings(model.Schema):
title=_(u'Twitter nick'),
description=_(
u'help_your_twitter_nick',
default=u'Enter your twitter nick. eg. simplesconsultoria',
),
default=u'Enter your twitter nick. eg. simplesconsultoria'),
required=False,
default='',
)
2 changes: 1 addition & 1 deletion sc/social/like/plugins/facebook/utils.py
Expand Up @@ -40,7 +40,7 @@ def facebook_language(languages, default):
if not languages:
# do not change anything
return default
languages = [languages, ] if not isinstance(languages, list) else languages
languages = [languages] if not isinstance(languages, list) else languages
languages = [fix_iso(l) for l in languages]
prefered = [l for l in languages if l in FB_LOCALES]
return prefered and prefered[0] or default
3 changes: 1 addition & 2 deletions sc/social/like/subscribers.py
Expand Up @@ -111,8 +111,7 @@ def assign_canonical_url(obj, event):
else:
logger.warn(
'Canonical domain not set in Social Media configlet; '
"Facebook's Open Graph canonical URL (og:orl) will not be available"
)
"Facebook's Open Graph canonical URL (og:orl) will not be available")


def check_sharing_best_practices(obj, event):
Expand Down
8 changes: 4 additions & 4 deletions sc/social/like/tests/test_plugin_facebook.py
Expand Up @@ -193,11 +193,11 @@ def test_fix_iso(self):
def test_facebook_language(self):
default = 'en_US'
self.assertEqual(facebook_language(['pt-br', 'pt'], default), 'pt_BR')
self.assertEqual(facebook_language(['de', ], default), 'de_DE')
self.assertEqual(facebook_language(['it', ], default), 'it_IT')
self.assertEqual(facebook_language(['de'], default), 'de_DE')
self.assertEqual(facebook_language(['it'], default), 'it_IT')
self.assertEqual(facebook_language(['fi', 'en'], default), 'fi_FI')
self.assertEqual(facebook_language(['ga', ], default), 'ga_IE')
self.assertEqual(facebook_language(['ji', ], default), default)
self.assertEqual(facebook_language(['ga'], default), 'ga_IE')
self.assertEqual(facebook_language(['ji'], default), default)
self.assertEqual(facebook_language([], default), default)


Expand Down
6 changes: 2 additions & 4 deletions sc/social/like/tiles/facebook.py
Expand Up @@ -41,8 +41,7 @@ class IFacebookTile(IPersistentCoverTile):
title=_(u'Width'),
description=_(
u'Set the maximum width of the widget between 180 and 500 pixels. '
u'Leave it empty to automatically adjust the widget to the width of the tile.'
),
u'Leave it empty to automatically adjust the widget to the width of the tile.'),
required=False,
default=None,
min=180,
Expand All @@ -53,8 +52,7 @@ class IFacebookTile(IPersistentCoverTile):
title=_(u'Height'),
description=_(
u'Set the height of a displayed widget, overriding the value stored with the widget ID. '
u'Must be greater than 70 pixels. '
),
u'Must be greater than 70 pixels. '),
required=True,
default=500,
min=70,
Expand Down
12 changes: 4 additions & 8 deletions sc/social/like/tiles/twitter.py
Expand Up @@ -42,8 +42,7 @@ class ITwitterTile(IPersistentCoverTile):
title=_(u'Width'),
description=_(
u'Set the maximum width of the widget between 180 and 520 pixels. '
u'Leave it empty to automatically adjust the widget to the width of the tile.'
),
u'Leave it empty to automatically adjust the widget to the width of the tile.'),
required=False,
default=None,
min=180,
Expand All @@ -55,8 +54,7 @@ class ITwitterTile(IPersistentCoverTile):
description=_(
u'Set the height of a displayed widget, overriding the value stored with the widget ID. '
u'Must be greater than 200 pixels. '
u'Note: this parameter does not apply if a tweet limit has been specified.'
),
u'Note: this parameter does not apply if a tweet limit has been specified.'),
required=False,
default=500,
min=200,
Expand All @@ -73,8 +71,7 @@ class ITwitterTile(IPersistentCoverTile):
title=_(u'Tweet limit'),
description=_(
u'Display an expanded timeline of between 1 and 20 tweets. '
u'Leave it empty to use the default or to set the height of the widget.'
),
u'Leave it empty to use the default or to set the height of the widget.'),
required=False,
default=None,
min=1,
Expand All @@ -86,8 +83,7 @@ class ITwitterTile(IPersistentCoverTile):
description=_(
u'A timeline widget is a live region of a page which may receive updates as new tweets become available. '
u'When specified as polite, assistive technologies will notify users of updates but generally do not interrupt the current task, and updates take low priority. '
u'When specified as assertive, assistive technologies will immediately notify the user, and could potentially clear the speech queue of previous updates.'
),
u'When specified as assertive, assistive technologies will immediately notify the user, and could potentially clear the speech queue of previous updates.'),
required=True,
values=['polite', 'assertive'],
default='polite',
Expand Down
3 changes: 1 addition & 2 deletions sc/social/like/upgrades/v3046/__init__.py
Expand Up @@ -11,8 +11,7 @@ def reindex_catalog(setup_tool):
test = 'test' in setup_tool.REQUEST # used to ignore transactions on tests
logger.info(
u'Reindexing the catalog. '
u'This process could take a long time on large sites. Be patient.'
)
u'This process could take a long time on large sites. Be patient.')
catalog = api.portal.get_tool('portal_catalog')
results = catalog()
logger.info(u'Found {0} objects'.format(len(results)))
Expand Down

0 comments on commit ef15464

Please sign in to comment.