Spaces:
Running
Running
| import ruamel.yaml | |
| def read_yaml_file(yaml_path: str, to_dict=True): | |
| """read from yaml file""" | |
| yaml = ruamel.yaml.YAML() | |
| with open(yaml_path, "r") as file: | |
| # yaml_content = yaml.safe_load(file) | |
| yaml_content = yaml.load(file) | |
| yaml_content = dict(yaml_content) if to_dict else yaml_content | |
| return yaml_content | |
| class Singleton(type): | |
| _instances = {} | |
| def __call__(cls, *args, **kwargs): | |
| if cls not in cls._instances: | |
| cls._instances[cls] = super(Singleton, cls).__call__(*args, | |
| **kwargs) | |
| return cls._instances[cls] |