From 6022b2a23db8945a7e7e9d99789cc5ab31a8b2ff Mon Sep 17 00:00:00 2001 From: jensens Date: Mon, 1 Feb 2016 15:39:17 +0100 Subject: [PATCH] [fc] Repository: Products.PortalTransforms Branch: refs/heads/master Date: 2016-02-01T13:36:21+01:00 Author: Philip Bauer (pbauer) Commit: https://github.com/plone/Products.PortalTransforms/commit/e9ff23b7f56297dadcfe91f4108b0d8b39ed2c6a Use docutils for rest since the rest-wrapper was removed from zope2 Files changed: M CHANGES.rst M Products/PortalTransforms/transforms/rest.py Repository: Products.PortalTransforms Branch: refs/heads/master Date: 2016-02-01T15:39:17+01:00 Author: Jens W. Klein (jensens) Commit: https://github.com/plone/Products.PortalTransforms/commit/ac64a87406a808e261063fff4e138ad9709cb818 Merge pull request #13 from plone/thet-zope4 Use docutils for rest-transforms Files changed: M CHANGES.rst M Products/PortalTransforms/transforms/rest.py --- last_commit.txt | 306 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 221 insertions(+), 85 deletions(-) diff --git a/last_commit.txt b/last_commit.txt index 5d8066bbdb..ab4289efbb 100644 --- a/last_commit.txt +++ b/last_commit.txt @@ -1,124 +1,260 @@ -Repository: Products.Archetypes +Repository: Products.PortalTransforms Branch: refs/heads/master -Date: 2016-01-26T13:51:24+01:00 +Date: 2016-02-01T13:36:21+01:00 Author: Philip Bauer (pbauer) -Commit: https://github.com/plone/Products.Archetypes/commit/912e6f2493a56fcb6c3d2d03b664dc91c71d8aac +Commit: https://github.com/plone/Products.PortalTransforms/commit/e9ff23b7f56297dadcfe91f4108b0d8b39ed2c6a -Replace zope.tal.ndiff with difflib.ndiff +Use docutils for rest since the rest-wrapper was removed from zope2 Files changed: M CHANGES.rst -M Products/Archetypes/tests/utils.py +M Products/PortalTransforms/transforms/rest.py diff --git a/CHANGES.rst b/CHANGES.rst -index c71df88..0475497 100644 +index ca732d5..7c4eb57 100644 --- a/CHANGES.rst +++ b/CHANGES.rst -@@ -10,7 +10,8 @@ New: +@@ -6,6 +6,9 @@ Changelog - Fixes: + New: --- *add item here* -+- Replace zope.tal.ndiff with difflib.ndiff. It was removed in zope.tal 4.0.0. ++- Use docutils for rest since the rest-wrapper was removed from zope2. + [pbauer] ++ + - Depend on ``Pillow>=3.1.0``. + [jensens] +diff --git a/Products/PortalTransforms/transforms/rest.py b/Products/PortalTransforms/transforms/rest.py +index e86a0ad..ed28b23 100644 +--- a/Products/PortalTransforms/transforms/rest.py ++++ b/Products/PortalTransforms/transforms/rest.py +@@ -1,6 +1,6 @@ + # -*- coding: utf-8 -*- + from Products.PortalTransforms.interfaces import ITransform +-from reStructuredText import HTML ++from docutils.core import publish_parts + from zope.interface import implementer - 1.10.11 (2015-10-27) -diff --git a/Products/Archetypes/tests/utils.py b/Products/Archetypes/tests/utils.py -index 98696aa..a5c9d21 100644 ---- a/Products/Archetypes/tests/utils.py -+++ b/Products/Archetypes/tests/utils.py -@@ -28,8 +28,8 @@ - import re - import sys - import logging -+import difflib - --from zope.tal import ndiff - from App.Common import package_home - from ZPublisher.HTTPRequest import HTTPRequest - from ZPublisher.HTTPResponse import HTTPResponse -@@ -88,15 +88,7 @@ def nicerange(lo, hi): - - - def showdiff(a, b): -- cruncher = ndiff.SequenceMatcher(ndiff.IS_LINE_JUNK, a, b) -- for tag, alo, ahi, blo, bhi in cruncher.get_opcodes(): -- if tag == "equal": -- continue -- print nicerange(alo, ahi) + tag[0] + nicerange(blo, bhi) -- ndiff.dump('<', a, alo, ahi) -- if a and b: -- print '---' -- ndiff.dump('>', b, blo, bhi) -+ print(''.join(difflib.ndiff(a, b))) - - - def populateFolder(folder, folder_type, doc_type): + +@@ -22,7 +22,7 @@ class rest(object): + default: + + >>> try: +- ... out = transform.convert('.. raw:: html\n :file: ', D()) ++ ... out = transform.convert('.. raw:: html\n :file: ', D()) # noqa + ... except NotImplementedError: + ... print 'Good' + ... else: +@@ -79,27 +79,64 @@ def name(self): + + def convert(self, orig, data, **kwargs): + # do the format ++ writer_name = kwargs.get('writer_name', 'html4css1') ++ + encoding = kwargs.get('encoding', 'utf-8') + input_encoding = kwargs.get('input_encoding', encoding) + output_encoding = kwargs.get('output_encoding', encoding) + language = kwargs.get('language', 'en') + warnings = kwargs.get('warnings', None) +- ++ stylesheet = kwargs.get('stylesheet', None) + initial_header_level = int(self.config.get('initial_header_level', 2)) + report_level = int(self.config.get('report_level', 2)) ++ settings = { ++ 'documentclass': '', ++ 'traceback': 1, ++ 'input_encoding': input_encoding, ++ 'output_encoding': output_encoding, ++ 'stylesheet': stylesheet, ++ 'stylesheet_path': None, ++ 'file_insertion_enabled': 0, ++ 'raw_enabled': 0, ++ 'language_code': language, ++ # starting level for elements: ++ 'initial_header_level': initial_header_level, ++ # set the reporting level to something sane: ++ 'report_level': report_level, ++ # don't break if we get errors: ++ 'halt_level': 6, ++ # remember warnings: ++ 'warning_stream': warnings, ++ } + +- settings = {'documentclass': '', +- 'traceback': 1, +- } +- +- html = HTML(orig, +- input_encoding=input_encoding, +- output_encoding=output_encoding, +- language_code=language, +- initial_header_level=initial_header_level, +- report_level=report_level, +- warnings=warnings, +- settings=settings) ++ parts = publish_parts( ++ source=orig, ++ writer_name=writer_name, ++ settings_overrides=settings, ++ config_section='zope application' ++ ) ++ ++ header = '%(title)s\n' % { ++ 'level': initial_header_level, ++ 'title': parts['title']} ++ ++ subheader = '%(subtitle)s\n' % { # noqa ++ 'level': initial_header_level+1, ++ 'subtitle': parts['subtitle']} ++ ++ body = '%(docinfo)s%(body)s' % { ++ 'docinfo': parts['docinfo'], ++ 'body': parts['body']} ++ ++ html = '' ++ if parts['title']: ++ html = html + header ++ if parts['subtitle']: ++ html = html + subheader ++ html = html + body ++ ++ if output_encoding != 'unicode': ++ html = html.encode(output_encoding) + + html = html.replace(' class="document"', '', 1) + data.setData(html) -Repository: Products.Archetypes +Repository: Products.PortalTransforms Branch: refs/heads/master -Date: 2016-02-01T15:34:11+01:00 +Date: 2016-02-01T15:39:17+01:00 Author: Jens W. Klein (jensens) -Commit: https://github.com/plone/Products.Archetypes/commit/eee6a55d87acdf2813f77493495ef124bea53ee5 +Commit: https://github.com/plone/Products.PortalTransforms/commit/ac64a87406a808e261063fff4e138ad9709cb818 -Merge pull request #51 from plone/thet-zope4 +Merge pull request #13 from plone/thet-zope4 -Replace deprecated zope.tal.ndiff with difflib.ndiff +Use docutils for rest-transforms Files changed: M CHANGES.rst -M Products/Archetypes/tests/utils.py +M Products/PortalTransforms/transforms/rest.py diff --git a/CHANGES.rst b/CHANGES.rst -index c71df88..0475497 100644 +index ca732d5..7c4eb57 100644 --- a/CHANGES.rst +++ b/CHANGES.rst -@@ -10,7 +10,8 @@ New: +@@ -6,6 +6,9 @@ Changelog - Fixes: + New: --- *add item here* -+- Replace zope.tal.ndiff with difflib.ndiff. It was removed in zope.tal 4.0.0. ++- Use docutils for rest since the rest-wrapper was removed from zope2. + [pbauer] ++ + - Depend on ``Pillow>=3.1.0``. + [jensens] + +diff --git a/Products/PortalTransforms/transforms/rest.py b/Products/PortalTransforms/transforms/rest.py +index e86a0ad..ed28b23 100644 +--- a/Products/PortalTransforms/transforms/rest.py ++++ b/Products/PortalTransforms/transforms/rest.py +@@ -1,6 +1,6 @@ + # -*- coding: utf-8 -*- + from Products.PortalTransforms.interfaces import ITransform +-from reStructuredText import HTML ++from docutils.core import publish_parts + from zope.interface import implementer + + +@@ -22,7 +22,7 @@ class rest(object): + default: + + >>> try: +- ... out = transform.convert('.. raw:: html\n :file: ', D()) ++ ... out = transform.convert('.. raw:: html\n :file: ', D()) # noqa + ... except NotImplementedError: + ... print 'Good' + ... else: +@@ -79,27 +79,64 @@ def name(self): + + def convert(self, orig, data, **kwargs): + # do the format ++ writer_name = kwargs.get('writer_name', 'html4css1') ++ + encoding = kwargs.get('encoding', 'utf-8') + input_encoding = kwargs.get('input_encoding', encoding) + output_encoding = kwargs.get('output_encoding', encoding) + language = kwargs.get('language', 'en') + warnings = kwargs.get('warnings', None) +- ++ stylesheet = kwargs.get('stylesheet', None) + initial_header_level = int(self.config.get('initial_header_level', 2)) + report_level = int(self.config.get('report_level', 2)) ++ settings = { ++ 'documentclass': '', ++ 'traceback': 1, ++ 'input_encoding': input_encoding, ++ 'output_encoding': output_encoding, ++ 'stylesheet': stylesheet, ++ 'stylesheet_path': None, ++ 'file_insertion_enabled': 0, ++ 'raw_enabled': 0, ++ 'language_code': language, ++ # starting level for elements: ++ 'initial_header_level': initial_header_level, ++ # set the reporting level to something sane: ++ 'report_level': report_level, ++ # don't break if we get errors: ++ 'halt_level': 6, ++ # remember warnings: ++ 'warning_stream': warnings, ++ } +- settings = {'documentclass': '', +- 'traceback': 1, +- } +- +- html = HTML(orig, +- input_encoding=input_encoding, +- output_encoding=output_encoding, +- language_code=language, +- initial_header_level=initial_header_level, +- report_level=report_level, +- warnings=warnings, +- settings=settings) ++ parts = publish_parts( ++ source=orig, ++ writer_name=writer_name, ++ settings_overrides=settings, ++ config_section='zope application' ++ ) ++ ++ header = '%(title)s\n' % { ++ 'level': initial_header_level, ++ 'title': parts['title']} ++ ++ subheader = '%(subtitle)s\n' % { # noqa ++ 'level': initial_header_level+1, ++ 'subtitle': parts['subtitle']} ++ ++ body = '%(docinfo)s%(body)s' % { ++ 'docinfo': parts['docinfo'], ++ 'body': parts['body']} ++ ++ html = '' ++ if parts['title']: ++ html = html + header ++ if parts['subtitle']: ++ html = html + subheader ++ html = html + body ++ ++ if output_encoding != 'unicode': ++ html = html.encode(output_encoding) - 1.10.11 (2015-10-27) -diff --git a/Products/Archetypes/tests/utils.py b/Products/Archetypes/tests/utils.py -index 98696aa..a5c9d21 100644 ---- a/Products/Archetypes/tests/utils.py -+++ b/Products/Archetypes/tests/utils.py -@@ -28,8 +28,8 @@ - import re - import sys - import logging -+import difflib - --from zope.tal import ndiff - from App.Common import package_home - from ZPublisher.HTTPRequest import HTTPRequest - from ZPublisher.HTTPResponse import HTTPResponse -@@ -88,15 +88,7 @@ def nicerange(lo, hi): - - - def showdiff(a, b): -- cruncher = ndiff.SequenceMatcher(ndiff.IS_LINE_JUNK, a, b) -- for tag, alo, ahi, blo, bhi in cruncher.get_opcodes(): -- if tag == "equal": -- continue -- print nicerange(alo, ahi) + tag[0] + nicerange(blo, bhi) -- ndiff.dump('<', a, alo, ahi) -- if a and b: -- print '---' -- ndiff.dump('>', b, blo, bhi) -+ print(''.join(difflib.ndiff(a, b))) - - - def populateFolder(folder, folder_type, doc_type): + html = html.replace(' class="document"', '', 1) + data.setData(html)