ó
½ÞZc           @   sy   d  d l  Z  d  d l m Z m Z m Z m Z m Z m Z d d l Td „  Z	 d „  Z
 d „  Z e d k ru e ƒ  n  d S(	   iÿÿÿÿN(   t   PYQT_VERSION_STRt   QDirt   QFilet	   QFileInfot	   QIODevicet   QTextStreami   (   t   *c           C   s   t  j j d ƒ d  S(   NsØ  Usage:
    pylupdate5 [options] project-file
    pylupdate5 [options] source-files -ts ts-files

Options:
    -help  Display this information and exit
    -version
           Display the version of pylupdate5 and exit
    -verbose
           Explain what is being done
    -noobsolete
           Drop all obsolete strings
    -tr-function name
           name() may be used instead of tr()
    -translate-function name
           name() may be used instead of translate()
(   t   syst   stderrt   write(    (    (    s3   lib/python2.7/site-packages/PyQt5/pylupdate_main.pyt
   printUsage   s    	c   
      C   s¾   t  ƒ  } x® | D]¦ } | j | ƒ } t ƒ  } t ƒ  }	 | j | ƒ | rZ | j | ƒ n  t | |  |	 | | | ƒ | r† |	 j ƒ  n  |	 j ƒ  |	 j | ƒ s t	 j
 j d | ƒ q q Wd  S(   Ns#   pylupdate5 error: Cannot save '%s'
(   R   t   relativeFilePatht   MetaTranslatort   loadt   setCodect   merget   stripObsoleteMessagest   stripEmptyContextst   saveR   R   R	   (
   t
   fetchedTort   tsFileNamest
   codecForTrt
   noObsoletet   verboset   dirt   tt   fnt   tort   out(    (    s3   lib/python2.7/site-packages/PyQt5/pylupdate_main.pyt   updateTsFiles/   s    			
c       
   C   ss  d }  t  ƒ  } d } d } g  } g  } t } t } t } d }	 t }
 t } d  } d  } x* t j d D] } | d k re t }
 qe qe Wt t j ƒ } d } x‘| | k  r,t j | } | d 7} | d k râ t ƒ  t j d ƒ n  | d k rt j	 j
 d t ƒ t j d ƒ n  | d	 k r*t } qœ n  | d
 k rBt } qœ n  | d k rZt } qœ n  | d k r¯| | k r’t j	 j
 d ƒ t j d ƒ n  t j | } | d 7} qœ n  | d k r| | k rçt j	 j
 d ƒ t j d ƒ n  t j | } | d 7} qœ n  |	 d 7}	 d } | st | ƒ } | j t j ƒ s\t j	 j
 d | ƒ t j d ƒ n  t | ƒ } | j ƒ  } | j ƒ  n  |
 rOt j ƒ  } t j t | ƒ j ƒ  ƒ t  ƒ  } d } d } g  } g  } xt | ƒ j ƒ  D]ÿ \ } } xð | j d ƒ D]ß } | d k rBt t j ƒ  j | ƒ | |  t | | | ƒ t } qü| d k rs| j t j ƒ  j | ƒ ƒ t } qü| d  k r•| } | j | ƒ qü| d k rª| } qü| d k rüt  t j ƒ  j | ƒ | |  t ƒ qüqüWqàWt! | | | | | ƒ | st j	 j
 d | ƒ n) t | ƒ d k r?t j	 j
 d | ƒ n  t j | ƒ qœ | rÍ| j" ƒ  j# d ƒ r¶t | ƒ } | j$ ƒ  s| j% ƒ  rŸ| j | ƒ qÊt j	 j
 d | ƒ q)t j	 j
 d | ƒ qœ t | ƒ } | j& ƒ  d! k rt | j ƒ  | |  t | | | ƒ qœ t  | j ƒ  | |  t ƒ qœ W|
 sLt! | | | | | ƒ n  |	 d k rot ƒ  t j d ƒ n  d  S("   Ns   @defaultt    i    i   s   -tss   -helps   -versions   pylupdate5 v%s
s   -noobsoletes   -verboses   -tr-functions,   pylupdate5 error: missing -tr-function name
i   s   -translate-functions3   pylupdate5 error: missing -translate-function name
s(   pylupdate5 error: Cannot open file '%s'
t    t   SOURCESt   TRANSLATIONSt   CODECt   DEFAULTCODECt
   CODECFORTRt   CODECFORSRCt   FORMSs@   pylupdate5 warning: File '%s' does not look like a project file
sE   pylupdate5 warning: Met no 'TRANSLATIONS' entry in project file '%s'
s   .tss8   pylupdate5 warning: For some reason, I cannot save '%s'
s0   pylupdate5 error: File '%s' lacks .ts extension
t   pyt   pyw(   R"   R#   R$   (   R'   R(   ('   R   t   Falset   Truet   NoneR   t   argvt   lenR
   t   exitR   R	   R    R   t   openR   t   ReadOnlyR   t   readAllt   closeR   t   currentPatht
   setCurrentR   t   patht   proFileTagMapt   itemst   splitt
   fetchtr_pyt   currentt   absoluteFilePatht   appendR   t
   fetchtr_uiR   t   lowert   endswitht   existst
   isWritablet   suffix(   t   defaultContextR   R   t   codecForSourceR   t   uiFileNamesR   R   t   metSomethingt   numFilest   standardSyntaxt	   metTsFlagt   tr_funct   translate_funct   argt   argct   it   fullTextt   fR   t   oldDirt   keyt   valuet   fi(    (    s3   lib/python2.7/site-packages/PyQt5/pylupdate_main.pyt   mainG   sö    	
	
	

										
t   __main__(   R   t   PyQt5.QtCoreR    R   R   R   R   R   t	   pylupdateR
   R   RU   t   __name__(    (    (    s3   lib/python2.7/site-packages/PyQt5/pylupdate_main.pyt   <module>   s   .
			§