
TQc           @  s   d  d l  m Z d  d l Z d  d l Z d  d l Z d  d l m Z d  d l m Z m	 Z	 d  d l
 m Z d   Z d d  Z d e f d	     YZ d S(
   i(   t   unicode_literalsN(   t   make_option(   t   BaseCommandt   CommandError(   t   npathc         C  sY   t  |  d   } | j d  } Wd  QX| d  d k pX | j t j  pX | j t j  S(   Nu   rbi   i   s   ﻿(   t   opent   readt
   startswitht   codecst   BOM_UTF16_LEt   BOM_UTF16_BE(   t   fnt   ft   sample(    (    sH   ../Django//lib/python/django/core/management/commands/compilemessages.pyt   has_bom
   s
    c         C  s  t  j j d d  d g } t  j j d  rP d d l m } | j | j  n  t	 t
 t  j j t t  j j |    } | s t d   n  x/| D]'} | r t  j j | | d  } n  x t  j |  D] \ } } } x | D] } | j d  r |  j d	 | | f  t  j j | |  }	 t |	  rCt d
 |	   n  t  j j |	  d }
 t |
 d  t  j d <t |
 d  t  j d <t j d k rd } n d } t  j |  q q Wq Wq Wd  S(   Nu   confu   localeu   DJANGO_SETTINGS_MODULEi(   t   settingsuz   This script should be run from the Django Git checkout or your project or app tree, or with the settings module specified.u   LC_MESSAGESu   .pou   processing file %s in %s
um   The %s file has a BOM (Byte Order Mark). Django only supports .po files encoded in UTF-8 and without any BOM.i    u   .mou   djangocompilemou   djangocompilepou   win32u@   msgfmt --check-format -o "%djangocompilemo%" "%djangocompilepo%"u>   msgfmt --check-format -o "$djangocompilemo" "$djangocompilepo"(   t   ost   patht   joint   environt   gett   django.confR   t   extendt   LOCALE_PATHSt   sett   mapt   abspatht   filtert   isdirR   t   walkt   endswitht   writeR   t   splitextR   t   syst   platformt   system(   t   stderrt   localet   basedirsR   t   basedirt   dirpatht   dirnamest	   filenamesR   R   t   pft   cmd(    (    sH   ../Django//lib/python/django/core/management/commands/compilemessages.pyt   compile_messages   s0    *	t   Commandc           B  sH   e  Z e j e d  d d d d d f Z d Z e Z e Z d   Z	 RS(   u   --localeu   -lt   destu   localet   helpu1   The locale to process. Default is to process all.uE   Compiles .po files to .mo files for use with builtin gettext support.c         K  s&   | j  d  } t |  j d | d  S(   Nu   localeR%   (   R   R-   R$   (   t   selft   optionsR%   (    (    sH   ../Django//lib/python/django/core/management/commands/compilemessages.pyt   handle@   s    (
   t   __name__t
   __module__R   t   option_listR   R0   t   Falset   requires_model_validationt   can_import_settingsR3   (    (    (    sH   ../Django//lib/python/django/core/management/commands/compilemessages.pyR.   6   s   (   t
   __future__R    R   R   R!   t   optparseR   t   django.core.management.baseR   R   t   django.utils._osR   R   t   NoneR-   R.   (    (    (    sH   ../Django//lib/python/django/core/management/commands/compilemessages.pyt   <module>   s   	%