-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcachingScripts.py
More file actions
58 lines (46 loc) · 1.48 KB
/
Copy pathcachingScripts.py
File metadata and controls
58 lines (46 loc) · 1.48 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import os
import sys
from fileSaveScripts import save_dataframe_to_csv
def directory_exists(path: str) -> bool:
"""
Check if a directory exists.
Args:
path (str): The directory path to check.
Returns:
bool: True if the directory exists, False otherwise.
"""
return os.path.isdir(path)
def file_exists(path: str) -> bool:
"""
Check if a file exists.
Args:
path (str): The file path to check.
Returns:
bool: True if the file exists, False otherwise.
"""
return os.path.isfile(path)
# Function to combine file path, file name, and extension into a full path
def combine_path(file_path, file_name, extension):
# Combine file path, file name, and extension
full_path = os.path.join(file_path, f"{file_name}{extension}")
return full_path
def cache_features(file_path, df):
overwrite_cache = True
if not overwrite_cache:
if file_exists(file_path):
print(f"The file {file_path} exists.")
return file_path
else:
return save_dataframe_to_csv(df, file_path)
else:
return save_dataframe_to_csv(df, file_path)
if __name__ == '__main__':
if len(sys.argv) != 2:
print("Usage: python cachingScripts.py <wav_file_path>")
sys.exit(1)
else:
path = sys.argv[1]
if directory_exists(path):
print(f"The directory {path} exists.")
else:
print(f"The directory {path} does not exist.")