def __init__(self, core: Core, attrs=None): self.data = {} # internal self.core = core # self.envs do nothing self.envs = EnvManager() self.installer = None # next fields are loaded from yaml # meta self.name = None self.title = None self.description = None self.link = None self.author = None self.icon = None # string list self.tags = [] self.eula = None # fiters self.os = None self.bitness = None self.web_server = None self.lang = None self.platform = None # versions self.version = '' self.installed_version = '' # installer stuff self.dependencies = [] self.files = [] self.install_command = None self.upgrade_command = None self.config = None self.uninstall_command = None self.find_installed_command = None self.parameters = {} if attrs is not None: for item in attrs.keys(): self.__dict__[item] = attrs[item] self.name = attrs[self.get_typename()] if attrs.get('files'): # create File objects for every file item self.files = [] for f in attrs.get('files', []): if f.get('file'): self.files.append(File(self, **f)) self.installer = Installer(self, self.install_command, self.upgrade_command, self.uninstall_command, self.find_installed_command)
def merge(self, **kwargs): """ Merges product representation in 'kwargs' dict with current product. Current product fields are overwritten by values from kwargs. :param kwargs: dict with product representation to merge. """ # name of attribute (product, engine, application) with product name typename = self.get_typename() self.name = kwargs[typename] #### self.title = kwargs.get('title') or self.title self.description = kwargs.get('description') or self.description self.link = kwargs.get('link') or self.link self.author = kwargs.get('author') or self.author self.icon = kwargs.get('icon') or self.icon self.tags = kwargs.get('tags') or self.tags self.eula = kwargs.get('eula') or self.eula self.os = kwargs.get('os') or self.os self.bitness = kwargs.get('bitness') or self.bitness self.web_server = kwargs.get('webserver') or self.web_server self.lang = kwargs.get('lang') or self.lang # это поле не читается из ямла, оно создаётся из: self.platform = Platform(self.os, self.bitness, self.web_server, self.lang) self.dependencies = kwargs.get('dependencies', []) or self.dependencies self.version = str(kwargs.get('version', '')) or self.version self.installed_version = str(kwargs.get('installed_version', '')) or self.installed_version self.config = kwargs.get('config') or self.config files_list = kwargs.get('files', []) if files_list and len(files_list) > 0: # create File objects for every file item self.files = [] for f in files_list: fs = f.__getstate__() if isinstance(f, File) else f if fs.get('file'): self.files.append(File(self, **fs)) self.install_command = kwargs.get('install_command', None) or self.install_command if self.install_command: self.install_command = self.install_command.rstrip() self.upgrade_command = kwargs.get('upgrade_command', None) or self.upgrade_command if self.upgrade_command: self.upgrade_command = self.upgrade_command.rstrip() self.uninstall_command = kwargs.get('uninstall_command', None) or self.uninstall_command if self.uninstall_command: self.uninstall_command = self.uninstall_command.rstrip() self.find_installed_command = kwargs.get( 'find_installed_command', None) or self.find_installed_command if self.find_installed_command: self.find_installed_command = self.find_installed_command.rstrip() self.parameters = kwargs.get('parameters', None) or self.parameters # TODO must be deprecated # create Installer from commands, # installer knows to how call install_command, uninstall_command self.installer = Installer(self, self.install_command, self.upgrade_command, self.uninstall_command, self.find_installed_command)