Commit ceb82c83 authored by Tristan Cavelier's avatar Tristan Cavelier

x2t: make get/setMetadata more flexible

parent 60a0b7f6
...@@ -161,23 +161,25 @@ class Handler(object): ...@@ -161,23 +161,25 @@ class Handler(object):
self.file.trash() self.file.trash()
def getMetadata(self, base_document=False): def getMetadata(self, base_document=False):
"""Returns a dictionary with all metadata of document. r"""Returns a dictionary with all metadata of document.
along with the metadata. /!\ Not Implemented: no format are handled correctly.
""" """
# XXX Cloudooo takes the first handler that can "handle" source_mimetype. # XXX Cloudooo takes the first handler that can "handle" source_mimetype.
# However, docx documents metadata can only be "handled" by the ooo handler. # However, docx documents metadata can only be "handled" by the ooo handler.
# Handlers should provide a way to tell if such capability is available for the required source mimetype. # Handlers should provide a way to tell if such capability is available for the required source mimetype.
# We have to define a precise direction on how to know/get what are handlers capabilities according to Cloudooo configuration. # We have to define a precise direction on how to know/get what are handlers capabilities according to Cloudooo configuration.
# And then, this method MUST raise on unhandled format. Here xformats are "handled" by cheating.
if self._source_format in ( if self._source_format in (
"docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation", "pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation",
): ):
return OOoHandler(self.base_folder_url, self._data, self._source_format, **self._init_kw).getMetadata(base_document) return OOoHandler(self.base_folder_url, self._data, self._source_format, **self._init_kw).getMetadata(base_document)
raise NotImplementedError return {}
def setMetadata(self, metadata={}): def setMetadata(self, metadata={}):
"""Returns image with new metadata. r"""Returns document with new metadata.
/!\ Not Implemented: no format are handled correctly.
Keyword arguments: Keyword arguments:
metadata -- expected an dictionary with metadata. metadata -- expected an dictionary with metadata.
""" """
...@@ -185,13 +187,14 @@ class Handler(object): ...@@ -185,13 +187,14 @@ class Handler(object):
# However, docx documents metadata can only be "handled" by the ooo handler. # However, docx documents metadata can only be "handled" by the ooo handler.
# Handlers should provide a way to tell if such capability is available for the required source mimetype. # Handlers should provide a way to tell if such capability is available for the required source mimetype.
# We have to define a precise direction on how to know/get what are handlers capabilities according to Cloudooo configuration. # We have to define a precise direction on how to know/get what are handlers capabilities according to Cloudooo configuration.
# And then, this method MUST raise on unhandled format. Here xformats are "handled" by cheating.
if self._source_format in ( if self._source_format in (
"docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation", "pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation",
): ):
return OOoHandler(self.base_folder_url, self._data, self._source_format, **self._init_kw).setMetadata(metadata) return OOoHandler(self.base_folder_url, self._data, self._source_format, **self._init_kw).setMetadata(metadata)
raise NotImplementedError return self.file.getContent()
@staticmethod @staticmethod
def getAllowedConversionFormatList(source_mimetype): def getAllowedConversionFormatList(source_mimetype):
......
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