mirror of
https://github.com/BetterAndroid/compose-multiplatform-template.git
synced 2025-09-08 03:24:23 +08:00
Initial commit
This commit is contained in:
32
initializer.py
Normal file
32
initializer.py
Normal file
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import json
|
||||
import sys
|
||||
|
||||
def replace_strings_in_file(file_path, replacements):
|
||||
with open(file_path, 'r') as file:
|
||||
content = file.read()
|
||||
for key, value in replacements.items():
|
||||
content = content.replace(key, value)
|
||||
with open(file_path, 'w') as file:
|
||||
file.write(content)
|
||||
|
||||
def replace_strings_in_directory(directory, replacements, extensions):
|
||||
for root, dirs, files in os.walk(directory):
|
||||
for file in files:
|
||||
file_path = os.path.join(root, file)
|
||||
if file_path.endswith(extensions):
|
||||
replace_strings_in_file(file_path, replacements)
|
||||
|
||||
def main():
|
||||
with open('initializer.json', 'r') as json_file:
|
||||
replacements = json.load(json_file)
|
||||
extensions = ('.kt', '.properties', '.xml', '.gradle.kts', '.xcconfig')
|
||||
replace_strings_in_directory('.', replacements, extensions)
|
||||
print("Project initialization successful.")
|
||||
os.remove(sys.argv[0])
|
||||
os.remove('initializer.json')
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Reference in New Issue
Block a user