def mkdir_p(path):
path = expand_path(path)<EOL>try:<EOL><INDENT>os.makedirs(path)<EOL><DEDENT>except OSError as exception:<EOL><INDENT>if exception.errno == errno.EEXIST and os.path.isdir(path):<EOL><INDENT>return '<STR_LIT>' + path<EOL><DEDENT>else:<EOL><INDENT>raise<EOL><DEDENT><DEDENT>return '<STR_LIT>' + path<EOL>
`mkdir -p` functionality (don't raise exception if path exists)

    Make containing directory and parent directories in `path`, if they don't exist.

    Arguments:
                    path (str): Full or relative path to a directory to be created with mkdir -p

    Returns:
                    str: 'pre-existing' or 'new'

    References:
                    http://stackoverflow.com/a/600612/623735