ó
®â0_c           @  sÞ  d  d l  m Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l m	 Z	 d  d l
 m Z d  d l Z d  d l m Z d  d l m Z d  d l m Z d  d l m Z m Z d  d	 l m Z m Z m Z d  d
 l m Z d  d l m Z m Z d  d l m  Z  d  d l! m" Z" d  d l# m$ Z$ d  d l% m& Z& e j' d e j( e j) Bƒ Z* d Z+ e, ƒ  Z- d „  Z. e	 d e, f d „  ƒ  Yƒ Z/ d e, f d „  ƒ  YZ0 d „  Z1 d „  Z2 d e f d „  ƒ  YZ3 d S(   iÿÿÿÿ(   t   unicode_literalsN(   t   total_ordering(   t	   dropwhile(   t   settings(   t   ImproperlyConfigured(   t   NamedTemporaryFile(   t   BaseCommandt   CommandError(   t   find_commandt   handle_extensionst   popen_wrapper(   t   upath(   t   DEFAULT_LOCALE_ENCODINGt	   force_str(   t   cached_property(   t   prepare_js_for_gettext(   t   get_text_list(   t
   templatizeu$   ^(?P<value>"Plural-Forms.+?\\n")\s*$i    c          G  s:   x3 |  D]+ } t  | ƒ d  k r t d | ƒ ‚ q q Wd  S(   NuL   Can't find %s. Make sure you have GNU gettext tools 0.15 or newer installed.(   R   t   NoneR   (   t   programst   program(    (    sN   /tmp/pip-unpacked-wheel-BAJOf3/django/core/management/commands/makemessages.pyt   check_programs    s
    t   TranslatableFilec           B  s;   e  Z d  „  Z d „  Z d „  Z d „  Z e d „  ƒ Z RS(   c         C  s   | |  _  | |  _ | |  _ d  S(   N(   t   filet   dirpatht
   locale_dir(   t   selfR   t	   file_nameR   (    (    sN   /tmp/pip-unpacked-wheel-BAJOf3/django/core/management/commands/makemessages.pyt   __init__+   s    		c         C  s,   d |  j  j t j j |  j |  j g ƒ f S(   Nu   <%s: %s>(   t	   __class__t   __name__t   ost   sept   joinR   R   (   R   (    (    sN   /tmp/pip-unpacked-wheel-BAJOf3/django/core/management/commands/makemessages.pyt   __repr__0   s    	c         C  s   |  j  | j  k S(   N(   t   path(   R   t   other(    (    sN   /tmp/pip-unpacked-wheel-BAJOf3/django/core/management/commands/makemessages.pyt   __eq__6   s    c         C  s   |  j  | j  k  S(   N(   R#   (   R   R$   (    (    sN   /tmp/pip-unpacked-wheel-BAJOf3/django/core/management/commands/makemessages.pyt   __lt__9   s    c         C  s   t  j j |  j |  j ƒ S(   N(   R   R#   R!   R   R   (   R   (    (    sN   /tmp/pip-unpacked-wheel-BAJOf3/django/core/management/commands/makemessages.pyR#   <   s    (   R   t
   __module__R   R"   R%   R&   t   propertyR#   (    (    (    sN   /tmp/pip-unpacked-wheel-BAJOf3/django/core/management/commands/makemessages.pyR   )   s
   				t	   BuildFilec           B  s_   e  Z d  Z d „  Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z d „  Z d „  Z	 d „  Z
 RS(   uO   
    Represents the state of a translatable file during the build process.
    c         C  s   | |  _  | |  _ | |  _ d  S(   N(   t   commandt   domaint   translatable(   R   R*   R+   R,   (    (    sN   /tmp/pip-unpacked-wheel-BAJOf3/django/core/management/commands/makemessages.pyR   E   s    		c         C  sX   |  j  d k r |  j j d k  S|  j  d k rT t j j |  j j ƒ d } | d k St S(	   Nu   djangojsi    i   i   u   djangoi   u   .py(   i    i   i   (	   R+   R*   t   gettext_versionR   R#   t   splitextR,   R   t   False(   R   t   file_ext(    (    sN   /tmp/pip-unpacked-wheel-BAJOf3/django/core/management/commands/makemessages.pyt   is_templatizedJ   s    
c         C  s
   |  j  j S(   N(   R,   R#   (   R   (    (    sN   /tmp/pip-unpacked-wheel-BAJOf3/django/core/management/commands/makemessages.pyR#   S   s    c         C  s_   |  j  s |  j Si d d 6d d 6j |  j ƒ } d |  j j | f } t j j |  j j | ƒ S(   u•   
        Path to a file which is being fed into GNU gettext pipeline. This may
        be either a translatable or its preprocessed version.
        u   cu   djangojsu   pyu   djangou   %s.%s(	   R1   R#   t   getR+   R,   R   R   R!   R   (   R   t	   extensiont   filename(    (    sN   /tmp/pip-unpacked-wheel-BAJOf3/django/core/management/commands/makemessages.pyt	   work_pathW   s    	
c         C  sÜ   |  j  s d S|  j j r" t j n d } t j |  j d d | ƒ } | j ƒ  } Wd QX|  j	 d k rv t
 | ƒ } n1 |  j	 d k r§ t | d |  j d d	 | ƒ} n  t j |  j d
 d d ƒ } | j | ƒ Wd QXd S(   uz   
        Preprocess (if necessary) a translatable file before passing it to
        xgettext GNU gettext utility.
        Nu   utf-8u   rt   encodingu   djangojsu   djangot   origini   t   charsetu   w(   R1   R*   t   settings_availableR   t   FILE_CHARSETt   iot   openR#   t   readR+   R   R   R5   t   write(   R   R6   t   fpt   src_datat   content(    (    sN   /tmp/pip-unpacked-wheel-BAJOf3/django/core/management/commands/makemessages.pyt
   preprocessf   s    	"c           s„   |  j  s | St j d k r1 |  j ‰ |  j ‰  n |  j d ‰ |  j d ‰  t j d t j ˆ ƒ d ‡  ‡ f d †  | d t j ƒS(   uß   
        Postprocess messages generated by xgettext GNU gettext utility.

        Transform paths as if these messages were generated from original
        translatable files rather than from preprocessed versions.
        u   nti   u	   ^(#: .*)(u   )c           s   |  j  ƒ  j ˆ ˆ  ƒ S(   N(   t   groupt   replace(   t   match(   t   new_patht   old_path(    sN   /tmp/pip-unpacked-wheel-BAJOf3/django/core/management/commands/makemessages.pyt   <lambda>   t    t   flags(	   R1   R   t   nameR5   R#   t   ret   subt   escapet	   MULTILINE(   R   t   msgs(    (   RF   RG   sN   /tmp/pip-unpacked-wheel-BAJOf3/django/core/management/commands/makemessages.pyt   postprocess_messagesz   s    		c         C  s8   |  j  r4 t j j |  j ƒ r4 t j |  j ƒ q4 n  d S(   uM   
        Remove a preprocessed copy of a translatable file (if any).
        N(   R1   R   R#   t   existsR5   t   unlink(   R   (    (    sN   /tmp/pip-unpacked-wheel-BAJOf3/django/core/management/commands/makemessages.pyt   cleanup”   s    	(   R   R'   t   __doc__R   R   R1   R#   R5   RB   RQ   RT   (    (    (    sN   /tmp/pip-unpacked-wheel-BAJOf3/django/core/management/commands/makemessages.pyR)   A   s   				c         C  s9   |  j  ƒ  } | r, | d r, | j d ƒ n  d j | ƒ S(   u  
    Take a block of raw text that will be passed through str.splitlines() to
    get universal newlines treatment.

    Return the resulting block of text with normalized `
` EOL sequences ready
    to be written to disk using current platform's native EOLs.
    iÿÿÿÿu    u   
(   t
   splitlinest   appendR!   (   t   raw_contentst
   lines_list(    (    sN   /tmp/pip-unpacked-wheel-BAJOf3/django/core/management/commands/makemessages.pyt   normalize_eols    s    c         C  sâ   | j  ƒ  } t j j |  ƒ r0 t t | ƒ } nq g  } t t } } x[ | D]S } | ry | ry t } | j d d ƒ } n  | r | r t } n  | j	 | ƒ qJ Wd j
 | ƒ } t j |  d d d ƒ } | j | ƒ Wd QXd S(   u|   
    Write the :param potfile: POT file with the :param msgs: contents,
    previously making sure its format is valid.
    u   charset=CHARSETu   charset=UTF-8u   
u   aR6   u   utf-8N(   RV   R   R#   RR   R   t   lenR/   t   TrueRD   RW   R!   R;   R<   R>   (   t   potfileRP   t	   pot_linest   linest   foundt   header_readt   lineR?   (    (    sN   /tmp/pip-unpacked-wheel-BAJOf3/django/core/management/commands/makemessages.pyt   write_pot_file¯   s    	t   Commandc           B  s¿   e  Z d  Z e Z e Z e Z e	 Z
 d d g Z d g Z d g Z d d g Z d „  Z d „  Z e d	 „  ƒ Z e d
 „  ƒ Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   uH  Runs over the entire source tree of the current directory and pulls out all strings marked for translation. It creates (or updates) a message file in the conf/locale (in the django tree) or locale (for projects and applications) directory.

You must run this command with one of either the --locale, --exclude, or --all options.u   -qu
   --previousu   --to-code=utf-8u   --no-obsoleteu   --from-code=UTF-8u   --add-comments=Translatorsc         C  sÏ  | j  d d d g  d d d d d d	 ƒ| j  d
 d d g  d d d d d d ƒ| j  d d d d d d d d ƒ| j  d d d d d d d t d d ƒ| j  d d d d d d d d ƒ| j  d d d d d d d t d d ƒ| j  d  d! d d d d" d g  d# d$ d d% ƒ| j  d& d d' d d( d t d d) ƒ| j  d* d d d d+ d t d d, ƒ| j  d- d d d d. d t d d/ ƒ| j  d0 d d d d1 d t d d2 ƒ| j  d3 d d d d4 d t d d5 ƒd  S(6   Nu   --localeu   -lt   defaultt   destu   localet   actionu   appendt   helpuf   Creates or updates the message files for the given locale(s) (e.g. pt_BR). Can be used multiple times.u	   --excludeu   -xu   excludeu@   Locales to exclude. Default is none. Can be used multiple times.u   --domainu   -du   djangou   domainu4   The domain of the message files (default: "django").u   --allu   -au
   store_trueu   allu3   Updates the message files for all existing locales.u   --extensionu   -eu
   extensionsu£   The file extension(s) to examine (default: "html,txt,py", or "js" if the domain is "djangojs"). Separate multiple extensions with commas, or use -e multiple times.u
   --symlinksu   -su   symlinksua   Follows symlinks to directories when examining source code and templates for translation strings.u   --ignoreu   -iu   ignore_patternst   metavaru   PATTERNu`   Ignore files or directories matching this glob-style pattern. Use multiple times to ignore more.u   --no-default-ignoreu   store_falseu   use_default_ignore_patternsuJ   Don't ignore the common glob-style patterns 'CVS', '.*', '*~' and '*.pyc'.u	   --no-wrapu   no_wrapu2   Don't break long message lines into several lines.u   --no-locationu   no_locationu%   Don't write '#: filename:line' lines.u   --no-obsoleteu   no_obsoleteu    Remove obsolete message strings.u
   --keep-potu   keep_potu<   Keep .pot file after making messages. Useful when debugging.(   t   add_argumentR/   R\   (   R   t   parser(    (    sN   /tmp/pip-unpacked-wheel-BAJOf3/django/core/management/commands/makemessages.pyt   add_argumentsÛ   sJ    c         O  s  | d } | d } | d |  _  | d |  _ | d } | d } | d |  _ | d } | d	 r| | d
 d d d g 7} n  t t | ƒ ƒ |  _ | d rî |  j d g |  _ |  j d g |  _ |  j d g |  _ |  j	 d g |  _	 n  | d rK|  j d g |  _ |  j d g |  _ |  j d g |  _ |  j	 d g |  _	 n  | d |  _
 | d |  _ |  j  d' k rƒt d ƒ ‚ n  |  j  d k rª| rž| n d g } n | r¶| n d d d g } t | ƒ |  _ | d  k rî| rî| sý|  j  d  k r0t d t j j t j d ƒ t j d f ƒ ‚ n  |  j d k rh|  j j d t t |  j ƒ d ƒ ƒ n  t |  _ g  |  _ d  |  _ t j j t j j d  d ƒ ƒ rçt j j t j j d  d ƒ ƒ g |  _ |  j d |  _ t |  _ n” |  j  r|  j j! t" j# ƒ n  t j j d ƒ r7|  j j$ t j j d ƒ ƒ n  |  j r{|  j d |  _ t j j% |  j ƒ s{t j& |  j ƒ q{n  t' t j j t( j( d! |  j ƒ ƒ }	 t) t j j |	 ƒ }
 | rÄ|
 } n" | pÍ|
 } t | ƒ t | ƒ } | rÿt* d" d# d$ ƒ n  t* d% ƒ zh |  j+ ƒ  } xU | D]M } |  j d k rK|  j j d& | ƒ n  x | D] } |  j, | | ƒ qRWqWWd  |  j sŠ|  j- ƒ  n  Xd  S((   Nu   localeu   excludeu   domainu	   verbosityu   allu
   extensionsu   symlinksu   ignore_patternsu   use_default_ignore_patternsu   CVSu   .*u   *~u   *.pycu   no_wrapu	   --no-wrapu   no_locationu   --no-locationu   no_obsoleteu   keep_potu   djangou   djangojsuD   currently makemessages only supports domains 'django' and 'djangojs'u   jsu   htmlu   txtu   pyu(   Type '%s help %s' for usage information.i    i   u(   examining files with the extensions: %s
u   andu   confu   %s/*u   msguniqu   msgmergeu	   msgattribu   xgettextu   processing locale %s
(   u   djangou   djangojs(.   R+   t	   verbosityt   symlinkst   listt   sett   ignore_patternst   msgmerge_optionst   msguniq_optionst   msgattrib_optionst   xgettext_optionst   no_obsoletet   keep_potR   R	   t
   extensionsR   R   R#   t   basenamet   syst   argvt   stdoutR>   R   R/   t   invoked_for_djangot   locale_pathst   default_locale_patht   isdirR!   t   abspathR\   R9   t   extendR   t   LOCALE_PATHSRW   RR   t   makedirst   filtert   globt   mapR   t   build_potfilest   write_po_filet   remove_potfiles(   R   t   argst   optionst   localet   excludet   process_allRx   Rq   t   extst   locale_dirst   all_localest   localest   potfilesR]   (    (    sN   /tmp/pip-unpacked-wheel-BAJOf3/django/core/management/commands/makemessages.pyt   handle  sŒ    







)-				!'		%	
	c         C  sc   t  d d g d t ƒ\ } } } t j d | ƒ } | rS t d „  | j ƒ  Dƒ ƒ St d ƒ ‚ d  S(   Nu   xgettextu	   --versiont   stdout_encodingu   (\d+)\.(\d+)\.?(\d+)?c         s  s'   |  ] } | d  k	 r t | ƒ Vq d  S(   N(   R   t   int(   t   .0t   d(    (    sN   /tmp/pip-unpacked-wheel-BAJOf3/django/core/management/commands/makemessages.pys	   <genexpr>~  s    u/   Unable to get gettext version. Is it installed?(   R
   R   RL   t   searcht   tuplet   groupsR   (   R   t   outt   errt   statust   m(    (    sN   /tmp/pip-unpacked-wheel-BAJOf3/django/core/management/commands/makemessages.pyR-   t  s    c         C  sF   y t  j Wn4 t k
 rA |  j d k r= |  j j d ƒ n  t SXt S(   Ni   u$   Running without configured settings.(   R   Rƒ   R   Rm   t   stderrR>   R/   R\   (   R   (    (    sN   /tmp/pip-unpacked-wheel-BAJOf3/django/core/management/commands/makemessages.pyR9   ‚  s    c   
      C  s;  |  j  d ƒ } |  j ƒ  |  j | ƒ g  } x|  j D]ý } t j j | d t |  j ƒ ƒ } t j j	 | ƒ sv q6 n  d g |  j
 | g } t | ƒ \ } } } | rì | t k rÇ t d | ƒ ‚ qì |  j d k rì |  j j | ƒ qì n  t | ƒ } t j | d d d ƒ }	 |	 j | ƒ Wd	 QX| j | ƒ q6 W| S(
   u<   
        Build pot files and apply msguniq to them.
        u   .u   %s.potu   msguniqu(   errors happened while running msguniq
%si    u   wR6   u   utf-8N(   t
   find_filesRŠ   t   process_filesR~   R   R#   R!   t   strR+   RR   Rs   R
   t	   STATUS_OKR   Rm   R|   R>   RZ   R;   R<   RW   (
   R   t	   file_listR”   R#   R]   R‹   RP   t   errorsRŸ   R?   (    (    sN   /tmp/pip-unpacked-wheel-BAJOf3/django/core/management/commands/makemessages.pyRˆ   Œ  s*    
"c         C  s\   xU |  j  D]J } t j j | d t |  j ƒ ƒ } t j j | ƒ r
 t j | ƒ q
 q
 Wd  S(   Nu   %s.pot(   R~   R   R#   R!   R¤   R+   RR   RS   (   R   R#   t   pot_path(    (    sN   /tmp/pip-unpacked-wheel-BAJOf3/django/core/management/commands/makemessages.pyRŠ   ¦  s    "c         C  s8  d „  } g  |  j  D] } t j j | ƒ ^ q } d „  d t j h Dƒ } g  } xW | D]O } xF | D]1 } | j | ƒ rd | j | t | ƒ  ƒ Pqd qd W| j | ƒ qW Wg  } g  }	 |  j rù g  t	 j
 t	 j f D] } | rÒ t j j | ƒ ^ qÒ }	 n  x2t j | d t d |  j ƒD]\ }
 } } xà | D]× } | t j j t j j |
 | ƒ ƒ | ƒ s†t j j t j j |
 ƒ | ƒ |	 k r¼| j | ƒ |  j d k r|  j j d | ƒ qq/| d k r/| j | ƒ |  j j d	 t j j t j j |
 ƒ | ƒ ƒ q/q/Wx| D]} t j j t j j |
 | ƒ ƒ } t j j | ƒ d } | |  j k so| | |  j  ƒ rž|  j d k r&|  j j d
 | |
 f ƒ q&qd } xB |  j D]7 } t j j |
 ƒ j t j j | ƒ ƒ r®| } Pq®q®W| sû|  j } n  | s
t } n  | j |  j |
 | | ƒ ƒ qWqWt  | ƒ S(   u‰   
        Helper method to get all files in the given root. Also check that there
        is a matching locale dir for each file.
        c           s>   t  j j ˆ ƒ ‰  ‡  ‡ f d †  ‰ t ‡ f d †  | Dƒ ƒ S(   uK   
            Check if the given path should be ignored or not.
            c           s"   t  j ˆ  |  ƒ p! t  j ˆ |  ƒ S(   N(   t   fnmatcht   fnmatchcase(   t   pattern(   R4   R#   (    sN   /tmp/pip-unpacked-wheel-BAJOf3/django/core/management/commands/makemessages.pyt   ignore¸  s    c         3  s   |  ] } ˆ  | ƒ Vq d  S(   N(    (   R˜   R«   (   R¬   (    sN   /tmp/pip-unpacked-wheel-BAJOf3/django/core/management/commands/makemessages.pys	   <genexpr>»  s    (   R   R#   Ry   t   any(   R#   Rq   (    (   R4   R¬   R#   sN   /tmp/pip-unpacked-wheel-BAJOf3/django/core/management/commands/makemessages.pyt
   is_ignored²  s    c         S  s   h  |  ] } d  | ’ q S(   u   %s*(    (   R˜   t   path_sep(    (    sN   /tmp/pip-unpacked-wheel-BAJOf3/django/core/management/commands/makemessages.pys	   <setcomp>¾  s   	 u   /t   topdownt   followlinksi   u   ignoring directory %s
u   localei    u   ignoring file %s in %s
N(!   Rq   R   R#   t   normcaseR    t   endswithRW   R[   R9   R   t
   MEDIA_ROOTt   STATIC_ROOTt   normpatht   walkR\   Rn   R!   R   t   removeRm   R|   R>   R~   t   insertR.   Rx   R   t
   startswitht   dirnameR   t   NO_LOCALE_DIRt   translatable_file_classt   sorted(   R   t   rootR®   t   pRq   t   dir_suffixest   norm_patternst
   dir_suffixt	   all_filest   ignored_rootsR   t   dirnamest	   filenamesR»   R4   t	   file_pathR0   R   R#   (    (    sN   /tmp/pip-unpacked-wheel-BAJOf3/django/core/management/commands/makemessages.pyR¢   ¬  sR    	(	:.*'5!! '	$c         C  sj   i  } x0 | D]( } | j  | j g  ƒ } | j | ƒ q Wx* | j ƒ  D] \ } } |  j | | ƒ qF Wd S(   uu   
        Group translatable files by locale directory and run pot file build
        process for each group.
        N(   t
   setdefaultR   RW   t   itemst   process_locale_dir(   R   R¦   t   file_groupsR,   t
   file_groupR   t   files(    (    sN   /tmp/pip-unpacked-wheel-BAJOf3/django/core/management/commands/makemessages.pyR£   é  s    c         C  s,  g  } xÄ | D]¼ } |  j  d k rE |  j j d | j | j f ƒ n  |  j d! k rZ q n  |  j |  |  j | ƒ } y | j ƒ  Wn9 t k
 r» } |  j j d | j | j | f ƒ q n X| j	 | ƒ q W|  j d k r"| j
 } d d |  j d | r d	 n d
 f d d d d d d g
 } nL |  j d k rjd d |  j d d d d d d d d d d d d g } n d Sg  | D] }	 |	 j ^ qu}
 t d d ƒ n } | j t d j |
 ƒ d t ƒƒ | j ƒ  | j d | j g ƒ | j |  j ƒ t | ƒ \ } } } Wd QX| r}| t k rXx | D] } | j ƒ  q"Wt d d j |
 ƒ | f ƒ ‚ q}|  j  d k r}|  j j | ƒ q}n  | r| t k r»t j j | d j ƒ } t d | ƒ ‚ n  x | D] } | j | ƒ } qÂWt j j | d  t |  j ƒ ƒ } t | | ƒ n  x | D] } | j ƒ  qWd S("   uÁ   
        Extract translatable literals from the specified files, creating or
        updating the POT file for a given locale directory.

        Uses the xgettext GNU gettext utility.
        i   u   processing file %s in %s
u   djangojsu   djangou6   UnicodeDecodeError: skipped file %s in %s (reason: %s)u   xgettextu   -du   --language=%su   Cu
   JavaScriptu   --keyword=gettext_noopu   --keyword=gettext_lazyu   --keyword=ngettext_lazy:1,2u   --keyword=pgettext:1c,2u   --keyword=npgettext:1c,2,3u
   --output=-u   --language=Pythonu   --keyword=ugettext_noopu   --keyword=ugettext_lazyu   --keyword=ungettext_lazy:1,2u   --keyword=pgettext_lazy:1c,2u   --keyword=npgettext_lazy:1c,2,3Nt   modeu   w+u   
R6   u   --files-fromu/   errors happened while running xgettext on %s
%si    u>   Unable to find a locale path to store translations for file %su   %s.pot(   u   djangojsu   django(   Rm   R|   R>   R   R   R+   t   build_file_classRB   t   UnicodeDecodeErrorRW   R1   R5   R   R   R!   R   t   flushR‚   RK   Ru   R
   R¥   RT   R   R¼   R   R#   R¶   RQ   R¤   Rc   (   R   R   RÎ   t   build_filesR,   t
   build_filet   eR1   R‹   t   bft   input_filest   input_files_listRP   R§   RŸ   RÈ   R]   (    (    sN   /tmp/pip-unpacked-wheel-BAJOf3/django/core/management/commands/makemessages.pyRË   õ  sŽ    				"
"c   
      C  s   t  j j t  j j | ƒ | d ƒ } t  j j | ƒ sF t  j | ƒ n  t  j j | d t |  j ƒ ƒ } t  j j | ƒ rö d g |  j	 | | g } t
 | ƒ \ } } } | rA| t k rÎ t d | ƒ ‚ qó |  j d k ró |  j j | ƒ qó qAnK t j | d d d ƒ }	 |	 j ƒ  } Wd	 QX|  j sA|  j | | ƒ } n  t | ƒ } | j d
 |  j d ƒ } t j | d d d ƒ }	 |	 j | ƒ Wd	 QX|  j rd g |  j d | | g } t
 | ƒ \ } } } | r| t k rôt d | ƒ ‚ q|  j d k r|  j j | ƒ qqn  d	 S(   uÈ   
        Creates or updates the PO file for self.domain and :param locale:.
        Uses contents of the existing :param potfile:.

        Uses msgmerge, and msgattrib GNU gettext utilities.
        u   LC_MESSAGESu   %s.pou   msgmergeu)   errors happened while running msgmerge
%si    u   rR6   u   utf-8Nu2   #. #-#-#-#-#  %s.pot (PACKAGE VERSION)  #-#-#-#-#
u    u   wu	   msgattribu   -ou*   errors happened while running msgattrib
%s(   R   R#   R!   R»   R€   R„   R¤   R+   RR   Rr   R
   R¥   R   Rm   R|   R>   R;   R<   R=   R}   t   copy_plural_formsRZ   RD   Rv   Rt   (
   R   R]   R   t   basedirt   pofileR‹   RP   R§   RŸ   R?   (    (    sN   /tmp/pip-unpacked-wheel-BAJOf3/django/core/management/commands/makemessages.pyR‰   T  s>    $"		c      	   C  s†  t  j j t  j j t  j j t t j ƒ ƒ ƒ ƒ } |  j d k rK d } n d } x.| D]&} t  j j | d d | d d | ƒ } t  j j	 | ƒ rX t
 j | d d d	 ƒ } t j | j ƒ  ƒ } Wd
 QX| r~t | j d ƒ ƒ }	 |  j d k r|  j j d |	 ƒ n  g  }
 t } xM | j ƒ  D]? } | rW| sHt j | ƒ rW|	 } t } n  |
 j | ƒ q%Wd j |
 ƒ } Pq~qX qX W| S(   uÓ   
        Copies plural forms header contents from a Django catalog of locale to
        the msgs string, inserting it at the right place. msgs should be the
        contents of a newly created .po file.
        u   djangojsu   djangou   confu   localeu   LC_MESSAGESu   %s.pou   rR6   u   utf-8Nu   valuei   u   copying plural forms: %s
u   
(   u   djangojsu   django(   u   django(   R   R#   R¶   R!   R»   R   t   djangot   __file__R+   RR   R;   R<   t   plural_forms_reRš   R=   R   RC   Rm   R|   R>   R/   RV   R\   RW   (   R   RP   R   t
   django_dirt   domainsR+   t	   django_poR?   R    t   plural_form_lineR_   R`   Rb   (    (    sN   /tmp/pip-unpacked-wheel-BAJOf3/django/core/management/commands/makemessages.pyRÙ   ~  s.    3	%	(   R   R'   Rh   R   R½   R)   RÐ   R/   t   requires_system_checksR\   t   leave_locale_aloneRr   Rs   Rt   Ru   Rl   R•   R   R-   R9   Rˆ   RŠ   R¢   R£   RË   R‰   RÙ   (    (    (    sN   /tmp/pip-unpacked-wheel-BAJOf3/django/core/management/commands/makemessages.pyRd   Ç   s(   			8	a
			=		_	*(4   t
   __future__R    R©   R†   R;   R   RL   Rz   t	   functoolsR   t	   itertoolsR   RÜ   t   django.confR   t   django.core.exceptionsR   t   django.core.files.tempR   t   django.core.management.baseR   R   t   django.core.management.utilsR   R	   R
   t   django.utils._osR   t   django.utils.encodingR   R   t   django.utils.functionalR   t   django.utils.jslexR   t   django.utils.textR   t   django.utils.translationR   t   compileRO   t   DOTALLRÞ   R¥   t   objectR¼   R   R   R)   RZ   Rc   Rd   (    (    (    sN   /tmp/pip-unpacked-wheel-BAJOf3/django/core/management/commands/makemessages.pyt   <module>   s<   			_		