def __init__(self, filename: str):
     self.log = log_init(AppConfigs.log_file())
     self.filename = filename
     self.data = []
     self.load()
     self.log.info('File storage created filename={} entries={}'.format(
         filename, len(self.data)))
Beispiel #2
0
 def __init__(self, sql_factory: SqlFactory):
     super().__init__(sql_factory.sql_template_file)
     self.sql_factory = sql_factory
     self.hostname = AppConfigs.get('db.hostname')
     self.port = AppConfigs.get_int('db.port')
     self.user = AppConfigs.get('db.user')
     self.password = AppConfigs.get('db.password')
     self.database = AppConfigs.get('db.database')
     self.log = log_init(AppConfigs.log_file())
     self.connector = None
     self.cursor = None
     self.connect()
 def __init__(self,
              clazz: Type,
              headers: list = None,
              cell_alignments: list = None,
              table_data: list = None,
              parent: QTableView = None):
     QAbstractTableModel.__init__(self, parent)
     self.clazz = clazz
     self.table_data = table_data or []
     self.headers = headers or self.headers_by_entity()
     self.cell_alignments = cell_alignments or []
     self.log = log_init(AppConfigs.log_file())
     self.log.info('{} headers={}'.format(clazz.__class__.__name__,
                                          '|'.join(self.headers)))
from abc import ABC
from typing import Optional, Type
from core.config.app_configs import AppConfigs
from src.core.enum.database_type import DatabaseType
from src.core.factory.mysql.item_factory import ItemFactory as MysqlItemFactory
from src.core.factory.sql_factory import SqlFactory
from src.core.tool.commons import log_init
from src.core.enum.model_enum import Model

LOG = log_init(AppConfigs.log_file())


class SqlFactoryFacade(ABC):
    __cache = {}
    __factories = {
        DatabaseType.MYSQL.name: {
            Model.ITEM.name: MysqlItemFactory
        }
    }

    @staticmethod
    def create_or_get(factory_class: Type):
        cache_key = factory_class.__name__
        if cache_key in SqlFactoryFacade.__cache:
            LOG.info('Retrieving factory {}'.format(cache_key))
            return SqlFactoryFacade.__cache[cache_key]
        else:
            LOG.info('Creating factory {}'.format(cache_key))
            SqlFactoryFacade.__cache[cache_key] = factory_class()
            return SqlFactoryFacade.__cache[cache_key]
Beispiel #5
0
 def __init__(self, window: QWidget, parent=None):
     super().__init__()
     self.window = window
     self.parent = parent
     self.log = log_init(AppConfigs.log_file())
     self.qt = QtFinder(self.window)
Beispiel #6
0
 def __init__(self, filename: str):
     super().__init__(filename)
     self.log = log_init(AppConfigs.log_file())
     self.db_filename = filename
     self.localDb = self.__create_or_get()