Ńň
ż
Lc           @   sű   d  d k  Z  d  d k l Z d  d k l Z d  d k l Z d Z d Z d Z	 d Z
 d	   Z d
   Z d   Z h d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6Z e d  Z h d d 6d d 6Z e d  Z d   Z d S(   i˙˙˙˙N(   t   settings(   t
   sum_column(   t   dictsumi˙˙˙i    i2   iČ   c         C   s(   |  d t  i j o |  S|  t  i Sd S(   s/   If path does not end with /, add it and return.i˙˙˙˙N(   t   ost   sep(   t   path(    (    s/   /var/www/Pootle/local_apps/pootle_store/util.pyt   add_trailing_slash'   s    c         C   s3   |  i  t i  o |  t t t i   S|  Sd  S(   N(   t
   startswithR    t   PODIRECTORYt   lenR   (   t   p(    (    s/   /var/www/Pootle/local_apps/pootle_store/util.pyt   relative_real_path0   s    c         C   s2   |  i  t i  p t i i t i |   S|  Sd  S(   N(   R   R    R   R   R   t   join(   R
   (    (    s/   /var/www/Pootle/local_apps/pootle_store/util.pyt   absolute_real_path7   s    t   fuzzyt   fuzzysourcewordst   reviewt   totalt   totalsourcewordst
   translatedt   translatedsourcewordst   translatedtargetwordst   untranslatedt   untranslatedsourcewordst   errorsc         C   sN   | } xA |  D]9 } y t  | | i    } Wq | d c d 7<q Xq W| S(   NR   i   (   R   t   getquickstats(   t   querysett   empty_statst   totalst   item(    (    s/   /var/www/Pootle/local_apps/pootle_store/util.pyt   statssumJ   s     u   isfuzzyc         C   sN   | } xA |  D]9 } y t  | | i    } Wq | d c d 7<q Xq W| S(   NR   i   (   R   t   getcompletestats(   R   R   R   R   (    (    s/   /var/www/Pootle/local_apps/pootle_store/util.pyt   completestatssumV   s     c         C   s  t  |  d g d t } t  |  i d t  d g d t } t  |  i d t  d g d t } t  |  i d t  d d g d t } h  } | d | d <| d d j o d | d <n | d | d <| d | d <| d d j o d | d	 <n | d | d	 <| d | d
 <| d
 d j o d | d <n | d | d <| d | d <| d d j o d | d <d | d <n | d | d <| d | d <| S(   s8   calculate translation statistics for given unit querysett   source_wordcountt   countt   statet   target_wordcountR   i    R   R   R   R   R   R   R   R   (   R   t   Truet   filtert   UNTRANSLATEDt   FUZZYt
   TRANSLATED(   t   unitsR   R   R   R   t   result(    (    s/   /var/www/Pootle/local_apps/pootle_store/util.pyt   calculate_stats_   s8    
(   R   t   django.confR    t   pootle_misc.aggregateR   t   pootle_misc.utilR   t   OBSOLETER'   R(   R)   R   R   R   t   empty_quickstatsR   t   empty_completestatsR    R,   (    (    (    s/   /var/www/Pootle/local_apps/pootle_store/util.pyt   <module>   s4   				

	

	