#!/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 - 2014 Michal Čihař

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

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, see <http://www.gnu.org/licenses/>.
'''
import IMAPUtils

class CreateIMAP(IMAPUtils.IMAPUtil):
    '''
    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()
