11#!/usr/bin/env python
22
3+ import ConfigParser
34import fnmatch
45import getopt
56import os
@@ -690,6 +691,22 @@ def getopt_keep_dashes(argv, short, long):
690691 args += after_dashes
691692 return opts , args
692693
694+ def read_coveragerc (coveragerc , section , key ):
695+ if not os .path .exists (coveragerc ):
696+ return None
697+ config = ConfigParser .SafeConfigParser ()
698+ config .read (coveragerc )
699+ if not config .has_section (section ):
700+ return None
701+ return config .get (section , key , None )
702+
703+ def get_omit_patterns ():
704+ omit = read_coveragerc (".coveragerc" , "run" , "omit" )
705+ if omit :
706+ return omit .split ("," )
707+ else :
708+ return []
709+
693710def main (argv ):
694711 skips = compile_all_re (SKIP_PATTERNS )
695712
@@ -792,8 +809,15 @@ def main(argv):
792809 patches_by_filename [filename ] = []
793810 patches_by_filename [filename ].append (patch )
794811
812+ omit_patterns = get_omit_patterns ()
795813 # Now go through and calculate coverage
796814 for (filename , patches ) in patches_by_filename .items ():
815+ if any ([fnmatch .fnmatch (filename , omit_pattern )
816+ for omit_pattern in omit_patterns ]):
817+ # print skipped file in yellow
818+ print "SKIPPING FILE: %s" % filename
819+ continue
820+
797821 (name , ext ) = os .path .splitext (filename )
798822 for parser in parsers :
799823 if ext in parser .extensions :
@@ -811,6 +835,13 @@ def main(argv):
811835 print_patch_hunks (patch , to_print , coverage , output )
812836 printed_any = 1
813837
838+ if all ([line .new in coverage
839+ for line in ihunk .lines
840+ for ihunk in patch .hunks
841+ for patch in patches ]):
842+ # print fully covered file in blue
843+ print "FULLY COVERED FILE: %s" % filename
844+
814845 return printed_any
815846
816847
0 commit comments