forked from FurnaceTool/ArmorExtract
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
23 lines (20 loc) · 709 Bytes
/
utils.py
File metadata and controls
23 lines (20 loc) · 709 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import os
import yaml, json
class Utils:
@staticmethod
def load_yaml(file_path: str, default = None) -> dict:
if not os.path.exists(file_path):
return default
with open(file_path, "r") as f:
return yaml.safe_load(f)
@staticmethod
def load_json(file_path: str, default = None) -> dict:
if not os.path.exists(file_path):
return default
with open(file_path, "r") as f:
return json.load(f)
@staticmethod
def save_json(file_path: str, data: dict) -> None:
os.makedirs(os.path.dirname(file_path), exist_ok=True)
with open(file_path, "w") as f:
json.dump(data, f, indent=4)