Python ConfigParser.NoSectionError() Examples
The following are 30
code examples of ConfigParser.NoSectionError().
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: simple_config.py From encompass with GNU General Public License v3.0 | 6 votes |
def read_system_config(path=SYSTEM_CONFIG_PATH): """Parse and return the system config settings in /etc/encompass.conf.""" result = {} if os.path.exists(path): try: import ConfigParser except ImportError: print "cannot parse encompass.conf. please install ConfigParser" return p = ConfigParser.ConfigParser() try: p.read(path) for k, v in p.items('client'): result[k] = v except (ConfigParser.NoSectionError, ConfigParser.MissingSectionHeaderError): pass return result
Example #2
Source File: protocol.py From rucio with Apache License 2.0 | 6 votes |
def _module_init_(cls): """ Initialize the class object on first module load. """ cls.register(cls.__hash, "hash") cls.register(cls.__identity, "identity") cls.register(cls.__ligo, "ligo") cls.register(cls.__belleii, "belleii") policy_module = None try: policy_module = config.config_get('policy', 'lfn2pfn_module') except (NoOptionError, NoSectionError): pass if policy_module: # TODO: The import of importlib is done like this due to a dependency issue with python 2.6 and incompatibility of the module with py3.x # More information https://github.com/rucio/rucio/issues/875 import importlib importlib.import_module(policy_module) cls._DEFAULT_LFN2PFN = config.get_lfn2pfn_algorithm_default()
Example #3
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 #4
Source File: config.py From rucio with Apache License 2.0 | 6 votes |
def config_get_bool(section, option, raise_exception=True, default=None): """ Return the boolean value for a given option in a section :param section: the named section. :param option: the named option. :param raise_exception: Boolean to raise or not NoOptionError or NoSectionError. :param default: the default value if not found. . :returns: the configuration value. """ try: return get_config().getboolean(section, option) except (ConfigParser.NoOptionError, ConfigParser.NoSectionError) as err: if raise_exception: raise err if default is None: return default return bool(default)
Example #5
Source File: versioneer.py From confusable_homoglyphs 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 #6
Source File: versioneer.py From bhmm with GNU Lesser General Public License v3.0 | 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 #7
Source File: s3.py From d6tpipe with MIT License | 6 votes |
def _get_s3_config(key=None): defaults = dict(configuration.get_config().defaults()) try: config = dict(configuration.get_config().items('s3')) except (NoSectionError, KeyError): return {} # So what ports etc can be read without us having to specify all dtypes for k, v in six.iteritems(config): try: config[k] = int(v) except ValueError: pass if key: return config.get(key) section_only = {k: v for k, v in config.items() if k not in defaults or v != defaults[k]} return section_only
Example #8
Source File: metadata.py From misp42splunk with GNU Lesser General Public License v3.0 | 6 votes |
def get_float(self, conf, stanza, option): '''Return the metadata value of option in [conf/stanza] section as a float. :param conf: Conf name. :type conf: ``string`` :param stanza: Stanza name. :type stanza: ``string`` :param option: Option name in section [conf/stanza]. :type option: ``string`` :returns: A float value. :rtype: ``float`` :raises ValueError: Raises ValueError if the value cannot be determined. Note that this can occur in several situations: - The stanza exists but the value does not exist (perhaps having never been updated). - The stanza does not exist. - The value exists but cannot be converted to a float. ''' try: return self._cfg.getfloat('/'.join([conf, stanza]), option) except (NoSectionError, NoOptionError): raise ValueError('The metadata value could not be determined.')
Example #9
Source File: metadata.py From misp42splunk with GNU Lesser General Public License v3.0 | 6 votes |
def get(self, conf, stanza, option): '''Return the metadata value of option in [conf/stanza] section. :param conf: Conf name. :type conf: ``string`` :param stanza: Stanza name. :type stanza: ``string`` :param option: Option name in section [conf/stanza]. :type option: ``string`` :returns: Value of option in section [conf/stanza]. :rtype: ``string`` :raises ValueError: Raises ValueError if the value cannot be determined. Note that this can occur in several situations: - The section does not exist. - The section exists but the option does not exist. ''' try: return self._cfg.get('/'.join([conf, stanza]), option) except (NoSectionError, NoOptionError): raise ValueError('The metadata value could not be determined.')
Example #10
Source File: metadata.py From misp42splunk with GNU Lesser General Public License v3.0 | 6 votes |
def get_float(self, conf, stanza, option): '''Return the metadata value of option in [conf/stanza] section as a float. :param conf: Conf name. :type conf: ``string`` :param stanza: Stanza name. :type stanza: ``string`` :param option: Option name in section [conf/stanza]. :type option: ``string`` :returns: A float value. :rtype: ``float`` :raises ValueError: Raises ValueError if the value cannot be determined. Note that this can occur in several situations: - The stanza exists but the value does not exist (perhaps having never been updated). - The stanza does not exist. - The value exists but cannot be converted to a float. ''' try: return self._cfg.getfloat('/'.join([conf, stanza]), option) except (NoSectionError, NoOptionError): raise ValueError('The metadata value could not be determined.')
Example #11
Source File: metadata.py From misp42splunk with GNU Lesser General Public License v3.0 | 6 votes |
def get(self, conf, stanza, option): '''Return the metadata value of option in [conf/stanza] section. :param conf: Conf name. :type conf: ``string`` :param stanza: Stanza name. :type stanza: ``string`` :param option: Option name in section [conf/stanza]. :type option: ``string`` :returns: Value of option in section [conf/stanza]. :rtype: ``string`` :raises ValueError: Raises ValueError if the value cannot be determined. Note that this can occur in several situations: - The section does not exist. - The section exists but the option does not exist. ''' try: return self._cfg.get('/'.join([conf, stanza]), option) except (NoSectionError, NoOptionError): raise ValueError('The metadata value could not be determined.')
Example #12
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 #13
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 #14
Source File: helper.py From Faraday-Software with GNU General Public License v3.0 | 6 votes |
def getLogger(self): """ Get logger configuration and create instance of a logger """ # Known paths where loggingConfig.ini can exist relpath1 = os.path.join('etc', 'faraday') relpath2 = os.path.join('..', 'etc', 'faraday') setuppath = os.path.join(sys.prefix, 'etc', 'faraday') userpath = os.path.join(os.path.expanduser('~'), '.faraday') self.path = '' # Check all directories until first instance of loggingConfig.ini for location in os.curdir, relpath1, relpath2, setuppath, userpath: try: logging.config.fileConfig(os.path.join(location, "loggingConfig.ini")) self.path = location break except ConfigParser.NoSectionError: pass self._logger = logging.getLogger(self._name) return self._logger
Example #15
Source File: versioneer.py From ipython-autotime with Apache License 2.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: test_cfgparser.py From ironpython2 with Apache License 2.0 | 5 votes |
def test_nosectionerror(self): import pickle e1 = ConfigParser.NoSectionError('section') for proto in range(pickle.HIGHEST_PROTOCOL + 1): pickled = pickle.dumps(e1, proto) e2 = pickle.loads(pickled) self.assertEqual(e1.message, e2.message) self.assertEqual(e1.args, e2.args) self.assertEqual(e1.section, e2.section) self.assertEqual(repr(e1), repr(e2))
Example #17
Source File: versioneer.py From lsfm with BSD 3-Clause "New" or "Revised" 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 #18
Source File: conf.py From openplotter with GNU General Public License v2.0 | 5 votes |
def set(self, section, item, value): self.read() try: self.data_conf.set(section, item, value) except ConfigParser.NoSectionError: self.data_conf.add_section(section) self.data_conf.set(section, item, value) self.write()
Example #19
Source File: versioneer.py From jupyterhub-kubernetes_spawner with Apache License 2.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 #20
Source File: versioneer.py From pybids 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 #21
Source File: a10_config.py From a10-neutron-lbaas with Apache License 2.0 | 5 votes |
def _get_neutron_conf(self, section, option): neutron_conf_dir = os.environ.get('NEUTRON_CONF_DIR', self._config.neutron_conf_dir) neutron_conf = '%s/neutron.conf' % neutron_conf_dir if os.path.exists(neutron_conf): LOG.debug("found neutron.conf file in /etc") n = ini.ConfigParser() n.read(neutron_conf) try: return n.get(section, option) except (ini.NoSectionError, ini.NoOptionError): pass
Example #22
Source File: versioneer.py From heliopy 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 #23
Source File: versioneer.py From dask-cloudprovider with BSD 3-Clause "New" or "Revised" 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 #24
Source File: conf.py From openplotter with GNU General Public License v2.0 | 5 votes |
def get(self, section, item): result = '' try: result = self.data_conf.get(section, item) except ConfigParser.NoSectionError: self.read() try: self.data_conf.add_section(section) except ConfigParser.DuplicateSectionError: pass self.data_conf.set(section, item, '') self.write() except ConfigParser.NoOptionError: self.set(section, item, '') return result
Example #25
Source File: conf.py From openplotter with GNU General Public License v2.0 | 5 votes |
def set(self, section, item, value): self.read() try: self.data_conf.set(section, item, value) except ConfigParser.NoSectionError: self.data_conf.add_section(section) self.data_conf.set(section, item, value) self.write()
Example #26
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 #27
Source File: versioneer.py From ib_dl with Apache License 2.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 #28
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 #29
Source File: config.py From bitmask-dev with GNU General Public License v3.0 | 5 votes |
def get(self, section, option, default=None, boolean=False): try: if boolean: return self.config.getboolean(section, option) item = self.config.get(section, option) return item except (ConfigParser.NoOptionError, ConfigParser.NoSectionError): if default is None: raise MissingConfigEntry("%s is missing the [%s]%s entry" % (self.config_path, section, option)) return default
Example #30
Source File: test_cfgparser.py From ironpython2 with Apache License 2.0 | 5 votes |
def test_query_errors(self): cf = self.newconfig() self.assertEqual(cf.sections(), [], "new ConfigParser should have no defined sections") self.assertFalse(cf.has_section("Foo"), "new ConfigParser should have no acknowledged " "sections") self.assertRaises(ConfigParser.NoSectionError, cf.options, "Foo") self.assertRaises(ConfigParser.NoSectionError, cf.set, "foo", "bar", "value") self.get_error(ConfigParser.NoSectionError, "foo", "bar") cf.add_section("foo") self.get_error(ConfigParser.NoOptionError, "foo", "bar")