Formatting...
authorThierry Florac <tflorac@ulthar.net>
Wed, 04 Sep 2019 15:56:28 +0200
changeset 1341 09247c61f985
parent 1340 d2e2e785252b
child 1342 999fa08d99c2
Formatting...
src/pyams_content/component/paragraph/html.py
src/pyams_content/component/paragraph/interfaces/html.py
src/pyams_content/component/paragraph/zmi/html.py
--- a/src/pyams_content/component/paragraph/html.py	Fri Jul 26 19:23:34 2019 +0200
+++ b/src/pyams_content/component/paragraph/html.py	Wed Sep 04 15:56:28 2019 +0200
@@ -10,8 +10,6 @@
 # FOR A PARTICULAR PURPOSE.
 #
 
-__docformat__ = 'restructuredtext'
-
 import re
 
 from pyquery import PyQuery
@@ -26,12 +24,16 @@
 from pyams_content.component.extfile.interfaces import IBaseExtFile, IExtFileContainerTarget
 from pyams_content.component.illustration.interfaces import IIllustrationTarget
 from pyams_content.component.links import ExternalLink, InternalLink, MailtoLink
-from pyams_content.component.links.interfaces import IExternalLink, IInternalLink, ILinkContainerTarget, IMailtoLink
-from pyams_content.component.paragraph import BaseParagraph, BaseParagraphContentChecker, BaseParagraphFactory
+from pyams_content.component.links.interfaces import IExternalLink, IInternalLink, \
+    ILinkContainerTarget, IMailtoLink
+from pyams_content.component.paragraph import BaseParagraph, BaseParagraphContentChecker, \
+    BaseParagraphFactory
 from pyams_content.component.paragraph.interfaces import IParagraphFactory
-from pyams_content.component.paragraph.interfaces.html import HTML_PARAGRAPH_NAME, HTML_PARAGRAPH_RENDERERS, \
-    HTML_PARAGRAPH_TYPE, IHTMLParagraph, IRawParagraph, RAW_PARAGRAPH_NAME, RAW_PARAGRAPH_RENDERERS, RAW_PARAGRAPH_TYPE
-from pyams_content.features.checker.interfaces import IContentChecker, MISSING_LANG_VALUE, MISSING_VALUE
+from pyams_content.component.paragraph.interfaces.html import HTML_PARAGRAPH_NAME, \
+    HTML_PARAGRAPH_RENDERERS, HTML_PARAGRAPH_TYPE, IHTMLParagraph, IRawParagraph, \
+    RAW_PARAGRAPH_NAME, RAW_PARAGRAPH_RENDERERS, RAW_PARAGRAPH_TYPE
+from pyams_content.features.checker.interfaces import IContentChecker, MISSING_LANG_VALUE, \
+    MISSING_VALUE
 from pyams_content.features.renderer import RenderersVocabulary
 from pyams_i18n.interfaces import II18n, II18nManager, INegotiator
 from pyams_sequence.interfaces import ISequentialIntIds
@@ -44,6 +46,9 @@
 from pyams_utils.vocabulary import vocabulary_config
 
 
+__docformat__ = 'restructuredtext'
+
+
 #
 # Raw HTML paragraph
 #
@@ -79,7 +84,7 @@
             langs = manager.get_languages()
         else:
             negotiator = get_utility(INegotiator)
-            langs = (negotiator.server_language, )
+            langs = (negotiator.server_language,)
         i18n = II18n(self.context)
         for lang in langs:
             value = i18n.get_attribute('body', lang, request)
@@ -88,7 +93,8 @@
                 if len(langs) == 1:
                     output.append(translate(MISSING_VALUE).format(field=field_title))
                 else:
-                    output.append(translate(MISSING_LANG_VALUE).format(field=field_title, lang=lang))
+                    output.append(
+                        translate(MISSING_LANG_VALUE).format(field=field_title, lang=lang))
         return output
 
 
@@ -176,8 +182,9 @@
                     extfile_info = IBaseExtFile(association, None)
                     if extfile_info is not None:
                         request = check_request()
-                        extfile_url = absolute_url(II18n(extfile_info).query_attribute('data', request=request),
-                                                   request=request)
+                        extfile_url = absolute_url(
+                            II18n(extfile_info).query_attribute('data', request=request),
+                            request=request)
                         if extfile_url.endswith(href):
                             has_link = True
                             break
@@ -219,7 +226,7 @@
             langs = manager.get_languages()
         else:
             negotiator = get_utility(INegotiator)
-            langs = (negotiator.server_language, )
+            langs = (negotiator.server_language,)
         i18n = II18n(self.context)
         for lang in langs:
             value = i18n.get_attribute('body', lang, request)
@@ -228,7 +235,8 @@
                 if len(langs) == 1:
                     output.append(translate(MISSING_VALUE).format(field=field_title))
                 else:
-                    output.append(translate(MISSING_LANG_VALUE).format(field=field_title, lang=lang))
+                    output.append(
+                        translate(MISSING_LANG_VALUE).format(field=field_title, lang=lang))
         return output
 
 
--- a/src/pyams_content/component/paragraph/interfaces/html.py	Fri Jul 26 19:23:34 2019 +0200
+++ b/src/pyams_content/component/paragraph/interfaces/html.py	Wed Sep 04 15:56:28 2019 +0200
@@ -33,8 +33,9 @@
     """Raw HTML paragraph interface"""
 
     body = I18nTextField(title=_("Source code"),
-                         description=_("<span>This code will be used 'as is', without any transformation, if using the "
-                                       "'raw' renderer. Use with care!!<br />Press &lt;CTRL&gt;+&lt;,&gt; to display "
+                         description=_("<span>This code will be used 'as is', without any "
+                                       "transformation, if using the 'raw' renderer. Use with "
+                                       "care!!<br />Press &lt;CTRL&gt;+&lt;,&gt; to display "
                                        "editor options...</span>"),
                          required=False)
 
--- a/src/pyams_content/component/paragraph/zmi/html.py	Fri Jul 26 19:23:34 2019 +0200
+++ b/src/pyams_content/component/paragraph/zmi/html.py	Wed Sep 04 15:56:28 2019 +0200
@@ -10,8 +10,6 @@
 # FOR A PARTICULAR PURPOSE.
 #
 
-__docformat__ = 'restructuredtext'
-
 from z3c.form import button
 from z3c.form.interfaces import INPUT_MODE
 from zope.interface import alsoProvides, implementer
@@ -22,12 +20,14 @@
 from pyams_content.component.paragraph.html import HTMLParagraph, RawParagraph
 from pyams_content.component.paragraph.interfaces import IBaseParagraph, IParagraphContainerTarget, \
     IParagraphFactorySettings, IParagraphTitle
-from pyams_content.component.paragraph.interfaces.html import HTML_PARAGRAPH_TYPE, IHTMLParagraph, IRawParagraph, \
-    RAW_PARAGRAPH_TYPE
-from pyams_content.component.paragraph.zmi import BaseParagraphAJAXAddForm, BaseParagraphAJAXEditForm, \
-    BaseParagraphAddForm, BaseParagraphAddMenu, BaseParagraphPropertiesEditForm, IParagraphInnerEditFormButtons, \
+from pyams_content.component.paragraph.interfaces.html import HTML_PARAGRAPH_TYPE, IHTMLParagraph, \
+    IRawParagraph, RAW_PARAGRAPH_TYPE
+from pyams_content.component.paragraph.zmi import BaseParagraphAJAXAddForm, \
+    BaseParagraphAJAXEditForm, BaseParagraphAddForm, BaseParagraphAddMenu, \
+    BaseParagraphPropertiesEditForm, IParagraphInnerEditFormButtons, \
     get_json_paragraph_refresh_event, get_json_paragraph_toolbar_refresh_event
-from pyams_content.component.paragraph.zmi.interfaces import IParagraphContainerView, IParagraphInnerEditor
+from pyams_content.component.paragraph.zmi.interfaces import IParagraphContainerView, \
+    IParagraphInnerEditor
 from pyams_content.interfaces import MANAGE_CONTENT_PERMISSION
 from pyams_form.form import ajax_config
 from pyams_form.interfaces.form import IInnerForm
@@ -46,6 +46,9 @@
 from pyams_viewlet.viewlet import viewlet_config
 from pyams_zmi.interfaces import IPropertiesEditForm
 
+
+__docformat__ = 'restructuredtext'
+
 from pyams_content import _
 
 
@@ -53,20 +56,23 @@
 # Raw HTML paragraph
 #
 
-@viewlet_config(name='add-raw-paragraph.divider', context=IParagraphContainerTarget, view=IParagraphContainerView,
-                layer=IPyAMSLayer, manager=IToolbarAddingMenu, weight=990)
+@viewlet_config(name='add-raw-paragraph.divider', context=IParagraphContainerTarget,
+                view=IParagraphContainerView, layer=IPyAMSLayer, manager=IToolbarAddingMenu,
+                weight=990)
 class RawParagraphAddMenuDivider(ProtectedFormObjectMixin, MenuDivider):
     """Source code paragraph add menu divider"""
 
     def __new__(cls, context, request, view, manager):
         settings = get_parent(context, IParagraphFactorySettings)
-        if (settings is not None) and (RawParagraphAddMenu.paragraph_type not in (settings.allowed_paragraphs or ())):
+        if (settings is not None) and (
+                RAW_PARAGRAPH_TYPE not in (settings.allowed_paragraphs or ())):
             return None
         return MenuDivider.__new__(cls)
 
 
-@viewlet_config(name='add-raw-paragraph.menu', context=IParagraphContainerTarget, view=IParagraphContainerView,
-                layer=IPyAMSLayer, manager=IToolbarAddingMenu, weight=999)
+@viewlet_config(name='add-raw-paragraph.menu', context=IParagraphContainerTarget,
+                view=IParagraphContainerView, layer=IPyAMSLayer, manager=IToolbarAddingMenu,
+                weight=999)
 class RawParagraphAddMenu(BaseParagraphAddMenu):
     """Source code paragraph add menu"""
 
@@ -147,8 +153,9 @@
 # Rich text paragraph
 #
 
-@viewlet_config(name='add-html-paragraph.menu', context=IParagraphContainerTarget, view=IParagraphContainerView,
-                layer=IPyAMSLayer, manager=IToolbarAddingMenu, weight=50)
+@viewlet_config(name='add-html-paragraph.menu', context=IParagraphContainerTarget,
+                view=IParagraphContainerView, layer=IPyAMSLayer, manager=IToolbarAddingMenu,
+                weight=50)
 class HTMLParagraphAddMenu(BaseParagraphAddMenu):
     """Rich text paragraph add menu"""
 
@@ -158,8 +165,8 @@
     paragraph_type = HTML_PARAGRAPH_TYPE
 
 
-@pagelet_config(name='add-html-paragraph.html', context=IParagraphContainerTarget, layer=IPyAMSLayer,
-                permission=MANAGE_CONTENT_PERMISSION)
+@pagelet_config(name='add-html-paragraph.html', context=IParagraphContainerTarget,
+                layer=IPyAMSLayer, permission=MANAGE_CONTENT_PERMISSION)
 @ajax_config(name='add-html-paragraph.json', context=IParagraphContainerTarget, layer=IPyAMSLayer,
              base=BaseParagraphAJAXAddForm)
 class HTMLParagraphAddForm(BaseParagraphAddForm):
@@ -224,7 +231,8 @@
                 get_json_paragraph_toolbar_refresh_event(parent, self.request))
             # refresh associations table
             output.setdefault('events', []).append(
-                get_json_switched_table_refresh_event(self.context, self.request, AssociationsTable))
+                get_json_switched_table_refresh_event(self.context, self.request,
+                                                      AssociationsTable))
         return output