mirror of
https://github.com/python/cpython.git
synced 2025-10-22 06:32:43 +00:00
Documented Bastian's patch.
Made handling OSError in 'mkpath()' more standard.
This commit is contained in:
parent
da4d1aef4e
commit
739d06689d
1 changed files with 9 additions and 7 deletions
|
@ -24,11 +24,13 @@ PATH_CREATED = {}
|
||||||
# succeed in that case).
|
# succeed in that case).
|
||||||
def mkpath (name, mode=0777, verbose=0, dry_run=0):
|
def mkpath (name, mode=0777, verbose=0, dry_run=0):
|
||||||
"""Create a directory and any missing ancestor directories. If the
|
"""Create a directory and any missing ancestor directories. If the
|
||||||
directory already exists, return silently. Raise
|
directory already exists (or if 'name' is the empty string, which
|
||||||
DistutilsFileError if unable to create some directory along the
|
means the current directory, which of course exists), then do
|
||||||
way (eg. some sub-path exists, but is a file rather than a
|
nothing. Raise DistutilsFileError if unable to create some
|
||||||
directory). If 'verbose' is true, print a one-line summary of
|
directory along the way (eg. some sub-path exists, but is a file
|
||||||
each mkdir to stdout."""
|
rather than a directory). If 'verbose' is true, print a one-line
|
||||||
|
summary of each mkdir to stdout. Return the list of directories
|
||||||
|
actually created."""
|
||||||
|
|
||||||
global PATH_CREATED
|
global PATH_CREATED
|
||||||
|
|
||||||
|
@ -71,9 +73,9 @@ def mkpath (name, mode=0777, verbose=0, dry_run=0):
|
||||||
try:
|
try:
|
||||||
os.mkdir (head)
|
os.mkdir (head)
|
||||||
created_dirs.append(head)
|
created_dirs.append(head)
|
||||||
except os.error, (errno, errstr):
|
except OSError, exc:
|
||||||
raise DistutilsFileError, \
|
raise DistutilsFileError, \
|
||||||
"could not create '%s': %s" % (head, errstr)
|
"could not create '%s': %s" % (head, exc[-1])
|
||||||
|
|
||||||
PATH_CREATED[head] = 1
|
PATH_CREATED[head] = 1
|
||||||
return created_dirs
|
return created_dirs
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue