mirror of
https://github.com/kennethreitz/django-heroku.git
synced 2026-06-05 23:10:16 +00:00
Refactored mkdir_p function to use os.makedirs
This commit is contained in:
+10
-14
@@ -15,20 +15,16 @@ def mkdir_p(newdir):
|
||||
- regular file in the way, raise an exception
|
||||
- parent directory(ies) does not exist, make them as well
|
||||
"""
|
||||
if os.path.isdir(newdir):
|
||||
pass
|
||||
elif os.path.isfile(newdir):
|
||||
raise OSError(
|
||||
"a file with the same name as the desired "
|
||||
"dir, '%s', already exists." % newdir
|
||||
)
|
||||
else:
|
||||
head, tail = os.path.split(newdir)
|
||||
if head and not os.path.isdir(head):
|
||||
mkdir_p(head)
|
||||
|
||||
if tail:
|
||||
os.mkdir(newdir)
|
||||
try:
|
||||
os.makedirs(newdir)
|
||||
except OSError as e:
|
||||
if e.errno == errno.EEXIST and os.path.isdir(newdir):
|
||||
pass
|
||||
else:
|
||||
raise OSError (
|
||||
"a file with the same name as the desired "
|
||||
"dir, '%s', already exists." % newdir
|
||||
)
|
||||
|
||||
|
||||
class HerokuDiscoverRunner(DiscoverRunner):
|
||||
|
||||
Reference in New Issue
Block a user