[docs]defget_file_metadata(file_path:str)->Dict:"""Get some handy metadate from filesystem. Args: file_path: str: file path in str """return{"file_path":file_path,"file_name":os.path.basename(file_path),"file_type":mimetypes.guess_type(file_path)[0],"file_size":os.path.getsize(file_path),"creation_datetime":datetime.fromtimestamp(Path(file_path).stat().st_ctime).strftime("%Y-%m-%d"),"last_modified_datetime":datetime.fromtimestamp(Path(file_path).stat().st_mtime).strftime("%Y-%m-%d"),"last_accessed_datetime":datetime.fromtimestamp(Path(file_path).stat().st_atime).strftime("%Y-%m-%d"),}
[docs]defload_yaml(yaml_path:str):ifnotos.path.exists(yaml_path):raiseValueError(f"YAML file {yaml_path} does not exist.")withopen(yaml_path,"r",encoding="utf-8")asstream:try:yaml_dict=yaml.safe_load(stream)exceptyaml.YAMLErrorasexc:raiseValueError(f"YAML file {yaml_path} could not be loaded.")fromexcreturnyaml_dict["modules"]