Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions buildout.d/versions.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ watchdog = 0.10.4
ipdb = 0.13.6
toml = 0.10.2
psutil = 5.4.6
cryptography = 3.3.2
wcwidth = 0.2.13
cffi = 1.15.1
pycparser = 2.21

# tests
plone.restapi = 7.7.0
Expand Down
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,7 @@
target = plone
[console_scripts]
odfsplit = appy.bin.odfsplit:main
# converter script to be used once the project runs python 3
# converter = appy.pod.converter:main
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je me demandais si c'était pas plus intelligent de push ce script sur la branche master et pas 3.x finalement

""",
)
6 changes: 5 additions & 1 deletion src/collective/documentgenerator/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from plone import api
from Products.CMFPlone.utils import safe_unicode

import appy.pod
import os
import re

Expand Down Expand Up @@ -35,10 +36,13 @@
u'Comma': u',', u'Semicolon': u';', u'Colon': u':', u'Space': u' ', u'Tabulation': u'\t'}
DEFAULT_CSV_STRING_DELIMITERS = {u"Double Quote": u'"', u"Single Quote": u"'"}

CONVSCRIPT = '{}/converter.py'.format(os.path.dirname(appy.pod.__file__))


if HAS_PLONE_5_2:
import sys
from zope.deprecation import deprecation

import sys
sys.modules['collective.documentgenerator.demo.helper.ATDemoHelperView'] = \
deprecation.deprecated(deprecation, 'Archetypes was removed from Plone 5.2.')

Expand Down
5 changes: 1 addition & 4 deletions src/collective/documentgenerator/events/styles_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,12 @@
from zExceptions import Redirect
from zope.i18n import translate

import appy.pod
import logging
import os


logger = logging.getLogger('collective.documentgenerator: styles update')

CONVSCRIPT = '{}/converter.py'.format(os.path.dirname(appy.pod.__file__))


def update_styles_of_all_PODtemplate(style_template, event):
"""
Expand Down Expand Up @@ -83,7 +80,7 @@ def _update_template_styles(pod_template, style_template_filename):
cmd = '{path} {script} {tmp_file} {extension} -e ' \
'{libreoffice_host} -p {port} ' \
'-t {style_template} -v -a {stream}'.format(path=config.get_uno_path(),
script=CONVSCRIPT,
script=config.CONVSCRIPT,
tmp_file=temp_file.name,
extension='odt',
libreoffice_host=config.get_oo_server(),
Expand Down
6 changes: 3 additions & 3 deletions src/collective/documentgenerator/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from collective.documentgenerator import _
from collective.documentgenerator import BLDT_DIR
from collective.documentgenerator import config
from collective.documentgenerator.config import CONVSCRIPT
from collective.documentgenerator.config import DEFAULT_OO_PORT
from collective.documentgenerator.config import get_oo_port_list
from collective.documentgenerator.config import get_oo_server
Expand Down Expand Up @@ -291,8 +292,7 @@ def convert_file(afile, fmt="pdf", renderer=False, gen_context=None, delete_temp
message = _(u"Conversion with renderer only works from odt files.")
raise Invalid(message)
return convert_odt(afile, fmt=fmt, gen_context=gen_context, delete_temp_files=delete_temp_files)
from appy.pod import converter
converter_path = converter.__file__.endswith(".pyc") and converter.__file__[:-1] or converter.__file__

file_ext = afile.filename.split('.')[-1].lower()
temp_file = create_temporary_file(afile, base_name=".{}".format(file_ext))
converted_filename = temp_file.name.replace(".{}".format(file_ext), ".{}".format(fmt))
Expand All @@ -301,7 +301,7 @@ def convert_file(afile, fmt="pdf", renderer=False, gen_context=None, delete_temp
ports = get_oo_port_list()
port = ports[0] if ports else DEFAULT_OO_PORT
command = "{python_uno_path} {converter_path} {temp_file} {fmt} -p {port} -e {server}".format(
python_uno_path=get_uno_path(), converter_path=converter_path, temp_file=temp_file.name, fmt=fmt,
python_uno_path=get_uno_path(), converter_path=CONVSCRIPT, temp_file=temp_file.name, fmt=fmt,
port=port, server=get_oo_server())
out, err, code = runCommand(command)
# This command has no output on success
Expand Down
Loading