refactor(parsers): replace configobj with stdlib implementations - #7026
Open
sshedi wants to merge 11 commits into
Open
refactor(parsers): replace configobj with stdlib implementations#7026sshedi wants to merge 11 commits into
sshedi wants to merge 11 commits into
Conversation
Contributor
Author
|
Discussion link: #7023 |
sshedi
force-pushed
the
drop-configobj
branch
3 times, most recently
from
August 21, 2026 19:29
e08c7e8 to
04f9007
Compare
SysConf is rewritten as a plain dict subclass that preserves comment lines, key ordering, and inline comments through a parse-then-emit cycle. Shell-variable quoting logic is retained verbatim. The quote format constants (_SQUOT, _DQUOT, etc.) are inlined from configobj so the output is byte-for-byte identical. NetworkManagerConf is rewritten on top of configparser.RawConfigParser with the same public API: sections, set_section_keypair(), write(). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Shreenidhi Shedi <shreenidhi.shedi@broadcom.com>
Both networkd_parse_lease() and network_manager_load_leases() used ConfigObj solely to parse flat key=value content with no sections. The new _parse_key_value() helper does the same with a simple loop, accepting a file-like object, a list of lines, or a plain string. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Shreenidhi Shedi <shreenidhi.shedi@broadcom.com>
Introduces _McollectiveConfig, a lightweight class that reads and writes mcollective server.cfg files. The format is sectionless key=value at the top level with optional [section] blocks. Original key and section ordering is preserved on write. The class exposes the same interface that the handler code used on ConfigObj: dict-style item access, .sections, and .write(file). The test helper that read the written file back via ConfigObj is replaced with a simple key=value parser so there is no longer any configobj dependency in this module or its tests. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Shreenidhi Shedi <shreenidhi.shedi@broadcom.com>
…merge merge_together() now accepts plain dicts and INI filenames. Dicts are deep-copied before merging so that the module-level LSC_BUILTIN_CFG constant is never mutated across calls. INI files are parsed with configparser.RawConfigParser, which handles the [client] section natively. No behaviour change for callers. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Shreenidhi Shedi <shreenidhi.shedi@broadcom.com>
…tting _format_repository_config() used ConfigObj only to produce a [section] block with key=value lines. The replacement builds that string directly, removing the dependency with no behaviour change for zypper repo files. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Shreenidhi Shedi <shreenidhi.shedi@broadcom.com>
These tests imported ConfigObj only to parse written sysconfig files and verify their contents. The verification is now done with an inline key=value loop, which reads KEY=VALUE lines and strips surrounding whitespace. No test logic changes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Shreenidhi Shedi <shreenidhi.shedi@broadcom.com>
All usages have been replaced with stdlib alternatives (configparser, copy, and plain dict/string operations). Remove the dependency from both requirements.txt and pyproject.toml. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Shreenidhi Shedi <shreenidhi.shedi@broadcom.com>
parse_key_value() parses flat key=value content (comments and blank lines ignored) from any of: string, bytes/bytearray, list/tuple, or file-like object. It replaces four private/inline copies that existed in dhcp.py and various test helpers. deep_merge() returns a new dict with override merged into base recursively (last-writer wins for scalars, recursive merge for nested dicts). It replaces the private _deep_merge() in cc_landscape.py. Unlike mergemanydict(), it uses no merger plugins and never mutates its inputs. Both functions are tested with comprehensive unit tests in TestParseKeyValue and TestDeepMerge. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Shreenidhi Shedi <shreenidhi.shedi@broadcom.com>
…value dhcp.py had a private _parse_key_value(). Four test files each had their own inline key=value parser or a private helper doing the same thing. All are now replaced with calls to util.parse_key_value(), removing ~60 lines of duplicated logic across the codebase. test_cc_mcollective: thin _parse_mcollective_config wrapper now delegates to util.parse_key_value and util.load_text_file instead of re-implementing parsing. test_cc_set_hostname: conf_parser is now a direct alias for util.parse_key_value. test_cc_timezone, test_cc_locale: inline loops replaced with single-line util.parse_key_value() calls. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Shreenidhi Shedi <shreenidhi.shedi@broadcom.com>
Replace the module-private _deep_merge() with util.deep_merge(). The new util function returns a fresh dict rather than mutating in place, so merge_together() is updated to use the return value instead of passing base by reference. This also removes the need to import copy, since deep_merge never mutates its inputs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Shreenidhi Shedi <shreenidhi.shedi@broadcom.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed Commit Message
refactor(parsers): replace configobj with stdlib implementations
Merge type