3 JZ!@sdZddlZddlZddlZddlZddddddd d d d g Zejdd kZerpeZ e Z e Z e ZddZdd Zn e Z e Z e Z eZddZdd ZyeZWnek rdd ZYnXyddlmZWnek rhyddlmZWn"ek r ddlmZYnXejdddddgZGdddeZefeee eedfe e!ee"fddZ#d#d d ZYnXydd!l$m%Z%Wn,ek rej&ej'Bdfd"d Z%YnXdS)$z?Module which provides compatibility with older Python versions.NPY3longxrangeunicode basestringubcallable lru_cachewhichcCs|S)N)sr r /usr/lib64/python3.6/_compat.pyrscCs |jdS)Nzlatin-1)encode)rr r rrscCs t|dS)NZunicode_escape)r)rr r rr"scCs|S)Nr )rr r rr%scCstddt|jDS)Ncss|]}d|jkVqdS)__call__N)__dict__).0klassr r r .szcallable..)anytype__mro__)objr r rr -s)r )RLock CacheInfohitsmissesmaxsizecurrsizec@s$eZdZdZefddZddZdS) _HashedSeq hashvaluecCs||dd<|||_dS)N)r!)selftuphashr r r__init__Es z_HashedSeq.__init__cCs|jS)N)r!)r"r r r__hash__Isz_HashedSeq.__hash__N)__name__ __module__ __qualname__ __slots__r$r%r&r r r rr Bs r c s|} |r2||j} | |7} x| D] } | | 7} q"W|rp| |fdd|D7} |r| |fdd| D7} n$|| dkr| d|kr| dSt| S)Nc3s|]}|VqdS)Nr )rv)rr rrWsz_make_key..c3s|]\}}|VqdS)Nr )rkr+)rr rrYsr)itemsr ) argskwdstypedkwd_mark fasttypessortedtuplerlenkeyZ sorted_itemsitemr )rr _make_keyLs   r9dFcsfdd}|S)z~Least-recently-used cache decorator, see: http://docs.python.org/3/library/functools.html#functools.lru_cache cstddg d \t jtt g ddg dd< g d\dkrn fdd}nPdkr f dd}n*  fdd}  fd d } fd d }|_||_||_tj |S)Nrr-r cs||}d7<|S)Nr-r )r/r0result)MISSESstats user_functionr rwrapperos z7lru_cache..decorating_function..wrappercsX||}|}|k r2d7<|S||}||<d7<|S)Nr-r )r/r0r7r<) HITSr=cache cache_getmake_keyrootr>r1r?r rr@ts   c sl|sr ||}n|} jzr|}|dk r \}|\}}}}||<||<|}||<|<||<||< d7<|SWd jX||} jz \}|krn kr|} || <|| <| } d<|} d|<|<| =| |<n,|}||||g}||<|<|< d7<Wd jX|S)Nr-r)acquirerelease) r/r0r7linkrEZ link_prevZ link_nextr<ZlastZoldrootZoldkey)rAKEYr=NEXTPREVRESULT_lenrBrClockrDr nonlocal_rootr>r1r?r rr@sN      c s2jzttSjXdS)zReport cache statisticsN)rF _CacheInfor6rGr )rAr=rBrNrr>r r cache_infos  z:lru_cache..decorating_function..cache_infoc sPjz8jd}||ddg|dd<ddgdd<WdjXdS)z$Clear the cache and cache statisticsrN)rFclearrG)rE)rBrNrOr>r r cache_clearsz;lru_cache..decorating_function..cache_clear)rr-)rr-r;r ) dictr9getr6r __wrapped__rQrS functoolsupdate_wrapper)r?r@rQrS)rr1)rArIr=rJrKrLrMrBrCrNrDrOrEr>r?rdecorating_functionbs,  *-  z&lru_cache..decorating_functionr )rr1rYr )rr1rr ^sc)r c s"dd}tjjr&||r"SdS|dkr>tjjdtj}|sFdS|jtj}tj dkrtj |krt|j dtj tjjddjtj}t fd d |Drg}q‡fd d |D}ng}t }xT|D]L}tjj|}||kr|j|x(|D] } tjj|| } || |r| SqWqWdS) aJGiven a command, mode, and a PATH string, return the path which conforms to the given mode on the PATH, or None if there is no such file. `mode` defaults to os.F_OK | os.X_OK. `path` defaults to the result of os.environ.get("PATH"), or can be overridden with a custom search path. cSs&tjj|o$tj||o$tjj| S)N)ospathexistsaccessisdir)fnmoder r r _access_checkszwhich.._access_checkNPATHZwin32rZPATHEXTc3s |]}jj|jVqdS)N)lowerendswith)rext)cmdr rrszwhich..csg|] }|qSr r )rrf)rgr r szwhich..)rZr[dirnameenvironrUdefpathsplitpathsepsysplatformcurdirinsertrsetnormcaseaddjoin) rgr`r[raZpathextfilesseendirZnormdirZthefilenamer )rgrr s8            )r:F)(__doc__ collectionsrWrZrn__all__ version_inforintrrangerstrrrrrr NameErrorr ImportErrorZ threadingrZdummy_threading namedtuplerPlistr objectrr frozensetrr4r5r6r9Zshutilr F_OKX_OKr r r rsT    k