(feat) add os_functionalities

This commit is contained in:
cardosofede
2023-06-09 20:21:20 +01:00
parent 45f9965ff2
commit 7e8da2cc46

View File

@@ -1,4 +1,6 @@
import os
import subprocess
import yaml
@@ -7,6 +9,20 @@ def remove_files_from_directory(directory: str):
os.remove(f"{directory}/{file}")
def remove_directory(directory: str):
process = subprocess.Popen(f"rm -rf {directory}", shell=True)
process.wait()
def dump_dict_to_yaml(data_dict, filename):
with open(filename, 'w') as file:
yaml.dump(data_dict, file)
def read_yaml_file(file_path):
with open(file_path, 'r') as file:
data = yaml.safe_load(file)
return data
def directory_exists(directory: str):
return os.path.exists(directory)