File size: 822 Bytes
88061c4 |
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 |
import json
import requests
def download_template(url):
response = requests.get(url)
response.raise_for_status()
return response.text
def replace_in_file(template, replacements):
for placeholder, replacement in replacements.items():
template = template.replace(placeholder, replacement)
return template
def main():
with open('model_def.json', 'r') as file:
model_def = json.load(file)
template_url = model_def["template_url"]
template_content = download_template(template_url)
output_content = replace_in_file(template_content, model_def["replacements"])
output_filename = 'README.md'
with open(output_filename, 'w') as output_file:
output_file.write(output_content)
print(f'Processed {output_filename}')
if __name__ == "__main__":
main()
|