Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
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
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
cloudooo
Commits
9956a05f
Commit
9956a05f
authored
Apr 30, 2021
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
small fixes
parent
68baeb0a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
13 deletions
+16
-13
cloudooo/file.py
cloudooo/file.py
+10
-4
cloudooo/handler/ooo/helper/unoconverter.py
cloudooo/handler/ooo/helper/unoconverter.py
+6
-9
No files found.
cloudooo/file.py
View file @
9956a05f
...
...
@@ -68,7 +68,8 @@ class File(object):
file_path
=
tempfile
.
mktemp
(
suffix
=
".%s"
%
self
.
source_format
,
dir
=
self
.
directory_name
)
# stores the data in temporary file
open
(
file_path
,
'wb'
).
write
(
self
.
original_data
)
with
open
(
file_path
,
'wb'
)
as
f
:
f
.
write
(
self
.
original_data
)
# If is a zipfile is need extract all files from whitin the compressed file
if
is_zipfile
(
file_path
):
zipfile
=
ZipFile
(
file_path
)
...
...
@@ -94,7 +95,9 @@ class File(object):
def
getContent
(
self
,
zip
=
False
):
"""Open the file and returns the content.
Keyword Arguments:
zip -- Boolean attribute. If True"""
zip -- Boolean attribute. If True
"""
# type: (bool) -> bytes
if
zip
:
current_dir_url
=
abspath
(
curdir
)
chdir
(
self
.
directory_name
)
...
...
@@ -106,12 +109,15 @@ class File(object):
zipfile
.
write
(
file
)
finally
:
zipfile
.
close
()
opened_zip
=
open
(
zip_path
,
'r'
).
read
()
with
open
(
zip_path
,
'rb'
)
as
f
:
opened_zip
=
f
.
read
()
remove
(
zip_path
)
chdir
(
current_dir_url
)
return
opened_zip
else
:
return
open
(
self
.
url
,
'r'
).
read
()
with
open
(
self
.
url
,
'rb'
)
as
f
:
content
=
f
.
read
()
return
content
def
getUrl
(
self
):
"""Returns full path."""
...
...
cloudooo/handler/ooo/helper/unoconverter.py
View file @
9956a05f
...
...
@@ -136,17 +136,14 @@ class UnoConverter(object):
def
_getPropertyToExport
(
self
,
destination_format
=
None
):
"""Create the property according to the extension of the file."""
property_list
=
()
if
destination_format
and
self
.
document_loaded
:
filter_name
=
self
.
_getFilterName
(
destination_format
,
self
.
document_type
)
property_list
=
[]
property
=
self
.
_createProperty
(
"Overwrite"
,
True
)
property_list
.
append
(
property
)
property
=
self
.
_createProperty
(
"FilterName"
,
filter_name
)
property_list
.
append
(
property
)
property_list
.
extend
(
self
.
_createSpecificProperty
(
filter_name
))
property_list
=
[
self
.
_createProperty
(
"Overwrite"
,
True
),
self
.
_createProperty
(
"FilterName"
,
filter_name
),
]
+
self
.
_createSpecificProperty
(
filter_name
)
return
property_list
else
:
return
()
def
_getPropertyToImport
(
self
,
source_url
):
"""Create the property for import filter, according to the extension of the file."""
...
...
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