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)))
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)))
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()
class MainMenuUi(QtView): form, window = uic \ .loadUiType("{}/ui/qt/forms/car_rental.ui".format(AppConfigs.root_dir())) def __init__(self): super().__init__(MainMenuUi.window()) self.form = MainMenuUi.form() self.form.setupUi(self.window) self.tabPanel = self.qt.find_widget(self.window, QTabWidget, 'tabPanel') self.labelStatusBar = self.qt.find_widget(self.window, QLabel, 'labelStatusBar') self.car_search = CarSearchView(self.window, self) self.car_edit = CarEditView(self.window, self) self.user_search = UserSearchView(self.window, self) self.user_edit = UserEditView(self.window, self) self.rental_search = RentalSearchView(self.window, self) self.rental_edit = RentalEditView(self.window, self) self.setup_ui() self.set_status('Ready.') def setup_ui(self): self.tabPanel.setCurrentIndex(0) self.tabPanel.currentChanged.connect(self.tab_changed) def show(self): self.window.show() def tab_changed(self, idx: int): self.car_search.stackedPanelCars.setCurrentIndex(0) self.user_search.stackedPanelUsers.setCurrentIndex(0) self.rental_search.stackedPanelRentals.setCurrentIndex(0) self.log.info('Tab: tabPanel changed to {}'.format(idx)) def set_status(self, message, color: Color = Color.BLACK): text = '<font color="{}">{}</font>'.format( str(color.name).lower(), message) self.labelStatusBar.setText(text)
def __init__(self): super().__init__("{}/../data/rentals.dat".format( AppConfigs.root_dir()))
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]
def get_rental_service() -> Service: return ServiceFacade.get(AppConfigs.repository_type(), AppConfigs.database_type(), Model.RENTAL)
def get_employee_service() -> Service: return ServiceFacade.get(AppConfigs.repository_type(), AppConfigs.database_type(), Model.EMPLOYEE)
def get_customer_service() -> Service: return ServiceFacade.get(AppConfigs.repository_type(), AppConfigs.database_type(), Model.CUSTOMER)
def get_car_service() -> Service: return ServiceFacade.get(AppConfigs.repository_type(), AppConfigs.database_type(), Model.CAR)
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)
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()
def __init__(self): super().__init__("{}/../data/customers.dat".format( AppConfigs.root_dir()))
def __init__(self): super().__init__("{}/../data/employees.dat".format(AppConfigs.root_dir()))