Commit f37ffe13 authored by Jérome Perrin's avatar Jérome Perrin

OOoUtils: deprecated openFromString in favor of openFromBytes WIP 🚧

parent e4df9d77
Pipeline #27225 canceled with stage
in 0 seconds
...@@ -91,7 +91,7 @@ if not (content_type.startswith('application/vnd.sun.xml') ...@@ -91,7 +91,7 @@ if not (content_type.startswith('application/vnd.sun.xml')
content_type=content_type) content_type=content_type)
tmp_ooo.convertToBaseFormat() tmp_ooo.convertToBaseFormat()
_, import_file_content = tmp_ooo.convert('ods') _, import_file_content = tmp_ooo.convert('ods')
parser.openFromString(str(import_file_content)) parser.openFromBytes(bytes(import_file_content))
else: else:
parser.openFile(import_file) parser.openFile(import_file)
......
...@@ -50,6 +50,7 @@ from lxml.etree import Element, XMLSyntaxError ...@@ -50,6 +50,7 @@ from lxml.etree import Element, XMLSyntaxError
from copy import deepcopy from copy import deepcopy
from warnings import warn from warnings import warn
from Products.ERP5Type.Utils import bytes2str from Products.ERP5Type.Utils import bytes2str
from Products.ERP5Type.Utils import deprecated
class CorruptedOOoFile(Exception): pass class CorruptedOOoFile(Exception): pass
...@@ -234,8 +235,9 @@ class OOoParser(Implicit): ...@@ -234,8 +235,9 @@ class OOoParser(Implicit):
self.pictures = {} self.pictures = {}
self.filename = None self.filename = None
def openFromString(self, text_content): def openFromBytes(self, bytes_content):
return self.openFile(BytesIO(text_content)) return self.openFile(BytesIO(bytes_content))
openFromString = deprecated("openFromString is deprecated, use openFromBytes instead")(openFromBytes)
def openFile(self, file_descriptor): def openFile(self, file_descriptor):
""" """
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment