/usr/local/lib/python3.6/site-packages/jinja2/__pycache__
NameSizeModeActions
async_utils.cpython-36.pyc24350644editdlrm
bccache.cpython-36.pyc130970644editdlrm
compiler.cpython-36.pyc543690644editdlrm
constants.cpython-36.pyc14960644editdlrm
debug.cpython-36.pyc53440644editdlrm
defaults.cpython-36.pyc12410644editdlrm
environment.cpython-36.pyc523970644editdlrm
exceptions.cpython-36.pyc54980644editdlrm
ext.cpython-36.pyc262740644editdlrm
filters.cpython-36.pyc497540644editdlrm
idtracking.cpython-36.pyc111250644editdlrm
lexer.cpython-36.pyc199830644editdlrm
loaders.cpython-36.pyc202170644editdlrm
meta.cpython-36.pyc37460644editdlrm
nativetypes.cpython-36.pyc48050644editdlrm
nodes.cpython-36.pyc411930644editdlrm
optimizer.cpython-36.pyc18610644editdlrm
parser.cpython-36.pyc276350644editdlrm
runtime.cpython-36.pyc328630644editdlrm
sandbox.cpython-36.pyc116960644editdlrm
tests.cpython-36.pyc64820644editdlrm
utils.cpython-36.pyc272170644editdlrm
visitor.cpython-36.pyc38390644editdlrm
_identifier.cpython-36.pyc18500644editdlrm
__init__.cpython-36.pyc18650644editdlrm
Edit: /usr/local/lib/python3.6/site-packages/jinja2/__pycache__/ext.cpython-36.pyc (26274B)
3 ^TBgz} @sLUdZddlZddlZddlZddlZddlmZddlm Z ddlm Z ddl m Z ddl mZdd l mZdd lmZdd lmZdd lmZdd lmZddlmZejrddlZddlmZddlmZddlmZGdddejZ Gddde Z!ej"e e!fZ#d@Z$ej%e&df$ej'dZ(GdddZ)eeej*ej*ej"ej*efdd d!Z+ej,e&ge&fej,de&fd"d#d$Z-ej,e&e&e.ge&fej,de&fd"d%d&Z/ej,e&e&ge&fej,de&fd"d'd(Z0ej,e&e&e&e.ge&fej,de&fd"d)d*Z1Gd+d,d,e)Z2Gd-d.d.e)Z3Gd/d0d0e)Z4Gd1d2d2e)Z5Gd3d4d4e)Z6Gd5d6d6e)Z7e$d7fe j8ej9e&e:ej;ej%e.e&ej"ejej?ej9e&ej9e&ej@e&ej*fej;ej%e.e&ej"ejd?ZBe2ZCe3ZDe4ZEe5ZFe6ZGe7ZHdS)Az2Extension 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,/tmp/pip-build-0s3hx122/Jinja2/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$.z\s*\n\s*c @s0eZdZUdZejeddddZe Z ej e dZ e dddd Ze ddd d Zdeejeejeed d dZdejdejdfdddZdejejejejfdddZdeejeejdddZd 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). N)rcCs|jd|j|_dS)N.)rr identifier)clsrrr__init_subclass__LszExtension.__init_subclass__d) environmentrcCs ||_dS)N)r,)rr,rrr__init__YszExtension.__init__cCs,tjttj|j}|jj|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)rr7r8r9rrr preprocesscszExtension.preprocessrr)streamrcCs|S)a It'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)r8linenorcCstj|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) )r@)rExtensionAttributer()rr8r@rrrattr~s zExtension.attr)r8argskwargsdyn_args dyn_kwargsr@rcCs8|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)r@)rCallrB)rr8rCrDrErFr@rrr call_methods  zExtension.call_method)N)N)NNNNN) rrr__doc__r.ZClassVarrr(r*settagsSetpriorityrr-r6Optionalr:UnionIterabler<rNodeListr?r rArBExprKeywordrGrHrrrrr&7s(  $  @r&) __contextrCrDrcOs|j|jdf||S)Nr)callresolve)rUrCrDrrr_gettext_aliassrX)funcrcs"ttttjtdfdd }|S)N)rU__string variablesrcs$|j|}|jjrt|}||S)N)rVeval_ctx autoescaper)rUrZr[r5)rYrrrs z"_make_new_gettext..gettext)r r rr.Any)rYrr)rYr_make_new_gettexts r_cs&ttttttjtdfdd }|S)N)rU __singular__plural__numr[rcs4|jd||j|||}|jjr,t|}||S)Nnum) setdefaultrVr\r]r)rUr`rarbr[r5)rYrrrs  z$_make_new_ngettext..ngettext)r r rr r.r^)rYrr)rYr_make_new_ngettextsrecs$tttttjtdfdd }|S)N)rU __string_ctxrZr[rcs2|jd||j||}|jjr*t|}||S)Nr")rdrVr\r]r)rUrfrZr[r5)rYrrr#s  z$_make_new_pgettext..pgettext)r r rr.r^)rYr#r)rYr_make_new_pgettexts  rgc s(tttttttjtdfdd }|S)N)rUrfr`rarbr[rcsB|jd||jd||j||||}|jjr:t|}||S)Nr"rc)rdrVr\r]r)rUrfr`rarbr[r5)rYrrr$s  z&_make_new_npgettext..npgettext)r r rr r.r^)rYr$r)rYr_make_new_npgettexts rhc seZdZdZdhZeddfdd Zd%deje ddd d Z d&eje dd d d Z d'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:tj|t|jd<|j|j|j|j|j|j dddS)Nr%F)Zinstall_gettext_translationsZinstall_null_translationsZinstall_gettext_callablesZuninstall_gettext_translationsZextract_translationsnewstyle_gettext) superr-rXglobalsextend_install _install_null_install_callables _uninstall_extract)rr,)r2rrr-s  z&InternationalizationExtension.__init___SupportedTranslations) translationsnewstylercCsdt|dd}|dkr|j}t|dd}|dkr4|j}t|dd}t|dd}|j|||||ddS)NZugettextZ ungettextr#r$)rur#r$)getattrrrrp)rrtrurrr#r$rrrrns    z&InternationalizationExtension._install)rurcCsxddl}|j}t|dr"|j}ntttddd}t|drF|j}ntttttddd }|j|j|j|||d dS) Nrr#)csrcSs|S)Nr)rwrxrrrr#*sz=InternationalizationExtension._install_null..pgettextr$)rwrxprrcSs|dkr |S|S)Nrr)rwrxryrrrrr$1sz>InternationalizationExtension._install_null..npgettext)rrrur#r$) rNullTranslationshasattrr#rr$r rpr)rrurrtr#r$rrrro s  z+InternationalizationExtension._install_null)rrrur#r$rcCsb|dk r||j_|jjrHt|}t|}|dk r8t|}|dk rHt|}|jjj||||ddS)N)rrr#r$)r,rjr_rergrhrlr4)rrrrur#r$rrrrp<sz0InternationalizationExtension._install_callables)rtrcCs"xdD]}|jjj|dqWdS)Nrrr#r$)rrr#r$)r,rlpop)rrtkeyrrrrqTs z(InternationalizationExtension._uninstall.)r7gettext_functionsrcCs t|tr|jj|}t||S)N) isinstancerr,r?extract_from_ast)rr7r~rrrrrXs  z&InternationalizationExtension._extractr)r=rcCst|jj}d}d}d}i}d}x|jjjdkr:|rD|jjd|jjdrRP|jjd}|j|kr|jd|jd|jt d |jjjd krt|j|j ||j<} n8|dkr|jdkr|jd k}q$nt j |jd ||j<} |dkr$t | t jr*t j dd }|||j<t jt j dd| }n| }|jdk}q$W|jjdd} d} t} |j|d\} }| r| j| |dkrt j | dd }| ddk}|jjjdrDd} t|j|jjjdkr|jjd}|j|kr|jd|jd|jt d ||j}|jdk}|jjd|j|d\}} t|j| j|n t|jx(| D] }||krTt j |d ||<qTW| sd}n|dkr|jd||dkr|jjd}|r|j|}| r|j| } |j|| ||t| |o| }|j||dk r ||gS|SdS)zParse a translatable tag.FNZ block_endcommaZcolonr8ztranslatable variable z defined twice.)excZassigntrimmed notrimmedloadZ_transstorercTrzname:pluralizezunknown variable z for pluralizationzpluralize without variableszext.i18n.trimmed)rr)nextr;r@currenttypeexpectZskip_ifvaluefailrZparse_expressionrNamerrGZAssignrJ _parse_blockr4testr,policies_trim_whitespace _make_nodeboolZ set_lineno)rr=r@num_called_num plural_exprZplural_expr_assignmentr[rtokenvarrZ have_plural referencedZsingular_namesrZ plural_namesr8noderrrr?cs                                   z#InternationalizationExtension.parse)string_ws_rercCs|jd|jS)N )substrip)rrrrrrrsz.InternationalizationExtension._trim_whitespace)r=allow_pluralizercCs g}g}x|jjjdkr<|j|jjjjddt|jq |jjjdkrt|j|jjdj}|j||jd|d|jjdq |jjjd krt|j|jjjd rPn|jjjd r|rP|j d |j d q |jj r|j dq t dq W|t |fS)z1Parse until the next block tag with a given name.data%z%%Zvariable_beginr8z%(z)sZ variable_endZ block_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=rrbufr8rrrrs6      z*InternationalizationExtension._parse_block)rrr[rvars_referencedrrc Cs|jj}| r0| r0|jdd}|r0|jdd}|dkr`tjdd}tj|tj|ggdd} n0tjdd} tj| tj|tj||ggdd} |rxf|jD]*\} } |r| dkrq| jj tj | | qWn.tj | } |rtj | tj dd |jD} tj| gS) z/Generates a useful node from the data provided.z%%rNrrrrccSs"g|]\}}tjtj||qSr)rZPairConst).0r}rrrr 7sz.)r,rjrrrrGritemsrDrrTZMarkSafeIfAutoescapeZModDictOutput) rrrr[rrrrurrrr}rrrrrs8        z(InternationalizationExtension._make_node)N)N)NNN)%rrrrIrKrr-r.rNrrnroCallablerr rprqGETTEXT_FUNCTIONSrOrTemplateSequenceIteratorTuplerrrQrRr?rPatternrrrrSrr __classcell__rr)r2rris2   Z<$s% ric@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}|j|_|S)N)r@)rExprStmtrr;r@Z parse_tupler)rr=rrrrr?Fs zExprStmtExtension.parseN)rrrrIrKrrr?rrrrr?src@s6eZdZdZddhZdejejej fdddZ dS) LoopControlExtensionz/Adds break and continue to the template engine.breakcontinuer)r=rcCs0t|j}|jdkr"tj|jdStj|jdS)Nr)r@)rr;rrBreakr@Continue)rr=rrrrr?Qs  zLoopControlExtension.parseN) rrrrIrKr.rOrrrr?rrrrrLsrcs$eZdZeddfdd ZZS) WithExtensionN)r,rcs tj|tjdtdddS)NzZThe 'with' extension is deprecated and will be removed in Jinja 3.1. This is built in now.) stacklevel)rkr-warningswarnDeprecationWarning)rr,)r2rrr-Ys  zWithExtension.__init__)rrrrr-rrr)r2rrXsrcs$eZdZeddfdd ZZS)AutoEscapeExtensionN)r,rcs tj|tjdtdddS)Nz`The 'autoescape' extension is deprecated and will be removed in Jinja 3.1. This is built in now.r)r)rkr-rrr)rr,)r2rrr-ds  zAutoEscapeExtension.__init__)rrrrr-rrr)r2rrcsrc@s8eZdZdZdhZdejdddZee ddd Z d S) DebugExtensionaA ``{% debug %}`` tag that dumps the available variables, filters, and tests. .. code-block:: html+jinja
{% debug %}
.. code-block:: text {'context': {'cycler': , ..., '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|jjdj}tj}|jd|g|d}tj|g|dS)Nz name:debug_render)r@)r;rr@rZContextReferencerHr)rr=r@r"resultrrrr?szDebugExtension.parse)r"rcCs8|jt|jjjt|jjjd}tj|dddS)N)r"filterstestsrT)depthcompact)get_allsortedr,rkeysrpprintpformat)rr"rrrrrszDebugExtension._renderN) rrrrIrKrrr?r rrrrrrrnsrT)astr~ babel_stylerccsx|jtjD]}t|jtj s|jj|kr2qg}x>|jD]4}t|tjrht|j t rh|j |j q>|j dq>Wx|j D]}|j dq~W|j dk r|j d|jdk r|j 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 sz#extract_from_ast..rr)Zfind_allrrGrrrr8rCrrrrrDrErFtuplelenr@)rr~rrstringsargr%outrrrrs.+         rc@sfeZdZdZejejeeefejeddddZ eej edddZ eej ed d d Z 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)rroffset last_lineno)rrrrrrr-sz_CommentFinder.__init__)rrcCs~zpxjt|j|j|D]R\}}}|dkry|jdd\}}Wntk rTwYnX||jkr|jgSqWgS||_XdS)Ncomment linecommentr)rr)reversedrrsplit ValueErrorrrstrip)rrr% token_typeZ token_valueprefixrrrrfind_backwardss z_CommentFinder.find_backwards)r@rcCsf|j s|j|krgSx>t|j|jdD]&\}\}}}||kr,|j|j|Sq,W|jt|jS)N)rr enumeraterrrr)rr@idxZ token_linenor%rrr find_commentss $z_CommentFinder.find_comments) rrrrIr.rrr rr-rRrrrrrrrs r)fileobjkeywordsroptionsrccsi}x4|jddjdD]}|j}|s*qd|t|<qWt|krJd|t<dtjttftttddd}||d d }t |jd t j |jd t j |jd t j |jdt j|jdt j|jdt j|jdpt j|jdpt j||dt j||dt jt j||dt jt|ddd}||dr*d |jd<||drrrrr)getrlower)rr}rrrrgetbool?szbabel_extract..getboolsilentTZblock_start_stringZblock_end_stringZvariable_start_stringZvariable_end_stringZcomment_start_stringZcomment_end_stringZline_statement_prefixZline_comment_prefixZ trim_blocksZ lstrip_blocksZkeep_trailing_newliner)Z cache_sizeZ auto_reloadrzext.i18n.trimmedrjencodingzutf-8)F)$rrrr rir.MappingrrrrZBLOCK_START_STRINGZBLOCK_END_STRINGZVARIABLE_START_STRINGZVARIABLE_END_STRINGZCOMMENT_START_STRINGZCOMMENT_END_STRINGZLINE_STATEMENT_PREFIXZLINE_COMMENT_PREFIXZ TRIM_BLOCKSZ LSTRIP_BLOCKSZNEWLINE_SEQUENCEZKEEP_TRAILING_NEWLINErrrjreaddecoder?listlexr:rrrr)rrrrrZextension_namerrr,r7rrfinderr@rYrrrr babel_extract sR%                r)r%rrr#r$)IrIrreZtypingr.rZ markupsaferrrrr,r exceptionsrrZruntimer r r utilsr r Z TYPE_CHECKINGZtyping_extensionstelexerrrr=rZProtocolrr!rOrsrrrcompilerr&r^rXrr_r rergrhrirrrrrrrrrrNrrZBinaryIOrrRrZi18nrZ loopcontrolsZwith_r]rrrrrs               m &*(K    *