ssato / python-anyconfig

Python library provides common APIs to load and dump configuration files in various formats
MIT License
278 stars 31 forks source link

Properties file ignores keys with empty values #51

Closed ajays20078 closed 8 years ago

ajays20078 commented 8 years ago

Loading and dumping a properties file having a empty value is ignoring the key, and dumps without the keys having empty value.

Example:

File name : /tmp/1.properties

Content:

username = "my_db_user"
password = 
>>> import anyconfig
>>> a = anyconfig.load("/tmp/1.properties")
>>> a
{'username': '"my_db_user"'}
>>> 

This can cause issues, when reading the file dumped using anyconfig. There are many open source software, which uses this feature to load default values if key is empty(key is present but empty) and they error out if key is not present.

Also "" or '' are not treated as empty by properties file, they are treated as strings as per the documentation here (so currently there is no way to specify empty values using anyconfig), so can anyconfig support loading and dumping empty values as it could break code which expects a key(which can be empty).

ajays20078 commented 8 years ago

Any updates on this?

ssato commented 8 years ago

Sorry, I've been very busy this week and don't have enough time to look at this.

At first glance, I guess your point the problem is absolutely right. Thanks a lot for that. But I want to take some time to look into this issue as same as #50 this weekend. Please wait for a while.

ssato commented 8 years ago

I think I could fix this issue by 5555bbd (properties branch). Could you please take a look at it?

ssato commented 8 years ago

FYI. I merged the related (possible) fixes in properties branch to master branch.

ajays20078 commented 8 years ago

Thanks for the update and PR. Will checkout master and revert back.

ajays20078 commented 8 years ago

Works as expected. Thanks!