404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@18.224.54.118: ~ $
from configparser import ConfigParser

from ..setting import ListSetting
from ..util import csv_to_list
from .filebased import FileBasedSource


__all__ = ("ConfigFileSource",)


class ConfigFileSource(FileBasedSource):
    def __init__(self, *args, **kwargs):
        self.section = kwargs.pop("section", None)
        super(ConfigFileSource, self).__init__(*args, **kwargs)

    def get_settings_from_file(self, file_path, settings, manager=None):
        section = self.section or manager.name.lower()

        parser = ConfigParser()
        parser.read(file_path)

        if not parser.has_section(section):
            return None

        for setting in settings:
            if parser.has_option(section, setting.name):
                opt = parser.get(section, setting.name)
                if isinstance(setting, ListSetting):
                    setting.value = csv_to_list(opt)
                else:
                    setting.value = opt

        return settings

Filemanager

Name Type Size Permission Actions
__pycache__ Folder 0755
__init__.py File 337 B 0644
base.py File 145 B 0644
commandline.py File 4.98 KB 0644
configfile.py File 978 B 0644
environment.py File 1001 B 0644
filebased.py File 2.58 KB 0644
jsonfile.py File 847 B 0644
mapping.py File 492 B 0644
modobj.py File 1.67 KB 0644
yamlfile.py File 853 B 0644