Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cloudooo
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
cloudooo
Commits
6c083b59
Commit
6c083b59
authored
Feb 16, 2017
by
Boris Kocherov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x2t: use OOHandler.getMetadata if need generate baseformat
parent
e0068547
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
19 deletions
+13
-19
cloudooo/handler/x2t/handler.py
cloudooo/handler/x2t/handler.py
+13
-19
No files found.
cloudooo/handler/x2t/handler.py
View file @
6c083b59
...
...
@@ -72,12 +72,6 @@ yformat_map = {
'ppty'
:
'pptx'
,
}
yformat2opendocument_map
=
{
'docy'
:
'odt'
,
'xlsy'
:
'ods'
,
'ppty'
:
'odp'
,
}
yformat_tuple
=
(
"docy"
,
"application/x-asc-text"
,
"xlsy"
,
"application/x-asc-spreadsheet"
,
...
...
@@ -239,19 +233,19 @@ class Handler(object):
r"""Returns a dictionary with all metadata of document.
"""
if
self
.
_source_format
in
yformat_tuple
and
self
.
_data
.
startswith
(
"PK
\
x03
\
x04
"
):
with
io
.
BytesIO
(
self
.
_data
)
as
memfile
,
ZipFile
(
memfile
)
as
zipfile
:
try
:
metadata
=
zipfile
.
read
(
"metadata.json"
)
except
KeyError
:
metadata
=
'{}'
metadata
=
json
.
loads
(
metadata
)
metadata
[
'MIMEType'
]
=
self
.
_getContentType
()
if
base_document
:
opendocument_format
=
yformat2opendocument_map
[
self
.
_source_format
]
metadata
[
'MIMEType'
]
=
guess_type
(
'a.'
+
opendocument_format
)[
0
]
metadata
[
'Data'
]
=
self
.
convert
(
opendocument_format
)
return
metadata
if
base_document
:
openxml_format
=
yformat_map
[
self
.
_source_format
]
data
=
self
.
convert
(
yformat_map
[
self
.
_source_format
]
)
return
OOoHandler
(
self
.
base_folder_url
,
data
,
openxml_format
,
**
self
.
_init_kw
).
getMetadata
(
base_document
)
else
:
with
io
.
BytesIO
(
self
.
_data
)
as
memfile
,
ZipFile
(
memfile
)
as
zipfile
:
try
:
metadata
=
zipfile
.
read
(
"metadata.json"
)
except
KeyError
:
metadata
=
'{}'
metadata
=
json
.
loads
(
metadata
)
metadata
[
'MIMEType'
]
=
self
.
_getContentType
()
return
metadata
else
:
return
OOoHandler
(
self
.
base_folder_url
,
self
.
_data
,
self
.
_source_format
,
**
self
.
_init_kw
).
getMetadata
(
base_document
)
...
...
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