Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib64/python3.5/Tools/i18n/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/Tools/i18n/__pycache__/pygettext.cpython-35.pyc



��Yf�V�@s�yddlZejZWnek
r9dd�ZYnXed�ZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZdZ
dgadjt�ZdZed	�Zdd
d�Zdd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zddd�Zdd�ZGdd�d�Zd d!�Zed"kr�e�ed#�d$d%ied&�dS)'�NcCs|S)N�)�srr�9/opt/alt/python35/lib64/python3.5/Tools/i18n/pygettext.py�<lambda>srapygettext -- Python equivalent of xgettext(1)

Many systems (Solaris, Linux, Gnu) provide extensive tools that ease the
internationalization of C programs. Most of these tools are independent of
the programming language and can be used from within Python programs.
Martin von Loewis' work[1] helps considerably in this regard.

There's one problem though; xgettext is the program that scans source code
looking for message strings, but it groks only C (or C++). Python
introduces a few wrinkles, such as dual quoting characters, triple quoted
strings, and raw strings. xgettext understands none of this.

Enter pygettext, which uses Python's standard tokenize module to scan
Python source code, generating .pot files identical to what GNU xgettext[2]
generates for C and C++ code. From there, the standard GNU tools can be
used.

A word about marking Python strings as candidates for translation. GNU
xgettext recognizes the following keywords: gettext, dgettext, dcgettext,
and gettext_noop. But those can be a lot of text to include all over your
code. C and C++ have a trick: they use the C preprocessor. Most
internationalized C source includes a #define for gettext() to _() so that
what has to be written in the source is much less. Thus these are both
translatable strings:

    gettext("Translatable String")
    _("Translatable String")

Python of course has no preprocessor so this doesn't work so well.  Thus,
pygettext searches only for _() by default, but see the -k/--keyword flag
below for how to augment this.

 [1] http://www.python.org/workshops/1997-10/proceedings/loewis.html
 [2] http://www.gnu.org/software/gettext/gettext.html

NOTE: pygettext attempts to be option and feature compatible with GNU
xgettext where ever possible. However some options are still missing or are
not fully implemented. Also, xgettext's use of command line switches with
option arguments is broken, and in these cases, pygettext just defines
additional switches.

Usage: pygettext [options] inputfile ...

Options:

    -a
    --extract-all
        Extract all strings.

    -d name
    --default-domain=name
        Rename the default output file from messages.pot to name.pot.

    -E
    --escape
        Replace non-ASCII characters with octal escape sequences.

    -D
    --docstrings
        Extract module, class, method, and function docstrings.  These do
        not need to be wrapped in _() markers, and in fact cannot be for
        Python to consider them docstrings. (See also the -X option).

    -h
    --help
        Print this help message and exit.

    -k word
    --keyword=word
        Keywords to look for in addition to the default set, which are:
        %(DEFAULTKEYWORDS)s

        You can have multiple -k flags on the command line.

    -K
    --no-default-keywords
        Disable the default set of keywords (see above).  Any keywords
        explicitly added with the -k/--keyword option are still recognized.

    --no-location
        Do not write filename/lineno location comments.

    -n
    --add-location
        Write filename/lineno location comments indicating where each
        extracted string is found in the source.  These lines appear before
        each msgid.  The style of comments is controlled by the -S/--style
        option.  This is the default.

    -o filename
    --output=filename
        Rename the default output file from messages.pot to filename.  If
        filename is `-' then the output is sent to standard out.

    -p dir
    --output-dir=dir
        Output files will be placed in directory dir.

    -S stylename
    --style stylename
        Specify which style to use for location comments.  Two styles are
        supported:

        Solaris  # File: filename, line: line-number
        GNU      #: filename:line

        The style name is case insensitive.  GNU style is the default.

    -v
    --verbose
        Print the names of the files being processed.

    -V
    --version
        Print the version of pygettext and exit.

    -w columns
    --width=columns
        Set width of output to columns.

    -x filename
    --exclude-file=filename
        Specify a file that contains a list of strings that are not be
        extracted from the input files.  Each string to be excluded must
        appear on a line by itself in the file.

    -X filename
    --no-docstrings=filename
        Specify a file that contains a list of files (one per line) that
        should not have their docstrings extracted.  This is only useful in
        conjunction with the -D option above.

If `inputfile' is -, standard input is read.
z1.5�_z, �a�# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ORGANIZATION
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: %(time)s\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=%(charset)s\n"
"Content-Transfer-Encoding: %(encoding)s\n"
"Generated-By: pygettext.py %(version)s\n"

cCsDttt�dtj�|r3t|dtj�tj|�dS)N�file)�print�__doc__�globals�sys�stderr�exit)�code�msgrrr�usage�srcCs�|rd}tand}tadd�t|�D�ax'tdd�D]}t|�t|<qJWdttd�<d	ttd
�<dttd�<d
ttd�<dttd�<dS)N��cSsg|]}d|�qS)z\%03or)�.0�irrr�
<listcomp>�s	z make_escapes.<locals>.<listcomp>� �z\\�\z\t�	z\r�
z\n�
z\"�")�escape_ascii�escape�escape_nonascii�range�escapes�chr�ord)Z
pass_nonascii�modrrrr�make_escapes�s	r&cCsdjdd�|D��S)Nrcss7|]-}t|�dkr+tt|�n|VqdS)rN)r$r")r�crrr�	<genexpr>�szescape_ascii.<locals>.<genexpr>)�join)r�encodingrrrr�srcCs#djdd�|j|�D��S)Nrcss|]}t|VqdS)N)r")r�brrrr(�sz"escape_nonascii.<locals>.<genexpr>)r)�encode)rr*rrrr �sr cCst|diii�S)N�__builtins__)�eval)rrrr�	safe_eval�sr/cCs�|jd�}t|�dkr;dt||�d}nt|ds^|d=|dd|d	<x1tt|��D]}t|||�||<qqWd}d|j|�d}|S)
Nr�rz\n"
"z""
"���r1r1r1)�split�lenrr!r))rr*�linesrZlinetermrrr�	normalize�s
r5csd�fdd�|D�kS)z6Check whether 'str' contains ANY of the chars in 'set'r0csg|]}|�k�qSrr)rr')�strrrrs	zcontainsAny.<locals>.<listcomp>r)r6�setr)r6r�containsAnysr8csidt�kr,dd�tj�D�dad|krE|jd�|j�fdd�|D��dS)zHelper for getFilesForName().�_py_extcSs-g|]#}|dtjkr|d�qS)�r)�imp�	PY_SOURCE)rZtriplerrrr
s	z"_visit_pyfiles.<locals>.<listcomp>rZCVScsAg|]7}tjj|�dtkrtjj�|��qS)r0)�os�path�splitextr9r))rr)�dirnamerrrs	N)rr;Zget_suffixesr9�remove�extend)�listr@�namesr)r@r�_visit_pyfiless
rEcCs|jdd�}t|�dkr�y3tj|d|�\}}}|rV|j�Wntk
rodSYnX|dtjkr�t|d|g�}qd}nlyQtj||�\}}}|r�|j�|dtjtjgkr�d}Wntk
rd}YnX|S)z�Get the filesystem path for a module or a package.

    Return the file system path to a file for a module, and to a directory for
    a package. Return None if the name is not found, or is a builtin or
    extension module.
    �.r0rNr:)	r2r3r;�find_module�close�ImportErrorZ
PKG_DIRECTORY�_get_modpkg_pathr<)Zdotted_nameZpathlist�partsr�pathnameZdescriptionrrrrJs*
		


rJcCs�tjj|�stt|d�r^tj|�}g}x!|D]}|jt|��q=W|St|�}|stgStjj|�r�g}tj	|t
|�|Stjj|�r�|gSgS)z]Get a list of module files for a filename, a module or package name,
    or a directory.
    z*?[])r=r>�existsr8�globrB�getFilesForNamerJ�isdir�walkrE)�name�filesrCrrrrrO?s"
rOc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dddd�Z
dd�Zdd�ZdS)�
TokenEatercCsF||_i|_|j|_g|_d|_d|_d|_dS)Nr0r1)�_TokenEater__options�_TokenEater__messages�_TokenEater__waiting�_TokenEater__state�_TokenEater__data�_TokenEater__lineno�_TokenEater__freshmodule�_TokenEater__curfile)�self�optionsrrr�__init__^s					zTokenEater.__init__cCs|j|||d�dS)Nr)rX)r]�ttype�tstringZstupZetup�linerrr�__call__gszTokenEater.__call__cCs�|j}|jr�|jj|j�r�|jr�|tjkrh|jt	|�|dd�d|_n!|tj
tjfkr�d|_dS|tjkr�|dkr�|j
|_dS|tjkr�||jkr�|j|_dS)N�isdocstringr0r�class�def)rerf)rU�
docstrings�nodocstrings�getr\r[�tokenize�STRING�_TokenEater__addentryr/�COMMENT�NL�NAME�_TokenEater__suiteseenrX�keywords�_TokenEater__keywordseen)r]r`ra�lineno�optsrrrZ	__waitingns			zTokenEater.__waitingcCs+|tjkr'|dkr'|j|_dS)N�:)rj�OP�_TokenEater__suitedocstringrX)r]r`rarsrrrZ__suiteseen�szTokenEater.__suiteseencCsh|tjkr:|jt|�|dd�|j|_n*|tjtjtjfkrd|j|_dS)Nrdr0)	rjrkrlr/rWrX�NEWLINE�INDENTrm)r]r`rarsrrrZ__suitedocstring�szTokenEater.__suitedocstringcCsL|tjkr<|dkr<g|_||_|j|_n|j|_dS)N�()rjrvrYrZ�_TokenEater__openseenrXrW)r]r`rarsrrrZ
__keywordseen�s
		zTokenEater.__keywordseencCs�|tjkrL|dkrL|jr=|jtj|j��|j|_n�|tjkrt|jj	t
|��nk|tjtj
tjtjtjgkr�ttd�d|d|jd|jidtj�|j|_dS)N�)z:*** %(file)s:%(lineno)s: Seen unexpected token "%(token)s"�tokenrrs)rjrvrYrl�EMPTYSTRINGr)rWrXrk�appendr/rmr}ry�DEDENTrxrnr	rr\rZrr
)r]r`rarsrrrZ
__openseen�s		
zTokenEater.__openseenNrcCsS|dkr|j}||jjkrO|j|f}||jj|i�|<dS)N)rZrU�	toexcluder\rV�
setdefault)r]rrsrd�entryrrrZ
__addentry�s
	zTokenEater.__addentrycCs||_d|_dS)Nr0)r\r[)r]�filenamerrr�set_filename�s	zTokenEater.set_filenamec
Cs�|j}tjd�}|jr*|jnd}ttd|dtd|ddid|�i}xT|jj�D]C\}}t	|j
��}|jt|�g�j
||f�qrWt	|j
��}	x�|	D]�}
||
}|j�x�|D]�\}}t|j��}t	|j
��}|js/n|j|jkr�x�|D]8\}
}d	|
d
|i}ttd�|d|�qHWn�|j|jkr@d}x||D]t\}
}d	|
d
|i}td
�|}t|�t|�|jkr||}q�t|d|�d|}q�Wt|�dkr@t|d|�|rVtdd|�tdt||�d|�tdd|�q�Wq�WdS)Nz%Y-%m-%d %H:%M%zzUTF-8�time�version�charsetr*Z8bitrr�rsz&# File: %(filename)s, line: %(lineno)dz#:z %(filename)s:%(lineno)dr:z#, docstringZmsgidz
msgstr ""
)rUr�Zstrftimer*r	�
pot_header�__version__rV�items�sorted�keysr��tupler�sort�any�values�writelocations�
locationstyle�SOLARISr�GNUr3�widthr5)r]�fpr^Z	timestampr*�reverse�k�vr�ZrkeysZrkeyZrentriesrdr�rs�dZloclinerrrr�write�sN	)


	
zTokenEater.write)
�__name__�
__module__�__qualname__r_rcrWrprwrrr{rlr�r�rrrrrT]s	
rTc0Cs	y_tjtjdd�dddddddd	d
ddd
ddddddg�\}}Wn5tjk
r�}ztd|�WYdd}~XnXGdd�d�}|�}d|jd|ji}x{|D]s\}}|dFkr�td�q�|dGkrd|_q�|dHkr+|d|_q�|dIkrCd|_	q�|dJkr[d|_
q�|dKkrz|jj|�q�|dLkr�ga
q�|dMkr�d|_q�|dNkr�d|_q�|dOkr|j|j��|_|jdkrEtdtd-�|�q�|dPkr$||_q�|dQkr<||_q�|dRkrTd|_q�|dSkr�ttd6�t�tjd�q�|dTkr�yt|�|_WqEtk
r�tdtd9�|�YqEXq�|dUkr�||_q�|dVkr�t|�}z5x.|j�}	|	sPd|j|	ddW�<qWWd|j�Xq�Wt |j	�|jj!t
�|jr�y,t|j�}|j"�|_#|j�Wq�t$k
r�ttd>�|jd?tj%�tjd�Yq�Xn	g|_#g}
x=|D]5}|d@kr|
j|�q�|
j!t&|��q�W|
}t'|�}x;|D]3}|d@kr�|jrtttdA��tj(j)}d}
n2|jr�ttdB�|�t|dC�}d}
z�|j*|�y1t+j+|j�}x|D]}||�q�WWnht+j,k
rf}zEtdD|j-d||j-dd|j-ddfd?tj%�WYdd}~XnXWd|
r{|j�XqIW|jd@kr�tj.}d}
n?|jr�t/j0j1|j|j�|_t|jdE�}d}
z|j2|�Wd|
r|j�XdS)XNr0zad:DEhk:Kno:p:S:Vvw:x:X:zextract-allzdefault-domain=r�helpzkeyword=zno-default-keywordszadd-locationzno-locationzoutput=zoutput-dir=zstyle=�verboser�zwidth=z
exclude-file=rgz
no-docstringsc@sdeZdZdZdZdZdZgZdZdZ	dZ
eZdZdZ
dZdZiZdS)zmain.<locals>.Optionsr0r:rrzmessages.pot�NN)r�r�r�r�r��
extractallrrq�outpath�outfiler�r�r�r��excludefilenamergrhrrrr�Optionssr�Zgnu�solaris�-h�--helpr�-a�
--extract-all�-d�--default-domainz.pot�-E�--escape�-D�--docstrings�-k�	--keyword�-K�--no-default-keywords�-n�--add-location�
--no-location�-S�--stylezInvalid value for --style: %s�-o�--output�-p�--output-dir�-v�	--verbose�-V�	--versionz%pygettext.py (xgettext for Python) %s�-w�--widthz'--width argument must be an integer: %s�-x�--exclude-file�-X�--no-docstringszCan't read --exclude-file: %sr�-zReading standard inputz
Working on %s�rbz%s: %s, line %d, column %d�w)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)r�)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�r1)3�getoptr�argv�errorrr�r�r�r�rrgrqr�default_keywordsr�ri�lowerr�rr�r�r	r�r�intr��
ValueErrorr��open�readlinerhrHr&rB�	readlinesr��IOErrorr
rOrT�stdin�bufferr�rj�
TokenError�args�stdoutr=r>r)r�)rtr�rr�r^Z	locationsZopt�argr�rbZexpandedZeaterr�Zclosep�tokensZ_token�errr�main�s� 		
	
	
	

			

0!			r��__main__z%*** Seen unexpected token "%(token)s"r}ZtestZmorethanonestring) Zfintl�gettextrrIr
r=r;rrNr�r�r}rjr�r�r)ZDEFAULTKEYWORDSr~r�rr&rr r/r5r8rErJrOrTr�r�rrrr�<module>sH

�			'��