ok

Mini Shell

Direktori : /proc/thread-self/root/usr/lib/python2.7/site-packages/babel/messages/
Upload File :
Current File : //proc/thread-self/root/usr/lib/python2.7/site-packages/babel/messages/checkers.pyc

�
��Mc@s�dZddlmZddlmZmZddlmZedddg�edd	g�ed
ddd
g�gZd�Z	d�Z
d�Zd�Ze�Z
dS(sQVarious routines that help with validation of translations.

:since: version 0.9
i����(tizip(tTranslationErrort
PYTHON_FORMAT(tsettitdtutxtXtftFtgtGcCs�|js.t|jt�s*td��ndS|dkr>dS|j}t|ttf�sh|f}nt|�|j	kr�td|j	��ndS(s0Verify the number of plurals in the translation.s/Found plural forms for non-pluralizable messageNs*Wrong number of plural forms (expected %d)(
tpluralizablet
isinstancetstringt
basestringRtNonetlistttupletlentnum_plurals(tcatalogtmessagetmsgstrs((s;/usr/lib/python2.7/site-packages/babel/messages/checkers.pyRs		cCs�d|jkrdS|j}t|ttf�s=|f}n|j}t|ttf�sg|f}nx3t||�D]"\}}|rwt||�qwqwWdS(s9Verify the format string placeholders in the translation.s
python-formatN(tflagstidRRRRRt_validate_format(RRtmsgidsRtmsgidtmsgstr((s;/usr/lib/python2.7/site-packages/babel/messages/checkers.pyt
python_format3s		c	Cs�d�}d�}d�}t|||f�\}}t|||f�\}}|rt|rt|rttd��n||kr�td��n|r&t|�t|�kr�td��nx�tt||��D]M\}	\\}
}\}
}|||�s�td|	d||f��q�q�Wnut|�}
xf|D]^\}}||
krdtd	|��q9|||
|�s9td
|||
|f��q9q9WdS(s�Test format string `alternative` against `format`.  `format` can be the
    msgid of a message and `alternative` one of the `msgstr`\s.  The two
    arguments are not interchangeable as `alternative` may contain less
    placeholders if `format` uses named placeholders.

    The behavior of this function is undefined if the string does not use
    string formattings.

    If the string formatting of `alternative` is compatible to `format` the
    function returns `None`, otherwise a `TranslationError` is raised.

    Examples for compatible format strings:

    >>> _validate_format('Hello %s!', 'Hallo %s!')
    >>> _validate_format('Hello %i!', 'Hallo %d!')

    Example for an incompatible format strings:

    >>> _validate_format('Hello %(name)s!', 'Hallo %s!')
    Traceback (most recent call last):
      ...
    TranslationError: the format strings are of different kinds

    This function is used by the `python_format` checker.

    :param format: The original format string
    :param alternative: The alternative format string that should be checked
                        against format
    :return: None on success
    :raises TranslationError: on formatting errors
    cSspg}xctj|�D]R}|j�\}}}|dkrO|dkrOqn|j|t|�f�qW|S(Nt%(RtfinditertgroupsRtappendtstr(Rtresulttmatchtnametformatttypechar((s;/usr/lib/python2.7/site-packages/babel/messages/checkers.pyt_parsedscSsA||krtSx*tD]"}||kr||krtSqWtS(N(tTruet_string_format_compatibilitiestFalse(tatbR((s;/usr/lib/python2.7/site-packages/babel/messages/checkers.pyt_compatiblems
cSscd}xP|D]H\}}|dkr4|dk}q
|dk|kr
td��q
q
Wt|�S(Ns5format string mixes positional and named placeholders(RRtbool(tresultst
positionalR'tchar((s;/usr/lib/python2.7/site-packages/babel/messages/checkers.pyt_check_positionalussplaceholders are incompatibles)the format strings are of different kindss-positional format placeholders are unbalancedsDincompatible format for placeholder %d: %r and %r are not compatibleisunknown named placeholder %rsDincompatible format for placeholder %r: %r and %r are not compatibleN(tmapRRt	enumerateRtdict(R(talternativeR*R0R5R.R/ta_positionaltb_positionaltidxt_tfirsttsecondttype_mapR'R)((s;/usr/lib/python2.7/site-packages/babel/messages/checkers.pyRCs.!				4!cCsfyddlm}Wntk
r.ttgSXg}x*|jd�D]}|j|j��qEW|S(Ni����(tworking_setsbabel.checkers(t
pkg_resourcesRAtImportErrorRRtiter_entry_pointsR#tload(RAtcheckerstentry_point((s;/usr/lib/python2.7/site-packages/babel/messages/checkers.pyt_find_checkers�s
N(t__doc__t	itertoolsRtbabel.messages.catalogRRt
babel.utilRR,RRRRHRF(((s;/usr/lib/python2.7/site-packages/babel/messages/checkers.pyt<module>s			`	

Zerion Mini Shell 1.0