From e8ad82987233a0bc046ee8167f1b27046aecacc9 Mon Sep 17 00:00:00 2001 From: Arnaud Fontaine Date: Tue, 22 Oct 2019 10:43:01 +0900 Subject: [PATCH 1/3] wkhtmltopdf: convertFile() is not supposed to work with mimetypes, only format. --- cloudooo/manager.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cloudooo/manager.py b/cloudooo/manager.py index 8ca5045..f5df2fb 100644 --- a/cloudooo/manager.py +++ b/cloudooo/manager.py @@ -123,8 +123,8 @@ class Manager(object): # use the conversion_kw in a possible interoperable way between all # "html to pdf" handlers. if (conversion_kw and - source_format in ("html", "text/html") and - destination_format in ("pdf", "application/pdf")): + source_format == "html" and + destination_format == "pdf"): handler_class = WkhtmltopdfHandler else: handler_class = getHandlerClass(source_format, -- 2.30.9 From 8945f3a0c004f36cd416847091fb772e72dd5124 Mon Sep 17 00:00:00 2001 From: Arnaud Fontaine Date: Tue, 22 Oct 2019 10:44:59 +0900 Subject: [PATCH 2/3] wkhtmltopdf: Also support 'htm' as source_format ('text/html' mimetype maps to both 'htm' and 'html' extensions). --- cloudooo/handler/wkhtmltopdf/tests/testWkhtmltopdfServer.py | 1 + cloudooo/manager.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cloudooo/handler/wkhtmltopdf/tests/testWkhtmltopdfServer.py b/cloudooo/handler/wkhtmltopdf/tests/testWkhtmltopdfServer.py index bd69d6c..5c1be4c 100644 --- a/cloudooo/handler/wkhtmltopdf/tests/testWkhtmltopdfServer.py +++ b/cloudooo/handler/wkhtmltopdf/tests/testWkhtmltopdfServer.py @@ -35,6 +35,7 @@ class TestServer(TestCase): return [ (join('data', 'test_with_png_dataurl.html'), "html", "pdf", "application/pdf"), (join('data', 'test_with_script.html'), "html", "pdf", "application/pdf"), + (join('data', 'test_with_script.html'), "htm", "pdf", "application/pdf"), ] def testConvertHtmltoPdf(self): diff --git a/cloudooo/manager.py b/cloudooo/manager.py index f5df2fb..95f5668 100644 --- a/cloudooo/manager.py +++ b/cloudooo/manager.py @@ -123,7 +123,7 @@ class Manager(object): # use the conversion_kw in a possible interoperable way between all # "html to pdf" handlers. if (conversion_kw and - source_format == "html" and + source_format in ("htm", "html") and destination_format == "pdf"): handler_class = WkhtmltopdfHandler else: -- 2.30.9 From e7d81d351777e2825328a5ebeac30cc6782d318b Mon Sep 17 00:00:00 2001 From: Arnaud Fontaine Date: Wed, 23 Oct 2019 11:00:59 +0900 Subject: [PATCH 3/3] WIP: According to Gabriel, convertFile() only work with format, not mimetype. Also update Interface for other methods based on the manager implementation. WIP because: convertBundle() too? but it is not implemented anywhere so remove? --- cloudooo/interfaces/manager.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/cloudooo/interfaces/manager.py b/cloudooo/interfaces/manager.py index ba30c9a..a8a5ce5 100644 --- a/cloudooo/interfaces/manager.py +++ b/cloudooo/interfaces/manager.py @@ -33,12 +33,12 @@ class IManager(Interface): """Provides public method to communicate with Cloudooo clients """ - def convertFile(content, source_mimetype, destination_mimetype, **kw): + def convertFile(content, source_format, destination_format, **kw): """Returns the converted file in the given format. content : binary data to convert - source_mimetype : mimetype of given content - destination_mimetype : expected output conversion mimetype + source_format : input format (extension without '.') + destination_format : output conversion format (extension without '.') **kw holds specific parameters for the conversion """ @@ -59,17 +59,17 @@ class IManager(Interface): **kw holds specific parameters for the conversion """ - def getFileMetadataItemList(content, source_mimetype): + def getFileMetadataItemList(content, source_format): """Returns a list key, value pairs representing the metadata values for the document. The structure of this list is "unpredictable" and follows the convention of each file. content : binary data where to reads metadata - source_mimetype : mimetype of given content + source_format : input format (extension without '.') """ - def convertFileAndGetMetadataItemList(content, source_mimetype, - destination_mimetype, **kw): + def convertFileAndGetMetadataItemList(content, source_format, + destination_format, **kw): """returns a converted version of provided content plus a dictionary of extracted metadata. signature of method is same as convertFile @@ -78,12 +78,12 @@ class IManager(Interface): 'metadata' entries. """ - def updateFileMetadata(content, source_mimetype, metadata_dict): + def updateFileMetadata(content, source_format, metadata_dict): """Updates the content with provided metadata and return the new file. content : binary data to convert - source_mimetype : mimetype of given content + source_format : input format (extension without '.') metadata_dict : Metadatas to include in content """ -- 2.30.9