def CreateDirectory(directory):
from six.moves.urllib.parse import urlparse<EOL>directory_url = urlparse(directory)<EOL>if _UrlIsLocal(directory_url):<EOL><INDENT>if not os.path.exists(directory):<EOL><INDENT>os.makedirs(directory)<EOL><DEDENT>return directory<EOL><DEDENT>elif directory_url.scheme == '<STR_LIT>':<EOL><INDENT>from ._exceptions import NotImplementedProtocol<EOL>raise NotImplementedProtocol(directory_url.scheme)<EOL><DEDENT>else:<EOL><INDENT>from ._exceptions import NotImplementedProtocol<EOL>raise NotImplementedProtocol(directory_url.scheme)<EOL><DEDENT>
Create directory including any missing intermediate directory.

:param unicode directory:

:return unicode|urlparse.ParseResult:
    Returns the created directory or url (see urlparse).

:raises NotImplementedProtocol:
    If protocol is not local or FTP.

.. seealso:: FTP LIMITATIONS at this module's doc for performance issues information