³ò
Á†rHc        	   @   sr  d  d k  Z  d  d k Z d  d k Z d  d k l Z d  d k Z d Z d Z e  i e e ƒ Z d Z	 h  d d <d d	 <d
 d <Z
 h  d d <d d <d d <d d <d d <d d <d d <Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d „  Z d „  Z d  „  Z d! „  Z d" „  Z d# „  Z d$ „  Z d% „  Z d& „  Z d' e f d( „  ƒ  YZ e d) j o n d S(*   iÿÿÿÿN(   t
   HTMLParsers'   http://bugs.debian.org/cgi-bin/soap.cgis   Debbugs/SOAP/V1s   http://bugs.debian.org/iZ   u   outstandingi2   u   resolvedi
   u   archivedi   u   criticali   u   gravei   u   seriousi   u	   importanti   u   normali   u   minori   u   wishlistt	   Bugreportc           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s9   Represents a bugreport from Debian's Bug Tracking System.c         C   s[   t  | ƒ |  _ d  |  _ d  |  _ d  |  _ d  |  _ d  |  _ d  |  _ d  |  _	 d  |  _
 d  S(   N(   t   unicodet   nrt   Nonet   summaryt	   submittert   statust   severityt   fulltextt   packaget   firstactiont
   lastaction(   t   selfR   (    (    s9   /home/venthur/debian/debianbts/debianbts/src/debianbts.pyt   __init__4   s    							c         C   s™   d |  i  } | d |  i 7} | d |  i 7} | d |  i 7} | d |  i 7} | d |  i 7} | d |  i 7} | d |  i 7} | d	 |  i 7} | S(
   Ns   Bug: %s
s   Package: %s
s   Summary: %s
s   Submitter: %s
s   Status: %s
s   Severity: %s
s   Firstaction: %s
s   Lastaction: %s
s   Fulltext: %s
(	   R   R
   R   R   R   R   R   R   R	   (   R   t   s(    (    s9   /home/venthur/debian/debianbts/debianbts/src/debianbts.pyt   __str__?   s    c         C   s2   t  i |  i i ƒ  d ƒ t i |  i i ƒ  d ƒ S(   s›   Returns an 'urgency value', the higher the number, the more urgent
        the bug is. Open bugs generally have higher urgencies than closed ones.
        iÈ   i   (   t   STATUS_VALUEt   getR   t   lowert   SEVERITY_VALUER   (   R   (    (    s9   /home/venthur/debian/debianbts/debianbts/src/debianbts.pyt   valueK   s    (   t   __name__t
   __module__t   __doc__R   R   R   (    (    (    s9   /home/venthur/debian/debianbts/debianbts/src/debianbts.pyR   1   s   		t   Buglogc           B   s    e  Z d  Z d „  Z d „  Z RS(   s+   Represents a single message of a bugreport.c         C   s"   t  | ƒ |  _ t  | ƒ |  _ d  S(   N(   R   t   headert   body(   R   R   R   (    (    s9   /home/venthur/debian/debianbts/debianbts/src/debianbts.pyR   U   s    c         C   s"   d |  i  } | d |  i 7} | S(   Ns   Header: 
%s
s
   Body: 
%s
(   R   R   (   R   R   (    (    s9   /home/venthur/debian/debianbts/debianbts/src/debianbts.pyR   Y   s    (   R   R   R   R   R   (    (    (    s9   /home/venthur/debian/debianbts/debianbts/src/debianbts.pyR   R   s   	c          G   s„   t  i |  Œ  } g  } | p na t | d ƒ t g  ƒ j o, x@ | d D] } | i t | ƒ ƒ qH Wn | i t | d ƒ ƒ | S(   s   Returns a list of Bugreports.i    (   t   servert
   get_statust   typet   appendt   _parse_status(   R   t   replyt   bugst   elem(    (    s9   /home/venthur/debian/debianbts/debianbts/src/debianbts.pyR   _   s     c         G   s   d  S(   N(    (   t   emailt   tag(    (    s9   /home/venthur/debian/debianbts/debianbts/src/debianbts.pyt   get_usertago   s    c         C   s~   t  t i |  ƒ ƒ } g  } x! | D] } | i t | ƒ ƒ q" Wg  } x2 | D]* } t | d | d ƒ } | i | ƒ qL W| S(   s   Returns a list of Buglogs.R   R   (   t
   _make_listR   t   get_bug_logR   t
   _make_dictR   (   R   R!   t   lt   it   blt   log(    (    s9   /home/venthur/debian/debianbts/debianbts/src/debianbts.pyR(   s   s      c         C   s   t  t i |  ƒ ƒ S(   s0   Returns a list of bugnumbers of the newest bugs.(   R'   R   t   newest_bugs(   t   amount(    (    s9   /home/venthur/debian/debianbts/debianbts/src/debianbts.pyR.   €   s    c          G   s   t  t i |  Œ  ƒ S(   s  
    Returns a list of bugnumbers, that match the conditions given bey the
    key-value pair(s).
    
    Possible keys are: package, submitter, maint, src, severity, status, tag, 
    owner, bugs.
    
    Example: get_bugs('package', 'gtk-qt-engine','severity', 'normal')
    (   R'   R   t   get_bugs(   t	   key_value(    (    s9   /home/venthur/debian/debianbts/debianbts/src/debianbts.pyR0   …   s    
c         C   sÅ   t  |  d ƒ } |  d } t | d d ƒ | _ t | d d ƒ | _ t i d t i | d ƒ ƒ | _ t i d t i | d ƒ ƒ | _ t | d	 d ƒ | _	 | d
 o d | _
 n
 d | _
 | S(   s'   Return a bugreport from a given status.t   keyR   t   subjects   utf-8R
   s   %Y-%m-%dt   datet   log_modifiedR   t   doneu   Resolvedu   Outstanding(   R   R   R   R
   t   timet   strftimet   gmtimeR   R   R   R   (   R   t   bugt   tmp(    (    s9   /home/venthur/debian/debianbts/debianbts/src/debianbts.pyR    ’   s    
""	c         C   s(   g  } x |  D] } | i  | ƒ q W| S(   s3   Converts a convert a SOAPpy array to a python list.(   R   (   t   listlikeR*   R+   (    (    s9   /home/venthur/debian/debianbts/debianbts/src/debianbts.pyR'   ¢   s
     c         C   s2   t  ƒ  } x" |  i ƒ  D] } |  | | | <q W| S(   s,   Converts a SOAPpy record into a python dict.(   t   dictt   _keys(   t   dictliket   dR+   (    (    s9   /home/venthur/debian/debianbts/debianbts/src/debianbts.pyR)   ©   s
    	 c         C   sX   t  i t t ƒ t |  ƒ ƒ } t ƒ  } | i t | i ƒ  d d ƒ ƒ | i ƒ  | i	 S(   s   Returns the full bugreports   utf-8t   replace(
   t   urllibt   urlopent   strt   BTS_URLt   HTMLStrippert   feedR   t   readt   closet   result(   t   bugnrt   reportt   parser(    (    s9   /home/venthur/debian/debianbts/debianbts/src/debianbts.pyt   get_html_fulltext°   s
    	
RF   c           B   sJ   e  Z d  Z d Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 RS(   s3   Strips all unwanted tags from given HTML/XML Stringt   imgc         C   s   t  i |  ƒ d |  _ d  S(   Nt    (   R    R   RJ   (   R   (    (    s9   /home/venthur/debian/debianbts/debianbts/src/debianbts.pyR   ¾   s    c         C   s   |  i  | 7_  d  S(   N(   RJ   (   R   t   data(    (    s9   /home/venthur/debian/debianbts/debianbts/src/debianbts.pyt   handle_dataÂ   s    c         C   s   |  i  d | d 7_  d  S(   Nt   &t   ;(   RJ   (   R   t   name(    (    s9   /home/venthur/debian/debianbts/debianbts/src/debianbts.pyt   handle_entityrefÅ   s    c         C   s   |  i  d | d 7_  d  S(   Ns   &#RT   (   RJ   (   R   RU   (    (    s9   /home/venthur/debian/debianbts/debianbts/src/debianbts.pyt   handle_charrefÈ   s    c         C   s}   | |  i  j oV |  i d | 7_ x- | D]% \ } } |  i d | | f 7_ q* W|  i d 7_ n |  i d | 7_ d  S(   Nt   <s    %s="%s"t   >s)   <p>[ %s-tag removed by reportbug-ng ]</p>(   t   invalid_tagsRJ   (   R   R%   t   attrst   kt   v(    (    s9   /home/venthur/debian/debianbts/debianbts/src/debianbts.pyt   handle_starttagË   s     c         C   s.   | |  i  j o d |  i | f |  _ n d  S(   Ns   %s</%s>(   RZ   RJ   (   R   R%   (    (    s9   /home/venthur/debian/debianbts/debianbts/src/debianbts.pyt   handle_endtagÔ   s    (
   R   R   R   RZ   R   RR   RV   RW   R^   R_   (    (    (    s9   /home/venthur/debian/debianbts/debianbts/src/debianbts.pyRF   ¹   s   						t   __main__(   t   SOAPpyt   osR7   R    RB   t   URLt   NSt	   SOAPProxyR   RE   R   R   t   objectR   R   R   R&   R(   R.   R0   R    R'   R)   RN   RF   R   (    (    (    s9   /home/venthur/debian/debianbts/debianbts/src/debianbts.pys   <module>   s@   						!										