MCPcopy
hub / github.com/FujiwaraChoki/MoneyPrinter / clean_dir

Function clean_dir

Backend/utils.py:25–50  ·  view source on GitHub ↗

Removes every file in a directory. Args: path (str): Path to directory. Returns: None

(path: str)

Source from the content-addressed store, hash-verified

23
24
25def clean_dir(path: str) -> None:
26 """
27 Removes every file in a directory.
28
29 Args:
30 path (str): Path to directory.
31
32 Returns:
33 None
34 """
35 try:
36 directory = Path(path).expanduser().resolve()
37 directory.mkdir(parents=True, exist_ok=True)
38 logger.info(f"Ensured directory exists: {directory}")
39
40 for entry in directory.iterdir():
41 if entry.is_dir():
42 shutil.rmtree(entry)
43 logger.info(f"Removed directory: {entry}")
44 else:
45 entry.unlink(missing_ok=True)
46 logger.info(f"Removed file: {entry}")
47
48 logger.info(colored(f"Cleaned {directory} directory", "green"))
49 except Exception as e:
50 logger.error(f"Error occurred while cleaning directory {path}: {str(e)}")
51
52
53def choose_random_song() -> Optional[str]:

Callers 2

upload_songsFunction · 0.90
process_next_jobFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected