2016-05-23 10:59:48 +02:00
|
|
|
"""
|
|
|
|
pyexcel_ods
|
|
|
|
~~~~~~~~~~~~~~~~~~~
|
|
|
|
The lower level ods file format handler using odfpy
|
2020-10-03 15:27:56 +02:00
|
|
|
:copyright: (c) 2015-2020 by Onni Software Ltd & its contributors
|
2016-05-23 10:59:48 +02:00
|
|
|
:license: New BSD License
|
|
|
|
"""
|
2019-03-19 09:37:19 +01:00
|
|
|
|
2016-06-09 00:43:46 +02:00
|
|
|
# flake8: noqa
|
2019-03-19 09:37:19 +01:00
|
|
|
from pyexcel_io.io import get_data as read_data
|
|
|
|
from pyexcel_io.io import isstream
|
|
|
|
from pyexcel_io.io import store_data as write_data
|
|
|
|
|
2016-05-23 10:59:48 +02:00
|
|
|
# this line has to be place above all else
|
|
|
|
# because of dynamic import
|
2020-10-03 15:27:56 +02:00
|
|
|
from pyexcel_io.plugins import IOPluginInfoChain, IOPluginInfoChainV2
|
2016-05-23 10:59:48 +02:00
|
|
|
|
2018-11-26 08:56:21 +01:00
|
|
|
__FILE_TYPE__ = "ods"
|
2020-10-03 15:27:56 +02:00
|
|
|
IOPluginInfoChain(__name__)
|
|
|
|
IOPluginInfoChainV2(__name__).add_a_reader(
|
2018-11-26 08:56:21 +01:00
|
|
|
relative_plugin_class_path="odsr.ODSBook",
|
2020-10-03 15:27:56 +02:00
|
|
|
locations=["file", "memory"],
|
|
|
|
file_types=[__FILE_TYPE__],
|
|
|
|
stream_type="binary",
|
|
|
|
).add_a_reader(
|
|
|
|
relative_plugin_class_path="odsr.ODSBookInContent",
|
|
|
|
locations=["content"],
|
2017-05-07 18:38:24 +02:00
|
|
|
file_types=[__FILE_TYPE__],
|
2018-11-26 08:56:21 +01:00
|
|
|
stream_type="binary",
|
2017-05-07 18:38:24 +02:00
|
|
|
).add_a_writer(
|
2018-11-26 08:56:21 +01:00
|
|
|
relative_plugin_class_path="odsw.ODSWriter",
|
2020-10-03 15:27:56 +02:00
|
|
|
locations=["file", "memory"],
|
2017-05-07 18:38:24 +02:00
|
|
|
file_types=[__FILE_TYPE__],
|
2018-11-26 08:56:21 +01:00
|
|
|
stream_type="binary",
|
2017-05-07 18:38:24 +02:00
|
|
|
)
|
|
|
|
|
2016-05-23 10:59:48 +02:00
|
|
|
|
|
|
|
def save_data(afile, data, file_type=None, **keywords):
|
2016-05-24 00:31:13 +02:00
|
|
|
"""standalone module function for writing module supported file type"""
|
2016-05-23 10:59:48 +02:00
|
|
|
if isstream(afile) and file_type is None:
|
2016-12-06 10:27:52 +01:00
|
|
|
file_type = __FILE_TYPE__
|
2016-05-23 10:59:48 +02:00
|
|
|
write_data(afile, data, file_type=file_type, **keywords)
|
|
|
|
|
|
|
|
|
|
|
|
def get_data(afile, file_type=None, **keywords):
|
2016-05-24 00:31:13 +02:00
|
|
|
"""standalone module function for reading module supported file type"""
|
2016-05-23 10:59:48 +02:00
|
|
|
if isstream(afile) and file_type is None:
|
2016-12-06 10:27:52 +01:00
|
|
|
file_type = __FILE_TYPE__
|
2016-05-23 10:59:48 +02:00
|
|
|
return read_data(afile, file_type=file_type, **keywords)
|