Ñò
?$ëLc           @   s  d  Z  d d k Z d d k l Z d d k l Z l Z d d k l	 Z	 d d k
 l Z d d k l Z d d k l Z l Z d d	 k l Z e i d
 ƒ Z d „  Z e i d ƒ Z d „  Z d e i f d „  ƒ  YZ d e f d „  ƒ  YZ d e i f d „  ƒ  YZ d d „ Z d S(   s3   Form fields required for handling translation filesiÿÿÿÿN(   t   forms(   t   get_languaget   ugettext(   t	   mark_safe(   t   multistring(   t   Unit(   t   FUZZYt
   TRANSLATED(   t   PLURAL_PLACEHOLDERs   
||
|	|\\c         C   s   d „  } t  i | |  ƒ S(   s   make whitespace chars visiblec         S   s7   h d d 6d d 6d d 6d d 6d	 d
 6} | |  i  ƒ  S(   Ns   \r\n
s   
s   \r
s   s   \n
s   
s   \t	s   	s   \\s   \(   t   group(   t   matcht   submap(    (    s0   /var/www/Pootle/local_apps/pootle_store/forms.pyt   replace&   s    
(   t   FORM_REt   sub(   t   textR   (    (    s0   /var/www/Pootle/local_apps/pootle_store/forms.pyt   highlight_whitespace$   s    		s   |
|	|\\r|\\n|\\t|\\\\c         C   s   d „  } t  i | |  ƒ S(   s1   replace visible whitespace with proper whitespacec         S   sE   h d d 6d d 6d d 6d d 6d d 6d d 6d d	 6} | |  i  ƒ  S(
   Nt    s   	s   
s   s   \ts   \ns   \rs   \s   \\(   R	   (   R
   R   (    (    s0   /var/www/Pootle/local_apps/pootle_store/forms.pyR   4   s    
(   t	   FORM_UNRER   (   R   R   (    (    s0   /var/www/Pootle/local_apps/pootle_store/forms.pyt   unhighlight_whitespace2   s    	t   MultiStringWidgetc           B   s2   e  Z d  Z d d e d „ Z d „  Z d „  Z RS(   sg   Custom Widget for editing multistrings, expands number of text
    area based on number of plural formsi   c         C   sj   | o t  i } n
 t  i } g  } t | ƒ D] } | | d | ƒ q. ~ } t t |  ƒ i | | ƒ d  S(   Nt   attrs(   R    t   Textareat	   TextInputt   xranget   superR   t   __init__(   t   selfR   t   npluralst   textareat   widgett   _[1]t   it   widgets(    (    s0   /var/www/Pootle/local_apps/pootle_store/forms.pyR   D   s
    	0c         C   sy   t  | ƒ d j o t | d ƒ Sd } xD t | ƒ D]6 \ } } | d t ƒ  t d | ƒ f 7} | | 7} q5 Wt | ƒ S(   Ni   i    R   s4   <p class="translation-text-headers" lang="%s">%s</p>s   Plural Form %d(   t   lenR   t	   enumerateR   t   _(   R   t   rendered_widgetst   outputR    R   (    (    s0   /var/www/Pootle/local_apps/pootle_store/forms.pyt   format_outputM   s      c         C   s¹   | d  j o d  g t |  i ƒ St | t ƒ o) g  } | i D] } | t | ƒ q@ ~ St | t ƒ o& g  } | D] } | t | ƒ qv ~ St | t ƒ o t | ƒ g St	 ‚ d  S(   N(
   t   NoneR"   R!   t
   isinstanceR   t   stringsR   t   listt
   basestringt
   ValueError(   R   t   valueR   t   stringt   _[2](    (    s0   /var/www/Pootle/local_apps/pootle_store/forms.pyt
   decompressW   s    )&N(   t   __name__t
   __module__t   __doc__R(   t   TrueR   R'   R1   (    (    (    s0   /var/www/Pootle/local_apps/pootle_store/forms.pyR   A   s   		
t   HiddenMultiStringWidgetc           B   s/   e  Z d  Z d d d „ Z d „  Z d „  Z RS(   s'   uses hidden input instead of text areasi   c         C   sP   g  } t  | ƒ D] } | t i d | ƒ q ~ } t t |  ƒ i | | ƒ d  S(   NR   (   R   R    t   HiddenInputR   R   R   (   R   R   R   R   R    R!   (    (    s0   /var/www/Pootle/local_apps/pootle_store/forms.pyR   e   s    3c         C   s   t  t |  ƒ i | ƒ S(   N(   R   R   R'   (   R   R%   (    (    s0   /var/www/Pootle/local_apps/pootle_store/forms.pyR'   i   s    c         C   s   |  S(   N(    (   R   (    (    s0   /var/www/Pootle/local_apps/pootle_store/forms.pyt   __call__l   s    	N(   R2   R3   R4   R(   R   R'   R8   (    (    (    s0   /var/www/Pootle/local_apps/pootle_store/forms.pyR6   c   s   	t   MultiStringFormFieldc           B   s#   e  Z d  d e d „ Z d „  Z RS(   i   c   	      O   s€   t  d | d | d | ƒ |  _ t d | ƒ |  _ g  } t | ƒ D] } | t i ƒ  qA ~ } t t |  ƒ i	 d | | | Ž d  S(   NR   R   R   t   fields(
   R   R   R6   t   hidden_widgett   rangeR    t	   CharFieldR   R9   R   (	   R   R   R   R   t   argst   kwargsR   R    R:   (    (    s0   /var/www/Pootle/local_apps/pootle_store/forms.pyR   x   s    -c         C   s%   g  } | D] } | t  | ƒ q ~ S(   N(   R   (   R   t	   data_listR   R/   (    (    s0   /var/www/Pootle/local_apps/pootle_store/forms.pyt   compress~   s    N(   R2   R3   R(   R5   R   RA   (    (    (    s0   /var/www/Pootle/local_apps/pootle_store/forms.pyR9   w   s   c            sÎ   ˆ d  j	 o |  i ‰ n d ‰ h |  i d 6|  i ƒ  d 6d d 6d d 6d d	 6‰ h |  i d 6|  i ƒ  d 6d
 d 6d d 6d d	 6‰  h d d 6d d 6d d	 6‰ d t i f ‡  ‡ ‡ ‡ ‡ f d †  ƒ  Y} | S(   Ni   t   langt   dirs   translation expanding focusthist   classi   t   rowsi
   t   tabindexs   comments expandingi   t   ft	   accesskeyt
   fuzzychecki   t   UnitFormc              s!  e  Z d  d d „  ƒ  YZ e i d e ƒ Z e d ˆ p d d e d e ƒ Z e d ˆ d e d ˆ ƒ Z	 e i
 d e d e d ƒ d	 e i d ˆ d
 d „  ƒ ƒ Z e i d e d	 e i d ˆ  ƒ d e d ƒ ƒ Z e i d e d	 e i d ˆ  ƒ ƒ Z ‡ f d †  Z d „  Z d „  Z d „  Z RS(   t   Metac           B   s   e  Z e Z d  g Z RS(   t   store(   R2   R3   R   t   modelt   exclude(    (    (    s0   /var/www/Pootle/local_apps/pootle_store/forms.pyRK   ž   s   t   requiredR   i   R   R   t   labelt   FuzzyR   t
   check_testc         S   s
   |  t  j S(    (   R   (   t   x(    (    s0   /var/www/Pootle/local_apps/pootle_store/forms.pyt   <lambda>§   s    s   Translator commentc            sU   |  i  d } |  i i i | j o t |  i _ n ˆ  d j o | i t ƒ n | S(   Nt   source_fi   (   t   cleaned_datat   instancet   sourceR*   R5   t   _source_updatedt   appendR   (   R   R.   (   t	   snplurals(    s0   /var/www/Pootle/local_apps/pootle_store/forms.pyt   clean_source_f®   s    c         S   s7   |  i  d } |  i i i | j o t |  i _ n | S(   Nt   target_f(   RV   RW   t   targetR*   R5   t   _target_updated(   R   R.   (    (    s0   /var/www/Pootle/local_apps/pootle_store/forms.pyt   clean_target_f·   s    c         S   s@   |  i  d } |  i i | j o t |  i _ n t |  i _ | S(   Nt   translator_comment(   RV   RW   Ra   R5   t   _translator_comment_updatedt   False(   R   R.   (    (    s0   /var/www/Pootle/local_apps/pootle_store/forms.pyt   clean_translator_comment½   s
    c         S   sn   |  i  d } |  i i | j o t |  i _ n t |  i _ | o t S|  i i t j o |  i i St Sd  S(   Nt   state(   RV   RW   Re   R5   t   _state_updatedRc   R   R   (   R   R.   (    (    s0   /var/www/Pootle/local_apps/pootle_store/forms.pyt   clean_stateÅ   s    (    (   R2   R3   RK   R    t   IntegerFieldRc   t   idR9   RU   R]   t   BooleanFieldR$   t   CheckboxInputRe   R=   R   Ra   t   developer_commentR\   R`   Rd   Rg   (    (   t   comment_attrst   fuzzy_attrst   target_attrst	   tnpluralsR[   (    s0   /var/www/Pootle/local_apps/pootle_store/forms.pyRJ      s    "			(   R(   R   t   codet   get_directionR    t	   ModelForm(   t   languageR[   RJ   (    (   Rm   Rn   Ro   Rp   R[   s0   /var/www/Pootle/local_apps/pootle_store/forms.pyt   unit_form_factory‚   s*    




+6(   R4   t   ret   djangoR    t   django.utils.translationR   R   R$   t   django.utils.safestringR   t   translate.misc.multistringR   t   pootle_store.modelsR   t   pootle_store.utilR   R   t   pootle_store.fieldsR   t   compileR   R   R   R   t   MultiWidgetR   R6   t   MultiValueFieldR9   R(   Ru   (    (    (    s0   /var/www/Pootle/local_apps/pootle_store/forms.pyt   <module>   s    		"