ó
È”Mc           @   s[   d  d l  Td  d l Td  d l Z d Z d d „ Z e j ƒ  sW e e j d e ƒ ƒ n  d S(   iÿÿÿÿ(   t   *Ns   /etc/smart/channels/c         C   sY  | d  k r! t j d t ƒ } n  t j j |  ƒ rUi  } x?t j |  ƒ D].} | j d ƒ pj | j d ƒ ss qI n  t j j	 |  | ƒ } t j j
 | ƒ s  qI n  t | ƒ } | j ƒ  } | j ƒ  y t | ƒ } Wn3 t k
 r} t j t d ƒ | | f ƒ qI n Xxl| D]d}	 |	 | k r'qn  t | |	 <t j d |	 f ƒ }
 | |	 } t j d |	 f ƒ } |
 r{| r{| }
 n  | r“| j d ƒ } n d  } | sÎ| j d ƒ } | s½|	 } qÜ| d |	 7} n | d |	 7} |
 s| st j t d	 ƒ | t ƒ rwy t |	 | ƒ Wn0 t k
 rG} t j t d ƒ | | f ƒ qXt j d |	 f | ƒ t j d |	 f | ƒ qst j d |	 f | ƒ q| s| | k s| |
 k rµqq| j d
 ƒ sÞt j t d ƒ t ƒ q| j d
 ƒ | j d
 ƒ k rÅ| s9t j t d ƒ | t |	 | ƒ t |	 | ƒ f t ƒ r¬y t |	 | ƒ Wn0 t k
 r|} t j t d ƒ | | f ƒ qÂXt j d |	 f | ƒ t j d |	 f | ƒ qst j d |	 f | ƒ qt | d
 ƒ } | d „ } d „  } y t | ƒ } Wn3 t k
 r/} t j t d ƒ | | f ƒ qn Xt } xË | D]Ã } |
 j | ƒ } | j | ƒ } | j | ƒ } | j | ƒ } | | k s=| | k rq=n  | sít j t d ƒ i | | ƒ d 6| d 6| | ƒ d 6| | ƒ d 6t ƒ r=| | | <t } q=q=W| r]y t |	 | ƒ Wn& t k
 rC} t j t | ƒ ƒ q]Xt j d |	 f | ƒ n  t j d |	 f | ƒ qWqI Wt j d ƒ sŽd  SxÄ t j d ƒ D]° }	 |	 | k ržt j d |	 f ƒ t j d |	 f ƒ sÞqžn  t j d |	 d f ƒ } | s|	 } n | d |	 7} | s5t j t d ƒ | t ƒ rNt j d |	 f ƒ qNqžqžWn  d  S(   Ns   force-channelsyncs   .channels   .repos   While using %s: %st   channelsynct   channelst   names    (%s)s&   New channel '%s' detected.
Include it?t   types   Channel in %s has no type.s_   Change in channel '%s' detected.
Old channel:

%s

New channel:

%s

Do you want to replace it?c         S   s7   x0 | j  D]% \ } } } } } | |  k r
 | Sq
 W|  S(   N(   t   fields(   t   keyt   infot   _keyt   labelt   ftypet   defaultt   descr(    (    s=   /usr/lib/python2.7/dist-packages/smart/plugins/channelsync.pyt   getLabel   s    c         S   sN   t  |  ƒ t k r. |  r$ t d ƒ p- t d ƒ S|  d  k rD t d ƒ St |  ƒ S(   Nt   Yest   Not   None(   R   t   boolt   _R   t   str(   t   value(    (    s=   /usr/lib/python2.7/dist-packages/smart/plugins/channelsync.pyt   toStr‡   s
    
s‚   Change in field '%(label)s' of channel '%(name)s' detected.
Old value: %(curvalue)s
New value: %(newvalue)s
Replace current value?R	   t   curvaluet   newvalues>   Removing channel '%s' was suggested.
Do you want to remove it?(   R   t   sysconft   gett   Falset   ost   patht   isdirt   listdirt   endswitht   joint   isfilet   opent   readt   closet   parseChannelsDescriptiont   Errort   ifacet   errorR   t   Truet   askYesNot   createChannelt   sett   fielpatht   createChannelDescriptiont   getChannelInfot   parseChannelDatat   unicodet   hast   keyst   remove(   t   channelsdirt   forcet	   seenaliast   entryt   filepatht   filet   datat   descriptionst   et   aliast   olddescrt   newdescrt   chndescrR   R   R   R   t   pardescrt   changedR   t   oldvalueR   t   parvaluet   chnvalue(    (    s=   /usr/lib/python2.7/dist-packages/smart/plugins/channelsync.pyt   syncChannels   sî    


		
			
		s   channel-sync-dir(	   t   smart.channelt   smartR   t   CHANNELSDIRR   RG   R   t   getReadOnlyR   (    (    (    s=   /usr/lib/python2.7/dist-packages/smart/plugins/channelsync.pyt   <module>   s   

«