Ñò
ÜÆLc           @   s  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  d k l Z l Z d  d k l Z d  d	 k l Z d  d
 k l Z l Z l Z d  d k l Z d  d k l Z d  d k l Z d e f d „  ƒ  YZ d e i f d „  ƒ  YZ d S(   iÿÿÿÿN(   t   ugettext_lazy(   t   models(   t   ObjectDoesNotExist(   t   checks(   t   langcode_re(   t   absolute_real_patht   statssum(   t
   max_column(   t   Unit(   t   filetype_choicest   factory_classest   is_monolingual(   t   getfromcache(   t   l(   t   RelatedManagert   ProjectManagerc           B   s   e  Z d  „  Z RS(   c         C   s   |  i  d | ƒ S(   Nt   code(   t   get(   t   selfR   (    (    s3   /var/www/Pootle/local_apps/pootle_project/models.pyt   get_by_natural_key(   s    (   t   __name__t
   __module__R   (    (    (    s3   /var/www/Pootle/local_apps/pootle_project/models.pyR   '   s   t   Projectc           B   sí  e  Z e ƒ  Z d  d4 d „  ƒ  YZ e d ƒ Z e d ƒ Z d5 g Z e	 e
 i i ƒ  ƒ Z e i ƒ  e i g  Z e D] Z e e e f qs [ ƒ e Z d e d ƒ f d e d ƒ f d	 e d
 ƒ f f Z e i d d d e d e d e d e d ƒ d e ƒ Z e i d d d e d e d ƒ ƒ Z e i d e d e ƒ Z e i d d d d d e d e d e d ƒ ƒ Z e i d d d d d e d e d ƒ ƒ Z e i d d d d d e d e d ƒ ƒ Z e i  d d e d e d ƒ ƒZ! e i d d d e d e d d d e d  ƒ ƒ Z" e i# d! d e d" e ƒZ$ d# „  Z% d! g e% _& d$ „  Z' d% „  Z( d& „  Z) e* d' „  ƒ Z+ e* d( „  ƒ Z, d) „  Z- d* „  Z. e/ e. ƒ Z0 d+ „  Z1 d, „  Z2 d- „  Z3 d. „  Z4 d/ „  Z5 e d0 „ Z6 d1 „  Z7 d2 „  Z8 d3 „  Z9 RS(6   t   Metac           B   s   e  Z d  g Z d Z RS(   R   t   pootle_app_project(   R   R   t   orderingt   db_table(    (    (    s3   /var/www/Pootle/local_apps/pootle_project/models.pyR   -   s   	ss   A short code for the project. This should only contain ASCII characters, numbers, and the underscore (_) character.sx   A description of this project. This is useful to give more information or instructions. This field should be valid HTML.t   standardt   autos   Automatic detection (slower)t   gnus'   GNU style: files named by language codet   nongnus+   Non-GNU: Each language in its own directoryt
   max_lengthiÿ   t   nullt   uniquet   db_indext   verbose_namet   Codet	   help_texts	   Full Namet   blanki2   t   defaultt   choicess   Quality Checkst   pos	   File Typei   s   Project Tree Styles   pootle_language.Languages   Source Languaget    s   Ignore Filess   pootle_app.Directoryt   editablec         C   s
   |  i  f S(   N(   R   (   R   (    (    s3   /var/www/Pootle/local_apps/pootle_project/models.pyt   natural_keyJ   s    c         C   s   |  i  S(   N(   t   fullname(   R   (    (    s3   /var/www/Pootle/local_apps/pootle_project/models.pyt   __unicode__N   s    c         O   sx   |  i  ƒ  } t i i | ƒ p t i | ƒ n d d k l } | i i i	 |  i
 ƒ |  _ t t |  ƒ i | | Ž  d  S(   Niÿÿÿÿ(   t	   Directory(   t   get_real_patht   ost   patht   existst   makedirst   pootle_app.models.directoryR/   t   objectst   projectst   get_or_make_subdirR   t	   directoryt   superR   t   save(   R   t   argst   kwargst   project_pathR/   (    (    s3   /var/www/Pootle/local_apps/pootle_project/models.pyR;   Q   s    c         O   s0   |  i  } t t |  ƒ i | | Ž  | i ƒ  d  S(   N(   R9   R:   R   t   delete(   R   R<   R=   R9   (    (    s3   /var/www/Pootle/local_apps/pootle_project/models.pyR?   [   s    	c         C   s   t  t i i d |  ƒ d d  ƒ S(   Nt#   store__translation_project__projectt   mtime(   R   R   R6   t   filtert   None(   R   (    (    s3   /var/www/Pootle/local_apps/pootle_project/models.pyt	   get_mtime`   s    c         C   s   t  |  i i ƒ  ƒ S(   N(   R   t   translationproject_sett   iterator(   R   (    (    s3   /var/www/Pootle/local_apps/pootle_project/models.pyt   getquickstatsd   s    c         C   s/   t  d |  i ƒ  d t |  i ƒ  d d ƒ ƒ S(   Ng      Y@t   translatedsourcewordst   totalsourcewordsi   (   t   intRG   t   max(   R   (    (    s3   /var/www/Pootle/local_apps/pootle_project/models.pyt   translated_percentageh   s    c         C   s   d |  i  d S(   Ns
   /projects/t   /(   R   (   R   (    (    s3   /var/www/Pootle/local_apps/pootle_project/models.pyt   _get_pootle_pathk   s    c         C   s   t  |  i ƒ S(   N(   R   R   (   R   (    (    s3   /var/www/Pootle/local_apps/pootle_project/models.pyR0   o   s    c         C   s   t  |  i ƒ S(   N(   R   t   pootle_path(   R   (    (    s3   /var/www/Pootle/local_apps/pootle_project/models.pyt   get_absolute_urlr   s    c         C   s    |  i  d j o d S|  i  Sd  S(   NR)   t   pot(   t   localfiletype(   R   (    (    s3   /var/www/Pootle/local_apps/pootle_project/models.pyt   get_template_filtetypeu   s    c         C   s   t  |  i S(   sH   returns the TranslationStore subclass required for parsing Project files(   R
   RR   (   R   (    (    s3   /var/www/Pootle/local_apps/pootle_project/models.pyt   get_file_class{   s    c         C   s   t  |  i ƒ  ƒ S(   s   is this a monolingual project(   R   RT   (   R   (    (    s3   /var/www/Pootle/local_apps/pootle_project/models.pyR      s    c         C   sA   | i  t i i |  i ƒ p$ | o | i  t i i |  i ƒ  ƒ S(   s˜   tests if filename matches project filetype (ie. extension),
        if match_templates is true will also check if file matches
        template filetype(   t   endswithR1   R2   t   extsepRR   RS   (   R   t   filenamet   match_templates(    (    s3   /var/www/Pootle/local_apps/pootle_project/models.pyt   file_belongs_to_projectƒ   s    c         C   s¸   yª t  i |  i ƒ  ƒ } | i ƒ  \ } } } | p t |  i | ƒ o d SnZ t d „  | ƒ o d Sx> t  i |  i ƒ  ƒ D]' \ } } } t |  i | ƒ o d Sq~ WWn n Xd  S(   NR   c         S   s   |  d  j p t  i |  ƒ S(   t	   templates(   R   t   match(   t   dirname(    (    s3   /var/www/Pootle/local_apps/pootle_project/models.pyt   <lambda>—   s    R   (   R1   t   walkR0   t   nextRB   RY   RC   (   R   t
   dirlistingt   dirpatht   dirnamest	   filenames(    (    s3   /var/www/Pootle/local_apps/pootle_project/models.pyt   _detect_treestyle‹   s    	 c         C   s:   |  i  d j o |  i  S|  i ƒ  } | d j	 o | Sd S(   s  returns the real treestyle, if treestyle is set to auto it
        checks the project directory and tries to guess if it is gnu
        style or nongnu style.

        we are biased towards nongnu because it makes managing project
        from the web easierR   R   N(   t	   treestyleRd   RC   (   R   t   detected(    (    s3   /var/www/Pootle/local_apps/pootle_project/models.pyt   get_treestyle¤   s    c         C   sa   y |  i  i d d ƒ SWnC t j
 o7 y |  i  i d |  i ƒ SWq] t j
 o q] Xn Xd  S(   Nt   language__codeRZ   t   language(   RE   R   R   t   source_language_id(   R   (    (    s3   /var/www/Pootle/local_apps/pootle_project/models.pyt   get_template_translationprojectµ   s    (    (   R   R   (:   R   R   R   R6   R   t   _t   code_help_textt   description_help_textt   checker_choicest   listR   t   projectcheckerst   keyst   checkerst   sortt   extendt   _[1]t   checkerR	   t   local_choicest   treestyle_choicesR   t	   CharFieldt   Falset   TrueR   R-   t	   TextFieldt   descriptiont
   checkstyleRR   Re   t
   ForeignKeyt   source_languaget   ignoredfilest   OneToOneFieldR9   R,   t   dependenciesR.   R;   R?   R   RD   RG   RL   RN   t   propertyRO   R0   RP   RS   RT   R   RY   Rd   Rg   Rk   (    (    (    s3   /var/www/Pootle/local_apps/pootle_project/models.pyR   +   sP   		
.6$0**!0			
										(    R1   t   django.utils.translationR    Rl   t	   django.dbR   t   django.core.exceptionsR   t   translate.filtersR   t   translate.lang.dataR   t   pootle_store.utilR   R   t   pootle_misc.aggregateR   t   pootle_store.modelsR   t   pootle_store.filetypesR	   R
   R   t   pootle_misc.utilR   t   pootle_misc.baseurlR   t   pootle_app.lib.utilR   R   t   ModelR   (    (    (    s3   /var/www/Pootle/local_apps/pootle_project/models.pyt   <module>   s   