简体   繁体   中英

Need advice for INI parsing and validation

My constraints

  • A mandatory section
  • An optional section
  • A single-level section
  • Only one identical option by section
  • Text values that can look like this:
    Electric= yes6batteries
    Electric= yes4battery
    Electric= yes8solar_panel
    Electric= yes
    Thermal= no
  • Conditional options, for example:
    Electric should not exist (or should be no) if Thermal= yes but must be if Thermal= no
  • Need to get the number or the content of the error/conflict lines

I looked ConfigObj but I soon abandoned because not validated for Python3.
I started working with ConfigParser but I'm not sure to reach what I want.
So I ask you what you would do in my place or if there is a library best suited to my need.

TOML isn't exactly the INI format, but it looks almost like it. There's a python library for TOML, and it works with Python 3.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM