mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-26 05:05:30 -04:00
Mkdir to always allow parents and exist ok (#2914)
This commit is contained in:
parent
d10e128e76
commit
231fcb651b
1 changed files with 3 additions and 3 deletions
|
|
@ -449,7 +449,7 @@ class Model:
|
|||
# Create directory if required
|
||||
d = Path(directory)
|
||||
if not d.is_dir():
|
||||
d.mkdir(parents=True)
|
||||
d.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
self.settings.export_to_xml(d)
|
||||
self.geometry.export_to_xml(d, remove_surfs=remove_surfs)
|
||||
|
|
@ -490,14 +490,14 @@ class Model:
|
|||
# exist, create it and place a 'model.xml' file there.
|
||||
if not str(xml_path).endswith('.xml'):
|
||||
if not xml_path.exists():
|
||||
os.mkdir(xml_path)
|
||||
xml_path.mkdir(parents=True, exist_ok=True)
|
||||
elif not xml_path.is_dir():
|
||||
raise FileExistsError(f"File exists and is not a directory: '{xml_path}'")
|
||||
xml_path /= 'model.xml'
|
||||
# if this is an XML file location and the file's parent directory does
|
||||
# not exist, create it before continuing
|
||||
elif not xml_path.parent.exists():
|
||||
os.mkdir(xml_path.parent)
|
||||
xml_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
if remove_surfs:
|
||||
warnings.warn("remove_surfs kwarg will be deprecated soon, please "
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue