File "ext.cpython-37.pyc"

Full Path: /home/attunedd/public_html/byp/izo/con7ext_sym404/rintoar.txt/opt/alt/python37/lib/python3.7/site-packages/jinja2/__pycache__/ext.cpython-37.pyc
File size: 25.63 KB
MIME-type: text/x-bytecode.python
Charset: 8 bit

B

˝`z}
@sPUdZddlZddlZddlZddlZddlmZddlm	Z	ddlm
Z
ddlmZddl
mZdd	l
mZdd
lmZddlmZddlmZdd
lmZddlmZejrddlZddlmZddlmZddlmZGdddejZ Gddde Z!ej"e e!fZ#dZ$ej%e&dfe'd<e(dZ)GdddZ*eeej+ej+ej"ej+efdddZ,ej-e&ge&fej-de&fdd d!Z.ej-e&e&e/ge&fej-de&fdd"d#Z0ej-e&e&ge&fej-de&fdd$d%Z1ej-e&e&e&e/ge&fej-de&fdd&d'Z2Gd(d)d)e*Z3Gd*d+d+e*Z4Gd,d-d-e*Z5Gd.d/d/e*Z6Gd0d1d1e*Z7Gd2d3d3e*Z8e$d4fe
j9ej:e&e;ej<ej%e/e&ej"ej=e&ej%ej=e&dfffd5d6d7Z>Gd8d9d9Z?ej@ej:e&ej:e&ejAe&ej+fej<ej%e/e&ej"ej=e&ej%ej=e&dffejBe&fd:d;d<ZCe3ZDe4ZEe5ZFe6ZGe7ZHe8ZIdS)=z2Extension API for adding custom tags and behavior.N)Markup)defaults)nodes)Environment)TemplateAssertionError)TemplateSyntaxError)concat)Context)	Undefined)
import_string)pass_context)Token)TokenStream)Parserc@s0eZdZeedddZeeeedddZdS)_TranslationsBasic)messagereturncCsdS)N)selfrrr;/opt/alt/python37/lib/python3.7/site-packages/jinja2/ext.pygettextsz_TranslationsBasic.gettext)singularpluralnrcCsdS)Nr)rrrrrrrngettextsz_TranslationsBasic.ngettextN)__name__
__module____qualname__strrintrrrrrrsrc@s4eZdZeeedddZeeeeedddZdS)_TranslationsContext)contextrrcCsdS)Nr)rr"rrrrpgettext"sz_TranslationsContext.pgettext)r"rrrrcCsdS)Nr)rr"rrrrrr	npgettext%sz_TranslationsContext.npgettextN)rrrrr#r r$rrrrr!!sr!)_rrr#r$.GETTEXT_FUNCTIONSz\s*\n\s*c	@s8eZdZUdZejeed<ddddZe	Z
ejeed<dZe
dd	d
dZe
dd	dd
Zd eejeejeedddZdejdejdfdddZdejejejejfdddZd!eejeejdddZd"eejejejejejejejejejejejeejdddZdS)#	ExtensionagExtensions can be used to add extra functionality to the Jinja template
    system at the parser level.  Custom extensions are bound to an environment
    but may not store environment specific data on `self`.  The reason for
    this is that an extension can be bound to another environment (for
    overlays) by creating a copy and reassigning the `environment` attribute.

    As extensions are created by the environment they cannot accept any
    arguments for configuration.  One may want to work around that by using
    a factory function, but that is not possible as extensions are identified
    by their import name.  The correct way to configure the extension is
    storing the configuration values on the environment.  Because this way the
    environment ends up acting as central configuration storage the
    attributes may clash which is why extensions have to ensure that the names
    they choose for configuration are not too generic.  ``prefix`` for example
    is a terrible name, ``fragment_cache_prefix`` on the other hand is a good
    name as includes the name of the extension (fragment cache).
    
identifierN)rcCs|jd|j|_dS)N.)rrr()clsrrr__init_subclass__LszExtension.__init_subclass__tagsd)environmentrcCs
||_dS)N)r.)rr.rrr__init__YszExtension.__init__cCs,ttt|j}|j|j||_|S)z=Create a copy of this extension bound to another environment.)	tcastr'object__new__	__class____dict__updater.)rr.rvrrrbind\szExtension.bind)sourcenamefilenamercCs|S)zThis method is called before the actual lexing and can be used to
        preprocess the source.  The `filename` is optional.  The return value
        must be the preprocessed source.
        r)rr9r:r;rrr
preprocesscszExtension.preprocessrr)streamrcCs|S)aIt's passed a :class:`~jinja2.lexer.TokenStream` that can be used
        to filter tokens returned.  This method has to return an iterable of
        :class:`~jinja2.lexer.Token`\s, but it doesn't have to return a
        :class:`~jinja2.lexer.TokenStream`.
        r)rr=rrr
filter_streamlszExtension.filter_streamr)parserrcCs
tdS)aIf any of the :attr:`tags` matched this method is called with the
        parser as first argument.  The token the parser stream is pointing at
        is the name token that matched.  This method has to return one or a
        list of multiple nodes.
        N)NotImplementedError)rr?rrrparsevszExtension.parse)r:linenorcCstj|j||dS)zReturn an attribute node for the current extension.  This is useful
        to pass constants on extensions to generated template code.

        ::

            self.attr('_my_attribute', lineno=lineno)
        )rB)rExtensionAttributer()rr:rBrrrattr~s
zExtension.attr)r:argskwargsdyn_args
dyn_kwargsrBrcCs8|dkrg}|dkrg}tj|j||d|||||dS)zsCall a method of the extension.  This is a shortcut for
        :meth:`attr` + :class:`jinja2.nodes.Call`.
        N)rB)rCallrD)rr:rErFrGrHrBrrrcall_methodszExtension.call_method)N)N)NNNNN) rrr__doc__r0ClassVarr__annotations__r+setr,Setpriorityrr/r8Optionalr<UnionIterabler>rNodeListrAr rCrDExprKeywordrIrJrrrrr'7s(
$	
@r')	__contextrErFrcOs|j|df||S)Nr)callresolve)rXrErFrrr_gettext_aliassr[)funcrcs"ttttjtdfdd}|S)N)rX__string	variablesrcs$||}|jjrt|}||S)N)rYeval_ctx
autoescaper)rXr]r^r7)r\rrrsz"_make_new_gettext.<locals>.gettext)r
r
rr0Any)r\rr)r\r_make_new_gettexts	rbcs&ttttttjtdfdd}|S)N)rX
__singular__plural__numr^rcs4|d|||||}|jjr,t|}||S)Nnum)
setdefaultrYr_r`r)rXrcrdrer^r7)r\rrrs
z$_make_new_ngettext.<locals>.ngettext)r
r
rr r0ra)r\rr)r\r_make_new_ngettextsrhcs$tttttjtdfdd}|S)N)rX__string_ctxr]r^rcs2|d||||}|jjr*t|}||S)Nr")rgrYr_r`r)rXrir]r^r7)r\rrr#s
z$_make_new_pgettext.<locals>.pgettext)r
r
rr0ra)r\r#r)r\r_make_new_pgettexts

rjc	s(tttttttjtdfdd}|S)N)rXrircrdrer^rcsB|d||d||||||}|jjr:t|}||S)Nr"rf)rgrYr_r`r)rXrircrdrer^r7)r\rrr$s	z&_make_new_npgettext.<locals>.npgettext)r
r
rr r0ra)r\r$r)r\r_make_new_npgettextsrkcseZdZdZdhZeddfddZd%deje	ddd	d
Z
d&eje	dddd
Zd'eje
ge
feje
e
ege
feje	ejeje
e
ge
fejeje
e
e
ege
fddddZdddddZefeje
ejfeje
ejejee
ejeje
ejeje
dfffdddZdejejejejfdddZefe
eje
e
dddZde	ejeje
e
fdd d!Ze
eje
ej e
ej!fejej!e	e	ej"d"d#d$Z#Z$S)(InternationalizationExtensionz-This extension adds gettext support to Jinja.ZtransN)r.rcs:t|t|jd<|j|j|j|j|j|j	dddS)Nr%F)Zinstall_gettext_translationsZinstall_null_translationsZinstall_gettext_callablesZuninstall_gettext_translationsZextract_translationsnewstyle_gettext)
superr/r[globalsextend_install
_install_null_install_callables
_uninstall_extract)rr.)r4rrr/s
z&InternationalizationExtension.__init___SupportedTranslations)translationsnewstylercCsdt|dd}|dkr|j}t|dd}|dkr4|j}t|dd}t|dd}|j|||||ddS)NZugettextZ	ungettextr#r$)rxr#r$)getattrrrrs)rrwrxrrr#r$rrrrqsz&InternationalizationExtension._install)rxrcCsxddl}|}t|dr"|j}ntttddd}t|drF|j}ntttttddd	}|j|j|j|||d
dS)Nrr#)csrcSs|S)Nr)rzr{rrrr#*sz=InternationalizationExtension._install_null.<locals>.pgettextr$)rzr{prrcSs|dkr|S|S)Nrr)rzr{r|rrrrr$1sz>InternationalizationExtension._install_null.<locals>.npgettext)rrrxr#r$)	rNullTranslationshasattrr#rr$r rsr)rrxrrwr#r$rrrrr s

z+InternationalizationExtension._install_null)rrrxr#r$rcCsb|dk	r||j_|jjrHt|}t|}|dk	r8t|}|dk	rHt|}|jjj||||ddS)N)rrr#r$)r.rmrbrhrjrkror6)rrrrxr#r$rrrrs<sz0InternationalizationExtension._install_callables)rwrcCs"xdD]}|jj|dqWdS)N)rrr#r$)r.ropop)rrwkeyrrrrtTs
z(InternationalizationExtension._uninstall.)r9gettext_functionsrcCs t|tr|j|}t||S)N)
isinstancerr.rAextract_from_ast)rr9rrrrruXs
z&InternationalizationExtension._extractr)r?rcCst|jj}d}d}d}i}d}x|jjjdkr:|rD|jd|jdrRP|jd}|j|kr|jd|jd|jt	d	|jjjd
krt|j|
||j<}	n8|dkr|jdkr|jdk}q$nt|jd
||j<}	|dkr$t
|	tjr*tdd
}|||j<ttdd|	}n|	}|jdk}q$W|jdd}
d}t}||d\}
}|
r||
|dkrt|
dd
}|
ddk}|jjdrDd}t|j|jjjdkr|jd}|j|kr|jd|jd|jt	d	||j}|jdk}|jd||d\}}
t|j||n
t|jx(|D] }||krTt|d
||<qTW|sd}n|dkr|d||dkr|jjd}|r||}|
r||
}
|||
||t||o|}|||dk	r
||gS|SdS)zParse a translatable tag.FNZ	block_endZcommacolonr:ztranslatable variable z defined twice.)excZassign)trimmedZ	notrimmedrloadZ_transstorerfTrzname:pluralizezunknown variable z for pluralizationzpluralize without variableszext.i18n.trimmed)nextr=rBcurrenttypeexpectZskip_ifvaluefailrZparse_expressionrNamerrIAssignrN_parse_blockr6testr.policies_trim_whitespace
_make_nodeboolZ
set_lineno)rr?rBnum_called_numplural_exprZplural_expr_assignmentr^rtokenvarrZhave_plural
referencedZsingular_namesrZplural_namesr:noderrrrAcs


















z#InternationalizationExtension.parse)string_ws_rercCs|d|S)N )substrip)rrrrrrrsz.InternationalizationExtension._trim_whitespace)r?allow_pluralizercCsg}g}x|jjjdkr<||jjjddt|jq
|jjjdkrt|j|jdj}|||d|d|jdq
|jjjd	krt|j|jjd
rPn|jjdr|rP|	d|	d
q
|jj
r|	dq
tdq
W|t|fS)z1Parse until the next block tag with a given name.data%z%%Zvariable_beginr:z%(z)sZvariable_endZblock_beginz
name:endtranszname:pluralizez:a translatable section can have only one pluralize sectionz;control structures in translatable sections are not allowedzunclosed translation blockzinternal parser error)
r=rrappendrreplacerrrrZeosRuntimeErrorr	)rr?rrbufr:rrrrs6


z*InternationalizationExtension._parse_block)rrr^rvars_referencedrrc
Cs|jj}|s,|s,|dd}|r,|dd}|dkr\tdd}t|t|ggdd}	n0tdd}
t|
t|t||ggdd}	|rxf|D]*\}}|r|dkrq|	j	t
||qWn.t|	}	|rt|	t
dd	|D}	t|	gS)
z/Generates a useful node from the data provided.z%%rNrrrrfcSs"g|]\}}tt||qSr)rZPairConst).0rrrrr
<listcomp>7sz<InternationalizationExtension._make_node.<locals>.<listcomp>)r.rmrrrrIritemsrFrrWZMarkSafeIfAutoescapeModDictOutput)
rrrr^rrrrxrrrrrrrrrs8

z(InternationalizationExtension._make_node)N)N)NNN)%rrrrKr,rr/r0rQrrqrrCallablerr rsrtr&rRrTemplateSequenceIteratorTuplerurTrUrArPatternrrrrVrr
__classcell__rr)r4rrls2	
 Z<$s%
rlc@s(eZdZdZdhZdejdddZdS)ExprStmtExtensionzrAdds a `do` tag to Jinja that works like the print statement just
    that it doesn't print the return value.
    dor)r?rcCs"tjt|jjd}||_|S)N)rB)rExprStmtrr=rBZparse_tupler)rr?rrrrrAFs
zExprStmtExtension.parseN)rrrrKr,rrrArrrrr?src@s6eZdZdZddhZdejejej	fdddZ
dS)	LoopControlExtensionz/Adds break and continue to the template engine.breakcontinuer)r?rcCs0t|j}|jdkr"tj|jdStj|jdS)Nr)rB)rr=rrBreakrBContinue)rr?rrrrrAQs

zLoopControlExtension.parseN)rrrrKr,r0rRrrrrArrrrrLsrcs$eZdZeddfddZZS)
WithExtensionN)r.rcs t|tjdtdddS)NzZThe 'with' extension is deprecated and will be removed in Jinja 3.1. This is built in now.)
stacklevel)rnr/warningswarnDeprecationWarning)rr.)r4rrr/Ys
zWithExtension.__init__)rrrrr/rrr)r4rrXsrcs$eZdZeddfddZZS)AutoEscapeExtensionN)r.rcs t|tjdtdddS)Nz`The 'autoescape' extension is deprecated and will be removed in Jinja 3.1. This is built in now.r)r)rnr/rrr)rr.)r4rrr/ds
zAutoEscapeExtension.__init__)rrrrr/rrr)r4rrcsrc@s8eZdZdZdhZdejdddZee	ddd	Z
d
S)DebugExtensionaA ``{% debug %}`` tag that dumps the available variables,
    filters, and tests.

    .. code-block:: html+jinja

        <pre>{% debug %}</pre>

    .. code-block:: text

        {'context': {'cycler': <class 'jinja2.utils.Cycler'>,
                     ...,
                     'namespace': <class 'jinja2.utils.Namespace'>},
         'filters': ['abs', 'attr', 'batch', 'capitalize', 'center', 'count', 'd',
                     ..., 'urlencode', 'urlize', 'wordcount', 'wordwrap', 'xmlattr'],
         'tests': ['!=', '<', '<=', '==', '>', '>=', 'callable', 'defined',
                   ..., 'odd', 'sameas', 'sequence', 'string', 'undefined', 'upper']}

    .. versionadded:: 2.11.0
    debugr)r?rcCs8|jdj}t}|jd|g|d}tj|g|dS)Nz
name:debug_render)rB)r=rrBrZContextReferencerJr)rr?rBr"resultrrrrAszDebugExtension.parse)r"rcCs8|t|jjt|jjd}tj|dddS)N)r"filterstestsrT)depthcompact)get_allsortedr.rkeysrpprintpformat)rr"rrrrrszDebugExtension._renderN)rrrrKr,rrrAr
rrrrrrrnsrT)astrbabel_stylerccsx|tjD]}t|jtjr|jj|kr0qg}x>|jD]4}t|tjrft|j	t
rf||j	q<|dq<Wx|jD]}|dq|W|j
dk	r|d|jdk	r|d|stdd|D}|sqnt|dkr|d}nt|}|j|jj|fVqWdS)aExtract localizable strings from the given template node.  Per
    default this function returns matches in babel style that means non string
    parameters as well as keyword arguments are returned as `None`.  This
    allows Babel to figure out what you really meant if you are using
    gettext functions that allow keyword arguments for placeholder expansion.
    If you don't want that behavior set the `babel_style` parameter to `False`
    which causes only strings to be returned and parameters are always stored
    in tuples.  As a consequence invalid gettext calls (calls without a single
    string parameter or string parameters after non-string parameters) are
    skipped.

    This example explains the behavior:

    >>> from jinja2 import Environment
    >>> env = Environment()
    >>> node = env.parse('{{ (_("foo"), _(), ngettext("foo", "bar", 42)) }}')
    >>> list(extract_from_ast(node))
    [(1, '_', 'foo'), (1, '_', ()), (1, 'ngettext', ('foo', 'bar', None))]
    >>> list(extract_from_ast(node, babel_style=False))
    [(1, '_', ('foo',)), (1, 'ngettext', ('foo', 'bar'))]

    For every string found this function yields a ``(lineno, function,
    message)`` tuple, where:

    * ``lineno`` is the number of the line on which the string was found,
    * ``function`` is the name of the ``gettext`` function used (if the
      string was extracted from embedded Python code), and
    *   ``message`` is the string, or a tuple of strings for functions
         with multiple string arguments.

    This extraction function operates on the AST and is because of that unable
    to extract any comments.  For comment support you have to use the babel
    extraction interface or extract comments yourself.
    Ncss|]}|dk	r|VqdS)Nr)rxrrr	<genexpr>sz#extract_from_ast.<locals>.<genexpr>rr)Zfind_allrrIrrrr:rErrrrrFrGrHtuplelenrB)rrrrstringsargr%outrrrrs.+




rc@sfeZdZdZejejeeefejeddddZ	eej
edddZeej
ed	d
dZdS)_CommentFinderzHelper class to find comments in a token stream.  Can only
    find comments for gettext calls forwards.  Once the comment
    from line 4 is found, a comment for line 1 will not return a
    usable value.
    N)tokenscomment_tagsrcCs||_||_d|_d|_dS)Nr)rroffsetlast_lineno)rrrrrrr/sz_CommentFinder.__init__)rrc	Cs~zpxjt|j|j|D]R\}}}|dkry|dd\}}Wntk
rTwYnX||jkr|gSqWgS||_XdS)N)commentZlinecommentr)reversedrrsplit
ValueErrorrrstrip)rrr%
token_typeZtoken_valueprefixrrrrfind_backwardss
z_CommentFinder.find_backwards)rBrcCsd|jr|j|krgSx>t|j|jdD]&\}\}}}||kr*||j|Sq*W|t|jS)N)rr	enumeraterrrr)rrBidxZtoken_linenor%rrr
find_commentss$z_CommentFinder.find_comments)
rrrrKr0rrr rr/rUrrrrrrrs
r)fileobjkeywordsroptionsrccsi}x4|dddD]}|}|s*qd|t|<qWt|krJd|t<dtjttftttddd}||d	d
}t	|dt
j|dt
j|d
t
j
|dt
j|dt
j|dt
j|dpt
j|dpt
j||dt
j||dt
jt
j||dt
jt|ddd}||dr*d
|jd<||dr<d
|_||dd}	y"||	}
t|||	}Wnt k
r|sdSXt!||}x.t"|
|D] \}
}}|
|||#|
fVqWdS)aBabel extraction method for Jinja templates.

    .. versionchanged:: 2.3
       Basic support for translation comments was added.  If `comment_tags`
       is now set to a list of keywords for extraction, the extractor will
       try to find the best preceding comment that begins with one of the
       keywords.  For best results, make sure to not have more than one
       gettext call in one line of code and the matching comment in the
       same line or the line before.

    .. versionchanged:: 2.5.1
       The `newstyle_gettext` flag can be set to `True` to enable newstyle
       gettext calls.

    .. versionchanged:: 2.7
       A `silent` option can now be provided.  If set to `False` template
       syntax errors are propagated instead of being ignored.

    :param fileobj: the file-like object the messages should be extracted from
    :param keywords: a list of keywords (i.e. function names) that should be
                     recognized as translation functions
    :param comment_tags: a list of translator tags to search for and include
                         in the results.
    :param options: a dictionary of additional options (optional)
    :return: an iterator over ``(lineno, funcname, message, comments)`` tuples.
             (comments will be empty currently)
    
extensions,NF)rrdefaultrcSs||t|dkS)N>1onyestrue)getrlower)rrrrrrgetbool?szbabel_extract.<locals>.getboolsilentTZblock_start_stringZblock_end_stringZvariable_start_stringZvariable_end_stringZcomment_start_stringZcomment_end_stringZline_statement_prefixZline_comment_prefixZtrim_blocksZ
lstrip_blocksZkeep_trailing_newliner)Z
cache_sizeZauto_reloadrzext.i18n.trimmedrmencodingzutf-8)F)$rrrrrlr0MappingrrrrZBLOCK_START_STRINGZBLOCK_END_STRINGZVARIABLE_START_STRINGZVARIABLE_END_STRINGZCOMMENT_START_STRINGZCOMMENT_END_STRINGZLINE_STATEMENT_PREFIXZLINE_COMMENT_PREFIXZTRIM_BLOCKSZ
LSTRIP_BLOCKSZNEWLINE_SEQUENCEZKEEP_TRAILING_NEWLINErrrmreaddecoderAlistZlexr<rrrr)rrrrrZextension_namerrr.r9rrfinderrBr\rrrr
babel_extract
sR% 


r)JrKrretypingr0rZ
markupsaferrrrr.r
exceptionsrrZruntimer	r
rutilsrr

TYPE_CHECKINGZtyping_extensionsteZlexerrrr?rZProtocolrr!rRrvr&rrrMcompilerr'rar[rrbr rhrjrkrlrrrrrrrrrrQrrBinaryIOrrUri18nrZloopcontrolsZwith_r`rrrrr<module>sx
m
&*(K
*<J)@V