Author: Armin Rigo <[email protected]>
Branch:
Changeset: r47044:5841ae63ade9
Date: 2011-09-03 14:46 +0200
http://bitbucket.org/pypy/pypy/changeset/5841ae63ade9/
Log: Don't use shutil and don't remove all files within __pycache__.
Instead only remove .pyc/.pyo files from these __pycache__
directories, and only kill the directory if it is empty afterwards
(common case).
diff --git a/pypy/tool/py.cleanup b/pypy/tool/py.cleanup
--- a/pypy/tool/py.cleanup
+++ b/pypy/tool/py.cleanup
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-import sys, os, stat, shutil
+import sys, os, stat
def clean(path):
global count
@@ -12,11 +12,12 @@
filename = os.path.join(path, fn)
st = os.lstat(filename)
if stat.S_ISDIR(st.st_mode):
+ clean(filename)
if fn == '__pycache__':
- shutil.rmtree(filename)
- count += 1
- else:
- clean(filename)
+ try:
+ os.rmdir(filename)
+ except OSError:
+ pass
elif fn.endswith('.pyc') or fn.endswith('.pyo'):
os.unlink(filename)
count += 1
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit