#NEWLINE# def parse_report( bigstring ) : #NEWLINE# #INDENT# imps = [ ] #NEWLINE# for line in bigstring . splitlines ( ) : #NEWLINE# #INDENT# if line . startswith ( 'qdisc' ) : #NEWLINE# #INDENT# if ( 'netem' in line ) : #NEWLINE# #INDENT# if ( 'delay' in line ) : #NEWLINE# #INDENT# delay = PQ ( 0.0 , 'ms' ) #NEWLINE# jitter = PQ ( 0.0 , 'ms' ) #NEWLINE# correlation = 0.0 #NEWLINE# mo = re . search ( 'delay ([0-9.]+\\s*\\D+)\\s+([0-9.]+\\s*\\D+)\\s+([0-9.]+)%' , line ) #NEWLINE# if mo : #NEWLINE# #INDENT# delay = PQ ( mo . group ( 1 ) ) #NEWLINE# jitter = PQ ( mo . group ( 2 ) ) #NEWLINE# correlation = Percent ( mo . group ( 3 ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# mo = re . search ( 'delay ([0-9.]+\\s*\\D+)\\s+([0-9.]+\\s*\\D+)' , line ) #NEWLINE# if mo : #NEWLINE# #INDENT# delay = PQ ( mo . group ( 1 ) ) #NEWLINE# jitter = PQ ( mo . group ( 2 ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# mo = re . search ( 'delay ([0-9.]+\\s*\\D+)' , line ) #NEWLINE# if mo : #NEWLINE# #INDENT# delay = PQ ( mo . group ( 1 ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# imps . append ( Delay ( delay , jitter = jitter , correlation = correlation ) ) #NEWLINE# #UNINDENT# if ( 'distribution' in line ) : #NEWLINE# #INDENT# mo = re . search ( 'distribution (\\w+)' , line ) #NEWLINE# dist = mo . group ( 1 ) #NEWLINE# imps . append ( Distribution ( correlation ) ) #NEWLINE# #UNINDENT# if ( 'loss' in line ) : #NEWLINE# #INDENT# correlation = 0.0 #NEWLINE# mo = re . search ( 'loss\\s+([0-9.]+)%\\s+([0-9.]+)%' , line ) #NEWLINE# if mo : #NEWLINE# #INDENT# pstr = mo . group ( 1 ) #NEWLINE# correlation = mo . group ( 2 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# mo = re . search ( 'loss\\s+([0-9.]+)%' , line ) #NEWLINE# if mo : #NEWLINE# #INDENT# pstr = mo . group ( 1 ) #NEWLINE# #UNINDENT# #UNINDENT# imps . append ( Drop ( pstr , correlation = correlation ) ) #NEWLINE# #UNINDENT# if ( 'corrupt' in line ) : #NEWLINE# #INDENT# correlation = 0.0 #NEWLINE# mo = re . search ( 'corrupt\\s+([0-9.]+)%\\s+([0-9.]+)%' , line ) #NEWLINE# if mo : #NEWLINE# #INDENT# pstr = mo . group ( 1 ) #NEWLINE# correlation = mo . group ( 2 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# mo = re . search ( 'corrupt\\s+([0-9.]+)%' , line ) #NEWLINE# if mo : #NEWLINE# #INDENT# pstr = mo . group ( 1 ) #NEWLINE# #UNINDENT# #UNINDENT# imps . append ( Corrupt ( pstr , correlation = correlation ) ) #NEWLINE# #UNINDENT# if ( 'duplicate' in line ) : #NEWLINE# #INDENT# correlation = 0.0 #NEWLINE# mo = re . search ( 'duplicate\\s+([0-9.]+)%\\s+([0-9.]+)%' , line ) #NEWLINE# if mo : #NEWLINE# #INDENT# pstr = mo . group ( 1 ) #NEWLINE# correlation = mo . group ( 2 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# mo = re . search ( 'duplicate\\s+([0-9.]+)%' , line ) #NEWLINE# if mo : #NEWLINE# #INDENT# pstr = mo . group ( 1 ) #NEWLINE# #UNINDENT# #UNINDENT# imps . append ( Duplicate ( pstr , correlation = correlation ) ) #NEWLINE# #UNINDENT# if ( 'reorder' in line ) : #NEWLINE# #INDENT# correlation = 0.0 #NEWLINE# mo = re . search ( 'reorder\\s+([0-9.]+)%\\s+([0-9.]+)%' , line ) #NEWLINE# if mo : #NEWLINE# #INDENT# pstr = mo . group ( 1 ) #NEWLINE# correlation = mo . group ( 2 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# mo = re . search ( 'reorder\\s+([0-9.]+)%' , line ) #NEWLINE# if mo : #NEWLINE# #INDENT# pstr = mo . group ( 1 ) #NEWLINE# #UNINDENT# #UNINDENT# imps . append ( Reorder ( pstr , correlation = correlation ) ) #NEWLINE# #UNINDENT# if ( 'gap' in line ) : #NEWLINE# #INDENT# mo = re . search ( 'gap\\s+([0-9]+)' , line ) #NEWLINE# pstr = mo . group ( 1 ) #NEWLINE# imps . append ( Gap ( pstr ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# return Impairment ( * imps )