# Path: lib/Settings.py
# class Settings:
#     def __init__(self,
#                  override_settings_path='settings.cfg'):
#         self.settingsFilePath = override_settings_path
#         self.parser = configparser.ConfigParser(interpolation=configparser.ExtendedInterpolation())
#         self.settings = None
#         self.getSettings()
# 
#     def getSettings(self):
#         self.parser.read('./settings.cfg')
#         self.settings = {section: dict(**self.parser[section]) for section in self.parser.sections()}
# 
#         return self.settings
# 
#     def getServiceIp(self, service):
#         return self.settings['general']['my_ip']
# 
# Path: lib/Wrappers/Logger.py
# class Logger:
#     def __init__(self, name):
#         if 'UNITTESTING' in os.environ:
#             self.logging = NullLogger()
#         else:
#             settings = Settings().getSettings()
#             logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
#                                 level=settings["logs"]["level"])
#             self.logging = logging.getLogger(name)
# 
#     def debug(self, *args, **kwargs):
#         self.logging.debug(*args, **kwargs)
# 
#     def info(self, *args, **kwargs):
#         self.logging.info(*args, **kwargs)
# 
#     def warning(self, *args, **kwargs):
#         self.logging.warning(*args, **kwargs)
# 
#     def error(self, *args, **kwargs):
#         self.logging.error(*args, **kwargs)
# 
#     def critical(self, *args, **kwargs):
#         self.logging.critical(*args, **kwargs)
# 
#     def log(self, *args, **kwargs):
#         self.logging.log(*args, **kwargs)


from warnings import filterwarnings
from lib.Settings import Settings
from lib.Wrappers.Logger import Logger
import MySQLdb
filterwarnings('ignore', category=MySQLdb.Warning)


class MailDomain:
    def __init__(self):
        self.logger = Logger(__name__)
        self.settings = Settings().getSettings()

    def create_domain(self, domain):
        self._prepare_db()
        self._prepare_table()
        self._insert_domain(domain)

    def domain_exists(self, domain):
        self._prepare_db()
        self._prepare_table()
        db = MySQLdb.connect(host=self.settings['email']['dbhost'],
                             user=self.settings['email']['dbuser'],
                             passwd=self.settings['email']['dbpwd'],

# Path: lib/Settings.py
# class Settings:
#     def __init__(self,
#                  override_settings_path='settings.cfg'):
#         self.settingsFilePath = override_settings_path
#         self.parser = configparser.ConfigParser(interpolation=configparser.ExtendedInterpolation())
#         self.settings = None
#         self.getSettings()
# 
#     def getSettings(self):
#         self.parser.read('./settings.cfg')
#         self.settings = {section: dict(**self.parser[section]) for section in self.parser.sections()}
# 
#         return self.settings
# 
#     def getServiceIp(self, service):
#         return self.settings['general']['my_ip']
# 
# Path: lib/Wrappers/Logger.py
# class Logger:
#     def __init__(self, name):
#         if 'UNITTESTING' in os.environ:
#             self.logging = NullLogger()
#         else:
#             settings = Settings().getSettings()
#             logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
#                                 level=settings["logs"]["level"])
#             self.logging = logging.getLogger(name)
# 
#     def debug(self, *args, **kwargs):
#         self.logging.debug(*args, **kwargs)
# 
#     def info(self, *args, **kwargs):
#         self.logging.info(*args, **kwargs)
# 
#     def warning(self, *args, **kwargs):
#         self.logging.warning(*args, **kwargs)
# 
#     def error(self, *args, **kwargs):
#         self.logging.error(*args, **kwargs)
# 
#     def critical(self, *args, **kwargs):
#         self.logging.critical(*args, **kwargs)
# 
#     def log(self, *args, **kwargs):
#         self.logging.log(*args, **kwargs)


# Path: lib/DomainManagement/MailDomain.py
from warnings import filterwarnings
from lib.Settings import Settings
from lib.Wrappers.Logger import Logger
import MySQLdb

filterwarnings('ignore', category=MySQLdb.Warning)


class MailDomain:
    def __init__(self):
        self.logger = Logger(__name__)
        self.settings = Settings().getSettings()

    def create_domain(self, domain):
        self._prepare_db()
        self._prepare_table()
        self._insert_domain(domain)

    def domain_exists(self, domain):
        self._prepare_db()
        self._prepare_table()
        db = MySQLdb.connect(host=self.settings['email']['dbhost'],
                             user=self.settings['email']['dbuser'],
                             passwd=self.settings['email']['dbpwd'],

                             db=self.settings['email']['dbname'])