Beispiel #1
0
    def add_include(config, path):
        insertion = 'INCLUDE={}'.format(os.path.join(config_path, config_name))

        # No global section
        if not '[global]' in config:
            config = '[global]\n{}\n{}'.format(insertion, config)
        # Global section with existing INCLUDE pair
        elif re.search(r'^INCLUDE\w*=\w*', config, flags=re.IGNORECASE | re.MULTILINE):
            config = re.sub(r'^INCLUDE\w*=\w*', insertion + ',', config, flags=re.IGNORECASE | re.MULTILINE)
        # Global section, no INCLUDE pair
        else:
            config = config.replace('[global]', '[global]\n' + insertion)

        with open(os.path.expanduser(path), 'w') as file:
            file.write(config)
Beispiel #2
0
 def set_property(path, expression, value):
     config = RegisterPluginDecorator.get_config(path)
     config = config.replace(expression, value)
     with open(os.path.expanduser(path), 'w') as file:
         file.write(config)