Commit f1c736a2 authored by wanglei's avatar wanglei

...新脚本

parent 128338fb
...@@ -83,23 +83,23 @@ def update_global_config(file_path, json_data): ...@@ -83,23 +83,23 @@ def update_global_config(file_path, json_data):
# 遍历 JSON 数据中的每个变量名,并在 GlobalConfig.kt 中更新对应的值 # 遍历 JSON 数据中的每个变量名,并在 GlobalConfig.kt 中更新对应的值
for var_name, var_value in json_data.items(): for var_name, var_value in json_data.items():
# 替换 const val 的值 # 替换 const val 的值
pattern_const = rf'\bconst\s+val\s+{re.escape(var_name)}\s*=\s*".*?"' pattern_const = rf'\bconst\s+val\s+{re.escape(var_name)}\s*=\s*.*'
replacement_const = f'const val {var_name} = "{var_value}"' replacement_const = f'const val {var_name} = "{var_value}"'
content = re.sub(pattern_const, replacement_const, content) content = re.sub(pattern_const, replacement_const, content)
# 替换 inline val 的值 pattern_inline = rf'\binline\s+val\s+{re.escape(var_name)}\s+get\(\)\s*=\s*.*'
pattern_inline = rf'\binline\s+val\s+{re.escape(var_name)}\s+get\(\)\s*=\s*".*?"'
replacement_inline = f'inline val {var_name} get() = "{var_value}"' replacement_inline = f'inline val {var_name} get() = "{var_value}"'
content = re.sub(pattern_inline, replacement_inline, content) content = re.sub(pattern_inline, replacement_inline, content)
# 将修改后的内容写回到 GlobalConfig.kt 文件 # 将修改后的内容写回到 GlobalConfig.kt 文件
with open(file_path, 'w', encoding='utf-8') as file: with open(file_path, 'w', encoding='utf-8') as file:
file.write(content) file.write(content)
print(content)
print("\nGlobalConfig.kt 文件已成功更新。") print("\nGlobalConfig.kt 文件已成功更新。")
except Exception as e: except Exception as e:
print(f"更新文件时发生错误: {e}") print(f"更新文件时发生错误: {e}")
def update_google_services(json_data): def update_google_services(json_data):
"""更新 google-services.json 文件内容""" """更新 google-services.json 文件内容"""
try: try:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment