Ñò
Ù7ÊLc        	   @   sv   d  d k  Z  d  d k l Z d  d k l Z d  d k l Z d  d k l Z d  d k	 l
 Z
 d e f d „  ƒ  YZ d S(	   iÿÿÿÿN(   t   NoArgsCommand(   t   make_option(   t   TranslationProject(   t   Language(   t   Projectt   PootleCommandc           B   s“   e  Z d  Z e i e d d d d d ƒe d d d d d	 d d
 ƒe d d d d d d d ƒe d d d d d d d ƒf Z d „  Z d „  Z RS(   sB   base class for handling recursive pootle store management commandss   --directoryt   destt	   directoryt   helps-   directory to refresh relative to po directorys	   --projectt   actiont   appendt   projectss   project to refreshs
   --languaget	   languagess   language to refreshs   --path-prefixt   storet   paths?   path prefix relative to translation project of files to refreshc      
   K   s®  t  |  d ƒ o` t i d |  i | ƒ y |  i | |  Wqp t j
 o# } t i d |  i | | ƒ d  SXn | om t  |  d ƒ o] t i d |  i | ƒ y |  i | |  Wqªt j
 o  } t i d |  i | ƒ d  SXnÆ t  |  d ƒ oµ | i i	 ƒ  } | o# | i
 | } | i d | ƒ } n xy | i ƒ  D]g } t i d |  i | i
 ƒ y |  i | |  Wq;t j
 o% } t i d |  i | i
 | ƒ q;Xq;Wn d  S(	   Nt   handle_translation_projectu   running %s over %su   failed to run %s over %s:
%st   handle_all_storesu   running %s over %s's filesu    failed to run %s over %s's filest   handle_storet   pootle_path__startswith(   t   hasattrt   loggingt   infot   nameR   t	   Exceptiont   errorR   t   storest   allt   pootle_patht   filtert   iteratorR   (   t   selft   tpR   t   optionst   et   store_queryR   (    (    sE   /var/www/Pootle/local_apps/pootle_app/management/commands/__init__.pyt   do_translation_project+   s4    

 c         K   s°  |  i  i i d ƒ d |  _ d d k l } d | i _ d | i _ d t	 i
 _ d t	 i
 _ | i d d ƒ } | oØ g  } g  } d } | i d ƒ } | o¬ | d o¡ | d g } t | ƒ d	 j o} | d	 or t i i d
 | d	 ƒ i ƒ  o; | d	 g } t | ƒ d j o d i | d ƒ } qAqEd i | d	 ƒ } qIqƒn7 | i d g  ƒ } | i d g  ƒ } | i d d ƒ } | o² t |  d ƒ o¢ t i i ƒ  } | o | i d | ƒ } n xs | i ƒ  D]a }	 t i d |  i |	 ƒ y |  i |	 |  WqÓt j
 o" }
 t i d |  i |	 |
 ƒ qÓXqÓWn t i i ƒ  } | o | i d | ƒ } n xA| i ƒ  D]3} t |  d ƒ ob t i d |  i | ƒ y |  i | |  Wqít j
 o% }
 t i d |  i | |
 ƒ quqíXn | i ƒ  } | i i d ƒ } | o: | o | i i  | j o
 d  } n | i d | ƒ } n | o |  i" | | |  n x; | i ƒ  D]- } | | j o qwn |  i" | | |  qwWquWd  S(   Nt   .iÿÿÿÿ(   t   TranslationStoreFieldFilei   R   t    t   /i    i   t   codeR   R   R   t   handle_languaget   code__inu   running %s over %su   failed to run %s over %s:
%st   handle_projectt   language__codet   language__code__in(#   t	   __class__t
   __module__t   splitR   t   pootle_store.fieldsR%   t   _store_cachet   maxsizet   cullsizeR   t   _non_db_state_cachet   gett   lenR   t   objectsR   t   countt   joinR   R   R   R   R   R)   R   R   R   R+   t   get_template_translationprojectt   translationproject_sett   order_byt   languageR(   t   NoneR#   (   R   R    R%   R   R   R   R   t
   path_partst
   lang_queryt   langR!   t   project_queryt   projectt   template_tpt   tp_queryR   (    (    sE   /var/www/Pootle/local_apps/pootle_app/management/commands/__init__.pyt   handle_noargsG   sv      & 
 (   t   __name__R/   t   __doc__R    t   option_listR   R#   RG   (    (    (    sE   /var/www/Pootle/local_apps/pootle_app/management/commands/__init__.pyR      s   	(   R   t   django.core.management.baseR    t   optparseR   t    pootle_translationproject.modelsR   t   pootle_language.modelsR   t   pootle_project.modelsR   R   (    (    (    sE   /var/www/Pootle/local_apps/pootle_app/management/commands/__init__.pyt   <module>   s   