def write_history(self): selected_tab = self.notebook.tab(self.notebook.select(), option='text') var_stack.set_var("SELECTED_TAB").append(selected_tab) the_list_yaml_ready= var_stack.repr_for_yaml(which_vars=var_stack.ResolveVarToList("__GUI_CONFIG_FILE_VARS__", default=[]), include_comments=False, resolve=False, ignore_unknown_vars=True) the_doc_yaml_ready = aYaml.YamlDumpDocWrap(the_list_yaml_ready, '!define', "Definitions", explicit_start=True, sort_mappings=True) with open(var_stack.ResolveVarToStr("INSTL_GUI_CONFIG_FILE_NAME"), "w", encoding='utf-8') as wfd: utils.make_open_file_read_write_for_all(wfd) aYaml.writeAsYaml(the_doc_yaml_ready, wfd)
def repr_for_yaml(self, what=None): """ Create representation of self suitable for printing as yaml. parameter 'what' is a list of identifiers to represent. If 'what' is None (the default) create representation of everything. InstlInstanceBase object is represented as two yaml documents: one for define (tagged !define), one for the index (tagged !index). """ retVal = list() if what is None: # None is all retVal.append(aYaml.YamlDumpDocWrap(var_stack, '!define', "Definitions", explicit_start=True, sort_mappings=True)) retVal.append(aYaml.YamlDumpDocWrap(self.install_definitions_index, '!index', "Installation index", explicit_start=True, sort_mappings=True)) else: defines = list() indexes = list() unknowns = list() for identifier in what: if identifier in var_stack: defines.append(var_stack.repr_for_yaml(identifier)) elif identifier in self.install_definitions_index: indexes.append({identifier: self.install_definitions_index[identifier].repr_for_yaml()}) else: unknowns.append(aYaml.YamlDumpWrap(value="UNKNOWN VARIABLE", comment=identifier + " is not in variable list")) if defines: retVal.append(aYaml.YamlDumpDocWrap(defines, '!define', "Definitions", explicit_start=True, sort_mappings=True)) if indexes: retVal.append( aYaml.YamlDumpDocWrap(indexes, '!index', "Installation index", explicit_start=True, sort_mappings=True)) if unknowns: retVal.append( aYaml.YamlDumpDocWrap(unknowns, '!unknowns', "Installation index", explicit_start=True, sort_mappings=True)) return retVal