-
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fc] Repository: Products.PortalTransforms
Branch: refs/heads/master Date: 2016-02-01T13:36:21+01:00 Author: Philip Bauer (pbauer) <bauer@starzel.de> Commit: plone/Products.PortalTransforms@e9ff23b 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) <jk@kleinundpartner.at> Commit: plone/Products.PortalTransforms@ac64a87 Merge pull request #13 from plone/thet-zope4 Use docutils for rest-transforms Files changed: M CHANGES.rst M Products/PortalTransforms/transforms/rest.py
- Loading branch information
Showing
1 changed file
with
221 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) <bauer@starzel.de> | ||
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: <isonum.txt>', D()) | ||
+ ... out = transform.convert('.. raw:: html\n :file: <isonum.txt>', 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 <H> 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 = '<h%(level)s class="title">%(title)s</h%(level)s>\n' % { | ||
+ 'level': initial_header_level, | ||
+ 'title': parts['title']} | ||
+ | ||
+ subheader = '<h%(level)s class="subtitle">%(subtitle)s</h%(level)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) <jk@kleinundpartner.at> | ||
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: <isonum.txt>', D()) | ||
+ ... out = transform.convert('.. raw:: html\n :file: <isonum.txt>', 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 <H> 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 = '<h%(level)s class="title">%(title)s</h%(level)s>\n' % { | ||
+ 'level': initial_header_level, | ||
+ 'title': parts['title']} | ||
+ | ||
+ subheader = '<h%(level)s class="subtitle">%(subtitle)s</h%(level)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) | ||
|
||
|