changeset 26:72602b2d107a

Added a cleanup script which will remove .pyc files and the like.
author Janus Dam Nielsen <janus.nielsen@alexandra.dk>
date Mon, 25 May 2009 11:57:30 +0200
parents a83e83de91ff
children 3e710b694df4
files cleanup.py
diffstat 1 files changed, 24 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cleanup.py	Mon May 25 11:57:30 2009 +0200
@@ -0,0 +1,24 @@
+#!/usr/bin/python
+
+import sys
+import os
+import re
+
+"""Delete various temporary files in the project directories."""
+
+pattern = r'.*\.pyc|.*~|.*\.orig|.*\.rej'
+
+def traverse(basedir):
+    for dirname, dirshere, fileshere in os.walk(basedir):
+        for filename in fileshere:
+            if re.match(pattern, filename):
+                pathname = os.path.join(dirname, filename)
+                print "Deleting %s" % pathname
+                os.remove(pathname)
+
+if __name__ == '__main__':
+    if len(sys.argv) == 1:
+        basedir = '.'
+    else:
+        basedir = sys.argv[1]
+    traverse(basedir)