@@ -60,7 +60,7 @@ def __init__(self, path):
60
60
try :
61
61
Path ('/invented/file/path' ).resolve (strict = True )
62
62
except TypeError :
63
- from tempfile import gettempdir
63
+ from tempfile import TemporaryDirectory
64
64
65
65
def _patch_resolve (self , strict = False ):
66
66
"""Add the argument strict to signature in Python>3,<3.6."""
@@ -80,15 +80,15 @@ def _write_text(self, text):
80
80
Path .write_text = _write_text
81
81
82
82
try :
83
- with tempfile . TemporaryDirectory () as tmpdir :
83
+ with TemporaryDirectory () as tmpdir :
84
84
(Path (tmpdir ) / 'exist_ok_test' ).mkdir (exist_ok = True )
85
85
except TypeError :
86
86
def _mkdir (self , mode = 0o777 , parents = False , exist_ok = False ):
87
- if not exist_ok and self . exists () :
88
- raise FileExistsError (str (self ))
89
- if not parents and not Path ( str ( self . parents )) .exists ():
90
- raise FileNotFoundError (str (self . parents ) )
91
- os . makedirs ( str ( self ), mode = mode , exist_ok = exist_ok )
87
+ if parents :
88
+ os . makedirs (str (self ), mode = mode , exist_ok = exist_ok )
89
+ elif not exist_ok or not self .exists ():
90
+ os . mkdir (str (self ), mode = mode )
91
+
92
92
Path .mkdir = _mkdir
93
93
94
94
except FileNotFoundError :
0 commit comments