&=d 0ddlZddlmZddZddZdZdS) N) exceptionscb|dS tj|tjtjz}n#t$r t jwxYwg}|)ttt|}|D]2}| ||r| |3|S)am Use the pattern_str to find any match in a list of strings This is a helper function for :func:`egrep_hierarchy`. Note that this function is never called with the `subindex` parameter set. Parameters ---------- strlist : [str, ...] list of strings in which to look for the pattern pattern_str : str regular expression pattern subindex : [int, ...] list of indexes of strings in strlist, specifying the elements in which to look for the pattern Returns ------- [int, ...] a list of indexes for the matches in the origin list N) recompileIM Exceptionr InvalidRegexlistrangelensearchappend)strlist pattern_strsubindexpat resultlistis 5/usr/lib/python3/dist-packages/reportbug/hiermatch.py egrep_listr s0t&jbdRTk22 &&&%%&Jc'll++,, !! ::gaj ! ! !   a s ,3A c g}tt|D]d}|r/||r$t||||||}ng}nt||||}||e|S)a Grep the nth item of a hierarchy [(x, [a, b]),...] This is a helper function for :func:`matched_hierarchy`. Note that this function is never called with the `subhier` and `nth` parameters set. Parameters ---------- hier : [(str, [str, ...]), (str, [str, ...]), ...] list of tuples with severity and bug list pattern_str : str regular expression pattern subhier : [[int, ...], ...], optional subhierarchy indices nth : int, optional should always be 1 (one) Returns ------- [[int, ...], [int, ...], ...] a subhierarchy (for each severity in the input hierarchy, the list of indexes of the bugs matching the pattern_str) )r rrr)hierrsubhiernth resulthierrrs regrep_hierarchyr3s4J 3t99   & &  ?qz 'Q k71:NN  #DGCL+>>J*%%%% cg}t|}tt|D]B|r8fd|D}|d|fC|S)a Create a new hierarchy from a pattern matching Parameters ---------- hier : [(str, [str, ...]), (str, [str, ...]), ...] list of tuples with severity and bug list pattern_str : str regular expression pattern Returns ------- [(str, [str, ...]), (str, [str, ...]), ...] list of tuples with severity and bug list, only including bugs matching the pattern_str c8g|]}d|S)r).0yrrs r z%matched_hierarchy..qs%555aDGAJqM555rr)rr rr)rrmhierresultitemrs` @rmatched_hierarchyr)\s" E T; / /F 3v;;  -- !9 -555556!9555D LL$q'!*d+ , , , Lr)N)Nr)rrrrr)r"rrr+se  &&&&R&&&&Rr