ó
é©Tc           @   s@   d  d l  Z  d  d l Z d d „ Z d d d „ Z d „  Z d S(   iÿÿÿÿNc         C   s¢   |  d k r d Sy  t j | t j t j Bƒ } Wn t j ‚ n Xg  } | d k rj t t |  ƒ ƒ } n  x1 | D]) } | j	 |  | ƒ rq | j
 | ƒ qq qq W| S(   s;   Use the pattern_str to find any match in a list of strings.N(   t   Nonet   ret   compilet   It   Mt
   exceptionst   InvalidRegext   ranget   lent   searcht   append(   t   strlistt   pattern_strt   subindext   patt
   resultlistt   i(    (    s7   /usr/lib/python2.7/dist-packages/reportbug/hiermatch.pyt
   egrep_list	   s     i   c         C   s…   g  } xx t  t |  ƒ ƒ D]d } | rY | | rP t |  | | | | | ƒ } qp g  } n t |  | | | ƒ } | j | ƒ q W| S(   s3   Grep the nth item of a hierarchy [(x, [a, b]),...].(   R   R   R   R
   (   t   hierR   t   subhiert   ntht
   resulthierR   R   (    (    s7   /usr/lib/python2.7/dist-packages/reportbug/hiermatch.pyt   egrep_hierarchy   s    
!	c         C   s‡   g  } t  |  | ƒ } xk t t | ƒ ƒ D]W } | | r( g  | | D] } |  | d | ^ qC } | j |  | d | f ƒ q( q( W| S(   s8   Actually create a new hierarchy from a pattern matching.i   i    (   R   R   R   R
   (   R   R   t   mhiert   resultR   t   yt   item(    (    s7   /usr/lib/python2.7/dist-packages/reportbug/hiermatch.pyt   matched_hierarchy.   s    
)"(   R   R   R    R   R   R   (    (    (    s7   /usr/lib/python2.7/dist-packages/reportbug/hiermatch.pyt   <module>   s   