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

Function 'get' bug? #74

Open
BercziSandor opened this issue Dec 3, 2020 · 2 comments
Open

Function 'get' bug? #74

BercziSandor opened this issue Dec 3, 2020 · 2 comments

Comments

@BercziSandor
Copy link

BercziSandor commented Dec 3, 2020

# 1: input file
# 2: Problem: 'get' for all doesn't gives all values: as.alma & av.alma are missing.
# 3-5: get works for the exact value.

~$ cat a.ini  # 1
alma = 12

[as]
alma = 12
korte = 15

[av]
alma = 12
~$ crudini --get --format=lines a.ini # 2
[ DEFAULT ] alma = 12
[ as ] korte = 15
[ av ]

~$ crudini --get a.ini "as" alma # 3
12
~$ crudini --get a.ini "av" alma # 4
12
~$ crudini --get a.ini "" alma # 5
12
@pixelb
Copy link
Owner

pixelb commented Dec 3, 2020

Indeed. This is due to the matching name (alma) in the default/global section.
The code has this comment:

# XXX: Note this strips an item from section
# if matching value also in default (global) section

I'll look into fixing it, thanks

@pixelb
Copy link
Owner

pixelb commented Dec 4, 2020

The reason for this is that global/DEFAULT entries auto propagate to all other sections.
Therefore entries in other sections that have the same value are redundant, and so not listed.

More problematically if we did remove this logic there is no way to distinguish default from explicit entries in iniparse,
so default entries would be listed for every section.

To address this we'd need iniparse to distinguish default from explicit entries.
This is discussed at https://stackoverflow.com/questions/2189288/how-to-exclude-defaults-from-python-configparser-items

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