DiffSK / configobj

Python 3+ compatible port of the configobj library
https://configobj.readthedocs.org
Other
321 stars 76 forks source link

WIP: Allow non-strings to be used for interpolation #169

Open WeatherGod opened 6 years ago

WeatherGod commented 6 years ago

Closes #129 Closes #156

coveralls commented 6 years ago

Coverage Status

Coverage increased (+0.04%) to 81.503% when pulling e4d0e46edc27d3dbab6c434290d3f65e2ebd8c07 on WeatherGod:interpolate_non_strings into 5b5de48a53cbceced3172bcd569ba7b2df7bfe6f on DiffSK:master.

WeatherGod commented 6 years ago

I labelled this a WIP because I think there are some lingering questions on behavior. Mainly, as I noted in the unit tests, I wasn't 100% sure what the result should be for listreference.

WeatherGod commented 6 years ago

Failures appear to be unrelated.

WeatherGod commented 6 years ago

I am now trying to apply this feature to my needs for my work project, and I am not quite happy with the behavior of lists, particularly string lists. Yes, there is the nice symmetry that the value you get in the interpolation would be the same as what would get output to a config file, so it is conceptually compact. But, what if you need the strings quoted? What if you don't want that trailing comma?

The Template and ConfigParser interpolators are somewhat limited in what they can do. Any chance that a {}-style interpolator would get accepted? If so, we could devise a format spec for list objects. I have actually done something like that in another work project that worked pretty well (I based the format spec off of some csh variable modifiers).