
$Nc           @   s?  d  d l  m Z y d  d l Z e j e Z Wn e e f k
 rL e Z n Xd  d l	 Z	 d  d l
 Z
 d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d e e j f d     YZ d e f d     YZ d e e j f d     YZ d	 e f d
     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ  d e f d     YZ! d e e f d      YZ" d! e e f d"     YZ# d# e$ f d$     YZ% e% Z& d S(%   i(   t   function_deprecated_byNt   TagSectionWrapperc           B   s)   e  Z d  Z d   Z d   Z d   Z RS(   s   Wrap a TagSection object, using its find_raw method to get field values

    This allows us to pick which whitespace to strip off the beginning and end
    of the data, so we don't lose leading newlines.
    c         C   s   | |  _  d  S(   N(   t   _TagSectionWrapper__section(   t   selft   section(    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyt   __init__4   s    c         C   s   |  j  j   S(   N(   R   t   keys(   R   (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyR   7   s    c         C   sZ   |  j  j |  } | d  k r- t |   n  | | j d  d } | j d  j d  S(   Nt   :i   s    	s   
(   R   t   find_rawt   Nonet   KeyErrort   findt   lstript   rstrip(   R   t   keyt   st   data(    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyt   __getitem__:   s
    (   t   __name__t
   __module__t   __doc__R   R   R   (    (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyR   -   s   		t
   OrderedSetc           B   sM   e  Z d  Z g  d  Z d   Z d   Z d   Z d   Z e Z d   Z	 RS(   s   A set-like object that preserves order when iterating over it

    We use this to keep track of keys in Deb822Dict, because it's much faster
    to look up if a key is in a set than in a list.
    c         C   s7   t    |  _ g  |  _ x | D] } |  j |  q Wd  S(   N(   t   sett   _OrderedSet__sett   _OrderedSet__ordert   add(   R   t   iterablet   item(    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyR   O   s    	c         C   s3   | |  k r/ |  j  j |  |  j j |  n  d  S(   N(   R   R   R   t   append(   R   R   (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyR   U   s    c         C   s$   |  j  j |  |  j j |  d  S(   N(   R   t   removeR   (   R   R   (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyR   \   s    c         C   s   t  |  j  S(   N(   t   iterR   (   R   (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyt   __iter__b   s    c         C   s   | |  j  k S(   N(   R   (   R   R   (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyt   __contains__f   s    c         C   s"   x | D] } |  j  |  q Wd  S(   N(   R   (   R   R   R   (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyt   extendn   s    (
   R   R   R   R   R   R   R   R    R   R!   (    (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyR   H   s   				t
   Deb822Dictc           B   sk   e  Z d  Z d d d d d  Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z d
   Z RS(   s3  A dictionary-like object suitable for storing RFC822-like data.

    Deb822Dict behaves like a normal dict, except:
        - key lookup is case-insensitive
        - key order is preserved
        - if initialized with a _parsed parameter, it will pull values from
          that dictionary-like object as needed (rather than making a copy).
          The _parsed dict is expected to be able to handle case-insensitive
          keys.

    If _parsed is not None, an optional _fields parameter specifies which keys
    in the _parsed dictionary are exposed.
    s   utf-8c         C   sf  i  |  _  t   |  _ d  |  _ | |  _ | d  k	 r t | d  rQ | j   } n t |  } y% x | D] \ } } | |  | <qg WWq t	 k
 r t
 |  j  } t
 | |  }	 t	 d | |	 f   q Xn  | d  k	 rb| |  _ | d  k r$|  j j g  |  j j   D] } t |  ^ q qb|  j j g  | D]$ }
 |  j j |
  r4t |
  ^ q4 n  d  S(   Nt   itemssC   dictionary update sequence element #%d has length %d; 2 is required(   t   _Deb822Dict__dictR   t   _Deb822Dict__keysR	   t   _Deb822Dict__parsedt   encodingt   hasattrR#   t   listt
   ValueErrort   lenR!   R   t   _strIt   has_key(   R   t   _dictt   _parsedt   _fieldsR'   R#   t   kt   vt   thist   len_t   f(    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyR      s*    				5c         C   s-   t  |  } |  j j |  | |  j | <d  S(   N(   R,   R%   R   R$   (   R   R   t   value(    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyt   __setitem__   s    c         C   s  t  |  } y |  j | } WnB t k
 ra |  j d  k	 r[ | |  j k r[ |  j | } qb   n Xt | t  ry | j |  j	  } Wqt
 k
 r } t j d |  j	 t  t j |  } y | j | d  } Wn t
 k
 r |  qX| d |  _	 qXn  | S(   Ns?   decoding from %s failed; attempting to detect the true encodingR'   (   R,   R$   R
   R&   R	   R%   t
   isinstancet   strt   decodeR'   t   UnicodeDecodeErrort   warningst   warnt   UnicodeWarningt   chardett   detect(   R   R   R6   t   et   result(    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyR      s*    	
c         C   sB   t  |  } |  j j |  y |  j | =Wn t k
 r= n Xd  S(   N(   R,   R%   R   R$   R
   (   R   R   (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyt   __delitem__   s    c         C   s   t  |  } | |  j k S(   N(   R,   R%   (   R   R   (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyR-      s    c         C   s    g  |  j  D] } t |  ^ q
 S(   N(   R%   R9   (   R   R   (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyR      s    c         C   s:   d d j  g  |  j   D] \ } } d | | f ^ q  S(   Ns   {%s}s   , s   %r: %r(   t   joinR#   (   R   R1   R2   (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyt   __repr__   s    c         C   si   |  j    } | j   | j    } | j   | | k s< t Sx& | D] } |  | | | k rC t SqC Wt S(   N(   R   t   sortt   Falset   True(   R   t   othert   mykeyst	   otherkeysR   (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyt   __eq__   s     
 
c         C   s   |  j  |   } | S(   N(   t	   __class__(   R   t   copy(    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyRN      s    N(   R   R   R   R	   R   R7   R   RC   R-   R   RE   RL   RN   (    (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyR"   s   s   			!	
				t   Deb822c           B   s   e  Z d d d d  d  Z d e e d  d  Z e e  Z d d  Z d   Z	 d   Z
 d   Z d d d  Z d   Z e e  Z d	   Z e e  Z d
   Z e e  Z d d  Z e e  Z d   Z e e  Z d   Z e e  Z d   Z RS(   s   utf-8c      
   C   s   t  | d  r | } d } n d } t j |  d | d | d | d | | d k	 r y |  j | |  Wq t k
 r| q Xn  d |  _ d S(   s  Create a new Deb822 instance.

        :param sequence: a string, or any any object that returns a line of
            input each time, normally a file().  Alternately, sequence can
            be a dict that contains the initial key-value pairs.

        :param fields: if given, it is interpreted as a list of fields that
            should be parsed (the rest will be discarded).

        :param _parsed: internal parameter.

        :param encoding: When parsing strings, interpret them in this encoding.
            (All values are given back as unicode objects, so an encoding is
            necessary in order to properly interpret the strings.)
        R#   R.   R/   R0   R'   N(   R(   R	   R"   R   t   _internal_parsert   EOFErrort   gpg_info(   R   t   sequencet   fieldsR/   R'   R.   (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyR      s    	c   
   
   c   s   t  r^ | r^ t | t  r^ t j |  } x | D]& } |  d | d t |  d |  Vq1 WnT t |  } |  | | d | }	 x0 t |	  d k r |	 V|  | | d | }	 q Wd S(   s  Generator that yields a Deb822 object for each paragraph in sequence.

        :param sequence: same as in __init__.

        :param fields: likewise.

        :param use_apt_pkg: if sequence is a file(), apt_pkg will be used 
            if available to parse the file, since it's much much faster.  Set
            this parameter to False to disable using apt_pkg.
        :param shared_storage: not used, here for historical reasons.  Deb822
            objects never use shared storage anymore.
        :param encoding: Interpret the paragraphs in this encoding.
            (All values are given back as unicode objects, so an encoding is
            necessary in order to properly interpret the strings.)
        RT   R/   R'   i    N(   t   _have_apt_pkgR8   t   filet   apt_pkgt   TagFileR   R   R+   (
   t   clsRS   RT   t   use_apt_pkgt   shared_storageR'   t   parserR   R   t   x(    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyt   iter_paragraphs  s    c            s  t  j d  } t  j d  } t  j d  }   f d   } t | t  rZ | j   } n  d  } d } x|  j |  D] }	 | j |	  }
 |
 r | r | |  | <n  | |
 j d   s d  } qv n  |
 j d  } |
 j d  } qv n  | j |	  }
 |
 rM| r| |  | <n  | |
 j d   s2d  } qv n  |
 j d  } d } qv n  | j |	  }
 |
 rv | d |	 7} qv qv qv W| r| |  | <n  d  S(	   Ns'   ^(?P<key>\S+)\s*:\s*(?P<data>\S.*?)\s*$s   ^(?P<key>\S+)\s*:\s*$s   ^\s(?P<data>.+?)\s*$c            s     d  k p |    k S(   N(   R	   (   R5   (   RT   (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyt   <lambda>D  s    t    R   R   s   
(	   t   ret   compileR8   t
   basestringt
   splitlinesR	   t   gpg_stripped_paragrapht   matcht   group(   R   RS   RT   t   singlet   multit	   multidatat   wanted_fieldt   curkeyt   contentt   linet   m(    (   RT   s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyRP   ?  sF    
c         C   s
   |  j    S(   N(   t   dump(   R   (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyt   __str__n  s    c         C   s
   |  j    S(   N(   Rp   (   R   (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyt   __unicode__q  s    c         C   s   t  |  |  S(   s   Return the self[key] as a string (or unicode)

        The default implementation just returns unicode(self[key]); however,
        this can be overridden in subclasses (e.g. _multivalued) that can take
        special values.
        (   t   unicode(   R   R   (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyt   get_as_stringv  s    c         C   s   | d k r! t j   } t } n t } | d k r? |  j } n  x |  j   D]{ } |  j |  } | sx | d d k r d | | f } n d | | f } | s | j | j |   qL | j |  qL W| r | j	   Sd S(   s  Dump the the contents in the original format

        If fd is None, return a unicode object.

        If fd is not None, attempt to encode the output to the encoding the
        object was initialized with, or the value of the encoding argument if
        it is not None.  This will raise UnicodeEncodeError if the encoding
        can't support all the characters in the Deb822Dict values.
        i    s   
s   %s:%s
s   %s: %s
N(
   R	   t   StringIORH   RG   R'   t   iterkeysRt   t   writet   encodet   getvalue(   R   t   fdR'   t   return_stringR   R6   t   entry(    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyRp     s     	c         C   s   | j  d  r t St Sd  S(   Ns   
(   t   countRG   RH   (   R   R   (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyt   is_single_line  s    c         C   s   |  j  |  S(   N(   R~   (   R   R   (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyt   is_multi_line  s    c         C   s.  | s
 | S| s | S|  j  |  r |  j  |  r d } | | j d  rT d } n  | | | j |  } | j   | d } } x8 | d D], } | | k r q n  | | | } | } q W| S|  j |  r$|  j |  r$x= | j t  D], } | | j t  k r | d | } q q W| St  d  S(   Nt    s   , i    i   s   
(   R~   R}   t   splitRF   R   Rd   RH   R*   (   R   t   s1t   s2t   delimt   Lt   prevt   mergedR   (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyt   _merge_fields  s.    	

c         C   s   | d  k r |  } | } n | } | } | | k r\ | | k r\ |  j | | | |  } n8 | | k ru | | } n | | k r | | } n t  | d  k r | |  | <d  S| S(   N(   R	   t   _mergeFieldsR
   (   R   R   t   d1t   d2t   x1t   x2R   (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyt   merge_fields  s     	
c   
      C   s  g  } g  } g  } d } t  j d  } t  j d  } t } xc|  D][} | j d  } | r| | j |  rs qC q| t } n  | j |  }	 |	 s| d k r | j |  s | j |  q| sPqq| d k r | j |  r d } q| j |  q| d k r| j |  qqC |	 j d  d k rC|	 j d	  } n& |	 j d  d
 k ri| j |  Pn  | j |  sC | s| j |  q| j |  qC qC Wt |  r| | | f St	 d   d S(   s   Return a (gpg_pre, payload, gpg_post) tuple

        Each element of the returned tuple is a list of lines (with trailing
        whitespace stripped).
        t   SAFEs5   ^-----(?P<action>BEGIN|END) PGP (?P<what>[^-]+)-----$s   ^$s   
s   SIGNED MESSAGEt	   SIGNATUREt   actiont   BEGINt   whatt   ENDs   only blank lines found in inputN(
   Ra   Rb   RH   t   stripRf   RG   R   Rg   R+   RQ   (
   RS   t   gpg_pre_linest   linest   gpg_post_linest   statet   gpgret
   blank_linet
   first_lineRn   Ro   (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyt   split_gpg_and_payload  sL    		c         C   s   |  j  |  d S(   Ni   (   R   (   RY   RS   (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyRe   9  s    c         C   sI   t  |  d  s t d  n  |  j d k rB t j |  j  |  _ n  |  j S(   s   Return a GpgInfo object with GPG signature information

        This method will raise ValueError if the signature is not available
        (e.g. the original text cannot be found)t   raw_texts   original text cannot be foundN(   R(   R*   RR   R	   t   GpgInfot   from_sequenceR   (   R   (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyt   get_gpg_info>  s
    	N(   R   R   R	   R   RH   RG   R^   t   classmethodRP   Rq   Rr   Rt   Rp   R~   R    t   isSingleLineR   t   isMultiLineR   R   R   t   mergeFieldsR   t   staticmethodRe   R   (    (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyRO      s.   	!/				(			$	<	R   c           B   sb   e  Z d  Z d Z d   Z d   Z e d d   Z e d	 g d
 g d   Z	 e d    Z
 RS(   s%  A wrapper around gnupg parsable output obtained via --status-fd

    This class is really a dictionary containing parsed output from gnupg plus
    some methods to make sense of the data.
    Keys are keywords and values are arguments suitably splitted.
    See /usr/share/doc/gnupg/DETAILS.gzt   GOODSIGt   EXPSIGt	   EXPKEYSIGt	   REVKEYSIGt   BADSIGc         C   s   |  j  d  p |  j  d  S(   s   Is the signature valid?R   t   VALIDSIG(   R-   (   R   (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyt   valid]  s    c         C   s   d S(   s>   Return the primary ID of the signee key, None is not availableN(    (   R   (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyt   uidc  s    c         C   s  t    } t |  t  r* |  j d  }  n  t | t  rK | j d  } n  |  | _ | | _ d } x |  D] } | j |  s qj n  | t |  } | j d  } | j	 d  } | |  } | t  j
 k r | | d j d d  } n | | d j d  } | | | <qj W| S(   s   Create a new GpgInfo object from gpg(v) --status-fd output (out) and
        optionally collect stderr as well (err).
        
        Both out and err can be lines in newline-terminated sequence or regular strings.s   
s	   [GNUPG:] R   i   (   R   R8   Rc   R   t   outt   errt
   startswithR+   R   R   t   uidkeys(   R   R   t   nt   headert   lR   R   R6   (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyt   from_outputg  s(    			
s&   /usr/share/keyrings/debian-keyring.gpgs   /usr/bin/gpgvc   
      C   s  | } | j  d d g  d d l } g  | D]B } | j j |  r, | j | | j  r, | j  d | g  ^ q, d | k r t d  n  d d l } | j | d | j	 d | j	 d	 | j	 } t
 |  t  r | j |   \ } }	 n | j d
 j |    \ } }	 t j | |	  S(   s   Create a new GpgInfo object from the given sequence.

        Sequence is a sequence of lines or a string
        executable is a list of args for subprocess.Popen, the first element being the gpg executables   --status-fdt   1iNs	   --keyrings'   cannot access any of the given keyringst   stdint   stdoutt   stderrs   
(   R!   t   ost   patht   isfilet   accesst   R_OKt   IOErrort
   subprocesst   Popent   PIPER8   Rc   t   communicateRD   R   R   (
   RS   t   keyringst
   executablet   argsR   R1   R   t   pR   R   (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyR     s    	M*c         G   s   t  t |   |  S(   sY   Create a new GpgInfo object from the given file, calls from_sequence(file(target), *args)(   R   RV   (   t   targetR   (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyt	   from_file  s    (   s   GOODSIGR   R   R   R   N(   R   R   R   R   R   R   R   R	   R   R   R   (    (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyR   R  s   		%t   PkgRelationc           B   sh   e  Z d  Z e j d  Z e j d  Z e j d  Z e j d  Z e	 d    Z
 e d    Z RS(   s   Inter-package relationships

    Structured representation of the relationships of a package to another,
    i.e. of what can appear in a Deb882 field like Depends, Recommends,
    Suggests, ... (see Debian Policy 7.1).
    s   ^\s*(?P<name>[a-zA-Z0-9.+\-]{2,})(\s*\(\s*(?P<relop>[>=<]+)\s*(?P<version>[0-9a-zA-Z:\-+~.]+)\s*\))?(\s*\[(?P<archs>[\s!\w\-]+)\])?\s*$s   \s*,\s*s   \s*\|\s*s   \s*c            sd    f d        f d     j  j | j    } t  j j |  } t  f d   |  S(   s|   Parse a package relationship string (i.e. the value of a field like
        Depends, Recommends, Build-Depends ...)
        c            sv   g  } xi   j  j |  j    D]O } t |  r[ | d d k r[ | j t | d f  q | j t | f  q W| S(   Ni    t   !i   (   t   _PkgRelation__blank_sep_RER   R   R+   R   RG   RH   (   t   rawt   archst   arch(   RY   (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyt   parse_archs  s    c            s    j  j |   } | r | j   } i | d d 6} | d d  k pR | d d  k sp | d | d f | d <n
 d  | d <| d d  k r d  | d <n   | d  | d <| St j d |  IJi |  d 6d  d 6d  d 6Sd  S(   Nt   namet   relopt   versionR   R   sL   deb822.py: WARNING: cannot parse package relationship "%s", returning it raw(   t   _PkgRelation__dep_RERf   t	   groupdictR	   t   sysR   (   R   Rf   t   partst   d(   R   RY   (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyt	   parse_rel  s     
c            s   t    |   S(   N(   t   map(   t   or_deps(   R   (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyR_     s    (   t   _PkgRelation__comma_sep_RER   R   R   t   _PkgRelation__pipe_sep_RE(   RY   R   t   tl_depst   cnf(    (   R   R   RY   s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyt   parse_relations  s
    
c            s@   d     f d       f d   } t  j t | |   d  S(   s   Format to string structured inter-package relationships
        
        Perform the inverse operation of parse_relations, returning a string
        suitable to be written in a package stanza.
        c         S   s"   |  \ } } | r | Sd | Sd  S(   NR   (    (   t	   arch_spect   exclR   (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyt   pp_arch  s    c      	      s   |  d } |  j  d  r> |  d d  k	 r> | d |  d 7} n  |  j  d  r |  d d  k	 r | d t j t   |  d   7} n  | S(   NR   R   s    (%s %s)R   s    [%s](   R-   R	   t   stringRD   R   (   t   depR   (   R   (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyt   pp_atomic_dep  s    
'c            s   t  j t   |   d  S(   Ns    | (   R   RD   R   (   t   deps(   R   (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyR_     s    s   , (   R   RD   R   (   t   relst	   pp_or_dep(    (   R   R   s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyR9     s    	(   R   R   R   Ra   Rb   R   R   R   R   R   R   R   R9   (    (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyR     s   	't   _lowercase_dictc           B   s   e  Z d  Z d   Z RS(   s4   Dictionary wrapper which lowercase keys upon lookup.c         C   s   t  j |  | j    S(   N(   t   dictR   t   lower(   R   R   (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyR     s    (   R   R   R   R   (    (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyR     s   t   _PkgRelationMixinc           B   s&   e  Z d  Z d   Z e d    Z RS(   sr  Package relationship mixin

    Inheriting from this mixin you can extend a Deb882 object with attributes
    letting you access inter-package relationship in a structured way, rather
    than as strings. For example, while you can usually use pkg['depends'] to
    obtain the Depends string of package pkg, mixing in with this class you
    gain pkg.depends to access Depends as a Pkgrel instance

    To use, subclass _PkgRelationMixin from a class with a _relationship_fields
    attribute. It should be a list of field names for which structured access
    is desired; for each of them a method wild be added to the inherited class.
    The method name will be the lowercase version of field name; '-' will be
    mangled as '_'. The method would return relationships in the same format of
    the PkgRelation' relations property.

    See Packages and Sources as examples.
    c         O   sh   t  i   |  _ t |  _ xI |  j D]> } | j   } |  j |  rS d  |  j | <q" g  |  j | <q" Wd  S(   N(   R   t   _PkgRelationMixin__relationsRG   t#   _PkgRelationMixin__parsed_relationst   _relationship_fieldsR   R-   R	   (   R   R   t   kwargsR   t   keyname(    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyR     s    	c            sh     j  sa t   f d     j j    } x( | D]  } t j   |    j | <q1 Wt   _  n    j S(   s?  Return a dictionary of inter-package relationships among the current
        and other packages.

        Dictionary keys depend on the package kind. Binary packages have keys
        like 'depends', 'recommends', ... while source packages have keys like
        'build-depends', 'build-depends-indep' and so on. See the Debian policy
        for the comprehensive field list.

        Dictionary values are package relationships returned as lists of lists
        of dictionaries (see below for some examples).

        The encoding of package relationships is as follows:
        - the top-level lists corresponds to the comma-separated list of
          Deb822, their components form a conjuction, i.e. they have to be
          AND-ed together
        - the inner lists corresponds to the pipe-separated list of Deb822,
          their components form a disjunction, i.e. they have to be OR-ed
          together
        - member of the inner lists are dictionaries with the following keys:
          - name:       package (or virtual package) name
          - version:    A pair <operator, version> if the relationship is
                        versioned, None otherwise. operator is one of "<<",
                        "<=", "=", ">=", ">>"; version is the given version as
                        a string.
          - arch:       A list of pairs <polarity, architecture> if the
                        relationship is architecture specific, None otherwise.
                        Polarity is a boolean (false if the architecture is
                        negated with "!", true otherwise), architecture the
                        Debian archtiecture name as a string.

        Examples:

          "emacs | emacsen, make, debianutils (>= 1.7)"     becomes
          [ [ {'name': 'emacs'}, {'name': 'emacsen'} ],
            [ {'name': 'make'} ],
            [ {'name': 'debianutils', 'version': ('>=', '1.7')} ] ]

          "tcl8.4-dev, procps [!hurd-i386]"                 becomes
          [ [ {'name': 'tcl8.4-dev'} ],
            [ {'name': 'procps', 'arch': (false, 'hurd-i386')} ] ]
        c            s     j  |  d  k S(   N(   R   R	   (   R   (   R   (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyR_   \  s    (   R   t   filterR   R   R   R   RH   (   R   t	   lazy_relsR   (    (   R   s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyt	   relations0  s    +	(   R   R   R   R   t   propertyR   (    (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyR   
  s   	t   _multivaluedc           B   s    e  Z d  Z d   Z d   Z RS(   s7  A class with (R/W) support for multivalued fields.

    To use, create a subclass with a _multivalued_fields attribute.  It should
    be a dictionary with *lower-case* keys, with lists of human-readable
    identifiers of the fields as the values.  Please see Dsc, Changes, and
    PdiffIndex as examples.
    c         O   s   t  j |  | |  x |  j j   D] \ } } y |  | } Wn t k
 rS q# n X|  j |  r} g  |  | <|  | j } n t   |  | <|  | j } x< t	 d  | j    D]% } | t t | | j      q Wq# Wd  S(   N(   RO   R   t   _multivalued_fieldsR#   R
   R   R   R"   t   updateR   R	   Rd   t   zipR   (   R   R   R   t   fieldRT   t   contentst   updater_methodRn   (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyR   l  s    
c         C   sP  | j    } | |  j k r<t j   } t |  | d  rJ |  | g } n | j d  |  | } |  j | } y |  j } Wn t k
 r i  } n Xx | D] } xs | D]k } t | |  }	 y | | | }
 Wn t k
 r |	 } n X|
 t	 |	  d |	 } | j d |  q W| j d  q W| j
   j d  St j |  |  Sd  S(   NR   s   
R   s    %s(   R   R   Ru   R(   Rw   t   _fixed_field_lengthst   AttributeErrorR9   R
   R+   Ry   R   RO   Rt   (   R   R   t   keylRz   t   arrayt   ordert   field_lengthsR   R]   t	   raw_valuet   lengthR6   (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyRt     s0    


(   R   R   R   R   Rt   (    (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyR   c  s   	t   _gpg_multivaluedc           B   s   e  Z d  Z d   Z RS(   s  A _multivalued class that can support gpg signed objects

    This class's feature is that it stores the raw text before parsing so that
    gpg can verify the signature.  Use it just like you would use the
    _multivalued class.

    This class only stores raw text if it is given a raw string, or if it
    detects a gpg signature when given a file or sequence of lines (see
    Deb822.split_gpg_and_payload for details).
    c         O   s  y | d } Wn# t  k
 r3 | j d d   } n X| d  k	 rlt | t  r[ | |  _ qlt | d  rm qly |  j |  \ } } } Wn t k
 r g  } } } n X| r1| r1t	 j	   } | j
 d j |   | j
 d  | j
 d j |   | j
 d  | j
 d j |   | j   |  _ n  y t |  } | | d <Wqlt  k
 rh| | d <qlXn  t j |  | |  d  S(   Ni    RS   R#   s   
s   

(   t
   IndexErrort   getR	   R8   Rc   R   R(   R   RQ   Ru   Rw   RD   Ry   R)   R   R   (   R   R   R   RS   R   R   R   R   (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyR     s6    (   R   R   R   R   (    (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyR    s   
t   Dscc           B   s>   e  Z i d  d d g d 6d d d g d 6d d d g d 6Z RS(   t   md5sumt   sizeR   t   filest   sha1s   checksums-sha1t   sha256s   checksums-sha256(   R   R   R   (    (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyR
    s   t   Changesc           B   sM   e  Z i d  d d d d g d 6d d d g d 6d d d g d	 6Z d
   Z RS(   R  R  R   t   priorityR   R  R  s   checksums-sha1R  s   checksums-sha256c         C   s   |  d d d } y | j  d  \ } } Wn t k
 rD d } n X|  d j d  ri |  d d  } n |  d d } d	 | | |  d f S(
   s>   Return the path in the pool where the files would be installedR  i    R   t   /t   maint   sourcet   libi   s   pool/%s/%s/%s(   R   R*   R   (   R   R   R   t
   subsectiont   subdir(    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyt   get_pool_path  s    
(   R   R   R   R  (    (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyR    s
   t
   PdiffIndexc           B   sS   e  Z i d  d g d 6d  d d g d 6d  d d g d 6Z e d    Z d   Z RS(   t   SHA1R  s   sha1-currentt   dates   sha1-historys   sha1-patchesc         C   sW   i  } xJ |  j  D]? } t |  | d  r/ q n  |  j |  } i | d 6| | <q W| S(   NR   R  (   R   R(   t   _get_size_field_length(   R   t   fixed_field_lengthsR   R  (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyR     s    c         C   s7   g  |  | D] } t  t | d   ^ q } t |  S(   NR  (   R+   R9   t   max(   R   R   R   t   lengths(    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyR    s    -(   R   R   R   R   R   R  (    (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyR    s   t   Releasec           B   s}   e  Z d  Z i d d d g d 6d d d g d 6d d d g d 6Z d Z d   Z e d   e  Z e d	    Z d
   Z	 RS(   s   Represents a Release file

    Set the size_field_behavior attribute to "dak" to make the size field
    length only as long as the longest actual value.  The default,
    "apt-ftparchive" makes the field 16 characters long regardless.
    R  R  R   R  R  s   apt-ftparchivec         C   s(   | d k r t  d   n	 | |  _ d  S(   Ns   apt-ftparchivet   daks<   size_field_behavior must be either 'apt-ftparchive' or 'dak'(   s   apt-ftparchiveR!  (   R*   t   _Release__size_field_behavior(   R   R6   (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyt   set_size_field_behavior!  s    c         C   s   |  j  S(   N(   R"  (   R   (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyR_   '  s    c         C   s>   i  } x1 |  j  D]& } |  j |  } i | d 6| | <q W| S(   NR  (   R   R  (   R   R  R   R  (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyR   *  s
    c         C   s]   |  j  d k r d S|  j  d k rY g  |  | D] } t t | d   ^ q- } t |  Sd  S(   Ns   apt-ftparchivei   R!  R  (   t   size_field_behaviorR+   R9   R  (   R   R   R   R  (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyR  2  s
    -(
   R   R   R   R   R"  R#  R   R$  R   R  (    (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyR     s   			t   Sourcesc           B   s,   e  Z d  Z d d d d d g Z d   Z RS(   s$   Represent an APT source package lists   build-dependss   build-depends-indeps   build-conflictss   build-conflicts-indept   binaryc         O   s*   t  j |  | |  t j |  | |  d  S(   N(   R
  R   R   (   R   R   R   (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyR   @  s    (   R   R   R   R   R   (    (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyR%  :  s   t   Packagesc        	   B   s8   e  Z d  Z d d d d d d d d d	 g	 Z d
   Z RS(   s$   Represent an APT binary package listt   dependss   pre-dependst
   recommendst   suggestst   breakst	   conflictst   providest   replacest   enhancesc         O   s*   t  j |  | |  t j |  | |  d  S(   N(   RO   R   R   (   R   R   R   (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyR   L  s    (   R   R   R   R   R   (    (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyR'  E  s
   		t   _CaseInsensitiveStringc           B   s2   e  Z d  Z d   Z d   Z d   Z d   Z RS(   s   Case insensitive string.
    c         C   s7   t  j |  |  } | j   | _ t | j  | _ | S(   N(   R9   t   __new__R   t	   str_lowert   hasht   str_lower_hash(   RY   t   str_R   (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyR1  V  s    c         C   s   |  j  S(   N(   R4  (   R   (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyt   __hash__\  s    c         C   s   |  j  | j   k S(   N(   R2  R   (   R   RI   (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyRL   _  s    c         C   s   |  j  S(   N(   R2  (   R   (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyR   b  s    (   R   R   R   R1  R6  RL   R   (    (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyR0  R  s
   			('   t   deprecationR    RW   RX   RH   RU   t   ImportErrorR   RG   R?   t   newRa   R   R   R<   Ru   t   UserDictt   objectt	   DictMixinR   R   R"   RO   R   R   R   R   R   R   R  R
  R  R  R   R%  R'  R9   R0  R,   (    (    (    s1   /usr/lib/python2.7/dist-packages/debian/deb822.pyt   <module>   sB   

+ [_RY=1*