'Create new Maildir folder if necessary
This will not update the list cached in getfolders(). You will
need to invoke :meth:`forgetfolders` to force new caching when
you are done creating folders yourself.
:param foldername: A relative mailbox name. The maildir will be
created in self.root+\'/\'+foldername. All intermediate folder
levels will be created if they do not exist yet. \'cur\',
\'tmp\', and \'new\' subfolders will be created in the maildir.'

def makefolder(self, foldername):

    self.ui.makefolder(self, foldername)
    if self.account.dryrun:
        return
    full_path = os.path.abspath(os.path.join(self.root, foldername))
    if (self.getsep() == '/'):
        for component in foldername.split('/'):
            assert (not (component in ['new', 'cur', 'tmp'])), "When    using    nested    folders    (/    as    a    Maildir    separator),    folder    names    may    not    contain    'new',    'cur',    'tmp'."
    assert (foldername.find('../') == (-1)), 'Folder    names    may    not    contain    ../'
    assert (not foldername.startswith('/')), 'Folder    names    may    not    begin    with    /'
    self.debug(("makefolder:    calling    makedirs    '%s'" % full_path))
    try:
        os.makedirs(full_path, 448)
    except OSError as e:
        if ((e.errno == 17) and os.path.isdir(full_path)):
            self.debug(("makefolder:    '%s'    already    a    directory" % foldername))
        else:
            raise
    for subdir in ['cur', 'new', 'tmp']:
        try:
            os.mkdir(os.path.join(full_path, subdir), 448)
        except OSError as e:
            if ((e.errno == 17) and os.path.isdir(full_path)):
                self.debug(("makefolder:    '%s'    already    has    subdir    %s" % (foldername, subdir)))
            else:
                raise
