[PATCH 04/20] py: Replace usage of configparser.read_fp
Jiaxun Yang
jiaxun.yang at flygoat.com
Tue Jun 11 23:04:03 CEST 2024
configparser.read_fp is deprecated long ago.
Replace with relevant API.
Signed-off-by: Jiaxun Yang <jiaxun.yang at flygoat.com>
---
tools/buildman/bsettings.py | 2 +-
tools/patman/settings.py | 9 ++++-----
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/tools/buildman/bsettings.py b/tools/buildman/bsettings.py
index e225ac2ca0f4..7dbc638d5841 100644
--- a/tools/buildman/bsettings.py
+++ b/tools/buildman/bsettings.py
@@ -29,7 +29,7 @@ def setup(fname=''):
settings.read(config_fname)
def add_file(data):
- settings.readfp(io.StringIO(data))
+ settings.read_file(io.StringIO(data), data)
def get_items(section):
"""Get the items from a section of the config.
diff --git a/tools/patman/settings.py b/tools/patman/settings.py
index 636983e32da8..308626107037 100644
--- a/tools/patman/settings.py
+++ b/tools/patman/settings.py
@@ -41,7 +41,6 @@ class _ProjectConfigParser(ConfigParser.ConfigParser):
- Merge general default settings/aliases with project-specific ones.
# Sample config used for tests below...
- >>> from io import StringIO
>>> sample_config = '''
... [alias]
... me: Peter P. <likesspiders at example.com>
@@ -59,25 +58,25 @@ class _ProjectConfigParser(ConfigParser.ConfigParser):
# Check to make sure that bogus project gets general alias.
>>> config = _ProjectConfigParser("zzz")
- >>> config.readfp(StringIO(sample_config))
+ >>> config.read_string(sample_config)
>>> str(config.get("alias", "enemies"))
'Evil <evil at example.com>'
# Check to make sure that alias gets overridden by project.
>>> config = _ProjectConfigParser("sm")
- >>> config.readfp(StringIO(sample_config))
+ >>> config.read_string(sample_config)
>>> str(config.get("alias", "enemies"))
'Green G. <ugly at example.com>'
# Check to make sure that settings get merged with project.
>>> config = _ProjectConfigParser("linux")
- >>> config.readfp(StringIO(sample_config))
+ >>> config.read_string(sample_config)
>>> sorted((str(a), str(b)) for (a, b) in config.items("settings"))
[('am_hero', 'True'), ('check_patch_use_tree', 'True'), ('process_tags', 'False')]
# Check to make sure that settings works with unknown project.
>>> config = _ProjectConfigParser("unknown")
- >>> config.readfp(StringIO(sample_config))
+ >>> config.read_string(sample_config)
>>> sorted((str(a), str(b)) for (a, b) in config.items("settings"))
[('am_hero', 'True')]
"""
--
2.43.0
More information about the U-Boot
mailing list