read existing configuration, save enums properly

This commit is contained in:
Ashwin Bharambe 2024-08-02 13:55:29 -07:00
parent 2cf9915806
commit 3bc827cd5f
3 changed files with 63 additions and 26 deletions

View file

@ -5,7 +5,9 @@
# the root directory of this source tree.
import getpass
import json
import os
from enum import Enum
from pathlib import Path
from typing import Optional
@ -65,3 +67,10 @@ def parse_config(config_dir: str, config_path: Optional[str] = None) -> str:
print("------------------------")
return config
class EnumEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, Enum):
return obj.value
return super().default(obj)