-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_configuration.py
executable file
·45 lines (37 loc) · 1.78 KB
/
generate_configuration.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import sys
import config_gen
# Define the hardcoded template files and their output names
TEMPLATES = {
'template.setup.py': 'setup.py',
'template.installer.wxs': 'installer.wxs',
'template.version.py': 'version.py',
}
def replace_template(template_file, output_file, version):
# Read the specified template file
try:
with open(template_file, 'r') as file:
template_content = file.read()
except FileNotFoundError:
print(f"Error: Template file '{template_file}' not found.")
sys.exit(1)
# Replace the placeholders with actual values
template_content = template_content.replace('{{version}}', version)
template_content = template_content.replace('{{name}}', config_gen.NAME)
template_content = template_content.replace('{{namelc}}', config_gen.NAMELC)
template_content = template_content.replace('{{author}}', config_gen.AUTHOR)
template_content = template_content.replace('{{author_email}}', config_gen.AUTHOR_EMAIL)
template_content = template_content.replace('{{description}}', config_gen.DESCRIPTION)
template_content = template_content.replace('{{url}}', config_gen.URL)
template_content = template_content.replace('{{upgradecode}}', config_gen.UPGRADECODE)
# Write the content to the corresponding output file
with open(output_file, 'w') as file:
file.write(template_content)
print(f"{output_file} generated with version {version}")
if __name__ == "__main__":
if len(sys.argv) != 2:
print("Usage: python generate_configuration.py <version>")
sys.exit(1)
version = sys.argv[1]
# Loop through the hardcoded templates and generate the corresponding files
for template_file, output_file in TEMPLATES.items():
replace_template(template_file, output_file, version)