예제 #1
0
 def __call__(self, *args, **kwargs) -> None:
     pybatch.PythonBatchCommandBase.__call__(self, *args, **kwargs)
     if self.config_files is not None:
         reader = ConfigVarYamlReader(config_vars)
         for config_file in self.config_files:
             reader.read_yaml_file(config_file)
     with utils.utf8_open_for_read(self.unresolved_file, "r") as rfd:
         text_to_resolve = rfd.read()
     resolved_text = config_vars.resolve_str(text_to_resolve)
     with utils.utf8_open_for_write(self.resolved_file, "w") as wfd:
         wfd.write(resolved_text)
예제 #2
0
    def test_readFile(self):
        input_file_path = Path(__file__).parent.joinpath("test_input.yaml")
        out_file_path = Path(__file__).parent.joinpath("test_out.yaml")
        expected_file_path = Path(__file__).parent.joinpath(
            "expected_output.yaml")

        reader = ConfigVarYamlReader()
        reader.read_yaml_file(input_file_path)
        variables_as_yaml = config_vars.repr_for_yaml()
        yaml_doc = aYaml.YamlDumpDocWrap(variables_as_yaml,
                                         '!define',
                                         "",
                                         explicit_start=True,
                                         sort_mappings=True)
        with open(out_file_path, "w") as wfd:
            aYaml.writeAsYaml(yaml_doc, wfd)

        out_lines = normalize_yaml_lines(out_file_path)
        expected_lines = normalize_yaml_lines(expected_file_path)

        self.assertEqual(out_lines, expected_lines)
예제 #3
0
    def init_specific_doc_readers(self):
        ConfigVarYamlReader.init_specific_doc_readers(self)
        self.specific_doc_readers.pop("__no_tag__", None)
        self.specific_doc_readers.pop("__unknown_tag__", None)

        self.specific_doc_readers["!define"] = self.read_defines
        self.specific_doc_readers["!define_const"] = self.read_const_defines

        acceptables = var_stack.ResolveVarToList("ACCEPTABLE_YAML_DOC_TAGS", default=[])
        if "__INSTL_COMPILED__" in var_stack:
            if var_stack.ResolveVarToStr("__INSTL_COMPILED__") == "True":
                acceptables.append("define_Compiled")
            else:
                acceptables.append("define_Uncompiled")
        for acceptibul in acceptables:
            if acceptibul.startswith("define_if_not_exist"):
                self.specific_doc_readers["!" + acceptibul] = self.read_defines_if_not_exist
            elif acceptibul.startswith("define"):
                self.specific_doc_readers["!" + acceptibul] = self.read_defines

        self.specific_doc_readers["!index"] = self.read_index
        self.specific_doc_readers["!require"] = self.read_require
예제 #4
0
    def __call__(self, *args, **kwargs) -> None:
        pybatch.PythonBatchCommandBase.__call__(self, *args, **kwargs)
        with config_vars.push_scope_context() as scope_context:
            if self.temp_config_vars:
                config_vars.update(self.temp_config_vars)
            if self.config_files is not None:
                reader = ConfigVarYamlReader(config_vars)
                for config_file in self.config_files:
                    reader.read_yaml_file(config_file)
            with utils.utf8_open_for_read(self.unresolved_file, "r") as rfd:
                text_to_resolve = rfd.read()
            resolved_text = config_vars.resolve_str(text_to_resolve)

            if self.raise_if_unresolved:
                unresolved_re = re.compile(r"""\$\(.*?\)""")
                all_unresolved = unresolved_re.findall(resolved_text)
                if all_unresolved:
                    unresolved_references = ", ".join(list(
                        set(all_unresolved)))
                    raise ValueError(
                        f"unresolved config_vars in {self.unresolved_file}: {unresolved_references}"
                    )
            with utils.utf8_open_for_write(self.resolved_file, "w") as wfd:
                wfd.write(resolved_text)
예제 #5
0
    def __init__(self, initial_vars=None):
        self.info_map_table = SVNTable()
        self.items_table = IndexItemsTable()
        ConfigVarYamlReader.__init__(self)

        search_paths_var = var_stack.get_configVar_obj("__SEARCH_PATHS__")
        self.path_searcher = utils.SearchPaths(search_paths_var)
        self.url_translator = connectionBase.translate_url
        self.init_default_vars(initial_vars)
        # noinspection PyUnresolvedReferences
        self.read_name_specific_defaults_file(super().__thisclass__.__name__)
        # initialize the search paths helper with the current directory and dir where instl is now
        self.path_searcher.add_search_path(os.getcwd())
        self.path_searcher.add_search_path(os.path.dirname(os.path.realpath(sys.argv[0])))
        self.path_searcher.add_search_path(var_stack.ResolveVarToStr("__INSTL_DATA_FOLDER__"))

        self.platform_helper = PlatformSpecificHelperFactory(var_stack.ResolveVarToStr("__CURRENT_OS__"), self)
        # init initial copy tool, tool might be later overridden after reading variable COPY_TOOL from yaml.
        self.platform_helper.init_copy_tool()

        self.install_definitions_index = dict()
        self.batch_accum = BatchAccumulator()
        self.do_not_write_vars = ("INFO_MAP_SIG", "INDEX_SIG", "PUBLIC_KEY", "AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "__CREDENTIALS__")
        self.out_file_realpath = None
예제 #6
0
 def __call__(self, *args, **kwargs) -> None:
     pybatch.PythonBatchCommandBase.__call__(self, *args, **kwargs)
     reader = ConfigVarYamlReader(config_vars)
     reader.read_yaml_file(self.file_to_read)
예제 #7
0
 def init_specific_doc_readers(self):
     ConfigVarYamlReader.init_specific_doc_readers(self)
     self.specific_doc_readers["!index"] = self.read_index
     self.specific_doc_readers["!require"] = self.read_require
예제 #8
0
 def __init__(self, config_vars, **kwargs) -> None:
     ConfigVarYamlReader.__init__(self, config_vars)