ó
ÍÿŠTc           @   sV   d  d l  Z  d  d l m Z d  d l m Z d  d l m Z d e f d „  ƒ  YZ d S(   iÿÿÿÿN(   t	   read_file(   t   APT_PREFERENCES_SIZE_LIMIT(   t   DataWatchert   AptPreferencesc           B   sP   e  Z d  Z d Z d Z d Z d Z d Z e Z	 d d „ Z
 d „  Z d „  Z RS(	   s:   
    Report the system APT preferences configuration.
    s   apt-preferencest   datai„  t   packages   /etc/aptc         C   s   | |  _  d  S(   N(   t   _etc_apt_directory(   t   selft   etc_apt_directory(    (    sD   /usr/lib/python2.7/dist-packages/landscape/monitor/aptpreferences.pyt   __init__   s    c   
      C   s[  i  } d „  } t  j j |  j d ƒ } t  j j | ƒ rL | | ƒ | | <n  t  j j |  j d ƒ } t  j j | ƒ rÍ xT t  j | ƒ D]@ } t  j j | | ƒ } t  j j | ƒ r† | | ƒ | | <q† q† Wn  | i  k rÝ d S|  j	 t
 | j ƒ  ƒ } x^ | j ƒ  D]P \ } } t
 | ƒ t
 | ƒ | k r| t
 | ƒ }	 | | d |	 !| | <qqW| S(   s·   Return a C{dict} mapping APT preferences files to their contents.

        If no APT preferences configuration is set at all on the system, then
        simply return C{None}
        c         S   s   t  t |  ƒ ƒ S(   N(   t   unicodeR    (   t   filename(    (    sD   /usr/lib/python2.7/dist-packages/landscape/monitor/aptpreferences.pyt   <lambda>   s    u   preferencesu   preferences.di    N(   t   ost   patht   joinR   t   existst   isdirt   listdirt   isfilet   Nonet
   size_limitt   lent   keyst	   iteritems(
   R   R   t   read_unicodet   preferences_filenamet   preferences_directoryt   entryR   t   item_size_limitt   contentst   truncated_contents_size(    (    sD   /usr/lib/python2.7/dist-packages/landscape/monitor/aptpreferences.pyt   get_data   s*    			c         C   s   |  j  d t ƒ S(   Nt   urgent(   t   exchanget   True(   R   (    (    sD   /usr/lib/python2.7/dist-packages/landscape/monitor/aptpreferences.pyt   run8   s    (   t   __name__t
   __module__t   __doc__t   persist_namet   message_typet   message_keyt   run_intervalt   scopeR   R   R	   R    R$   (    (    (    sD   /usr/lib/python2.7/dist-packages/landscape/monitor/aptpreferences.pyR   	   s   	 (   R   t   landscape.lib.fsR    t   landscape.constantsR   t   landscape.monitor.pluginR   R   (    (    (    sD   /usr/lib/python2.7/dist-packages/landscape/monitor/aptpreferences.pyt   <module>   s   