xoa.cfgm.filter_section

xoa.cfgm.filter_section(sec, cfgfilter, default=False)[source]

Recursively filter a section according to a dict of specifications

When encountering an option of sec, it removed if its value in cfgfilter is set to False. When not found, it default to the __default__ key of cfgfilter. And if the __default__ is not found, it defaults to False (filtered out). When an option is a section and its value in cfgfilter is a dictionary, this subsection is filtered in the same way with the value as restrictions (cfgfilter[subsection]).

Parameters:
  • sec – A configobj.Section instance.

  • cfgfilter – A dictionary tree with the same structure as sec.