From a3a4f1ff19d9d24067ba852671282627318acb93 Mon Sep 17 00:00:00 2001 From: Karim shoair Date: Sat, 30 Nov 2024 18:01:35 +0200 Subject: [PATCH] A cleanup script to use with development --- cleanup.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 cleanup.py diff --git a/cleanup.py b/cleanup.py new file mode 100644 index 0000000..8a1ed3a --- /dev/null +++ b/cleanup.py @@ -0,0 +1,42 @@ +import shutil +from pathlib import Path + + +# Clean up after installing for local development +def clean(): + # Get the current directory + base_dir = Path.cwd() + + # Directories and patterns to clean + cleanup_patterns = [ + 'build', + 'dist', + '*.egg-info', + '__pycache__', + '.eggs', + '.pytest_cache' + ] + + # Clean directories + for pattern in cleanup_patterns: + for path in base_dir.glob(pattern): + try: + if path.is_dir(): + shutil.rmtree(path) + else: + path.unlink() + print(f"Removed: {path}") + except Exception as e: + print(f"Could not remove {path}: {e}") + + # Remove compiled Python files + for path in base_dir.rglob('*.py[co]'): + try: + path.unlink() + print(f"Removed compiled file: {path}") + except Exception as e: + print(f"Could not remove {path}: {e}") + + +if __name__ == '__main__': + clean()