human-readable mkdir error

This commit is contained in:
Adrian Sampson 2012-11-03 12:16:32 -07:00
parent 289287690e
commit c569ddd412
2 changed files with 8 additions and 3 deletions

View file

@ -95,7 +95,7 @@ class FilesystemError(HumanReadableException):
clause = 'while {0} {1} to {2}'.format(
self._gerund(), repr(self.paths[0]), repr(self.paths[1])
)
elif self.verb in ('delete', 'write'):
elif self.verb in ('delete', 'write', 'create'):
clause = 'while {0} {1}'.format(
self._gerund(), repr(self.paths[0])
)
@ -185,7 +185,11 @@ def mkdirall(path):
"""
for ancestor in ancestry(path):
if not os.path.isdir(syspath(ancestor)):
os.mkdir(syspath(ancestor))
try:
os.mkdir(syspath(ancestor))
except (OSError, IOError) as exc:
raise FilesystemError(exc, 'create', (ancestor,),
traceback.format_exc())
def prune_dirs(path, root=None, clutter=('.DS_Store', 'Thumbs.db')):
"""If path is an empty directory, then remove it. Recursively remove

View file

@ -69,7 +69,8 @@ Changelog
* Fix a crash when input is read from a pipe without a specified encoding.
* Fix some problem with identifying files on Windows with Unicode directory
names in their path.
* Add a human-readable error message when writing files' tags fails.
* Add human-readable error messages when writing files' tags fails or when a
directory can't be created.
* Changed plugin loading so that modules can be imported without
unintentionally loading the plugins they contain.