Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
3pia
VISPA
VISPA web
Commits
06d6b6ab
Commit
06d6b6ab
authored
Mar 12, 2013
by
Marcel
Browse files
Add convenience functions to fs.
parent
fdc734ff
Changes
1
Hide whitespace changes
Inline
Side-by-side
vispa/remote/filesystem.py
View file @
06d6b6ab
...
...
@@ -263,27 +263,27 @@ class FileSystem(object):
if
cut
:
os
.
remove
(
target
)
def
save_file_content
(
self
,
path
,
content
,
force
=
True
):
#check if file already exists
path
=
os
.
path
.
expandvars
(
os
.
path
.
expanduser
(
path
))
# check if file already exists
if
os
.
path
.
exists
(
path
)
and
not
force
:
return
False
,
"The file '%s' already exists!"
%
path
out
=
open
(
path
,
"w"
)
for
line
in
content
.
data
:
out
.
write
(
line
)
return
False
out
=
open
(
path
,
"wb"
)
out
.
write
(
content
)
out
.
close
()
return
True
,
"File saved!"
return
True
def
get_file_content
(
self
,
path
):
path
=
os
.
path
.
expandvars
(
os
.
path
.
expanduser
(
path
))
f
=
open
(
path
,
"r"
)
content
=
f
.
read
()
f
.
close
()
if
content
==
''
:
content
=
' '
return
content
def
get_mtime
(
self
,
path
):
path
=
os
.
path
.
expandvars
(
os
.
path
.
expanduser
(
path
))
return
os
.
path
.
getmtime
(
path
)
def
is_browser_file
(
self
,
path
):
extension
=
path
.
split
(
"."
)[
-
1
]
return
extension
in
FileSystem
.
BROWSER_EXTENSIONS
...
...
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