Skip to content

Commit

Permalink
Revert auto_mkdir default in open() and special case local (#1365)
Browse files Browse the repository at this point in the history
  • Loading branch information
martindurant authored Sep 19, 2023
1 parent 5f79058 commit e3b19cc
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions fsspec/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ def open_files(
num=1,
protocol=None,
newline=None,
auto_mkdir=True,
expand=True,
**kwargs,
):
Expand Down Expand Up @@ -248,6 +249,9 @@ def open_files(
newline: bytes or None
Used for line terminator in text mode. If None, uses system default;
if blank, uses no translation.
auto_mkdir: bool (True)
If in write mode, this will ensure the target directory exists before
writing, by calling ``fs.mkdirs(exist_ok=True)``.
expand: bool
**kwargs: dict
Extra options that make sense to a particular storage connection, e.g.
Expand Down Expand Up @@ -284,6 +288,11 @@ def open_files(
protocol=protocol,
expand=expand,
)
if fs.protocol == "file":
fs.auto_mkdir = auto_mkdir
elif "r" not in mode and auto_mkdir:
parents = {fs._parent(path) for path in paths}
[fs.makedirs(parent, exist_ok=True) for parent in parents]
return OpenFiles(
[
OpenFile(
Expand Down

0 comments on commit e3b19cc

Please sign in to comment.