Python ConfigParser.DuplicateSectionError() Examples
The following are 30
code examples of ConfigParser.DuplicateSectionError().
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: pip-link-build.py From ansible-lxc-rpc with Apache License 2.0 | 5 votes |
def build_install_section(main_dir_path, main_config): """Build the install section with links. :param main_dir_path: ``str`` Directory path :param main_config: ``object`` ConfigParser object """ links = [] links_dir = os.path.join(main_dir_path, 'links.d') if os.path.isdir(links_dir): _link = config_files(config_dir_path=links_dir, extension='.link') links.extend(pip_links(_link)) # Add install section if not already found try: main_config.add_section('install') except ConfigParser.DuplicateSectionError: pass # Get all items from the install section try: install_items = main_config.items('install') except ConfigParser.NoSectionError: install_items = None link_strings = set_links(links) if install_items: for item in install_items: if item[0] != 'find-links': main_config.set('install', *item) main_config.set('install', 'find-links', link_strings)
Example #2
Source File: test_cfgparser.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_duplicatesectionerror(self): import pickle e1 = ConfigParser.DuplicateSectionError('section') pickled = pickle.dumps(e1) 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 #3
Source File: test_cfgparser.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_weird_errors(self): cf = self.newconfig() cf.add_section("Foo") self.assertRaises(ConfigParser.DuplicateSectionError, cf.add_section, "Foo")
Example #4
Source File: inventory.py From product-sp with Apache License 2.0 | 5 votes |
def ensure_required_groups(self, groups): for group in groups: try: self.debug("Adding group {0}".format(group)) self.config.add_section(group) except configparser.DuplicateSectionError: pass
Example #5
Source File: config.py From python-ilorest-library-old with Apache License 2.0 | 5 votes |
def save(self, filename=None): #TODO: Maybe unused """Save configuration settings from the file filename, if filename is None then the value from get_configfile() is used :param filename: file name to be used for config saving. :type filename: str. """ fname = self.get_configfile() if filename is not None and len(filename) > 0: fname = filename if fname is None or len(fname) == 0: return config = ConfigParser.RawConfigParser() try: config.add_section(self._sectionname) except ConfigParser.DuplicateSectionError: pass # ignored for key in self._get_ac_keys(): ackey = '_ac__%s' % key config.set(self._sectionname, key, str(self.__dict__[ackey])) fileh = open(self._configfile, 'wb') config.write(fileh) fileh.close()
Example #6
Source File: test_cfgparser.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_duplicatesectionerror(self): import pickle e1 = ConfigParser.DuplicateSectionError('section') pickled = pickle.dumps(e1) 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 #7
Source File: test_cfgparser.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_weird_errors(self): cf = self.newconfig() cf.add_section("Foo") self.assertRaises(ConfigParser.DuplicateSectionError, cf.add_section, "Foo")
Example #8
Source File: test_cfgparser.py From medicare-demo with Apache License 2.0 | 5 votes |
def test_weird_errors(self): cf = self.newconfig() cf.add_section("Foo") self.assertRaises(ConfigParser.DuplicateSectionError, cf.add_section, "Foo")
Example #9
Source File: test_cfgparser.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_duplicatesectionerror(self): import pickle e1 = ConfigParser.DuplicateSectionError('section') pickled = pickle.dumps(e1) 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 #10
Source File: test_cfgparser.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_weird_errors(self): cf = self.newconfig() cf.add_section("Foo") self.assertRaises(ConfigParser.DuplicateSectionError, cf.add_section, "Foo")
Example #11
Source File: pip-link-build.py From ansible-lxc-rpc with Apache License 2.0 | 5 votes |
def build_main_config(add_conf, main_config): """Build configuration from all found conf files. :param add_conf: ``object`` ConfigParser object :param main_config: ``object`` ConfigParser object """ for section in add_conf.sections(): try: main_config.add_section(section) except ConfigParser.DuplicateSectionError: pass for k, v in add_conf.items(section): main_config.set(section, k, v)
Example #12
Source File: pip-link-build.py From ansible-lxc-rpc with Apache License 2.0 | 5 votes |
def build_install_section(main_dir_path, main_config): """Build the install section with links. :param main_dir_path: ``str`` Directory path :param main_config: ``object`` ConfigParser object """ links = [] links_dir = os.path.join(main_dir_path, 'links.d') if os.path.isdir(links_dir): _link = config_files(config_dir_path=links_dir, extension='.link') links.extend(pip_links(_link)) # Add install section if not already found try: main_config.add_section('install') except ConfigParser.DuplicateSectionError: pass # Get all items from the install section try: install_items = main_config.items('install') except ConfigParser.NoSectionError: install_items = None link_strings = set_links(links) if install_items: for item in install_items: if item[0] != 'find-links': main_config.set('install', *item) main_config.set('install', 'find-links', link_strings)
Example #13
Source File: pip-link-build.py From ansible-lxc-rpc with Apache License 2.0 | 5 votes |
def build_main_config(add_conf, main_config): """Build configuration from all found conf files. :param add_conf: ``object`` ConfigParser object :param main_config: ``object`` ConfigParser object """ for section in add_conf.sections(): try: main_config.add_section(section) except ConfigParser.DuplicateSectionError: pass for k, v in add_conf.items(section): main_config.set(section, k, v)
Example #14
Source File: pip-link-build.py From ansible-lxc-rpc with Apache License 2.0 | 5 votes |
def build_install_section(main_dir_path, main_config): """Build the install section with links. :param main_dir_path: ``str`` Directory path :param main_config: ``object`` ConfigParser object """ links = [] links_dir = os.path.join(main_dir_path, 'links.d') if os.path.isdir(links_dir): _link = config_files(config_dir_path=links_dir, extension='.link') links.extend(pip_links(_link)) # Add install section if not already found try: main_config.add_section('install') except ConfigParser.DuplicateSectionError: pass # Get all items from the install section try: install_items = main_config.items('install') except ConfigParser.NoSectionError: install_items = None link_strings = set_links(links) if install_items: for item in install_items: if item[0] != 'find-links': main_config.set('install', *item) main_config.set('install', 'find-links', link_strings)
Example #15
Source File: pip-link-build.py From ansible-lxc-rpc with Apache License 2.0 | 5 votes |
def build_main_config(add_conf, main_config): """Build configuration from all found conf files. :param add_conf: ``object`` ConfigParser object :param main_config: ``object`` ConfigParser object """ for section in add_conf.sections(): try: main_config.add_section(section) except ConfigParser.DuplicateSectionError: pass for k, v in add_conf.items(section): main_config.set(section, k, v)
Example #16
Source File: pip-link-build.py From ansible-lxc-rpc with Apache License 2.0 | 5 votes |
def build_main_config(add_conf, main_config): """Build configuration from all found conf files. :param add_conf: ``object`` ConfigParser object :param main_config: ``object`` ConfigParser object """ for section in add_conf.sections(): try: main_config.add_section(section) except ConfigParser.DuplicateSectionError: pass for k, v in add_conf.items(section): main_config.set(section, k, v)
Example #17
Source File: fusesocconfigparser.py From fusesoc with BSD 2-Clause "Simplified" License | 5 votes |
def __init__(self, config_file): if sys.version[0] == "2": CP.__init__(self) else: super().__init__() if not os.path.exists(config_file): raise Exception("Could not find " + config_file) f = open(config_file) id_string = f.readline().split("=") if id_string[0].strip().upper() in ["CAPI", "SAPI"]: self.type = id_string[0] else: raise SyntaxError("Could not find API type in " + config_file) try: self.version = int(id_string[1].strip()) except ValueError: raise SyntaxError("Unknown version '{}'".format(id_string[1].strip())) except IndexError: raise SyntaxError("Could not find API version in " + config_file) if sys.version[0] == "2": exceptions = (configparser.ParsingError, configparser.DuplicateSectionError) else: exceptions = ( configparser.ParsingError, configparser.DuplicateSectionError, configparser.DuplicateOptionError, ) try: if sys.version[0] == "2": self.readfp(f) else: self.read_file(f) except configparser.MissingSectionHeaderError: raise SyntaxError("Missing section header") except exceptions as e: raise SyntaxError(e.message)
Example #18
Source File: pip-link-build.py From ansible-lxc-rpc with Apache License 2.0 | 5 votes |
def build_main_config(add_conf, main_config): """Build configuration from all found conf files. :param add_conf: ``object`` ConfigParser object :param main_config: ``object`` ConfigParser object """ for section in add_conf.sections(): try: main_config.add_section(section) except ConfigParser.DuplicateSectionError: pass for k, v in add_conf.items(section): main_config.set(section, k, v)
Example #19
Source File: pip-link-build.py From ansible-lxc-rpc with Apache License 2.0 | 5 votes |
def build_install_section(main_dir_path, main_config): """Build the install section with links. :param main_dir_path: ``str`` Directory path :param main_config: ``object`` ConfigParser object """ links = [] links_dir = os.path.join(main_dir_path, 'links.d') if os.path.isdir(links_dir): _link = config_files(config_dir_path=links_dir, extension='.link') links.extend(pip_links(_link)) # Add install section if not already found try: main_config.add_section('install') except ConfigParser.DuplicateSectionError: pass # Get all items from the install section try: install_items = main_config.items('install') except ConfigParser.NoSectionError: install_items = None link_strings = set_links(links) if install_items: for item in install_items: if item[0] != 'find-links': main_config.set('install', *item) main_config.set('install', 'find-links', link_strings)
Example #20
Source File: pip-link-build.py From ansible-lxc-rpc with Apache License 2.0 | 5 votes |
def build_main_config(add_conf, main_config): """Build configuration from all found conf files. :param add_conf: ``object`` ConfigParser object :param main_config: ``object`` ConfigParser object """ for section in add_conf.sections(): try: main_config.add_section(section) except ConfigParser.DuplicateSectionError: pass for k, v in add_conf.items(section): main_config.set(section, k, v)
Example #21
Source File: inventory.py From kubespray with Apache License 2.0 | 5 votes |
def ensure_required_groups(self, groups): for group in groups: try: self.debug("Adding group {0}".format(group)) self.config.add_section(group) except configparser.DuplicateSectionError: pass
Example #22
Source File: inventory.py From streaming-integrator with Apache License 2.0 | 5 votes |
def ensure_required_groups(self, groups): for group in groups: try: self.debug("Adding group {0}".format(group)) self.config.add_section(group) except configparser.DuplicateSectionError: pass
Example #23
Source File: test_cfgparser.py From oss-ftp with MIT License | 5 votes |
def test_duplicatesectionerror(self): import pickle e1 = ConfigParser.DuplicateSectionError('section') pickled = pickle.dumps(e1) 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 #24
Source File: test_cfgparser.py From oss-ftp with MIT License | 5 votes |
def test_weird_errors(self): cf = self.newconfig() cf.add_section("Foo") self.assertRaises(ConfigParser.DuplicateSectionError, cf.add_section, "Foo")
Example #25
Source File: test_cfgparser.py From BinderFilter with MIT License | 5 votes |
def test_duplicatesectionerror(self): import pickle e1 = ConfigParser.DuplicateSectionError('section') pickled = pickle.dumps(e1) 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 #26
Source File: test_cfgparser.py From BinderFilter with MIT License | 5 votes |
def test_weird_errors(self): cf = self.newconfig() cf.add_section("Foo") self.assertRaises(ConfigParser.DuplicateSectionError, cf.add_section, "Foo")
Example #27
Source File: test_cfgparser.py From ironpython2 with Apache License 2.0 | 5 votes |
def test_duplicatesectionerror(self): import pickle e1 = ConfigParser.DuplicateSectionError('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 #28
Source File: test_cfgparser.py From ironpython2 with Apache License 2.0 | 5 votes |
def test_weird_errors(self): cf = self.newconfig() cf.add_section("Foo") self.assertRaises(ConfigParser.DuplicateSectionError, cf.add_section, "Foo")
Example #29
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 #30
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