³ò
SÏíHc           @   sç   d  d k  Z  d  d k Z d  d k Z d  d k Z d  d k Z d  d k Z d  d k Z d  d k Z d  d k Z d  d k	 Z	 d  d k
 Td „  Z d d d „  ƒ  YZ d d d „  ƒ  YZ d d d	 „  ƒ  YZ d
 d d „  ƒ  YZ d d g Z d S(   iÿÿÿÿN(   t   *c         C   sI   h  d d <d d <d d <d d <d d	 <} | i  |  i ƒ  d
 ƒ S(   Ni   t   lowi   t   mediumi   t   highi   t	   emergencyt   criticali   (   t   gett   lower(   t   ut   urgency_map(    (    s)   /usr/share/apt-listchanges/DebianFiles.pyt   numeric_urgency(   s    			t   ControlStanzac           B   s#   e  Z d  „  Z d „  Z d „  Z RS(   c         C   sŸ   d  } x’ | i d ƒ D] } | p Pn | d d j o0 | o% t |  | t |  | ƒ d | ƒ q— q | i d d ƒ \ } } t |  | | i ƒ  ƒ q Wd  S(   Ns   
i    t    s   	t   :i   (   R   s   	(   t   Nonet   splitt   setattrt   getattrt   lstrip(   t   selft   strt   fieldt   linet   value(    (    s)   /usr/share/apt-listchanges/DebianFiles.pyt   __init__3   s     )c         C   s    t  |  d |  i ƒ i d ƒ d S(   Nt   SourceR   i    (   R   t   PackageR   (   R   (    (    s)   /usr/share/apt-listchanges/DebianFiles.pyt   source@   s    c         C   s*   t  |  d ƒ o |  i i d ƒ d d j S(   Nt   StatusR   i   t	   installed(   t   hasattrR   R   (   R   (    (    s)   /usr/share/apt-listchanges/DebianFiles.pyR   C   s    (   t   __name__t
   __module__R   R   R   (    (    (    s)   /usr/share/apt-listchanges/DebianFiles.pyR   2   s   		t   ControlParserc           B   s5   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C   s   g  |  _  h  |  _ d  S(   N(   t   stanzast   index(   R   (    (    s)   /usr/share/apt-listchanges/DebianFiles.pyR   G   s    	c         C   s?   h  |  i  | <x+ |  i D]  } | |  i  | t | | ƒ <q Wd  S(   N(   R#   R"   R   (   R   R   t   stanza(    (    s)   /usr/share/apt-listchanges/DebianFiles.pyt	   makeindexK   s    
 c         C   sW   |  i  g  } t | d ƒ i ƒ  i d ƒ D] } | o | t | ƒ q* q* ~ 7_  d  S(   Nt   rs   

(   R"   t   opent   readR   R   (   R   t   filet   _[1]t   x(    (    s)   /usr/share/apt-listchanges/DebianFiles.pyt   readfileP   s    c         C   s3   t  i d | ƒ } |  i i t | i ƒ  ƒ ƒ d  S(   Ns   dpkg-deb -f %s(   t   ost   popenR"   t   appendR   R(   (   R   t   debt   fh(    (    s)   /usr/share/apt-listchanges/DebianFiles.pyt   readdebS   s    c         C   s‹   |  i  i | ƒ o2 |  i  | i | ƒ o |  i  | | Sq‡ d  SnC x? |  i D]4 } t | | ƒ o t | | ƒ | j o | SqO qO Wd  S(   N(   R#   t   has_keyR   R"   R   R   (   R   R   R   R$   (    (    s)   /usr/share/apt-listchanges/DebianFiles.pyt   findW   s    
 &(   R   R    R   R%   R,   R2   R4   (    (    (    s)   /usr/share/apt-listchanges/DebianFiles.pyR!   F   s
   				R   c           B   sG   e  Z e i d  ƒ Z d „  Z d d „ Z d „  Z d „  Z	 d „  Z
 RS(   s8   ^\S+ \((?P<version>.*)\) .*;.*urgency=(?P<urgency>\w+).*c         C   sZ   | |  _  t ƒ  } | i |  i  ƒ | i d } | i |  _ | i ƒ  |  _ | i |  _ d  S(   Ni    (   t   pathR!   R2   R"   R   t   binaryR   t   Version(   R   R5   t   parsert   pkgdata(    (    s)   /usr/share/apt-listchanges/DebianFiles.pyR   f   s    		c   
         sü   ˆ i  d ƒ } ˆ i  d ƒ } ˆ i  d ƒ } g  } | d j p | d j o | i | ƒ n | d j p | d j o | i | ƒ | i | ƒ n ˆ i | ƒ ‰ ‡  ‡ ‡ f d †  } t | | d	 ƒ } t | | | d	 ƒ }	 t i ˆ d ƒ | |	 f S(
   sÅ   Extract changelog entries, news or both from the package.
        If since_version is specified, only return entries later than the specified version.
        returns a sequence of Changes objects.s   NEWS.Debians   changelog.Debiant	   changelogt   botht   newst
   changelogsc            s&   |  p ˆ i  t i i ˆ | ƒ ˆ  ƒ S(    (   t   read_changelogR-   R5   t   join(   t   acct   fname(   t   since_versionR   t   tempdir(    s)   /usr/share/apt-listchanges/DebianFiles.pyt   <lambda>ƒ   s    i   N(   t   _changelog_variationst   extendt   extract_contentst   reduceR   t   shutilt   rmtree(
   R   t   whichRB   t   news_filenamest   changelog_filenamest   changelog_filenames_nativet	   filenamest
   find_firstR<   R:   (    (   RB   R   RC   s)   /usr/share/apt-listchanges/DebianFiles.pyt   extract_changesq   s    c      	   C   se   t  i d d ƒ } d |  i | d i g  } | D] } | d | d q/ ~ ƒ f } t i | ƒ | S(   Nt   prefixs   apt-listchangessF   dpkg-deb --fsys-tarfile %s | tar xf - --wildcards -C %s %s 2>/dev/nullR   t   '(   t   tempfilet   mkdtempR5   R?   R-   t   system(   R   RO   RC   R*   R+   t   extract_command(    (    s)   /usr/share/apt-listchanges/DebianFiles.pyRG   Œ   s    	6c         C   s—  t  i  | ƒ } d  } x¢ | D]š } yb t i i | ƒ o t i t d ƒ | IJn0 | i d ƒ o t	 i
 | ƒ } n t | ƒ } PWq t j
 o# } | i t i j o q¶ ‚  q Xq W| p d  Sn t d ƒ } d } d } x‘ | i ƒ  D]ƒ }	 |  i i |	 ƒ }
 |
 oZ d } | oI t i |
 i d ƒ | ƒ d j o" t t |
 i d ƒ ƒ | ƒ } qcPqgn | |	 7} qî W| p d  Sn t |  i | | ƒ S(	   Ns(   Ignoring `%s' (seems to be a directory!)s   .gzR   t    i    i   t   versiont   urgency(   t   globR   R-   R5   t   isdirt   syst   stderrt   _t   endswitht   gzipt   GzipFileR'   t   IOErrort   errnot   ENOENTR
   t	   readlinest   changelog_headert   matcht   apt_pkgt   VersionComparet   groupt   maxt   ChangesR   (   R   t   filenameRB   RO   t   fdt   eRZ   t   changest   is_debian_changelogR   Rh   (    (    s)   /usr/share/apt-listchanges/DebianFiles.pyR>   š   sF      	c         C   sA   d d d d d d d d g } g  } | D] } | | | q) ~ S(	   Ns   usr/doc/*/%s.gzs   usr/share/doc/*/%s.gzs   usr/doc/*/%ss   usr/share/doc/*/%ss   ./usr/doc/*/%s.gzs   ./usr/share/doc/*/%s.gzs   ./usr/doc/*/%ss   ./usr/share/doc/*/%s(    (   R   Rn   t   formatsR*   R+   (    (    s)   /usr/share/apt-listchanges/DebianFiles.pyRE   Å   s    	N(   R   R    t   ret   compileRg   R   R   RQ   RG   R>   RE   (    (    (    s)   /usr/share/apt-listchanges/DebianFiles.pyR   c   s   			+Rm   c           B   s   e  Z d  „  Z RS(   c         C   s   | |  _  | |  _ | |  _ d  S(   N(   t   packageRq   RZ   (   R   Rv   Rq   RZ   (    (    s)   /usr/share/apt-listchanges/DebianFiles.pyR   Ñ   s    		(   R   R    R   (    (    (    s)   /usr/share/apt-listchanges/DebianFiles.pyRm   Ð   s   (    (    (    (    (   Rt   R]   R-   t   os.pathRT   Ra   Rd   R[   RI   Ri   t   ALChacksR
   R   R!   R   Rm   t   __all__(    (    (    s)   /usr/share/apt-listchanges/DebianFiles.pys   <module>   s   $
	
m