Skip to content
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

section keys not displayed when values overlap with global defaults #50

Open
makesse opened this issue Dec 12, 2017 · 3 comments
Open

Comments

@makesse
Copy link

makesse commented Dec 12, 2017

I am trying to manipulate my Ansible hosts.ini files, which looks like this:

host1.example.com
host2.example.com
host3.example.com
host4.example.com

[group1]
host1.example.com
host2.example.com

[group2]
host3.example.com
host4.example.com

When I want to get all hosts (global items), I run the following command:

$ crudini --get hosts.ini ''
host1.example.com
host2.example.com
host3.example.com
host4.example.com

However, when I want to display the hosts in section group1, I do not get any output at all:

$ crudini --get hosts.ini 'group1'
$

If I modify the ini file to look like this:

host1.example.com
host2.example.com
host3.example.com
host4.example.com

[group1]
host1.example.com=1
host2.example.com=1

[group2]
host3.example.com=1
host4.example.com=1

and run the same command again I get the following output:

$ crudini --get hosts.ini 'group1'
host1.example.com
host2.example.com

Is it possible to get identical behavior for the default and the other sections?

I am running crudini-0.9-1.el7.noarch

@pixelb
Copy link
Owner

pixelb commented Dec 16, 2017

Indeed that's a bug that should have been handled when implementing issue #38
Thanks for the clear reproducer. It should be easy enough to address

@pixelb
Copy link
Owner

pixelb commented Dec 16, 2017

What's going on here is that in ini files, keys in the global section are returned as keys in each section. Therefore we have logic to strip keys from each section that overlap with the global section.
To handle this case we'll have to tag the global values differently.
I.e. append '.default' to the value, and only exclude those from each section.

@pixelb pixelb changed the title section variables not displayed when items do not contain equation marks section keys not displayed when values overlap with global defaults Dec 16, 2017
@makesse
Copy link
Author

makesse commented Dec 27, 2017

@pixelb : thank you for the update. Is there anything I can do to help fixing this? I am not a python coder but willing to test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants