def test_copy(self, sample_configurations_data): for config in sample_configurations_data: filename = config["filename"] xcfg = XConfig(filename=filename, no_deep_parse=True) print("#" * 10) print(filename) print(xcfg) xcfg_copy = xcfg.copy() xcfg_copy.deep_parse() xcfg_correct = XConfig(filename=filename) assert not DeepDiff(xcfg_correct.to_dict(), xcfg_copy.to_dict()) assert xcfg_copy == xcfg_correct
def prompt(cls, xconfig: XConfig, close_app: bool = True) -> XConfig: """Prompts the placeholders of an xconfig and fill them with the user answers, it returns a copy of the original xconfig :param xconfig: the xconfig :type xconfig: XConfig :param close_app: if True the app will be closed if all the placeholder are not filled, defaults to True :type close_app: bool, optional :return: the filled xconfig :rtype: XConfig """ xconfig = xconfig.copy() unique_phs = cls.unique_placeholders_with_order( xconfig.available_placeholders() ) # user interaction questions = [cls.placeholder_to_question(x) for x in unique_phs] answers = cls._system_prompt(questions) # replaces placeholders with inquirer answers xconfig.replace_variables_map(answers) xconfig.check_available_placeholders(close_app=close_app) return xconfig