From 7e8da2cc467f048888a2b4f84628edcfcd5fe5f5 Mon Sep 17 00:00:00 2001 From: cardosofede Date: Fri, 9 Jun 2023 20:21:20 +0100 Subject: [PATCH] (feat) add os_functionalities --- utils/os_utils.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/utils/os_utils.py b/utils/os_utils.py index 4456ef2..caaad2b 100644 --- a/utils/os_utils.py +++ b/utils/os_utils.py @@ -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)