def ensuredir(dpath, mode=<NUM_LIT>):
if isinstance(dpath, (list, tuple)):  <EOL><INDENT>dpath = join(*dpath)<EOL><DEDENT>if not exists(dpath):<EOL><INDENT>try:<EOL><INDENT>os.makedirs(normpath(dpath), mode=mode)<EOL><DEDENT>except OSError:  <EOL><INDENT>raise<EOL><DEDENT><DEDENT>return dpath<EOL>
Ensures that directory will exist. creates new dir with sticky bits by
default

Args:
    dpath (str): dir to ensure. Can also be a tuple to send to join
    mode (int): octal mode of directory (default 0o1777)

Returns:
    str: path - the ensured directory