#!/usr/bin/python
# -*- coding: UTF-8 -*-
# vim: expandtab sw=4 ts=4 sts=4:
'''
Creates folders on IMAP.
'''
__author__ = 'Michal Čihař'
__email__ = 'michal@cihar.com'
__license__ = '''
Copyright (c) 2003 - 2007 Michal Čihař

This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License version 2 as published by
the Free Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.

You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
'''
import IMAPUtils

class CreateIMAP(IMAPUtils.IMAPUtils):
    '''
    Class for creating IMAP folders.
    '''

    def create(self):
        '''
        Creates folders as defined in config.
        '''
        for folder in self._config.options('create'):
            if self._verbose:
                print "Creating folder %s" % folder
            if self._simulate:
                continue
            self._imap.create(folder)

    def run(self):
        '''
        Executes all actions.
        '''
        self.login()
        self.create()

if __name__ == '__main__':
    CreateIMAP().run()
