def contains_all_options(optiongroup, parentstyle, matchvalues=False):
# type: (Dict[Any, Any], Style, bool) -> bool
"""Returns true if all options in optiongroup are present in parentstyle.
If matchvalues is True, the values in optiongroup must also match
those in the parentstyle.
"""
for optionname, value in optiongroup.items():
if optionname not in parentstyle:
return False
if isinstance(value, dict):
parent_suboptions = parentstyle[optionname]
if not contains_all_options(value, parent_suboptions, matchvalues=matchvalues):
return False
elif matchvalues:
pvalue = parentstyle.get(optionname)
if type(pvalue) != type(value):
return False
if pvalue != value:
return False
return True
评论列表
文章目录