@@ -32,8 +32,9 @@ def wrap(self, func):
32
32
def wrapper (path , * args , ** kwargs ):
33
33
if path .absolute () in self :
34
34
return
35
+ result = func (path , * args , ** kwargs )
35
36
self .add (path .absolute ())
36
- return func ( path , * args , ** kwargs )
37
+ return result
37
38
38
39
return wrapper
39
40
@@ -44,29 +45,23 @@ def wrapper(path, *args, **kwargs):
44
45
45
46
@functools .singledispatch
46
47
@wrapper
47
- def mkpath (name : pathlib .Path , mode = 0o777 , verbose = True , dry_run = False ):
48
+ def mkpath (name : pathlib .Path , mode = 0o777 , verbose = True , dry_run = False ) -> None :
48
49
"""Create a directory and any missing ancestor directories.
49
50
50
51
If the directory already exists (or if 'name' is the empty string, which
51
52
means the current directory, which of course exists), then do nothing.
52
53
Raise DistutilsFileError if unable to create some directory along the way
53
54
(eg. some sub-path exists, but is a file rather than a directory).
54
55
If 'verbose' is true, log the directory created.
55
- Return the list of directories actually created.
56
56
"""
57
57
if verbose and not name .is_dir ():
58
58
log .info ("creating %s" , name )
59
59
60
- ancestry = itertools .chain ((name ,), name .parents )
61
- missing = (path for path in ancestry if not path .is_dir ())
62
-
63
60
try :
64
61
dry_run or name .mkdir (mode = mode , parents = True , exist_ok = True )
65
62
except OSError as exc :
66
63
raise DistutilsFileError (f"could not create '{ name } ': { exc .args [- 1 ]} " )
67
64
68
- return list (map (str , missing ))
69
-
70
65
71
66
@mkpath .register
72
67
def _ (name : str , * args , ** kwargs ):
0 commit comments