stephen-bunn/file-config

INI serialization support

Closed this issue ยท 2 comments

Expected Behavior

I want to also add support for dumping to and loading from .ini files.
Should add a dumps_ini and loads_ini methods.

Current Behavior

There is no support ๐Ÿ˜ž

Possible Solution

Most likely I can just use configparser.
Particularly the read_dict method will be helpful.


โค๏ธ Thank you!

While looking through configparser and how this could be implemented I'm noticing how crappy the configparser library really is.

ConfigParser doesn't handle:

  • Nested dictionaries (treated as strings)
  • Lists (treated as strings)
  • Proper typing (everything is considered to be a string)

I'm unsure if this is part of the ini spec but it's pretty damn bad.
So any kind of serialization and loading methods using ConfigParser will need to have custom logic for writing the content in a restoreable manner.

Solution to dealing with this is just to create a custom ConfigParser class which deals with the serialization and de-serialization of the parser instance.