6d1e4d06cf
Signed-off-by: Nico Schottelius <nico@brief.schottelius.org>
27 lines
591 B
Groff
27 lines
591 B
Groff
# From curl http://armstrong.cc/~steven/tmp/makedirs.py:
|
|
|
|
#!/usr/bin/env python2
|
|
|
|
import os
|
|
|
|
def makedirs(path, mode=0o777, exist_ok=False):
|
|
try:
|
|
os.makedirs(path, mode=mode, exist_ok=exist_ok)
|
|
except TypeError:
|
|
try:
|
|
os.makedirs(path, mode=mode)
|
|
except OSError as e:
|
|
if exist_ok and e.errno == 17: # File exists
|
|
pass
|
|
else:
|
|
raise
|
|
|
|
|
|
makedirs('/tmp/python/makedirs')
|
|
|
|
try:
|
|
makedirs('/tmp/python/makedirs')
|
|
except OSError as e:
|
|
print(e)
|
|
|
|
makedirs('/tmp/python/makedirs', exist_ok=True)
|