summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Ward <gward@python.net>2000-03-03 03:00:02 (GMT)
committerGreg Ward <gward@python.net>2000-03-03 03:00:02 (GMT)
commit96182d7b68cfb2226af0c0e701b9d35d1aa59603 (patch)
tree10b96446a648200722cdbe2d93af46c70707ad2b
parent63c2b250ef8fb9341f3b848d66ed914ed1dc8bc2 (diff)
downloadcpython-96182d7b68cfb2226af0c0e701b9d35d1aa59603.zip
cpython-96182d7b68cfb2226af0c0e701b9d35d1aa59603.tar.gz
cpython-96182d7b68cfb2226af0c0e701b9d35d1aa59603.tar.bz2
Fixed 'mkpath()' to accept empty string silently (it's just the current dir).
Fixed all DistutilsFileError messages to wrap file/dir names in quotes.
-rw-r--r--Lib/distutils/util.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/Lib/distutils/util.py b/Lib/distutils/util.py
index 85f3a34..b20f5be 100644
--- a/Lib/distutils/util.py
+++ b/Lib/distutils/util.py
@@ -39,7 +39,7 @@ def mkpath (name, mode=0777, verbose=0, dry_run=0):
name = os.path.normpath (name)
- if os.path.isdir (name):
+ if os.path.isdir (name) or name == '':
return
if PATH_CREATED.get (name):
return
@@ -71,7 +71,7 @@ def mkpath (name, mode=0777, verbose=0, dry_run=0):
try:
os.mkdir (head)
except os.error, (errno, errstr):
- raise DistutilsFileError, "%s: %s" % (head, errstr)
+ raise DistutilsFileError, "'%s': %s" % (head, errstr)
PATH_CREATED[head] = 1
@@ -197,19 +197,21 @@ def _copy_file_contents (src, dst, buffer_size=16*1024):
try:
fsrc = open(src, 'rb')
except os.error, (errno, errstr):
- raise DistutilsFileError, "could not open %s: %s" % (src, errstr)
+ raise DistutilsFileError, \
+ "could not open '%s': %s" % (src, errstr)
try:
fdst = open(dst, 'wb')
except os.error, (errno, errstr):
- raise DistutilsFileError, "could not create %s: %s" % (dst, errstr)
+ raise DistutilsFileError, \
+ "could not create '%s': %s" % (dst, errstr)
while 1:
try:
buf = fsrc.read (buffer_size)
except os.error, (errno, errstr):
raise DistutilsFileError, \
- "could not read from %s: %s" % (src, errstr)
+ "could not read from '%s': %s" % (src, errstr)
if not buf:
break
@@ -218,7 +220,7 @@ def _copy_file_contents (src, dst, buffer_size=16*1024):
fdst.write(buf)
except os.error, (errno, errstr):
raise DistutilsFileError, \
- "could not write to %s: %s" % (dst, errstr)
+ "could not write to '%s': %s" % (dst, errstr)
finally:
if fdst:
@@ -258,7 +260,7 @@ def copy_file (src, dst,
if not os.path.isfile (src):
raise DistutilsFileError, \
- "can't copy %s: not a regular file" % src
+ "can't copy '%s': not a regular file" % src
if os.path.isdir (dst):
dir = dst
@@ -321,7 +323,7 @@ def copy_tree (src, dst,
if not dry_run and not os.path.isdir (src):
raise DistutilsFileError, \
- "cannot copy tree %s: not a directory" % src
+ "cannot copy tree '%s': not a directory" % src
try:
names = os.listdir (src)
except os.error, (errno, errstr):
@@ -329,7 +331,7 @@ def copy_tree (src, dst,
names = []
else:
raise DistutilsFileError, \
- "error listing files in %s: %s" % (src, errstr)
+ "error listing files in '%s': %s" % (src, errstr)
if not dry_run:
mkpath (dst, verbose=verbose)