mirror of
https://codeberg.org/polarisfm/youtube-dl
synced 2024-11-26 18:34:32 +01:00
Use os.makedirs instead of homebrewn pmkdir
This commit is contained in:
parent
ef53099e35
commit
50891fece7
12
youtube-dl
12
youtube-dl
@ -455,16 +455,6 @@ class FileDownloader(object):
|
|||||||
self._screen_file = [sys.stdout, sys.stderr][params.get('logtostderr', False)]
|
self._screen_file = [sys.stdout, sys.stderr][params.get('logtostderr', False)]
|
||||||
self.params = params
|
self.params = params
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def pmkdir(filename):
|
|
||||||
"""Create directory components in filename. Similar to Unix "mkdir -p"."""
|
|
||||||
components = filename.split(os.sep)
|
|
||||||
aggregate = [os.sep.join(components[0:x]) for x in xrange(1, len(components))]
|
|
||||||
aggregate = ['%s%s' % (x, os.sep) for x in aggregate] # Finish names with separator
|
|
||||||
for dir in aggregate:
|
|
||||||
if not os.path.exists(dir):
|
|
||||||
os.mkdir(dir)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def format_bytes(bytes):
|
def format_bytes(bytes):
|
||||||
if bytes is None:
|
if bytes is None:
|
||||||
@ -721,7 +711,7 @@ class FileDownloader(object):
|
|||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.pmkdir(filename)
|
os.makedirs(os.path.dirname(filename))
|
||||||
except (OSError, IOError), err:
|
except (OSError, IOError), err:
|
||||||
self.trouble(u'ERROR: unable to create directories: %s' % str(err))
|
self.trouble(u'ERROR: unable to create directories: %s' % str(err))
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user