Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
weiliang
WindEnergyToolbox
Commits
d3c6596d
Commit
d3c6596d
authored
Feb 01, 2016
by
David Verelst
Browse files
exist_ok does not exists for os.makedirs in PY27
parent
85ca8f61
Changes
5
Hide whitespace changes
Inline
Side-by-side
wetb/gtsdf/gtsdf.py
View file @
d3c6596d
...
...
@@ -223,7 +223,9 @@ def save(filename, data, **kwargs):
if
not
filename
.
lower
().
endswith
(
'.hdf5'
):
filename
+=
".hdf5"
os
.
makedirs
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
filename
)),
exist_ok
=
True
)
# exist_ok does not exist in Python27
if
not
os
.
path
.
exists
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
filename
))):
os
.
makedirs
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
filename
)))
#, exist_ok=True)
f
=
h5py
.
File
(
filename
,
"w"
)
try
:
f
.
attrs
[
"type"
]
=
"General time series data format"
...
...
wetb/hawc2/htc_file.py
View file @
d3c6596d
...
...
@@ -82,7 +82,9 @@ class HTCFile(HTCContents, HTCDefaults):
filename
=
self
.
filename
else
:
self
.
filename
=
filename
os
.
makedirs
(
os
.
path
.
dirname
(
filename
),
exist_ok
=
True
)
# exist_ok does not exist in Python27
if
not
os
.
path
.
exists
():
os
.
makedirs
(
os
.
path
.
dirname
(
filename
))
#, exist_ok=True)
with
open
(
filename
,
'w'
)
as
fid
:
fid
.
write
(
str
(
self
))
...
...
wetb/hawc2/log_file.py
View file @
d3c6596d
...
...
@@ -67,7 +67,9 @@ class LogFile(object):
def
__str__
(
self
):
return
self
.
txt
def
clear
(
self
):
os
.
makedirs
(
os
.
path
.
dirname
(
self
.
filename
),
exist_ok
=
True
)
# exist_ok does not exist in Python27
if
not
os
.
path
.
exists
(
os
.
path
.
dirname
(
self
.
filename
)):
os
.
makedirs
(
os
.
path
.
dirname
(
self
.
filename
))
#, exist_ok=True)
with
open
(
self
.
filename
,
'w'
):
pass
self
.
reset
()
...
...
wetb/hawc2/shear_file.py
View file @
d3c6596d
...
...
@@ -51,7 +51,9 @@ def save(filename, y_coordinates, z_coordinates, u=None, v=None, w=None):
assert
vuw
[
i
].
shape
==
shape
,
(
i
,
vuw
[
i
].
shape
,
shape
)
os
.
makedirs
(
os
.
path
.
dirname
(
filename
),
exist_ok
=
True
)
# exist_ok does not exist in Python27
if
not
os
.
path
.
exists
(
os
.
path
.
dirname
(
filename
)):
os
.
makedirs
(
os
.
path
.
dirname
(
filename
))
#, exist_ok=True)
with
open
(
filename
,
'w'
)
as
fid
:
fid
.
write
(
" # autogenerated shear file
\n
"
)
fid
.
write
(
" %d %d
\n
"
%
(
len
(
y_coordinates
),
len
(
z_coordinates
)))
...
...
wetb/hawc2/simulation.py
View file @
d3c6596d
...
...
@@ -138,7 +138,9 @@ class Simulation(object):
src
=
os
.
path
.
join
(
self
.
modelpath
,
src
)
for
src_file
in
glob
.
glob
(
src
):
dst
=
os
.
path
.
join
(
self
.
tmp_modelpath
,
os
.
path
.
relpath
(
src_file
,
self
.
modelpath
))
os
.
makedirs
(
os
.
path
.
dirname
(
dst
),
exist_ok
=
True
)
# exist_ok does not exist in Python27
if
not
os
.
path
.
exists
(
os
.
path
.
dirname
(
dst
)):
os
.
makedirs
(
os
.
path
.
dirname
(
dst
))
#, exist_ok=True)
shutil
.
copy
(
src_file
,
dst
)
if
not
os
.
path
.
isfile
(
dst
)
or
os
.
stat
(
dst
).
st_size
!=
os
.
stat
(
src_file
).
st_size
:
print
(
"error copy "
,
dst
)
...
...
@@ -169,7 +171,9 @@ class Simulation(object):
for
src_file
in
glob
.
glob
(
src
):
dst_file
=
os
.
path
.
join
(
self
.
modelpath
,
os
.
path
.
relpath
(
src_file
,
self
.
tmp_modelpath
))
os
.
makedirs
(
os
.
path
.
dirname
(
dst_file
),
exist_ok
=
True
)
# exist_ok does not exist in Python27
if
not
os
.
path
.
exists
(
os
.
path
.
dirname
(
dst_file
)):
os
.
makedirs
(
os
.
path
.
dirname
(
dst_file
))
#, exist_ok=True)
if
not
os
.
path
.
isfile
(
dst_file
)
or
os
.
path
.
getmtime
(
dst_file
)
!=
os
.
path
.
getmtime
(
src_file
):
shutil
.
copy
(
src_file
,
dst_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