@@ -20,7 +20,7 @@ def mkpath(name, mode=0o777, verbose=True, dry_run=False): # noqa: C901
20
20
means the current directory, which of course exists), then do nothing.
21
21
Raise DistutilsFileError if unable to create some directory along the way
22
22
(eg. some sub-path exists, but is a file rather than a directory).
23
- If 'verbose' is true, print a one-line summary of each mkdir to stdout .
23
+ If 'verbose' is true, log the directory created .
24
24
Return the list of directories actually created.
25
25
26
26
os.makedirs is not used because:
@@ -36,12 +36,11 @@ def mkpath(name, mode=0o777, verbose=True, dry_run=False): # noqa: C901
36
36
if not isinstance (name , str ):
37
37
raise DistutilsInternalError (f"mkpath: 'name' must be a string (got { name !r} )" )
38
38
39
- # XXX what's the better way to handle verbosity? print as we create
40
- # each directory in the path (the current behaviour), or only announce
41
- # the creation of the whole path? (quite easy to do the latter since
42
- # we're not using a recursive algorithm)
43
-
44
39
name = os .path .normpath (name )
40
+
41
+ if verbose and not os .path .isdir (name ):
42
+ log .info ("creating %s" , name )
43
+
45
44
created_dirs = []
46
45
if os .path .isdir (name ) or name == '' :
47
46
return created_dirs
@@ -66,9 +65,6 @@ def mkpath(name, mode=0o777, verbose=True, dry_run=False): # noqa: C901
66
65
if abs_head in _path_created :
67
66
continue
68
67
69
- if verbose >= 1 :
70
- log .info ("creating %s" , head )
71
-
72
68
if not dry_run :
73
69
try :
74
70
os .mkdir (head , mode )
0 commit comments