packages: check-unused-files.py - use glob for blacklisting

glen glen at pld-linux.org
Tue May 25 16:03:59 CEST 2010


Author: glen                         Date: Tue May 25 14:03:59 2010 GMT
Module: packages                      Tag: HEAD
---- Log message:
- use glob for blacklisting

---- Files affected:
packages:
   check-unused-files.py (1.8 -> 1.9) 

---- Diffs:

================================================================
Index: packages/check-unused-files.py
diff -u packages/check-unused-files.py:1.8 packages/check-unused-files.py:1.9
--- packages/check-unused-files.py:1.8	Tue May 25 15:16:16 2010
+++ packages/check-unused-files.py	Tue May 25 16:03:53 2010
@@ -3,6 +3,7 @@
 import subprocess
 import sys
 import os
+import fnmatch
 
 if len(sys.argv) != 2:
     print >> sys.stderr, "Usage: %s <spec>" % sys.argv[0]
@@ -36,13 +37,22 @@
 
 obsolete = []
 
-for file in os.listdir(dir):
-    file = os.path.basename(file)
+def blacklisted(file):
     if file in [ '.', '..', 'CVS', '.cvsignore', 'dropin', 'md5', 'adapter', 'builder',
             'relup.sh', 'compile.sh', 'repackage.sh', 'rsync.sh', 'TODO', os.path.basename(spec) ]:
+        return True
+
+    for pat in ['log.*', '.#*', '*~', '*.orig', '*.sw?']:
+        if fnmatch.fnmatch(file, pat):
+            return True
+
+    return False
+
+for file in os.listdir(dir):
+    file = os.path.basename(file)
+    if blacklisted(file):
         continue
-    if file[:4] == 'log.' or file[:2] == '.#' or file[-1] == '~': # IndexError: or file[-5] == '.orig':
-        continue
+
     if file not in files:
         print "Obsolete file: %s" % file
         obsolete.append(file)
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/check-unused-files.py?r1=1.8&r2=1.9&f=u



More information about the pld-cvs-commit mailing list