File size: 1,306 Bytes
3ed071b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""OS helper functions."""

import os
import shutil

from modules.console_colors import ULTRASINGER_HEAD


def create_folder(folder_name: str) -> None:
    """Creates a folder if it doesn't exist."""
    print(f"{ULTRASINGER_HEAD} Creating output folder. -> {folder_name}")
    is_exist = os.path.exists(folder_name)
    if not is_exist:
        os.makedirs(folder_name)


def move(original: str, target: str) -> None:
    """Moves a file from one location to another."""
    shutil.move(original, target)


def copy(original: str, target: str) -> None:
    """Copies a file from one location to another."""
    shutil.copy(original, target)


def rename(original: str, target: str) -> None:
    """Renames a file."""
    os.rename(original, target)


def current_executor_path() -> str:
    """Current executor path"""
    return os.getcwd()


def path_join(path1: str, path2: str) -> str:
    """Joins two paths together"""
    return os.path.join(path1, path2)


def check_file_exists(file_path: str) -> bool:
    """Checks if a file exists."""
    return os.path.isfile(file_path)


def check_if_folder_exists(song_output: str) -> bool:
    """Checks if a folder exists."""
    return os.path.isdir(song_output)


def remove_folder(cache_path):
    """Removes a folder."""
    shutil.rmtree(cache_path)