classBestEffort:"""Guess option value conversion based on the string format"""def__init__(self,key_sep=_KEY_SEP,section_splitter=_SECTION_SPLITTER,):self.key_sep=key_sepself.section_splitter=section_splitterself.split_dict=partial(split_kv_pairs,key_sep=key_sep)defprocess_values(self,doc:M)->M:doc_items=list(doc.items())forname,sectionindoc_items:doc[name]=self.apply_best_effort_to_section(section)# Separate nested sectionsifself.section_splitter.search(name):keys=tuple(self.section_splitter.split(name))doc.rename(name,keys)returndocdefapply_best_effort_to_section(self,section:M)->M:options=list(section.items())# Convert option values:forfield,valueinoptions:self.apply_best_effort(section,field,value)returnsectiondefapply_best_effort(self,container:M,field:str,value:str):ifisinstance(field,HiddenKey):returnifnotisinstance(value,str):returnlines=value.splitlines()iflen(lines)>1:ifself.key_sepinvalue:container[field]=self.split_dict(value)else:container[field]=split_list(value)eliffield.endswith("version"):container[field]=split_comment(value)else:container[field]=split_scalar(value)