Browse Source

use exclude_paths as regular expression

Alan Hamlett 10 years ago
parent
commit
651b8218a4
1 changed files with 7 additions and 2 deletions
  1. 7
    2
      gitstats

+ 7
- 2
gitstats View File

477
             except ValueError:
477
             except ValueError:
478
                 print 'Warning: failed to parse line "%s"' % line
478
                 print 'Warning: failed to parse line "%s"' % line
479
 
479
 
480
+
481
+        # compile exclude_paths regex
482
+        conf['exclude_paths'] = [re.compile(pattern, re.IGNORECASE) for pattern in conf['exclude_paths']]
483
+
480
         # extensions and size of files
484
         # extensions and size of files
481
         lines = getpipeoutput(['git ls-tree -r -l -z %s' % getcommitrange('HEAD', end_only = True)]).split('\000')
485
         lines = getpipeoutput(['git ls-tree -r -l -z %s' % getcommitrange('HEAD', end_only = True)]).split('\000')
482
         blobs_to_read = []
486
         blobs_to_read = []
492
             fullpath = parts[4]
496
             fullpath = parts[4]
493
 
497
 
494
             exclude = False
498
             exclude = False
495
-            for path in conf['exclude_paths']:
496
-                if path in fullpath:
499
+            for pattern in conf['exclude_paths']:
500
+                if pattern.search(fullpath):
497
                     exclude = True
501
                     exclude = True
498
                     break
502
                     break
499
             if exclude:
503
             if exclude:
504
+                print 'Excluding file: %s' % fullpath
500
                 continue
505
                 continue
501
 
506
 
502
             self.total_size += size
507
             self.total_size += size