ÿØÿàJFIFÿþ ÿÛC       ÿÛC ÿÀÿÄÿÄ"#QrÿÄÿÄ&1!A"2qQaáÿÚ ?Øy,æ/3JæÝ¹È߲؋5êXw²±ÉyˆR”¾I0ó2—PI¾IÌÚiMö¯–þrìN&"KgX:Šíµ•nTJnLK„…@!‰-ý ùúmë;ºgµŒ&ó±hw’¯Õ@”Ü— 9ñ-ë.²1<yà‚¹ïQÐU„ہ?.’¦èûbß±©Ö«Âw*VŒ) `$‰bØÔŸ’ëXÖ-ËTÜíGÚ3ð«g Ÿ§¯—Jx„–’U/ÂÅv_s(Hÿ@TñJÑãõçn­‚!ÈgfbÓc­:él[ðQe 9ÀPLbÃãCµm[5¿ç'ªjglå‡Ûí_§Úõl-;"PkÞÞÁQâ¼_Ñ^¢SŸx?"¸¦ùY騐ÒOÈ q’`~~ÚtËU¹CڒêV  I1Áß_ÿÙ fc@stdZddlZddlZddlZddlmZddlmZddlm Z ddl m Z ddl mZmZmZmZedd1id d 6ZeZd jZd ejd kZdZdZdZdZdZdZdZ e!dZ"ddZ#dZ$e!dZ%ddddZ'de(dddZ)de!d Z*d!e+fd"YZ,y!dd#lm-Z-e-j.e,Wne/k rnXd2d3e(e!d'Z0dd(Z1ed)e+fd*YZ2d+e+fd,YZ3d-e+fd.YZ4yd/dUe(Z5Wne6k rSe!Z5nXdd0l7m8Z8m9Z9m:Z:dS(4s jinja2.utils ~~~~~~~~~~~~ Utility functions. :copyright: (c) 2017 by the Jinja Team. :license: BSD, see LICENSE for more details. iN(tdeque(t ascii_letters(tdigits(tLock(t text_typet string_typestimplements_iteratort url_quotet MissingTypecCsdS(Ntmissing((tx((s0/usr/lib/python2.7/site-packages/jinja2/utils.pyttt__repr__us\/t/cCs t|_|S(s+This decorator can be used to mark a function or method context callable. A context callable is passed the active :class:`Context` as first argument when called from the template. This is useful if a function wants to get access to the context or functions provided on the context object. For example a function that returns a sorted list of template variables the current template exports could look like this:: @contextfunction def get_exported_names(context): return sorted(context.exported_vars) (tTruetcontextfunction(tf((s0/usr/lib/python2.7/site-packages/jinja2/utils.pyR s cCs t|_|S(sGThis decorator can be used to mark a function or method as an eval context callable. This is similar to the :func:`contextfunction` but instead of passing the context, an evaluation context object is passed. For more information about the eval context, see :ref:`eval-context`. .. versionadded:: 2.4 (Rtevalcontextfunction(R((s0/usr/lib/python2.7/site-packages/jinja2/utils.pyR0s cCs t|_|S(sThis decorator can be used to mark a function or method as environment callable. This decorator works exactly like the :func:`contextfunction` decorator just that the first argument is the active :class:`Environment` and not context. (Rtenvironmentfunction(R((s0/usr/lib/python2.7/site-packages/jinja2/utils.pyR=s cCstj|j|S(s%Marks the function as internally used(t internal_codetaddt__code__(R((s0/usr/lib/python2.7/site-packages/jinja2/utils.pyt internalcodeGscCsddlm}t||S(sCheck if the object passed is undefined. This does nothing more than performing an instance check against :class:`Undefined` but looks nicer. This can be used for custom filters or tests that want to react to undefined variables. For example a custom default filter can look like this:: def default(var, default=''): if is_undefined(var): return default return var i(t Undefined(tjinja2.runtimeRt isinstance(tobjR((s0/usr/lib/python2.7/site-packages/jinja2/utils.pyt is_undefinedMs cCsx|D]}qWdS(s4Consumes an iterable without doing anything with it.N((titerabletevent((s0/usr/lib/python2.7/site-packages/jinja2/utils.pytconsume]s cCs8ddlm}ddlm}|j|jdS(s"Jinja2 keeps internal caches for environments and lexers. These are used so that Jinja2 doesn't have to recreate environments and lexers all the time. Normally you don't have to care about that but if you are measuring memory consumption you may want to clean the caches. i(t_spontaneous_environments(t _lexer_cacheN(tjinja2.environmentR t jinja2.lexerR!tclear(R R!((s0/usr/lib/python2.7/site-packages/jinja2/utils.pyt clear_cachescs cCsyd|kr*|jdd\}}nEd|kre|jd}dj|d }|d}n t|Stt|dd|g|SWn#ttfk r|sqnXdS(sImports an object based on a string. This is useful if you want to use import paths as endpoints or something similar. An import path can be specified either in dotted notation (``xml.sax.saxutils.escape``) or with a colon as object delimiter (``xml.sax.saxutils:escape``). If the `silent` is True the return value will be `None` if the import fails. :return: imported object t:it.iN(tsplittjoint __import__tgetattrtNonet ImportErrortAttributeError(t import_nametsilenttmoduleRtitems((s0/usr/lib/python2.7/site-packages/jinja2/utils.pyt import_stringos     #trbcCsRyt||SWn:tk rM}|jtjtjtjfkrNqNnXdS(sZReturns a file descriptor for the filename if that file exists, otherwise `None`. N(topentIOErrorterrnotENOENTtEISDIRtEINVAL(tfilenametmodete((s0/usr/lib/python2.7/site-packages/jinja2/utils.pytopen_if_existss !cCsc|dkrdS|tkr dS|jjdkrA|jj}n|jjd|jj}d|S( sReturns the name of the object's type. For some recognized singletons the name of the object is returned instead. (For example for `None` and `Ellipsis`). R,tEllipsist __builtin__tbuiltinsR's %s objectN(R@RA(R,R?t __class__t __module__t__name__(Rtname((s0/usr/lib/python2.7/site-packages/jinja2/utils.pytobject_type_reprs  cCsSy$ddlm}||d|SWn(tk rNddlm}||SXdS(sYPrettyprint an object. Either use the `pretty` library or the builtin `pprint`. i(tprettytverbose(tpformatN(RGR-tpprintRI(RRHRGRI((s0/usr/lib/python2.7/site-packages/jinja2/utils.pyRIs  cCso|d}tjdtt|}|rFdtt|pId}|rbdt|ped}xt|D]\}} d| d} } } tjd| } | r| j} | | j} n| jdrtj d | } | r| j} | | j } qn| j dsd| kr| j d r| j d rt | dkr| dt tkr| jds| jds| jdrd| |||| f} n| j ds| j drd| |||| f} nd| krL| j d rLd| krLtjd| rLd| | f} n| | | ||R't,s s>s([)>.,\n]|>)+$swww.t@shttp://shttps://is.orgs.nets.coms%ss%sR&s^\S@\w[\w.-]*\.\w$s%su(RMRNR'ROs s>(treR(Rtescapet enumeratetmatchtgrouptendtendswithtsearchtstartt startswithRKt_letterst_digitsR)(ttextttrim_url_limittrelttargetttrim_urltwordstrel_attrt target_attrtitwordtheadtmiddlettailRT((s0/usr/lib/python2.7/site-packages/jinja2/utils.pyturlizesT "     iiidcCsddlm}ddlm}m}|j}g}x}t|D]o} t} d} } d} d}g}xt t|||D]\}} x,tr||} | |kr| }PqqW| r| j } t } n||dd| kr|} | d7} | d7} n||d d | krK|} } | d 7} t} n|j | qWd j |}|jdr|d d }n|jd s|d 7}n|j |qEW|sd j |Stdj d|DS(s+Generate some lorem ipsum for the template.i(tLOREM_IPSUM_WORDS(tchoicet randrangeiiiiROi iR'u u u css|]}dt|VqdS(u

%s

N(RR(t.0R ((s0/usr/lib/python2.7/site-packages/jinja2/utils.pys .sN(tjinja2.constantsRktrandomRlRmR(trangeRR,RSt capitalizetFalsetappendR)RWtMarkup(tnthtmltmintmaxRkRlRmRbtresultt_tnext_capitalizedt last_commat last_fullstopRftlasttptidx((s0/usr/lib/python2.7/site-packages/jinja2/utils.pytgenerate_lorem_ipsumsJ  (            sutf-8cCst|tst|}nt|tr?|j|}n| rLdpOd}tt||}|r|jdd}n|S(s&URL escapes a single bytestring or unicode string with the given charset if applicable to URL safe quoting under all rules that need to be considered under all supported Python versions. If non strings are provided they are converted to their unicode representation first. RR s%20t+(RRRtencodeRtreplace(Rtcharsettfor_qstsafetrv((s0/usr/lib/python2.7/site-packages/jinja2/utils.pytunicode_urlencode1stLRUCachecBseZdZdZdZdZdZdZdZddZ ddZ d Z d Z d Zd Zd ZdZdZdZdZdZdZdZdZeZdZeZRS(s"A simple LRU Cache implementation.cCs,||_i|_t|_|jdS(N(tcapacityt_mappingRt_queuet _postinit(tselfR((s0/usr/lib/python2.7/site-packages/jinja2/utils.pyt__init__Ks   cCsL|jj|_|jj|_|jj|_t|_|jj |_ dS(N( Rtpopleftt_poplefttpopt_poptremovet_removeRt_wlockRtt_append(R((s0/usr/lib/python2.7/site-packages/jinja2/utils.pyRQs  cCs"i|jd6|jd6|jd6S(NRRR(RRR(R((s0/usr/lib/python2.7/site-packages/jinja2/utils.pyt __getstate__Ys  cCs|jj||jdS(N(t__dict__tupdateR(Rtd((s0/usr/lib/python2.7/site-packages/jinja2/utils.pyt __setstate__`scCs |jfS(N(R(R((s0/usr/lib/python2.7/site-packages/jinja2/utils.pyt__getnewargs__dscCs;|j|j}|jj|jt|j|_|S(s&Return a shallow copy of the instance.(RBRRRRR(RR((s0/usr/lib/python2.7/site-packages/jinja2/utils.pytcopygscCs%y ||SWntk r |SXdS(s/Return an item from the cache dict or `default`N(tKeyError(Rtkeytdefault((s0/usr/lib/python2.7/site-packages/jinja2/utils.pytgetns  cCsQ|jjz/y ||SWntk r:|||<|SXWd|jjXdS(svSet `default` if the key is not in the cache otherwise leave unchanged. Return the value of this key. N(RtacquireRtrelease(RRR((s0/usr/lib/python2.7/site-packages/jinja2/utils.pyt setdefaultus     cCs@|jjz|jj|jjWd|jjXdS(sClear the cache.N(RRRR$RR(R((s0/usr/lib/python2.7/site-packages/jinja2/utils.pyR$s   cCs ||jkS(s$Check if a key exists in this cache.(R(RR((s0/usr/lib/python2.7/site-packages/jinja2/utils.pyt __contains__scCs t|jS(s%Return the current size of the cache.(RKR(R((s0/usr/lib/python2.7/site-packages/jinja2/utils.pyt__len__scCsd|jj|jfS(Ns<%s %r>(RBRDR(R((s0/usr/lib/python2.7/site-packages/jinja2/utils.pyR s cCs|jjz]|j|}|jd|krey|j|Wntk rTnX|j|n|SWd|jjXdS(sGet an item from the cache. Moves the item up so that it has the highest priority then. Raise a `KeyError` if it does not exist. iN(RRRRRt ValueErrorRR(RRR((s0/usr/lib/python2.7/site-packages/jinja2/utils.pyt __getitem__s   cCs|jjzh||jkr/|j|n+t|j|jkrZ|j|j=n|j|||j|nXWd|jjXdS(s]Remove an item from the cache dict. Raise a `KeyError` if it does not exist. N(RRRRRR(RR((s0/usr/lib/python2.7/site-packages/jinja2/utils.pyt __delitem__s   cCs=gt|jD]}||j|f^q}|j|S(sReturn a list of items.(tlistRRtreverse(RRRz((s0/usr/lib/python2.7/site-packages/jinja2/utils.pyR2s/ cCst|jS(sIterate over all items.(titerR2(R((s0/usr/lib/python2.7/site-packages/jinja2/utils.pyt iteritemsscCs!g|jD]}|d^q S(sReturn a list of all values.i(R2(RR ((s0/usr/lib/python2.7/site-packages/jinja2/utils.pytvaluesscCst|jS(sIterate over all values.(RR(R((s0/usr/lib/python2.7/site-packages/jinja2/utils.pyt itervaluescCs t|S(s7Return a list of all keys ordered by most recent usage.(R(R((s0/usr/lib/python2.7/site-packages/jinja2/utils.pytkeysscCstt|jS(s[Iterate over all keys in the cache dict, ordered by the most recent usage. (treversedttupleR(R((s0/usr/lib/python2.7/site-packages/jinja2/utils.pytiterkeysscCstt|jS(sVIterate over the values in the cache dict, oldest items coming first. (RRR(R((s0/usr/lib/python2.7/site-packages/jinja2/utils.pyt __reversed__sN(RDRCt__doc__RRRRRRR,RRR$RRR RRRR2RRRRRt__iter__Rt__copy__(((s0/usr/lib/python2.7/site-packages/jinja2/utils.pyRDs2                     (tMutableMappingRwthtmtxmlcsHtd|Dtd|Dfd}|S(scIntelligently sets the initial value of autoescaping based on the filename of the template. This is the recommended way to configure autoescaping if you do not want to write a custom function yourself. If you want to enable it for all templates created from strings or for all templates with `.html` and `.xml` extensions:: from jinja2 import Environment, select_autoescape env = Environment(autoescape=select_autoescape( enabled_extensions=('html', 'xml'), default_for_string=True, )) Example configuration to turn it on at all times except if the template ends with `.txt`:: from jinja2 import Environment, select_autoescape env = Environment(autoescape=select_autoescape( disabled_extensions=('txt',), default_for_string=True, default=True, )) The `enabled_extensions` is an iterable of all the extensions that autoescaping should be enabled for. Likewise `disabled_extensions` is a list of all templates it should be disabled for. If a template is loaded from a string then the default from `default_for_string` is used. If nothing matches then the initial value of autoescaping is set to the value of `default`. For security reasons this function operates case insensitive. .. versionadded:: 2.9 css(|]}d|jdjVqdS(R'N(tlstriptlower(RnR ((s0/usr/lib/python2.7/site-packages/jinja2/utils.pys #scss(|]}d|jdjVqdS(R'N(RR(RnR ((s0/usr/lib/python2.7/site-packages/jinja2/utils.pys %scsF|dkrS|j}|jr/tS|jrBtSS(N(R,RRWRRs(t template_name(Rtdefault_for_stringtdisabled_patternstenabled_patterns(s0/usr/lib/python2.7/site-packages/jinja2/utils.pyt autoescape's  (R(tenabled_extensionstdisabled_extensionsRRR((RRRRs0/usr/lib/python2.7/site-packages/jinja2/utils.pytselect_autoescapes &     cKsa|d krtj}n|||jddjddjddjdd}t|S( sWorks exactly like :func:`dumps` but is safe for use in ``