def __init__(self, config, json=None, ovl_dict=None, xml=None, ignore=0): self.config = config self.output = config['output'] self.module_controller = Modules(path=MOD_PATH, namepath='layman.overlays.modules', output=self.output) self._encoding_ = get_encoding(self.output) if xml is not None: self.from_xml(xml, ignore) elif ovl_dict is not None: self.from_dict(ovl_dict, ignore) elif json is not None: self.from_json(json, ignore)
def __init__(self, config, paths=None, ignore=0, ignore_init_read_errors=False, allow_missing=False): self.config = config self.db_type = config['db_type'] self.ignore = ignore self.ignore_init_read_errors = ignore_init_read_errors self.mod_ctl = Modules(path=MOD_PATH, namepath='layman.db_modules', output=config['output']) self.output = config['output'] self.overlays = {} self.paths = paths path_found = False self.output.debug('Initializing overlay list handler', 8) if isinstance(self.db_type, STR): self.db_type = [x.strip() for x in self.db_type.split(',')] if len(self.db_type) > 1: msg = 'DbBase; warning, multiple instances of "db_type" found:'\ ' %(db_types)s.\nDefaulting to: %(db_type)s'\ % {'db_types': self.db_type, 'db_type': self.db_type[0]} self.output.warn(msg) self.db_type = self.db_type[0] + '_db' for path in self.paths: if not os.path.exists(path): continue success = self.read_db(path) if not success: msg = 'DbBase; error, Failed to read database at "%(path)s"\n'\ 'Hint: If you manually set db_type. Please reset it and '\ 'let layman-updater\nmigrate it. Otherwise layman\'s '\ 'database is not initialized, nor populated\nwith any '\ 'existing data.\nRun the following: "layman-updater -m '\ '<db_type>"' % {'path': path} self.output.error(msg) sys.exit(-1) path_found = True if not path_found and not allow_missing: msg = 'Warning: an installed db file was not found at: %(path)s'\ % {'path': str(self.paths)} self.output.warn(msg)
def __init__(self, config, overlays): #TODO add custom_conf_type support self.config = config self.conf_types = config['conf_type'] self.output = config['output'] self.overlays = overlays self.module_controller = Modules(path=MOD_PATH, namepath='layman.config_modules', output=self.output) if isinstance(self.conf_types, STR): self.conf_types = [x.strip() for x in self.conf_types.split(',')] if not self.conf_types and self.config['require_repoconfig']: self.output.error('No Repo configuration type found, but' + '\nis required in order to continue...')