简体   繁体   English

需要有关INI解析和验证的建议

[英]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 电气= yes6电池
    Electric= yes4battery 电气= yes4电池
    Electric= yes8solar_panel 电= 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 如果Thermal =是,则电气不应该存在(或应该不存在),但是如果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. 我查看了ConfigObj,但很快就放弃了,因为未通过Python3验证。
I started working with ConfigParser but I'm not sure to reach what I want. 我开始使用ConfigParser,但不确定是否达到我想要的目标。
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. TOML并不完全是INI格式,但看起来却差不多。 There's a python library for TOML, and it works with Python 3. 有一个用于TOML的python库 ,它可用于Python 3。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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