lutris/utils/cleanup_prefix.py
Alexander Ravenheart f5e8e007b3 - Replaced pipenv with poetry
- Updated min version check in setup.py to Python 3.6
- Updated isort config file and calls to align with v5.x
- Added init-hook for gi imports in .pylintrc to avoid invalid no-member issues
- Makefile: added lock, show-tree, bandit, black, mypy; updated test, cover, dev, isort, autopep8, check, isort-check, flake8, pylint; removed req, requirements;
- Updated .travis.yml to use poetry and make
- Added my email in AUTHORS
- Updated CONTRIBUTING.md
- Updated lint_python.yml to use poetry and make, reorganized instructions to have all install related steps first
- sorted imports: lutris, lutris-wrapper, cleanup_prefix.py and multiple files in tests dir
2021-11-17 21:17:43 -08:00

42 lines
1.1 KiB
Python

import os
import shutil
import sys
KNOWN_DIRS = [
"ProgramData/Microsoft/Windows",
"Program Files/Common Files/Microsoft Shared",
"Program Files/Common Files/System",
"Program Files/Internet Explorer",
"Program Files/Windows Media Player",
"Program Files/Windows NT",
"windows",
]
def delete_known_dirs(prefix_path):
for known_dir in KNOWN_DIRS:
full_path = os.path.join(prefix_path, "drive_c", known_dir)
if not os.path.exists(full_path):
continue
print("Deleting %s", full_path)
shutil.rmtree(full_path)
def remove_empty_dirs(dirname):
empty_folders = []
for root, dirs, files in os.walk(dirname, topdown=True):
print(root, files, dirs)
if not files and not dirs:
empty_folders.append(root)
for folder in empty_folders:
os.rmdir(folder)
return empty_folders
if __name__ == "__main__":
dirname = sys.argv[1]
delete_known_dirs(dirname)
empty_folders = True
while empty_folders:
empty_folders = remove_empty_dirs(dirname)