-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathutils.py
More file actions
24 lines (20 loc) · 858 Bytes
/
utils.py
File metadata and controls
24 lines (20 loc) · 858 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import os
import json
import yaml
def read_json(path:str):
with open(path, 'r') as file:
data = json.load(file)
return data
def get_available_templates(templates_folder:str):
# Initialize template options list
template_options = []
template_descriptions = {}
# Fetch YAML files in the templates folder and extract name and description
if os.path.exists(templates_folder):
for filename in os.listdir(templates_folder):
if filename.endswith(".yaml"):
with open(os.path.join(templates_folder, filename), 'r') as file:
template = yaml.safe_load(file)
template_options.append(filename)
template_descriptions[filename] = template.get('description', 'No description available')
return template_options, template_descriptions