16 lines
479 B
Python
16 lines
479 B
Python
|
import os
|
||
|
|
||
|
|
||
|
def maybe_makedirs(path_to_create):
|
||
|
"""This function will create a directory, unless it exists already,
|
||
|
at which point the function will return.
|
||
|
The exception handling is necessary as it prevents a race condition
|
||
|
from occurring.
|
||
|
Inputs:
|
||
|
path_to_create - A string path to a directory you'd like created.
|
||
|
"""
|
||
|
try:
|
||
|
os.makedirs(path_to_create)
|
||
|
except OSError:
|
||
|
if not os.path.isdir(path_to_create):
|
||
|
raise
|