Lines Matching +full:- +full:replace

3 # Copyright (c) 2017-2019 Tony Su
6 # SPDX-License-Identifier: MIT
8 # Adapted from https://github.com/peitaosu/XML-Preprocessor
85 def _pp_include(self, xml_str: str) -> str:
86 include_regex = r"(<\?include([\w\s\\/.:_-]+)\s*\?>)"
90 with open(inc_file_path, "r", encoding="utf-8") as inc_file:
92 xml_str = xml_str.replace(group_inc, inc_file_content)
95 def _pp_env_var(self, xml_str: str) -> str:
99 xml_str = xml_str.replace(group_env, os.environ[group_var])
102 def _pp_sys_var(self, xml_str: str) -> str:
106 xml_str = xml_str.replace(group_sys, self.sys_vars[group_var])
109 def _pp_cus_var(self, xml_str: str) -> str:
116 xml_str = xml_str.replace(group_def, "")
120 xml_str = xml_str.replace(
126 def _pp_foreach(self, xml_str: str) -> str:
134 xml_str = xml_str.replace(group_for, group_texts)
137 def _pp_error_warning(self, xml_str: str) -> str:
146 xml_str = xml_str.replace(group_wrn, "")
149 def _pp_if_eval(self, xml_str: str) -> str:
159 xml_str = xml_str.replace(ifelif, f"<?{tag} {result}?>")
162 def _pp_ifdef_ifndef(self, xml_str: str) -> str:
170 xml_str = xml_str.replace(group_ifndef, f"<?if {result}?>")
173 def _pp_if_elseif(self, xml_str: str) -> str:
201 xml_str = xml_str.replace(group_full, result)
209 xml_str = xml_str.replace(group_full, result)
215 xml_str = xml_str.replace(group_full, result)
218 def _pp_command(self, xml_str: str) -> str:
226 xml_str = xml_str.replace(group_cmd, output)
229 def _pp_blanks(self, xml_str: str) -> str:
236 def preprocess(self, xml_str: str) -> str:
264 def preprocess_xml(path: str) -> str:
265 with open(path, "r", encoding="utf-8") as original_file:
274 with open(path, "w", encoding="utf-8") if path else sys.stdout as output_file:
280 print("Usage: xml-preprocessor input.xml [output.xml]")