def extract_template(path_string, value_dict): template = path_string for key, value in value_dict.items(): if str(value) in template: template = template.replace(str(value), f'<{key}>') return template