@@ -91,6 +91,8 @@ class OSFS(FS):
91
91
create_mode (int): The permissions that will be used to create
92
92
the directory if ``create`` is `True` and the path doesn't
93
93
exist, defaults to ``0o777``.
94
+ expand_vars(bool): If `True` (the default) environment variables of
95
+ the form $name or ${name} will be expanded.
94
96
95
97
Raises:
96
98
`fs.errors.CreateFailed`: If ``root_path`` does not
@@ -108,6 +110,7 @@ def __init__(
108
110
root_path , # type: Text
109
111
create = False , # type: bool
110
112
create_mode = 0o777 , # type: SupportsInt
113
+ expand_vars = True , # type: bool
111
114
):
112
115
# type: (...) -> None
113
116
"""Create an OSFS instance.
@@ -118,7 +121,9 @@ def __init__(
118
121
self .root_path = root_path
119
122
_drive , _root_path = os .path .splitdrive (fsdecode (fspath (root_path )))
120
123
_root_path = _drive + (_root_path or "/" ) if _drive else _root_path
121
- _root_path = os .path .expanduser (os .path .expandvars (_root_path ))
124
+ _root_path = os .path .expanduser (
125
+ os .path .expandvars (_root_path ) if expand_vars else _root_path
126
+ )
122
127
_root_path = os .path .normpath (os .path .abspath (_root_path ))
123
128
self ._root_path = _root_path
124
129
0 commit comments