-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments not preserved on merge #171
Milestone
Comments
+1, we have this issue in pgcli: dbcli/pgcli#1240. |
This was referenced Feb 26, 2021
makes sense and thanks for the MR; adding to 5.1.0 milestone |
I should add that parentage is also not preserved on merge. This is what we do to get around these V5 limitations: from configobj import Section
def merge_config(self_config, indict):
"""Merge and patch a config file"""
# Do a ConfigObj merge:
self_config.merge(indict)
# Then fix comments and parentage:
patch_config(self_config, indict)
def patch_config(self_config, indict):
"""The ConfigObj merge does not transfer over parentage, nor comments. This function
fixes these limitations.
"""
for key in self_config:
if isinstance(self_config[key], Section) \
and key in indict and isinstance(indict[key], Section):
self_config[key].parent = self_config
self_config[key].main = self_config.main
self_config.comments[key] = indict.comments[key]
self_config.inline_comments[key] = indict.inline_comments[key]
patch_config(self_config[key], indict[key]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using ConfigObj v5.0.6, consider this:
The output is:
while I would have expected
The text was updated successfully, but these errors were encountered: