Exemple #1
0
    def pref_load(self, **options):
        data = jsonToData(fread(rootConfJsonFile))
        if isfile(confJsonFile):
            try:
                userData = jsonToData(fread(confJsonFile))
            except Exception:
                log.exception(
                    f"error while loading user config file {confJsonFile!r}")
            else:
                data.update(userData)

        for key in self.prefKeys:
            try:
                self.pref[key] = data.pop(key)
            except KeyError:
                pass
        for key, value in data.items():
            log.warning(
                f"unknown config key {key!r}, you may edit {confJsonFile}"
                " file and remove this key")

        for key, value in options.items():
            if key in self.prefKeys:
                self.pref[key] = value

        return True
Exemple #2
0
    def loadConfig(self, **options):
        from pyglossary.json_utils import jsonToData
        data = jsonToData(fread(rootConfJsonFile))
        if isfile(confJsonFile):
            try:
                userData = jsonToData(fread(confJsonFile))
            except Exception:
                log.exception(
                    f"error while loading user config file {confJsonFile!r}")
            else:
                data.update(userData)

        for key in self.configDefDict:
            try:
                self.config[key] = data.pop(key)
            except KeyError:
                pass
        for key, value in data.items():
            log.warning(
                f"unknown config key {key!r}, you may edit {confJsonFile}"
                " file and remove this key")

        for key, value in options.items():
            if key in self.configDefDict:
                self.config[key] = value

        log.setTimeEnable(self.config["log_time"])

        log.debug("loaded config")
        return True
Exemple #3
0
    def pref_load(self, **options):
        data = jsonToData(fread(rootConfJsonFile))
        if isfile(confJsonFile):
            try:
                userData = jsonToData(fread(confJsonFile))
            except Exception:
                log.exception('error while loading user config file "%s"'%confJsonFile)
            else:
                data.update(userData)

        for key in self.prefKeys:
            try:
                self.pref[key] = data.pop(key)
            except KeyError:
                pass
        for key, value in data.items():
            log.warning('unkown config key "%s"'%key)

        for key, value in options.items():
            if key in self.prefKeys:
                self.pref[key] = value
        
        return True
Exemple #4
0
	def pref_load(self, **options):
		data = jsonToData(fread(rootConfJsonFile))
		if isfile(confJsonFile):
			try:
				userData = jsonToData(fread(confJsonFile))
			except Exception:
				log.exception('error while loading user config file "%s"'%confJsonFile)
			else:
				data.update(userData)

		for key in self.prefKeys:
			try:
				self.pref[key] = data.pop(key)
			except KeyError:
				pass
		for key, value in data.items():
			log.warning('unkown config key "%s"'%key)

		for key, value in options.items():
			if key in self.prefKeys:
				self.pref[key] = value
		
		return True