1570ba320c style: 代码格式化和字符串处理优化
- 优化代码缩进和换行,提高可读性
- 统一使用单引号或双引号,保持一致性
- 移除冗余的空格和括号,精简代码
2025-02-15 21:30:24 +08:00

26 lines
568 B
Python

from contextlib import suppress
from pathlib import Path
def file_switch(path: Path) -> None:
if path.exists():
path.unlink()
else:
path.touch()
def remove_empty_directories(path: Path) -> None:
exclude = {
"\\.",
"\\_",
"\\__",
}
for dir_path, dir_names, file_names in path.walk(
top_down=False,
):
if any(i in str(dir_path) for i in exclude):
continue
if not dir_names and not file_names:
with suppress(OSError):
dir_path.rmdir()