import os import re #from ini_tools.enviroment import BASE_PATH, MP_PATH # environment was removed get this path in different way from ini_tools import get_messages_strings_names_txt def load_template(template_path, messages_strings_names_txt): with open(template_path) as f: text = f.read() expr = re.compile('\n\[(.*?)\]\n') def add_name(match): key = match.group(1) return '\n[%s]\nname=%s\n' % (key, messages_strings_names_txt[key]) with open(template_path, 'w') as f: f.write(expr.sub(add_name, text)) if __name__ == '__main__': for path in [BASE_PATH, MP_PATH]: template_path = os.path.join(path, 'stats', 'templates.ini') load_template(template_path, get_messages_strings_names_txt(path))
parser.add_argument(dest='mod_path', help="root folder of mod") parser.add_argument( '--save-path', help="folder to save result, if not specified save it to mod_path") parser.add_argument('--rewrite', help="If specified rewrite ini files", action="store_true") args = parser.parse_args() path = args.mod_path save_path = args.save_path if save_path is None: save_path = path rewrite = args.rewrite messages_strings_names_txt = get_messages_strings_names_txt(path) load_stats_assignweapons_txt(path) load_stats_functions_txt(path) load_stats_research_multiplayer_prresearch_txt(path) load_stats_research_multiplayer_redcomponents_txt(path) load_stats_research_multiplayer_redstructure_txt(path) load_stats_research_multiplayer_researchfunctions_txt(path) load_stats_research_multiplayer_resultcomponent_txt(path) load_stats_research_multiplayer_resultstructure_txt(path) load_stats_structurefunctions_txt(path) load_stats_structureweapons_txt(path) load_stats_weaponsounds_txt(path) ConvertBodypropulsionimd(path, save_path, rewrite) ConvertBody(path, save_path, rewrite) ConvertConstructions(path, save_path, rewrite)
# Here goes nothing. if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument(dest='mod_path', help="root folder of mod") parser.add_argument('--save-path', help="folder to save result, if not specified save it to mod_path") parser.add_argument('--rewrite', help="If specified rewrite ini files", action="store_true") args = parser.parse_args() path=args.mod_path save_path = args.save_path if save_path is None: save_path = path rewrite = args.rewrite messages_strings_names_txt = get_messages_strings_names_txt(path) load_stats_assignweapons_txt(path) load_stats_functions_txt(path) load_stats_research_multiplayer_prresearch_txt(path) load_stats_research_multiplayer_redcomponents_txt(path) load_stats_research_multiplayer_redstructure_txt(path) load_stats_research_multiplayer_researchfunctions_txt(path) load_stats_research_multiplayer_resultcomponent_txt(path) load_stats_research_multiplayer_resultstructure_txt(path) load_stats_structurefunctions_txt(path) load_stats_structureweapons_txt(path) load_stats_weaponsounds_txt(path) ConvertBodypropulsionimd(path, save_path, rewrite) ConvertBody(path, save_path, rewrite) ConvertConstructions(path, save_path, rewrite)
import os import re #from ini_tools.enviroment import BASE_PATH, MP_PATH # environment was removed get this path in different way from ini_tools import get_messages_strings_names_txt def load_template(template_path, messages_strings_names_txt): with open(template_path) as f: text = f.read() expr = re.compile('\n\[(.*?)\]\n') def add_name(match): key = match.group(1) return '\n[%s]\nname=%s\n' % (key, messages_strings_names_txt[key]) with open(template_path, 'w') as f: f.write(expr.sub(add_name, text)) if __name__ == '__main__': for path in [BASE_PATH, MP_PATH]: template_path = os.path.join(path, 'stats', 'templates.ini') load_template(template_path, get_messages_strings_names_txt(path))