<s> '''<STR_LIT>''' <EOL> import re <EOL> import logging <EOL> from . import CallgrindAnnotateNoOutputFileError <EOL> logger = logging . getLogger ( __name__ ) <EOL> logger . setLevel ( logging . INFO ) <EOL> class AnnotationFile ( object ) : <EOL> '''<STR_LIT>''' <EOL> def __init__ ( self , f ) : <EOL> self . file = f <EOL> self . lines = None <EOL> self . _read ( ) <EOL> self . coverage = { } <EOL> self . process_lines ( ) <EOL> def _read ( self ) : <EOL> try : <EOL> fd = open ( self . file , '<STR_LIT:r>' ) <EOL> self . lines = [ l . strip ( ) for l in fd . readlines ( ) ] <EOL> except : <EOL> raise CallgrindAnnotateNoOutputFileError ( self . file ) <EOL> def print_lines ( self ) : <EOL> for l in self . lines : <EOL> print l <EOL> def print_coverage ( self ) : <EOL> for ( k , v ) in self . coverage . iteritems ( ) : <EOL> print k , v <EOL> def process_coverage_line ( self , line ) : <EOL> m = re . match ( '<STR_LIT>' , line ) <EOL> if m : <EOL> count = int ( m . group ( <NUM_LIT:1> ) . replace ( '<STR_LIT:U+002C>' , '<STR_LIT>' ) ) <EOL> filematch = m . group ( <NUM_LIT:2> ) <EOL> func = m . group ( <NUM_LIT:3> ) <EOL> lib = '<STR_LIT>' <EOL> if m . group ( <NUM_LIT:4> ) : <EOL> lib = m . group ( <NUM_LIT:4> ) <EOL> logger . debug ( "<STR_LIT>" , count , filematch , func , lib ) <EOL> key = '<STR_LIT::>' . join ( ( lib , filematch , func ) ) <EOL> self . coverage [ key ] = count <EOL> else : <EOL> logger . debug ( "<STR_LIT>" % line ) <EOL> def process_lines ( self ) : <EOL> for line in self . lines : <EOL> self . process_coverage_line ( line ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> from optparse import OptionParser <EOL> hdlr = logging . StreamHandler ( ) <EOL> logger . addHandler ( hdlr ) <EOL> parser = OptionParser ( ) <EOL> parser . add_option ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT:store_true>' , help = '<STR_LIT>' ) <EOL> parser . add_option ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> ( options , args ) = parser . parse_args ( ) <EOL> for arg in args : <EOL> a = AnnotationFile ( arg ) <EOL> print a . __dict__ </s>
