pere commited on
Commit
99b98ce
1 Parent(s): bcfea9d

Update update_template.py

Browse files
Files changed (1) hide show
  1. update_template.py +29 -0
update_template.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import requests
3
+
4
+ def download_template(url):
5
+ response = requests.get(url)
6
+ response.raise_for_status()
7
+ return response.text
8
+
9
+ def replace_in_file(template, replacements):
10
+ for placeholder, replacement in replacements.items():
11
+ template = template.replace(placeholder, replacement)
12
+ return template
13
+
14
+ def main():
15
+ with open('model_def.json', 'r') as file:
16
+ model_def = json.load(file)
17
+
18
+ template_url = model_def["template_url"]
19
+ template_content = download_template(template_url)
20
+
21
+ output_content = replace_in_file(template_content, model_def["replacements"])
22
+ output_filename = 'README.md'
23
+
24
+ with open(output_filename, 'w') as output_file:
25
+ output_file.write(output_content)
26
+ print(f'Processed {output_filename}')
27
+
28
+ if __name__ == "__main__":
29
+ main()