Spaces:
Sleeping
Sleeping
File size: 798 Bytes
bab1031 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | """Generic file handling functions."""
from glob import glob
from os.path import isfile, isdir
import yaml
from easydict import EasyDict
############################################################
# Lambda functions
############################################################
ls_all = lambda path: [path for path in glob(f"{path}/*")]
ls_dir = lambda path: [path for path in glob(f"{path}/*") if isdir(path)]
ls_file = lambda path: [path for path in glob(f"{path}/*") if isfile(path)]
############################################################
# File loading functions
############################################################
def load_yaml(path: str) -> EasyDict:
"""Load yaml file."""
with open(path, "r") as f:
config = yaml.safe_load(f)
return EasyDict(config)
|