U  e)@sddlmZddlZddlZddlZddlZddlZddlZddlm Z ddZ GdddZ d d Z d#d d Z Gd ddZGdddZGdddeZGdddZGdddeZedejZddZddZddZd$dd Zd!d"ZdS)%)parseN)importlib_metadata_getcCs||_|j|_|SN) __wrapped____name__)Z decoratedfnr 7/opt/hc_python/lib/python3.8/site-packages/mako/util.pyupdate_wrappersr c@s$eZdZddZddZddZdS) PluginLoadercCs||_i|_dSr)groupimpls)selfr r r r __init__szPluginLoader.__init__cCsl||jkr|j|St|jD]&}|j|kr |j|j|<|Sq ddlm}|d|j|fdS)Nr) exceptionszCan't load plugin %s %s)rrr nameloadmakorZRuntimeException)rrimplrr r r rs      zPluginLoader.loadcsfdd}||j|<dS)Ncs4t}dddD]}t||}qt|S)N.r) __import__splitgetattr)modtoken modulepathobjnamer r r,s z#PluginLoader.register..load)r)rrrrrr rr register+szPluginLoader.registerN)r __module__ __qualname__rrrr r r r r sr cCsFd}tj|sBz|d7}t|dWq|dkr:YqXqdS)z,create and/or verify a filesystem directory.rriN)ospathexistsmakedirs)Zdir_triesr r r verify_directory5s r(cCs(|dkr |St|ttfs |gS|SdSr) isinstancelisttuple)xdefaultr r r to_listCs r.c@s"eZdZdZdddZddZdS)memoized_propertyz2A read-only @property that is only evaluated once.NcCs||_|p|j|_|j|_dSrfget__doc__rrr1docr r r rPs zmemoized_property.__init__cCs&|dkr |S|||j|j<}|Sr)r1__dict__r)robjclsresultr r r __get__Uszmemoized_property.__get__)Nrr r!r2rr9r r r r r/Ls r/c@s"eZdZdZdddZddZdS)memoized_instancemethodzDecorate a method memoize its return value. Best applied to no-arg methods: memoization is not sensitive to argument values, and will always return the same value even when called with different arguments. NcCs||_|p|j|_|j|_dSrr0r3r r r rfs z memoized_instancemethod.__init__cs.dkr Sfdd}j|_j|_|S)Ncs>jf||fdd}j|_j|_|jj<S)NcsSrr )akwr8r r memorsz>memoized_instancemethod.__get__..oneshot..memo)r1rr2r5)argsr=r?r6rr>r oneshotos   z0memoized_instancemethod.__get__..oneshot)rr2)rr6r7rBr rAr r9ks  zmemoized_instancemethod.__get__)Nr:r r r r r;\s r;c@seZdZdZddZdS) SetLikeDictz0a dictionary that has some setlike methods on itcCstf|}|||S)zproduce a 'union' of this dict and another (at the key level). values in the second dict take precedence over that of the first)rCupdate)rotherr,r r r unions  zSetLikeDict.unionN)rr r!r2rFr r r r rCsrCc@s*eZdZdZd ddZddZdd ZdS) FastEncodingBufferzVa very rudimentary buffer that is faster than StringIO, and supports unicode data.NstrictcCs*t|_||_d|_||_|jj|_dS)N) collectionsdequedataencodingdelimerrorsappendwrite)rrMrOr r r rs  zFastEncodingBuffer.__init__cCst|_|jj|_dSr)rJrKrLrPrQrr r r truncates zFastEncodingBuffer.truncatecCs2|jr |j|j|j|jS|j|jSdSr)rMrNjoinrLencoderOrRr r r getvalues zFastEncodingBuffer.getvalue)NrH)rr r!r2rrSrVr r r r rGs rGc@sPeZdZdZGdddZdddZddZd d Zd d Zd dZ ddZ dS)LRUCachea$A dictionary-like object that stores a limited number of items, discarding lesser used items periodically. this is a rewrite of LRUCache from Myghty to use a periodic timestamp-based paradigm so that synchronization is not really needed. the size management is inexact. c@seZdZddZddZdS)zLRUCache._ItemcCs||_||_t|_dSr)keyvaluetimeit default_timer timestamprrXrYr r r rszLRUCache._Item.__init__cCs t|jSr)reprrYrRr r r __repr__szLRUCache._Item.__repr__N)rr r!rr_r r r r _Itemsr`?cCs||_||_dSr)capacity threshold)rrbrcr r r rszLRUCache.__init__cCst||}t|_|jSr)dict __getitem__rZr[r\rY)rrXitemr r r res  zLRUCache.__getitem__cCsddt|DS)NcSsg|] }|jqSr )rY).0ir r r sz#LRUCache.values..)rdvaluesrRr r r rjszLRUCache.valuescCs||kr||S|||<|Srr r]r r r setdefaultszLRUCache.setdefaultcCsBt||}|dkr0|||}t|||n||_|dSr)rdgetr` __setitem__rY _manage_size)rrXrYrfr r r rms   zLRUCache.__setitem__c Csvt||j|j|jkrrtt|tddd}||jdD],}z ||j=WqBt k rlYqYqBXqBqdS)Nr\T)rXreverse) lenrbrcsortedrdrjoperator attrgetterrXKeyError)rZbytimerfr r r rns zLRUCache._manage_sizeN)ra) rr r!r2r`rrerjrkrmrnr r r r rWs  rWz([ \t\f]* \# .* coding[=:][ \t]*([-\w.]+)c Cs|}|dz|}|tj}|r>|ttjd}t| dd}|szt | ddWnt t fk rYnX|}t| dd}|r|rt dW"dS|r| dWSWdSW5||XdS)aDeduce the encoding of a Python source file (binary mode) from magic comment. It does this in the same way as the `Python interpreter`__ .. __: http://docs.python.org/ref/encodings.html The ``fp`` argument should be a seekable file object in binary mode. rNasciiignorez\python refuses to compile code with both a UTF8 byte-order-mark and a magic encoding commentutf_8r)tellseekreadline startswithcodecsBOM_UTF8rp_PYTHON_MAGIC_COMMENT_rematchdecoder ImportError SyntaxErrorr )fpposline1Zhas_bommline2r r r parse_encodings6     rcs4t}|ddfdd|DdS)z{repr() a dictionary with the keys in order. Used by the lexer unit test to compare parse trees based on strings. {z, c3s|]}d||fVqdS)z%r: %rNr )rgkdr r "sz#sorted_dict_repr..})r*keyssortrT)rrr rr sorted_dict_reprs rcCsxt|drdSd|_tddd|j}t||_|jjD]&}|jdkrL||_q6|jdkr6||_q6t|j d|_ t|j d |_ t|j d |_ t|j d j d|_t|j d j dj|_t|j d j|_t|j d jj|_t|j d jjj|_t|j d jjj|_t|j d jjjj|_t|j d jj|_t|j d jjj|_t|j d jjjj|_t|j d jjjjj|_t|j djj|_t|j djjj|_t|j djjjj|_ t|j djj|_!t|j djj"dj|_#t|j djjj|_$t|j djjjj|_%t|j djjjj&j|_'t|j djjjj|_(t|j djj|_!t|j djj"dj|_#t|j djj)d|_*t|j djj)d |_+t|j djjj)d|_,t|j djjj)d |_-t|j djj)d|_.t|j djj)d |_/t|j djj)d |_0t|j djj)d |_1t|j djj)d|_2t|j djj)d |_3dS)zdAttempt to restore the required classes to the _ast module if it appears to be missing them ASTNiadef foo(): pass class Bar: pass if False: pass baz = 'mako' 1 + 2 - 3 * 4 / 5 6 // 7 % 8 << 9 >> 10 11 & 12 ^ 13 | 14 15 and 16 or 17 -baz + (not +18) - ~17 baz and 'foo' or 'bar' (mako is baz == baz) is not baz != mako mako > baz < mako >= baz <= mako mako in baz not in makoz execrrrr" )4hasattr PyCF_ONLY_ASTcompiletypeModule__mro__rrrbody FunctionDefClassDefIftargetsNamectxStorerYStropSubleftAddrightDivMultRShiftLShiftModFloorDivBitOrBitXorBitAndOrrjAndInvertNotoperandUAddUSubZopsIsNotNotEqIsEqGtLtGtELtEInNotIn)_astrr7r r r restore__ast%sd     rrbc Cs*t||}|W5QRSQRXdSr)openread)r$moderr r r read_filevs rcCs@t|d}z&t|}|}|r*||}|WS|XdS)Nr)rcloserrr)r$rrMrLr r r read_python_file{s  r)N)r)astrr|rJrrr#rerZcompatrr r r(r.r/r;rdrCrGrWrVERBOSEr~rrrrrr r r r s2   # ?1 Q