From 7273cdc733bc22e04d0a7aeba2bc17f00dbe28ea Mon Sep 17 00:00:00 2001 From: wanchao-xu Date: Thu, 21 Sep 2023 10:51:57 +0800 Subject: [PATCH] Don't stop gbs command if gbs conf has duplicate section/option. * SafeConfigParser has been renamed to ConfigParser in Python 3.2 * ConfigParser of python3 provides duplicate section/option error Change-Id: I8a26c61a0d7a7bb14577d8940b4b712afefa3d4c Signed-off-by: wanchao-xu --- gitbuildsys/conf.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/gitbuildsys/conf.py b/gitbuildsys/conf.py index 01eeb92..54073d7 100644 --- a/gitbuildsys/conf.py +++ b/gitbuildsys/conf.py @@ -27,7 +27,7 @@ import binascii import codecs import shutil from collections import namedtuple -from configparser import SafeConfigParser, \ +from configparser import ConfigParser, \ MissingSectionHeaderError, Error from gitbuildsys import errors @@ -45,14 +45,14 @@ def encode_passwd(passwd): return base64.b64encode(codecs.encode(passwd.encode(), 'bz2')).decode() -class BrainConfigParser(SafeConfigParser): +class BrainConfigParser(ConfigParser): """Standard ConfigParser derived class which can reserve most of the comments, indents, and other user customized stuff inside the ini file. """ def read_one(self, filename): """only support one input file""" - return SafeConfigParser.read(self, filename) + return ConfigParser.read(self, filename) def _read(self, fptr, fname): """Parse a sectioned setup file. @@ -67,7 +67,7 @@ class BrainConfigParser(SafeConfigParser): self._flines = fptr.readlines() fptr.seek(0) - return SafeConfigParser._read(self, fptr, fname) + return ConfigParser._read(self, fptr, fname) def _set_into_file(self, section, option, value, replace_opt=None): """Set the value in the file contents @@ -147,9 +147,9 @@ class BrainConfigParser(SafeConfigParser): """ if not self.has_section(section): self.add_section(section) - SafeConfigParser.set(self, section, option, value) + ConfigParser.set(self, section, option, value) if replace_opt: - SafeConfigParser.remove_option(self, section, replace_opt) + ConfigParser.remove_option(self, section, replace_opt) # If the code reach here, it means the section and key are ok try: @@ -270,7 +270,7 @@ url = http://download.tizen.org/releases/daily/trunk/ivi/latest/ self._cfgparsers = [] for fpath in self._cfgfiles: - cfgparser = BrainConfigParser() + cfgparser = BrainConfigParser(strict=False) try: cfgparser.read_one(fpath) if cfgparser.has_section('general') and \ @@ -812,9 +812,9 @@ class BizConfigManager(ConfigMgr): return profile -class MappingConfigParser(SafeConfigParser): +class MappingConfigParser(ConfigParser): def __init__(self, file, defaults=None): - SafeConfigParser.__init__(self, defaults=None) + ConfigParser.__init__(self, defaults=None) self._obs_meta = {} self._prefix_meta = {} self._repo_meta = {} -- 2.34.1