Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Titouan Soulard
erp5
Commits
6351b926
Commit
6351b926
authored
Mar 20, 2023
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
OOoUtils: deprecated openFromString in favor of openFromBytes WIP
🚧
parent
1924004f
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
20 additions
and
16 deletions
+20
-16
bt5/erp5_accounting/TestTemplateItem/portal_components/test.erp5.testAccounting.py
...emplateItem/portal_components/test.erp5.testAccounting.py
+1
-1
bt5/erp5_ooo_import/SkinTemplateItem/portal_skins/erp5_ooo_import/Base_importFile.py
...plateItem/portal_skins/erp5_ooo_import/Base_importFile.py
+2
-2
bt5/erp5_simplified_invoicing/TestTemplateItem/portal_components/test.erp5.testInvoice.py
...stTemplateItem/portal_components/test.erp5.testInvoice.py
+1
-1
bt5/erp5_web/TestTemplateItem/portal_components/test.erp5.testOOoChart.py
...tTemplateItem/portal_components/test.erp5.testOOoChart.py
+2
-2
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getCategoriesSpreadSheetMapping.py
...l_skins/erp5_core/Base_getCategoriesSpreadSheetMapping.py
+1
-1
product/ERP5OOo/OOoUtils.py
product/ERP5OOo/OOoUtils.py
+4
-2
product/ERP5OOo/tests/testOOoParser.py
product/ERP5OOo/tests/testOOoParser.py
+7
-5
product/ERP5OOo/tests/testOOoStyle.py
product/ERP5OOo/tests/testOOoStyle.py
+2
-2
No files found.
bt5/erp5_accounting/TestTemplateItem/portal_components/test.erp5.testAccounting.py
View file @
6351b926
...
...
@@ -3387,7 +3387,7 @@ class TestAccountingExport(AccountingTestCase):
form_id
=
'AccountingTransaction_view'
)
from
Products.ERP5OOo.OOoUtils
import
OOoParser
parser
=
OOoParser
()
parser
.
openFrom
String
(
ods_data
)
parser
.
openFrom
Bytes
(
ods_data
)
content_xml
=
parser
.
oo_files
[
'content.xml'
]
# just make sure that we have the correct account name
self
.
assertEqual
(
...
...
bt5/erp5_ooo_import/SkinTemplateItem/portal_skins/erp5_ooo_import/Base_importFile.py
View file @
6351b926
...
...
@@ -20,11 +20,11 @@ def getSpreadsheet(file):
tmp_ooo
.
edit
(
data
=
file
.
read
(),
content_type
=
content_type
)
tmp_ooo
.
convertToBaseFormat
()
ignored
,
import_file_content
=
tmp_ooo
.
convert
(
'ods'
)
ooo_parser
.
openFrom
String
(
str
(
import_file_content
))
ooo_parser
.
openFrom
Bytes
(
bytes
(
import_file_content
))
else
:
ooo_parser
.
openFile
(
file
)
else
:
ooo_parser
.
openFrom
String
(
file
)
ooo_parser
.
openFrom
Bytes
(
file
)
return
ooo_parser
.
getSpreadsheetsMapping
()
...
...
bt5/erp5_simplified_invoicing/TestTemplateItem/portal_components/test.erp5.testInvoice.py
View file @
6351b926
...
...
@@ -636,7 +636,7 @@ class TestInvoice(TestInvoiceMixin):
# the <draw:image> should not be present, because there's no logo
parser
=
OOoParser
()
parser
.
openFrom
String
(
odt
)
parser
.
openFrom
Bytes
(
odt
)
style_xml
=
parser
.
oo_files
[
'styles.xml'
]
self
.
assertNotIn
(
'<draw:image'
,
style_xml
)
...
...
bt5/erp5_web/TestTemplateItem/portal_components/test.erp5.testOOoChart.py
View file @
6351b926
...
...
@@ -149,7 +149,7 @@ class TestOOoChart(TestOOoChartMixin):
from
Products.ERP5OOo.OOoUtils
import
OOoParser
parser
=
OOoParser
()
parser
.
openFrom
String
(
body
)
parser
.
openFrom
Bytess
(
body
)
content_xml_view
=
parser
.
oo_files
[
'content.xml'
]
doc_view
=
etree
.
fromstring
(
content_xml_view
)
...
...
@@ -243,7 +243,7 @@ class TestOOoChart(TestOOoChartMixin):
from
Products.ERP5OOo.OOoUtils
import
OOoParser
parser
=
OOoParser
()
parser
.
openFrom
String
(
body
)
parser
.
openFrom
Bytes
(
body
)
content_xml_view
=
parser
.
oo_files
[
'content.xml'
]
doc_view
=
etree
.
fromstring
(
content_xml_view
)
...
...
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getCategoriesSpreadSheetMapping.py
View file @
6351b926
...
...
@@ -91,7 +91,7 @@ if not (content_type.startswith('application/vnd.sun.xml')
content_type
=
content_type
)
tmp_ooo
.
convertToBaseFormat
()
_
,
import_file_content
=
tmp_ooo
.
convert
(
'ods'
)
parser
.
openFrom
String
(
str
(
import_file_content
))
parser
.
openFrom
Bytes
(
bytes
(
import_file_content
))
else
:
parser
.
openFile
(
import_file
)
...
...
product/ERP5OOo/OOoUtils.py
View file @
6351b926
...
...
@@ -50,6 +50,7 @@ from lxml.etree import Element, XMLSyntaxError
from
copy
import
deepcopy
from
warnings
import
warn
from
Products.ERP5Type.Utils
import
bytes2str
from
Products.ERP5Type.Utils
import
deprecated
class
CorruptedOOoFile
(
Exception
):
pass
...
...
@@ -234,8 +235,9 @@ class OOoParser(Implicit):
self
.
pictures
=
{}
self
.
filename
=
None
def
openFromString
(
self
,
text_content
):
return
self
.
openFile
(
BytesIO
(
text_content
))
def
openFromBytes
(
self
,
bytes_content
):
return
self
.
openFile
(
BytesIO
(
bytes_content
))
openFromString
=
deprecated
(
"openFromString is deprecated, use openFromBytes instead"
)(
openFromBytes
)
def
openFile
(
self
,
file_descriptor
):
"""
...
...
product/ERP5OOo/tests/testOOoParser.py
View file @
6351b926
...
...
@@ -52,16 +52,17 @@ class TestOOoParser(unittest.TestCase):
self
.
assertEqual
(
person_mapping
[
1
],
[
'John Doe 0'
,
'John'
,
'Doe 0'
,
'john.doe0@foo.com'
])
def
test_openFrom
String
(
self
):
def
test_openFrom
Bytes
(
self
):
parser
=
OOoParser
()
parser
.
openFromString
(
open
(
makeFilePath
(
'import_data_list.ods'
),
'rb'
)
.
read
())
with
open
(
makeFilePath
(
'import_data_list.ods'
),
'rb'
)
as
f
:
parser
.
openFromBytes
(
f
.
read
())
mapping
=
parser
.
getSpreadsheetsMapping
()
self
.
assertEqual
([
'Person'
],
list
(
mapping
.
keys
()))
def
test_getSpreadSheetMappingStyle
(
self
):
parser
=
OOoParser
()
parser
.
openFile
(
open
(
makeFilePath
(
'import_data_list_with_style.ods'
),
'rb'
))
with
open
(
makeFilePath
(
'import_data_list_with_style.ods'
),
'rb'
)
as
f
:
parser
.
openFile
(
f
)
mapping
=
parser
.
getSpreadsheetsMapping
()
self
.
assertEqual
([
'Feuille1'
],
list
(
mapping
.
keys
()))
self
.
assertEqual
(
mapping
[
'Feuille1'
][
1
],
...
...
@@ -75,7 +76,8 @@ class TestOOoParser(unittest.TestCase):
def
test_getSpreadSheetMappingDataTypes
(
self
):
parser
=
OOoParser
()
parser
.
openFile
(
open
(
makeFilePath
(
'import_data_list_data_type.ods'
),
'rb'
))
with
open
(
makeFilePath
(
'import_data_list_data_type.ods'
),
'rb'
)
as
f
:
parser
.
openFile
(
f
)
mapping
=
parser
.
getSpreadsheetsMapping
()
self
.
assertEqual
([
'Feuille1'
],
list
(
mapping
.
keys
()))
self
.
assertEqual
(
mapping
[
'Feuille1'
][
0
],
...
...
product/ERP5OOo/tests/testOOoStyle.py
View file @
6351b926
...
...
@@ -454,7 +454,7 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
# Is it good to do this only for ODT ?
from
Products.ERP5OOo.OOoUtils
import
OOoParser
parser
=
OOoParser
()
parser
.
openFrom
String
(
body
)
parser
.
openFrom
Bytes
(
body
)
content_xml
=
bytes2str
(
parser
.
oo_files
[
'content.xml'
])
self
.
assertIn
(
'<Escape>&<text:line-break/>newline'
,
content_xml
)
...
...
@@ -484,7 +484,7 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
from
Products.ERP5OOo.OOoUtils
import
OOoParser
parser
=
OOoParser
()
parser
.
openFrom
String
(
body
)
parser
.
openFrom
Bytes
(
body
)
content_xml
=
bytes2str
(
parser
.
oo_files
[
'content.xml'
])
self
.
assertIn
(
message
,
content_xml
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment