Python configparser.SafeConfigParser() Examples
The following are 30
code examples of configparser.SafeConfigParser().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
configparser
, or try the search function
.
Example #1
Source File: versioneer.py From wg-gesucht-crawler-cli with MIT License | 6 votes |
def get_config_from_root(root): # This might raise EnvironmentError (if setup.cfg is missing), or # configparser.NoSectionError (if it lacks a [versioneer] section), or # configparser.NoOptionError (if it lacks "VCS="). See the docstring at # the top of versioneer.py for instructions on writing your setup.cfg . setup_cfg = os.path.join(root, "setup.cfg") parser = configparser.SafeConfigParser() with open(setup_cfg, "r") as f: parser.readfp(f) VCS = parser.get("versioneer", "VCS") # mandatory def get(parser, name): if parser.has_option("versioneer", name): return parser.get("versioneer", name) return None cfg = VersioneerConfig() cfg.VCS = VCS cfg.style = get(parser, "style") or "" cfg.versionfile_source = get(parser, "versionfile_source") cfg.versionfile_build = get(parser, "versionfile_build") cfg.tag_prefix = get(parser, "tag_prefix") cfg.parentdir_prefix = get(parser, "parentdir_prefix") cfg.verbose = get(parser, "verbose") return cfg
Example #2
Source File: config.py From rucio with Apache License 2.0 | 6 votes |
def __init__(self): if sys.version_info < (3, 2): self.parser = ConfigParser.SafeConfigParser(os.environ) else: self.parser = ConfigParser.ConfigParser(defaults=os.environ) if 'RUCIO_CONFIG' in os.environ: self.configfile = os.environ['RUCIO_CONFIG'] else: configs = [os.path.join(confdir, 'rucio.cfg') for confdir in get_config_dirs()] self.configfile = next(iter(filter(os.path.exists, configs)), None) if self.configfile is None: raise RuntimeError('Could not load Rucio configuration file. ' 'Rucio looked in the following paths for a configuration file, in order:' '\n\t' + '\n\t'.join(configs)) if not self.parser.read(self.configfile) == [self.configfile]: raise RuntimeError('Could not load Rucio configuration file. ' 'Rucio tried loading the following configuration file:' '\n\t' + self.configfile)
Example #3
Source File: versioneer.py From landmarkerio-server with BSD 3-Clause "New" or "Revised" License | 6 votes |
def get_config_from_root(root): # This might raise EnvironmentError (if setup.cfg is missing), or # configparser.NoSectionError (if it lacks a [versioneer] section), or # configparser.NoOptionError (if it lacks "VCS="). See the docstring at # the top of versioneer.py for instructions on writing your setup.cfg . setup_cfg = os.path.join(root, "setup.cfg") parser = configparser.SafeConfigParser() with open(setup_cfg, "r") as f: parser.readfp(f) VCS = parser.get("versioneer", "VCS") # mandatory def get(parser, name): if parser.has_option("versioneer", name): return parser.get("versioneer", name) return None cfg = VersioneerConfig() cfg.VCS = VCS cfg.style = get(parser, "style") or "" cfg.versionfile_source = get(parser, "versionfile_source") cfg.versionfile_build = get(parser, "versionfile_build") cfg.tag_prefix = get(parser, "tag_prefix") cfg.parentdir_prefix = get(parser, "parentdir_prefix") cfg.verbose = get(parser, "verbose") return cfg
Example #4
Source File: versioneer.py From recordlinkage with BSD 3-Clause "New" or "Revised" License | 6 votes |
def get_config_from_root(root): # This might raise EnvironmentError (if setup.cfg is missing), or # configparser.NoSectionError (if it lacks a [versioneer] section), or # configparser.NoOptionError (if it lacks "VCS="). See the docstring at # the top of versioneer.py for instructions on writing your setup.cfg . setup_cfg = os.path.join(root, "setup.cfg") parser = configparser.SafeConfigParser() with open(setup_cfg, "r") as f: parser.readfp(f) VCS = parser.get("versioneer", "VCS") # mandatory def get(parser, name): if parser.has_option("versioneer", name): return parser.get("versioneer", name) return None cfg = VersioneerConfig() cfg.VCS = VCS cfg.style = get(parser, "style") or "" cfg.versionfile_source = get(parser, "versionfile_source") cfg.versionfile_build = get(parser, "versionfile_build") cfg.tag_prefix = get(parser, "tag_prefix") cfg.parentdir_prefix = get(parser, "parentdir_prefix") cfg.verbose = get(parser, "verbose") return cfg
Example #5
Source File: settings.py From Paradrop with Apache License 2.0 | 6 votes |
def load_from_file(path): """ Load settings from an INI file. This will check the configuration file for a lowercase version of all of the settings in this module. It will look in a section called "base". The example below will set PORTAL_SERVER_PORT. [base] portal_server_port = 4444 """ config = configparser.SafeConfigParser() config.read(path) mod = sys.modules[__name__] for name, _ in iterate_module_attributes(mod): # Check if lowercase version exists in the file and load the # appropriately-typed value. key = name.lower() if config.has_option(constants.BASE_SETTINGS_SECTION, key): value = config.get(constants.BASE_SETTINGS_SECTION, key) setattr(mod, name, parseValue(value))
Example #6
Source File: validator.py From ovirt-ansible-disaster-recovery with Apache License 2.0 | 5 votes |
def _set_dr_conf_variables(self, conf_file): _SECTION = 'validate_vars' _VAR_FILE = 'var_file' # Get default location of the yml var file. settings = SafeConfigParser() settings.read(conf_file) if _SECTION not in settings.sections(): settings.add_section(_SECTION) if not settings.has_option(_SECTION, _VAR_FILE): settings.set(_SECTION, _VAR_FILE, '') var_file = settings.get(_SECTION, _VAR_FILE, vars=DefaultOption(settings, _SECTION, site=self.def_var_file)) # If no default location exists, get the location from the user. while not var_file: var_file = input("%s%sVar file is not initialized. " "Please provide the location of the var file " "(%s):%s " % (WARN, PREFIX, self.def_var_file, END) or self.def_var_file) self.var_file = var_file
Example #7
Source File: oauth2.py From courseraprogramming with Apache License 2.0 | 5 votes |
def configuration(): 'Loads configuration from the file system.' defaults = ''' [oauth2] client_id = NS8qaSX18X_Eu0pyNbLsnA client_secret = bUqKqGywnGXEJPFrcd4Jpw hostname = localhost port = 9876 api_endpoint = https://api.coursera.org auth_endpoint = https://accounts.coursera.org/oauth2/v1/auth token_endpoint = https://accounts.coursera.org/oauth2/v1/token scopes = view_profile manage_graders verify_tls = True token_cache = ~/.coursera/oauth2_cache.pickle [upload] transloadit_bored_api = https://api2.transloadit.com/instances/bored ''' cfg = configparser.SafeConfigParser() cfg.read_file(io.StringIO(defaults)) cfg.read([ '/etc/coursera/courseraprogramming.cfg', os.path.expanduser('~/.coursera/courseraprogramming.cfg'), 'courseraprogramming.cfg', ]) return cfg
Example #8
Source File: validator.py From ovirt-ansible-disaster-recovery with Apache License 2.0 | 5 votes |
def _set_dr_conf_variables(self, conf_file): _SECTION = 'validate_vars' _VAR_FILE = 'var_file' # Get default location of the yml var file. settings = SafeConfigParser() settings.read(conf_file) if _SECTION not in settings.sections(): settings.add_section(_SECTION) if not settings.has_option(_SECTION, _VAR_FILE): settings.set(_SECTION, _VAR_FILE, '') var_file = settings.get(_SECTION, _VAR_FILE, vars=DefaultOption(settings, _SECTION, site=self.def_var_file)) # If no default location exists, get the location from the user. while not var_file: var_file = input("%s%sVar file is not initialized. " "Please provide the location of the var file " "(%s):%s " % (WARN, PREFIX, self.def_var_file, END) or self.def_var_file) self.var_file = var_file
Example #9
Source File: validator.py From ovirt-ansible-disaster-recovery with Apache License 2.0 | 5 votes |
def _set_dr_conf_variables(self, conf_file): _SECTION = 'validate_vars' _VAR_FILE = 'var_file' # Get default location of the yml var file. settings = SafeConfigParser() settings.read(conf_file) if _SECTION not in settings.sections(): settings.add_section(_SECTION) if not settings.has_option(_SECTION, _VAR_FILE): settings.set(_SECTION, _VAR_FILE, '') var_file = settings.get(_SECTION, _VAR_FILE, vars=DefaultOption(settings, _SECTION, site=self.def_var_file)) # If no default location exists, get the location from the user. while not var_file: var_file = input("%s%sVar file is not initialized. " "Please provide the location of the var file " "(%s):%s " % (WARN, PREFIX, self.def_var_file, END) or self.def_var_file) self.var_file = var_file
Example #10
Source File: validator.py From ovirt-ansible-disaster-recovery with Apache License 2.0 | 5 votes |
def _set_dr_conf_variables(self, conf_file): _SECTION = 'validate_vars' _VAR_FILE = 'var_file' # Get default location of the yml var file. settings = SafeConfigParser() settings.read(conf_file) if _SECTION not in settings.sections(): settings.add_section(_SECTION) if not settings.has_option(_SECTION, _VAR_FILE): settings.set(_SECTION, _VAR_FILE, '') var_file = settings.get(_SECTION, _VAR_FILE, vars=DefaultOption(settings, _SECTION, site=self.def_var_file)) # If no default location exists, get the location from the user. while not var_file: var_file = input("%s%sVar file is not initialized. " "Please provide the location of the var file " "(%s):%s " % (WARN, PREFIX, self.def_var_file, END) or self.def_var_file) self.var_file = var_file
Example #11
Source File: util.py From auto-alt-text-lambda-api with MIT License | 5 votes |
def open_config(filename): cfg = configparser.SafeConfigParser() cfg.read(filename) yield cfg with open(filename, 'w') as fp: cfg.write(fp)
Example #12
Source File: validator.py From ovirt-ansible-disaster-recovery with Apache License 2.0 | 5 votes |
def _set_dr_conf_variables(self, conf_file): _SECTION = 'validate_vars' _VAR_FILE = 'var_file' # Get default location of the yml var file. settings = SafeConfigParser() settings.read(conf_file) if _SECTION not in settings.sections(): settings.add_section(_SECTION) if not settings.has_option(_SECTION, _VAR_FILE): settings.set(_SECTION, _VAR_FILE, '') var_file = settings.get(_SECTION, _VAR_FILE, vars=DefaultOption(settings, _SECTION, site=self.def_var_file)) # If no default location exists, get the location from the user. while not var_file: var_file = input("%s%sVar file is not initialized. " "Please provide the location of the var file " "(%s):%s " % (WARN, PREFIX, self.def_var_file, END) or self.def_var_file) self.var_file = var_file
Example #13
Source File: settings.py From python-netsurv with MIT License | 5 votes |
def _get_config_data(file_path, sections): settings = {} with io.open(file_path) as config_file: if file_path.endswith('.toml'): if toml: config = toml.load(config_file) for section in sections: config_section = config for key in section.split('.'): config_section = config_section.get(key, {}) settings.update(config_section) else: if '[tool.isort]' in config_file.read(): warnings.warn("Found {} with [tool.isort] section, but toml package is not installed. " "To configure isort with {}, install with 'isort[pyproject]'.".format(file_path, file_path)) else: if file_path.endswith('.editorconfig'): line = '\n' last_position = config_file.tell() while line: line = config_file.readline() if '[' in line: config_file.seek(last_position) break last_position = config_file.tell() if sys.version_info >= (3, 2): config = configparser.ConfigParser(strict=False) config.read_file(config_file) else: config = configparser.SafeConfigParser() config.readfp(config_file) for section in sections: if config.has_section(section): settings.update(config.items(section)) return settings
Example #14
Source File: settings.py From python-netsurv with MIT License | 5 votes |
def _get_config_data(file_path, sections): settings = {} with io.open(file_path) as config_file: if file_path.endswith('.toml'): if toml: config = toml.load(config_file) for section in sections: config_section = config for key in section.split('.'): config_section = config_section.get(key, {}) settings.update(config_section) else: if '[tool.isort]' in config_file.read(): warnings.warn("Found {} with [tool.isort] section, but toml package is not installed. " "To configure isort with {}, install with 'isort[pyproject]'.".format(file_path, file_path)) else: if file_path.endswith('.editorconfig'): line = '\n' last_position = config_file.tell() while line: line = config_file.readline() if '[' in line: config_file.seek(last_position) break last_position = config_file.tell() if sys.version_info >= (3, 2): config = configparser.ConfigParser(strict=False) config.read_file(config_file) else: config = configparser.SafeConfigParser() config.readfp(config_file) for section in sections: if config.has_section(section): settings.update(config.items(section)) return settings
Example #15
Source File: versioneer.py From bitmask-dev with GNU General Public License v3.0 | 5 votes |
def get_config_from_root(root): """Read the project setup.cfg file to determine Versioneer config.""" # This might raise EnvironmentError (if setup.cfg is missing), or # configparser.NoSectionError (if it lacks a [versioneer] section), or # configparser.NoOptionError (if it lacks "VCS="). See the docstring at # the top of versioneer.py for instructions on writing your setup.cfg . setup_cfg = os.path.join(root, "setup.cfg") parser = configparser.SafeConfigParser() with open(setup_cfg, "r") as f: parser.readfp(f) VCS = parser.get("versioneer", "VCS") # mandatory def get(parser, name): if parser.has_option("versioneer", name): return parser.get("versioneer", name) return None cfg = VersioneerConfig() cfg.VCS = VCS cfg.style = get(parser, "style") or "" cfg.versionfile_source = get(parser, "versionfile_source") cfg.versionfile_build = get(parser, "versionfile_build") cfg.tag_prefix = get(parser, "tag_prefix") if cfg.tag_prefix in ("''", '""'): cfg.tag_prefix = "" cfg.parentdir_prefix = get(parser, "parentdir_prefix") cfg.verbose = get(parser, "verbose") return cfg
Example #16
Source File: versioneer.py From kevlar with MIT License | 5 votes |
def get_config_from_root(root): """Read the project setup.cfg file to determine Versioneer config.""" # This might raise EnvironmentError (if setup.cfg is missing), or # configparser.NoSectionError (if it lacks a [versioneer] section), or # configparser.NoOptionError (if it lacks "VCS="). See the docstring at # the top of versioneer.py for instructions on writing your setup.cfg . setup_cfg = os.path.join(root, "setup.cfg") parser = configparser.SafeConfigParser() with open(setup_cfg, "r") as f: parser.readfp(f) VCS = parser.get("versioneer", "VCS") # mandatory def get(parser, name): if parser.has_option("versioneer", name): return parser.get("versioneer", name) return None cfg = VersioneerConfig() cfg.VCS = VCS cfg.style = get(parser, "style") or "" cfg.versionfile_source = get(parser, "versionfile_source") cfg.versionfile_build = get(parser, "versionfile_build") cfg.tag_prefix = get(parser, "tag_prefix") if cfg.tag_prefix in ("''", '""'): cfg.tag_prefix = "" cfg.parentdir_prefix = get(parser, "parentdir_prefix") cfg.verbose = get(parser, "verbose") return cfg
Example #17
Source File: validator.py From ovirt-ansible-disaster-recovery with Apache License 2.0 | 5 votes |
def _set_dr_conf_variables(self, conf_file): _SECTION = 'validate_vars' _VAR_FILE = 'var_file' # Get default location of the yml var file. settings = SafeConfigParser() settings.read(conf_file) if _SECTION not in settings.sections(): settings.add_section(_SECTION) if not settings.has_option(_SECTION, _VAR_FILE): settings.set(_SECTION, _VAR_FILE, '') var_file = settings.get(_SECTION, _VAR_FILE, vars=DefaultOption(settings, _SECTION, site=self.def_var_file)) # If no default location exists, get the location from the user. while not var_file: var_file = input("%s%sVar file is not initialized. " "Please provide the location of the var file " "(%s):%s " % (WARN, PREFIX, self.def_var_file, END) or self.def_var_file) self.var_file = var_file
Example #18
Source File: validator.py From ovirt-ansible-disaster-recovery with Apache License 2.0 | 5 votes |
def _set_dr_conf_variables(self, conf_file): _SECTION = 'validate_vars' _VAR_FILE = 'var_file' # Get default location of the yml var file. settings = SafeConfigParser() settings.read(conf_file) if _SECTION not in settings.sections(): settings.add_section(_SECTION) if not settings.has_option(_SECTION, _VAR_FILE): settings.set(_SECTION, _VAR_FILE, '') var_file = settings.get(_SECTION, _VAR_FILE, vars=DefaultOption(settings, _SECTION, site=self.def_var_file)) # If no default location exists, get the location from the user. while not var_file: var_file = input("%s%sVar file is not initialized. " "Please provide the location of the var file " "(%s):%s " % (WARN, PREFIX, self.def_var_file, END) or self.def_var_file) self.var_file = var_file
Example #19
Source File: validator.py From ovirt-ansible-disaster-recovery with Apache License 2.0 | 5 votes |
def _set_dr_conf_variables(self, conf_file): _SECTION = 'validate_vars' _VAR_FILE = 'var_file' # Get default location of the yml var file. settings = SafeConfigParser() settings.read(conf_file) if _SECTION not in settings.sections(): settings.add_section(_SECTION) if not settings.has_option(_SECTION, _VAR_FILE): settings.set(_SECTION, _VAR_FILE, '') var_file = settings.get(_SECTION, _VAR_FILE, vars=DefaultOption(settings, _SECTION, site=self.def_var_file)) # If no default location exists, get the location from the user. while not var_file: var_file = input("%s%sVar file is not initialized. " "Please provide the location of the var file " "(%s):%s " % (WARN, PREFIX, self.def_var_file, END) or self.def_var_file) self.var_file = var_file
Example #20
Source File: validator.py From ovirt-ansible-disaster-recovery with Apache License 2.0 | 5 votes |
def _set_dr_conf_variables(self, conf_file): _SECTION = 'validate_vars' _VAR_FILE = 'var_file' # Get default location of the yml var file. settings = SafeConfigParser() settings.read(conf_file) if _SECTION not in settings.sections(): settings.add_section(_SECTION) if not settings.has_option(_SECTION, _VAR_FILE): settings.set(_SECTION, _VAR_FILE, '') var_file = settings.get(_SECTION, _VAR_FILE, vars=DefaultOption(settings, _SECTION, site=self.def_var_file)) # If no default location exists, get the location from the user. while not var_file: var_file = input("%s%sVar file is not initialized. " "Please provide the location of the var file " "(%s):%s " % (WARN, PREFIX, self.def_var_file, END) or self.def_var_file) self.var_file = var_file
Example #21
Source File: validator.py From ovirt-ansible-disaster-recovery with Apache License 2.0 | 5 votes |
def _set_dr_conf_variables(self, conf_file): _SECTION = 'validate_vars' _VAR_FILE = 'var_file' # Get default location of the yml var file. settings = SafeConfigParser() settings.read(conf_file) if _SECTION not in settings.sections(): settings.add_section(_SECTION) if not settings.has_option(_SECTION, _VAR_FILE): settings.set(_SECTION, _VAR_FILE, '') var_file = settings.get(_SECTION, _VAR_FILE, vars=DefaultOption(settings, _SECTION, site=self.def_var_file)) # If no default location exists, get the location from the user. while not var_file: var_file = input("%s%sVar file is not initialized. " "Please provide the location of the var file " "(%s):%s " % (WARN, PREFIX, self.def_var_file, END) or self.def_var_file) self.var_file = var_file
Example #22
Source File: validator.py From ovirt-ansible-disaster-recovery with Apache License 2.0 | 5 votes |
def _set_dr_conf_variables(self, conf_file): _SECTION = 'validate_vars' _VAR_FILE = 'var_file' # Get default location of the yml var file. settings = SafeConfigParser() settings.read(conf_file) if _SECTION not in settings.sections(): settings.add_section(_SECTION) if not settings.has_option(_SECTION, _VAR_FILE): settings.set(_SECTION, _VAR_FILE, '') var_file = settings.get(_SECTION, _VAR_FILE, vars=DefaultOption(settings, _SECTION, site=self.def_var_file)) # If no default location exists, get the location from the user. while not var_file: var_file = input("%s%sVar file is not initialized. " "Please provide the location of the var file " "(%s):%s " % (WARN, PREFIX, self.def_var_file, END) or self.def_var_file) self.var_file = var_file
Example #23
Source File: validator.py From ovirt-ansible-disaster-recovery with Apache License 2.0 | 5 votes |
def _set_dr_conf_variables(self, conf_file): _SECTION = 'validate_vars' _VAR_FILE = 'var_file' # Get default location of the yml var file. settings = SafeConfigParser() settings.read(conf_file) if _SECTION not in settings.sections(): settings.add_section(_SECTION) if not settings.has_option(_SECTION, _VAR_FILE): settings.set(_SECTION, _VAR_FILE, '') var_file = settings.get(_SECTION, _VAR_FILE, vars=DefaultOption(settings, _SECTION, site=self.def_var_file)) # If no default location exists, get the location from the user. while not var_file: var_file = input("%s%sVar file is not initialized. " "Please provide the location of the var file " "(%s):%s " % (WARN, PREFIX, self.def_var_file, END) or self.def_var_file) self.var_file = var_file
Example #24
Source File: validator.py From ovirt-ansible-disaster-recovery with Apache License 2.0 | 5 votes |
def _set_dr_conf_variables(self, conf_file): _SECTION = 'validate_vars' _VAR_FILE = 'var_file' # Get default location of the yml var file. settings = SafeConfigParser() settings.read(conf_file) if _SECTION not in settings.sections(): settings.add_section(_SECTION) if not settings.has_option(_SECTION, _VAR_FILE): settings.set(_SECTION, _VAR_FILE, '') var_file = settings.get(_SECTION, _VAR_FILE, vars=DefaultOption(settings, _SECTION, site=self.def_var_file)) # If no default location exists, get the location from the user. while not var_file: var_file = input("%s%sVar file is not initialized. " "Please provide the location of the var file " "(%s):%s " % (WARN, PREFIX, self.def_var_file, END) or self.def_var_file) self.var_file = var_file
Example #25
Source File: validator.py From ovirt-ansible-disaster-recovery with Apache License 2.0 | 5 votes |
def _set_dr_conf_variables(self, conf_file): _SECTION = 'validate_vars' _VAR_FILE = 'var_file' # Get default location of the yml var file. settings = SafeConfigParser() settings.read(conf_file) if _SECTION not in settings.sections(): settings.add_section(_SECTION) if not settings.has_option(_SECTION, _VAR_FILE): settings.set(_SECTION, _VAR_FILE, '') var_file = settings.get(_SECTION, _VAR_FILE, vars=DefaultOption(settings, _SECTION, site=self.def_var_file)) # If no default location exists, get the location from the user. while not var_file: var_file = input("%s%sVar file is not initialized. " "Please provide the location of the var file " "(%s):%s " % (WARN, PREFIX, self.def_var_file, END) or self.def_var_file) self.var_file = var_file
Example #26
Source File: validator.py From ovirt-ansible-disaster-recovery with Apache License 2.0 | 5 votes |
def _set_dr_conf_variables(self, conf_file): _SECTION = 'validate_vars' _VAR_FILE = 'var_file' # Get default location of the yml var file. settings = SafeConfigParser() settings.read(conf_file) if _SECTION not in settings.sections(): settings.add_section(_SECTION) if not settings.has_option(_SECTION, _VAR_FILE): settings.set(_SECTION, _VAR_FILE, '') var_file = settings.get(_SECTION, _VAR_FILE, vars=DefaultOption(settings, _SECTION, site=self.def_var_file)) # If no default location exists, get the location from the user. while not var_file: var_file = input("%s%sVar file is not initialized. " "Please provide the location of the var file " "(%s):%s " % (WARN, PREFIX, self.def_var_file, END) or self.def_var_file) self.var_file = var_file
Example #27
Source File: validator.py From ovirt-ansible-disaster-recovery with Apache License 2.0 | 5 votes |
def _set_dr_conf_variables(self, conf_file): _SECTION = 'validate_vars' _VAR_FILE = 'var_file' # Get default location of the yml var file. settings = SafeConfigParser() settings.read(conf_file) if _SECTION not in settings.sections(): settings.add_section(_SECTION) if not settings.has_option(_SECTION, _VAR_FILE): settings.set(_SECTION, _VAR_FILE, '') var_file = settings.get(_SECTION, _VAR_FILE, vars=DefaultOption(settings, _SECTION, site=self.def_var_file)) # If no default location exists, get the location from the user. while not var_file: var_file = input("%s%sVar file is not initialized. " "Please provide the location of the var file " "(%s):%s " % (WARN, PREFIX, self.def_var_file, END) or self.def_var_file) self.var_file = var_file
Example #28
Source File: validator.py From ovirt-ansible-disaster-recovery with Apache License 2.0 | 5 votes |
def _set_dr_conf_variables(self, conf_file): _SECTION = 'validate_vars' _VAR_FILE = 'var_file' # Get default location of the yml var file. settings = SafeConfigParser() settings.read(conf_file) if _SECTION not in settings.sections(): settings.add_section(_SECTION) if not settings.has_option(_SECTION, _VAR_FILE): settings.set(_SECTION, _VAR_FILE, '') var_file = settings.get(_SECTION, _VAR_FILE, vars=DefaultOption(settings, _SECTION, site=self.def_var_file)) # If no default location exists, get the location from the user. while not var_file: var_file = input("%s%sVar file is not initialized. " "Please provide the location of the var file " "(%s):%s " % (WARN, PREFIX, self.def_var_file, END) or self.def_var_file) self.var_file = var_file
Example #29
Source File: validator.py From ovirt-ansible-disaster-recovery with Apache License 2.0 | 5 votes |
def _set_dr_conf_variables(self, conf_file): _SECTION = 'validate_vars' _VAR_FILE = 'var_file' # Get default location of the yml var file. settings = SafeConfigParser() settings.read(conf_file) if _SECTION not in settings.sections(): settings.add_section(_SECTION) if not settings.has_option(_SECTION, _VAR_FILE): settings.set(_SECTION, _VAR_FILE, '') var_file = settings.get(_SECTION, _VAR_FILE, vars=DefaultOption(settings, _SECTION, site=self.def_var_file)) # If no default location exists, get the location from the user. while not var_file: var_file = input("%s%sVar file is not initialized. " "Please provide the location of the var file " "(%s):%s " % (WARN, PREFIX, self.def_var_file, END) or self.def_var_file) self.var_file = var_file
Example #30
Source File: validator.py From ovirt-ansible-disaster-recovery with Apache License 2.0 | 5 votes |
def _set_dr_conf_variables(self, conf_file): _SECTION = 'validate_vars' _VAR_FILE = 'var_file' # Get default location of the yml var file. settings = SafeConfigParser() settings.read(conf_file) if _SECTION not in settings.sections(): settings.add_section(_SECTION) if not settings.has_option(_SECTION, _VAR_FILE): settings.set(_SECTION, _VAR_FILE, '') var_file = settings.get(_SECTION, _VAR_FILE, vars=DefaultOption(settings, _SECTION, site=self.def_var_file)) # If no default location exists, get the location from the user. while not var_file: var_file = input("%s%sVar file is not initialized. " "Please provide the location of the var file " "(%s):%s " % (WARN, PREFIX, self.def_var_file, END) or self.def_var_file) self.var_file = var_file