/snap/core22/2411/usr/lib/python3.10/__pycache__
NameSizeModeActions
abc.cpython-310.pyc67510644editdlrm
aifc.cpython-310.pyc246850644editdlrm
antigravity.cpython-310.pyc8220644editdlrm
argparse.cpython-310.pyc635390644editdlrm
ast.cpython-310.pyc557390644editdlrm
asynchat.cpython-310.pyc70250644editdlrm
asyncore.cpython-310.pyc160020644editdlrm
base64.cpython-310.pyc171620644editdlrm
bdb.cpython-310.pyc258320644editdlrm
binhex.cpython-310.pyc128700644editdlrm
bisect.cpython-310.pyc25880644editdlrm
bz2.cpython-310.pyc108700644editdlrm
calendar.cpython-310.pyc263030644editdlrm
cgi.cpython-310.pyc267230644editdlrm
cgitb.cpython-310.pyc99980644editdlrm
chunk.cpython-310.pyc48600644editdlrm
cmd.cpython-310.pyc127070644editdlrm
code.cpython-310.pyc99570644editdlrm
codecs.cpython-310.pyc332190644editdlrm
codeop.cpython-310.pyc55950644editdlrm
colorsys.cpython-310.pyc32650644editdlrm
compileall.cpython-310.pyc127330644editdlrm
configparser.cpython-310.pyc454580644editdlrm
contextlib.cpython-310.pyc208950644editdlrm
contextvars.cpython-310.pyc2460644editdlrm
copy.cpython-310.pyc69960644editdlrm
copyreg.cpython-310.pyc46830644editdlrm
cProfile.cpython-310.pyc51130644editdlrm
crypt.cpython-310.pyc35500644editdlrm
csv.cpython-310.pyc117980644editdlrm
dataclasses.cpython-310.pyc265780644editdlrm
datetime.cpython-310.pyc565330644editdlrm
decimal.cpython-310.pyc3620644editdlrm
difflib.cpython-310.pyc589050644editdlrm
dis.cpython-310.pyc156560644editdlrm
doctest.cpython-310.pyc761750644editdlrm
enum.cpython-310.pyc260630644editdlrm
filecmp.cpython-310.pyc87490644editdlrm
fileinput.cpython-310.pyc140720644editdlrm
fnmatch.cpython-310.pyc42440644editdlrm
fractions.cpython-310.pyc186000644editdlrm
ftplib.cpython-310.pyc289770644editdlrm
functools.cpython-310.pyc283350644editdlrm
genericpath.cpython-310.pyc39070644editdlrm
getopt.cpython-310.pyc63390644editdlrm
getpass.cpython-310.pyc42100644editdlrm
gettext.cpython-310.pyc182210644editdlrm
glob.cpython-310.pyc58520644editdlrm
graphlib.cpython-310.pyc76160644editdlrm
gzip.cpython-310.pyc185460644editdlrm
hashlib.cpython-310.pyc68450644editdlrm
heapq.cpython-310.pyc138650644editdlrm
hmac.cpython-310.pyc69730644editdlrm
imaplib.cpython-310.pyc424320644editdlrm
imghdr.cpython-310.pyc39050644editdlrm
imp.cpython-310.pyc97860644editdlrm
inspect.cpython-310.pyc851530644editdlrm
io.cpython-310.pyc36630644editdlrm
ipaddress.cpython-310.pyc626700644editdlrm
keyword.cpython-310.pyc9270644editdlrm
linecache.cpython-310.pyc41420644editdlrm
locale.cpython-310.pyc461540644editdlrm
lzma.cpython-310.pyc121000644editdlrm
mailbox.cpython-310.pyc600910644editdlrm
mailcap.cpython-310.pyc73200644editdlrm
mimetypes.cpython-310.pyc176190644editdlrm
modulefinder.cpython-310.pyc161660644editdlrm
netrc.cpython-310.pyc39330644editdlrm
nntplib.cpython-310.pyc316230644editdlrm
ntpath.cpython-310.pyc147040644editdlrm
nturl2path.cpython-310.pyc17470644editdlrm
numbers.cpython-310.pyc118660644editdlrm
opcode.cpython-310.pyc54470644editdlrm
operator.cpython-310.pyc135080644editdlrm
optparse.cpython-310.pyc477540644editdlrm
os.cpython-310.pyc315990644editdlrm
pathlib.cpython-310.pyc420520644editdlrm
pdb.cpython-310.pyc474400644editdlrm
pickle.cpython-310.pyc468820644editdlrm
pickletools.cpython-310.pyc677600644editdlrm
pipes.cpython-310.pyc77690644editdlrm
pkgutil.cpython-310.pyc183610644editdlrm
platform.cpython-310.pyc274290644editdlrm
plistlib.cpython-310.pyc237650644editdlrm
poplib.cpython-310.pyc136700644editdlrm
posixpath.cpython-310.pyc105600644editdlrm
pprint.cpython-310.pyc178750644editdlrm
profile.cpython-310.pyc143910644editdlrm
pstats.cpython-310.pyc236210644editdlrm
pty.cpython-310.pyc41430644editdlrm
pyclbr.cpython-310.pyc97750644editdlrm
pydoc.cpython-310.pyc856450644editdlrm
py_compile.cpython-310.pyc73390644editdlrm
queue.cpython-310.pyc107920644editdlrm
quopri.cpython-310.pyc57940644editdlrm
random.cpython-310.pyc227480644editdlrm
re.cpython-310.pyc142270644editdlrm
reprlib.cpython-310.pyc52500644editdlrm
rlcompleter.cpython-310.pyc59540644editdlrm
runpy.cpython-310.pyc94110644editdlrm
sched.cpython-310.pyc61150644editdlrm
secrets.cpython-310.pyc21750644editdlrm
selectors.cpython-310.pyc171050644editdlrm
shelve.cpython-310.pyc94920644editdlrm
shlex.cpython-310.pyc77820644editdlrm
shutil.cpython-310.pyc385360644editdlrm
signal.cpython-310.pyc29350644editdlrm
site.cpython-310.pyc179220644editdlrm
sitecustomize.cpython-310.pyc2250644editdlrm
smtpd.cpython-310.pyc261470644editdlrm
smtplib.cpython-310.pyc357660644editdlrm
sndhdr.cpython-310.pyc69620644editdlrm
socket.cpython-310.pyc289630644editdlrm
socketserver.cpython-310.pyc253470644editdlrm
sre_compile.cpython-310.pyc151940644editdlrm
sre_constants.cpython-310.pyc63570644editdlrm
sre_parse.cpython-310.pyc217550644editdlrm
ssl.cpython-310.pyc452710644editdlrm
stat.cpython-310.pyc42730644editdlrm
statistics.cpython-310.pyc370510644editdlrm
string.cpython-310.pyc71020644editdlrm
stringprep.cpython-310.pyc170750644editdlrm
struct.cpython-310.pyc3070644editdlrm
subprocess.cpython-310.pyc447410644editdlrm
sunau.cpython-310.pyc164820644editdlrm
symtable.cpython-310.pyc128350644editdlrm
sysconfig.cpython-310.pyc181510644editdlrm
tabnanny.cpython-310.pyc69500644editdlrm
tarfile.cpython-310.pyc706740644editdlrm
telnetlib.cpython-310.pyc185060644editdlrm
tempfile.cpython-310.pyc273390644editdlrm
textwrap.cpython-310.pyc138120644editdlrm
this.cpython-310.pyc12640644editdlrm
threading.cpython-310.pyc449690644editdlrm
timeit.cpython-310.pyc117690644editdlrm
token.cpython-310.pyc27380644editdlrm
tokenize.cpython-310.pyc171940644editdlrm
trace.cpython-310.pyc198700644editdlrm
traceback.cpython-310.pyc217120644editdlrm
tracemalloc.cpython-310.pyc175250644editdlrm
tty.cpython-310.pyc10790644editdlrm
turtle.cpython-310.pyc1288570644editdlrm
types.cpython-310.pyc95250644editdlrm
typing.cpython-310.pyc852770644editdlrm
uu.cpython-310.pyc38670644editdlrm
uuid.cpython-310.pyc224980644editdlrm
warnings.cpython-310.pyc136460644editdlrm
wave.cpython-310.pyc175940644editdlrm
weakref.cpython-310.pyc203430644editdlrm
webbrowser.cpython-310.pyc170000644editdlrm
xdrlib.cpython-310.pyc78800644editdlrm
zipapp.cpython-310.pyc60130644editdlrm
zipfile.cpython-310.pyc618450644editdlrm
zipimport.cpython-310.pyc170330644editdlrm
_aix_support.cpython-310.pyc28790644editdlrm
_bootsubprocess.cpython-310.pyc22940644editdlrm
_collections_abc.cpython-310.pyc329250644editdlrm
_compat_pickle.cpython-310.pyc58720644editdlrm
_compression.cpython-310.pyc45120644editdlrm
_distutils_system_mod.cpython-310.pyc54220644editdlrm
_markupbase.cpython-310.pyc75720644editdlrm
_osx_support.cpython-310.pyc115350644editdlrm
_pydecimal.cpython-310.pyc1577360644editdlrm
_pyio.cpython-310.pyc736540644editdlrm
_py_abc.cpython-310.pyc46830644editdlrm
_sitebuiltins.cpython-310.pyc35470644editdlrm
_strptime.cpython-310.pyc159450644editdlrm
_sysconfigdata__linux_x86_64-linux-gnu.cpython-310.pyc353850644editdlrm
_sysconfigdata__x86_64-linux-gnu.cpython-310.pyc353790644editdlrm
_threading_local.cpython-310.pyc65390644editdlrm
_weakrefset.cpython-310.pyc76080644editdlrm
__future__.cpython-310.pyc41310644editdlrm
__phello__.foo.cpython-310.pyc1300644editdlrm
Edit: /snap/core22/2411/usr/lib/python3.10/__pycache__/functools.cpython-310.pyc (28335B)
o `wi@sdZgdZddlmZddlmZddlmZddlm Z ddl m Z dZ d Z e e fd d Ze e fd d ZefddZefddZefddZefddZefddZefddZefddZefddZefddZefd d!Zefd"d#Zefd$d%Zd&efd'efd(efgd(efd)efd&efgd)efd(efd'efgd'efd&efd)efgd*Zd+d,Zd-d.Zzdd/l mZWn e!yYnwe"Z#e#fd0d1Z$zdd2l m$Z$Wn e!yYnwGd3d4d4Z%zdd5l m%Z%Wn e!yYnwGd6d7d7e"Z&d8d9Z'ed:gd;Z(Gdd?Z0dXdBdCZ1dDdEZ2zddFl m2Z2Wn e!y;YnwdGdHZ3dIdJZ4dYdLdMZ5dNdOZ6dPdQZ7dRdSZ8GdTdUdUZ9e"Z:GdVdWdWZ;dKS)ZzEfunctools.py - Tools for working with functions and callable objects )update_wrapperwrapsWRAPPER_ASSIGNMENTSWRAPPER_UPDATEStotal_orderingcache cmp_to_key lru_cachereducepartial partialmethodsingledispatchsingledispatchmethodcached_property)get_cache_token) namedtuple)recursive_repr)RLock) GenericAlias) __module____name__ __qualname____doc____annotations__)__dict__c Csd|D]}zt||}Wn tyYqwt|||q|D]}t||t||iq||_|S)aUpdate a wrapper function to look like the wrapped function wrapper is the function to be updated wrapped is the original function assigned is a tuple naming the attributes assigned directly from the wrapped function to the wrapper function (defaults to functools.WRAPPER_ASSIGNMENTS) updated is a tuple naming the attributes of the wrapper that are updated with the corresponding attribute from the wrapped function (defaults to functools.WRAPPER_UPDATES) )getattrAttributeErrorsetattrupdate __wrapped__)wrapperwrappedassignedupdatedattrvaluer& /usr/lib/python3.10/functools.pyr#s rcCstt|||dS)aDecorator factory to apply update_wrapper() to a wrapper function Returns a decorator that invokes update_wrapper() with the decorated function as the wrapper argument and the arguments to wraps() as the remaining arguments. Default arguments are as for update_wrapper(). This is a convenience function to simplify applying partial() to update_wrapper(). r!r"r#)r rr(r&r&r'rAs rcC*t|||}||ur|S| o||kS)zIReturn a > b. Computed by @total_ordering from (not a < b) and (a != b).type__lt__selfotherNotImplemented op_resultr&r&r' _gt_from_ltYr2cC(t|||}||ur|S|p||kS)zEReturn a <= b. Computed by @total_ordering from (a < b) or (a == b).r*r-r&r&r' _le_from_lt` r5cC"t|||}||ur|S| S)z=Return a >= b. Computed by @total_ordering from (not a < b).r*r-r&r&r' _ge_from_ltgr8cC*t|||}||ur|S| p||kS)zJReturn a >= b. Computed by @total_ordering from (not a <= b) or (a == b).r+__le__r-r&r&r' _ge_from_lenr3r=cC(t|||}||ur|S|o||kS)zFReturn a < b. Computed by @total_ordering from (a <= b) and (a != b).r;r-r&r&r' _lt_from_leur6r?cCr7)z=Return a > b. Computed by @total_ordering from (not a <= b).r;r-r&r&r' _gt_from_le|r9r@cCr))zIReturn a < b. Computed by @total_ordering from (not a > b) and (a != b).r+__gt__r-r&r&r' _lt_from_gtr3rCcCr4)zEReturn a >= b. Computed by @total_ordering from (a > b) or (a == b).rAr-r&r&r' _ge_from_gtr6rDcCr7)z=Return a <= b. Computed by @total_ordering from (not a > b).rAr-r&r&r' _le_from_gtr9rEcCr:)zJReturn a <= b. Computed by @total_ordering from (not a >= b) or (a == b).r+__ge__r-r&r&r' _le_from_ger3rHcCr>)zFReturn a > b. Computed by @total_ordering from (a >= b) and (a != b).rFr-r&r&r' _gt_from_ger6rIcCr7)z=Return a < b. Computed by @total_ordering from (not a >= b).rFr-r&r&r' _lt_from_ger9rJrBr<rGr,)r,r<rBrGcsVfddtD}|stdt|}t|D]\}}||vr(||_t||qS)z6Class decorator that fills in missing ordering methodscs(h|]}t|dtt|dur|qSN)robject).0opclsr&r' s(z!total_ordering..z6must define at least one ordering operation: < > <= >=)_convert ValueErrormaxrr)rProotsrootopnameopfuncr&rOr'rs rcsGfdddt}|S)z,Convert a cmp= function into a key= functioncsZeZdZdgZddZfddZfddZfdd Zfd d Zfd d Z dZ dS)zcmp_to_key..KobjcSs ||_dSrKrY)r.rYr&r&r'__init__s zcmp_to_key..K.__init__cs|j|jdkSNrrZr.r/mycmpr&r'r,zcmp_to_key..K.__lt__cs|j|jdkSr\rZr]r^r&r'rBr`zcmp_to_key..K.__gt__cs|j|jdkSr\rZr]r^r&r'__eq__r`zcmp_to_key..K.__eq__cs|j|jdkSr\rZr]r^r&r'r<r`zcmp_to_key..K.__le__cs|j|jdkSr\rZr]r^r&r'rGr`zcmp_to_key..K.__ge__N) rrr __slots__r[r,rBrar<rG__hash__r&r^r&r'Ks     rd)rL)r_rdr&r^r'rsr)rcCsRt|}|turzt|}Wntytddw|}|D]}|||}q|S)a reduce(function, iterable[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence or iterable, from left to right, so as to reduce the iterable to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is present, it is placed before the items of the iterable in the calculation, and serves as a default when the iterable is empty. z0reduce() of empty iterable with no initial valueN)iter_initial_missingnext StopIteration TypeError)functionsequenceinitialitr%elementr&r&r'r s    r )r csJeZdZdZdZfddZddZeddZd d Z d d Z Z S) r zSNew function with partial application of the given arguments and keywords. )funcargskeywordsr __weakref__cs^t|stdt|dr|j|}i|j|}|j}tt||}||_||_||_|S)Nz#the first argument must be callablero) callablerihasattrrprqrosuperr __new__)rProrprqr. __class__r&r'rvs  zpartial.__new__cOs*i|j|}|jg|j|Ri|SrKrqrorp)r.rprqr&r&r'__call__+szpartial.__call__cCst|j}t|jg}|dd|jD|dd|jDt|jdkr6d|dd |dS|dd |dS) Ncss|]}t|VqdSrK)repr)rMxr&r&r' 3z#partial.__repr__..css"|] \}}|d|VqdS)=Nr&rMkvr&r&r'r}4s functoolsz functools.(, )) r+rr{roextendrprqitemsrjoin)r.qualnamerpr&r&r'__repr__/s  zpartial.__repr__cCs*t||jf|j|j|jpd|jpdffSrK)r+rorprqrr.r&r&r' __reduce__9szpartial.__reduce__cCst|ts tdt|dkrtdt||\}}}}t|r9t|tr9|dur0t|tr9|dur=t|ts=tdt|}|durHi}n t|turRt|}|durXi}||_||_||_ ||_ dS)Nz(argument to __setstate__ must be a tuplezexpected 4 items in state, got zinvalid partial state) isinstancetuplerilenrsdictr+rrorprq)r.staterorpkwds namespacer&r&r' __setstate__=s(     zpartial.__setstate__) rrrrrbrvrzrrrr __classcell__r&r&rwr'r s   r )r c@sFeZdZdZddZddZddZd d d Zed d Z e e Z dS)r zMethod descriptor with partial application of the given arguments and keywords. Supports wrapping existing descriptors and handles non-descriptor callables as instance methods. cOsht|st|dstd|t|tr)|j|_|j||_i|j||_dS||_||_||_dS)N__get__z${!r} is not callable or a descriptor) rsrtriformatrr rorprq)r.rorprqr&r&r'r[cs   zpartialmethod.__init__cCsNdtt|j}ddd|jD}d}|j|jj|jj |j ||dS)Nrcss |] \}}d||VqdS)z{}={!r}N)rrr&r&r'r}xsz)partialmethod.__repr__..z*{module}.{cls}({func}, {args}, {keywords}))modulerProrprq) rmapr{rprqrrrxrrro)r.rprq format_stringr&r&r'rvs  zpartialmethod.__repr__csfdd}j|_|_|S)Ncs,ij|}j|gj|Ri|SrKry) cls_or_selfrprqrr&r'_methodsz3partialmethod._make_unbound_method.._method)__isabstractmethod___partialmethod)r.rr&rr'_make_unbound_methods z"partialmethod._make_unbound_methodNcCst|jdd}d}|dur4|||}||jur4t|g|jRi|j}z|j|_Wn ty3Ynw|dur@|||}|S)Nr) rror rprq__self__rrr)r.rYrPgetresultnew_funcr&r&r'rs    zpartialmethod.__get__cCt|jddSNrFrrorr&r&r'rz"partialmethod.__isabstractmethod__rK) rrrrr[rrrpropertyr classmethodr__class_getitem__r&r&r&r'r [s   r cCst|tr |j}t|ts|SrK)rr roror&r&r'_unwrap_partials  r CacheInfo)hitsmissesmaxsizecurrsizec@s(eZdZdZdZefddZddZdS) _HashedSeqz This class guarantees that hash() will be called no more than once per element. This is important because the lru_cache() will hash the key multiple times on a cache miss. hashvaluecCs||dd<|||_dSrKr)r.tuphashr&r&r'r[s z_HashedSeq.__init__cCs|jSrKrrr&r&r'rcsz_HashedSeq.__hash__N)rrrrrbrr[rcr&r&r&r'rs   rc s|}|r||7}|D]} || 7}q |r7||fdd|D7}|r3||fdd|D7}t|S||dkrI|d|vrI|dSt|S)aMake a cache key from optionally typed positional and keyword arguments The key is constructed in a way that is flat as possible rather than as a nested structure that would take more memory. If there is only a single argument and its data type is known to cache its hash value, then that argument is returned without a wrapper. This saves space and improves lookup speed. c3|]}|VqdSrKr&rMrr+r&r'r}r~z_make_key..c3rrKr&rrr&r'r}r~r)rvaluesr) rprtypedkwd_mark fasttypesrr+rkeyitemr&rr' _make_keys  rFcs~ttr dkr dn*tr.ttr.d}t|t}fdd|_t||Sdur6tdfdd}|S) aLeast-recently-used cache decorator. If *maxsize* is set to None, the LRU features are disabled and the cache can grow without bound. If *typed* is True, arguments of different types will be cached separately. For example, f(3.0) and f(3) will be treated as distinct calls with distinct results. Arguments to the cached function must be hashable. View the cache statistics named tuple (hits, misses, maxsize, currsize) with f.cache_info(). Clear the cache and statistics with f.cache_clear(). Access the underlying function with f.__wrapped__. See: https://en.wikipedia.org/wiki/Cache_replacement_policies#Least_recently_used_(LRU) rrc dSNrrr&r&rr&r' zlru_cache..Nz=Expected first argument to be an integer, a callable, or Nonecs(t|t}fdd|_t||S)Ncrrr&r&rr&r'rrz8lru_cache..decorating_function..)_lru_cache_wrapper _CacheInfocache_parametersr) user_functionr rr&r'decorating_functions z&lru_cache..decorating_function) rintrsboolrrrrri)rrrr rr&rr'rs   rcstt d\id djjt gddgdd< dkr4 fdd}n' durF fdd}n fdd} fdd } fd d }||_||_|S) N)rrrFcsd7|i|}|SNrr&)rprr)rrr&r'r sz#_lru_cache_wrapper..wrappercsL||}|}|urd7|Sd7|i|}||<|Srr&)rprrr)r cache_getrmake_keyrsentinelrrr&r'r 's  c s ||} C|}|dur@|\}}}}||<||< }||< <||< |<d7|WdS d7 Wdn1sNwY|i|} a|vrbnKr } || <|| <|  } } d < <| =| |<n+ }| ||g}||< <|< kWd|SWd|SWd|S1swY|Srr&) rprrlink link_prev link_next_keyrlastoldrootoldkey oldresult)KEYNEXTPREVRESULTrr cache_lenfullrlockrrrrVrrr&r'r 6sX       $ $ $$cs8WdS1swYdS)zReport cache statisticsNr&r&)rrrrrrr&r' cache_infoos$z&_lru_cache_wrapper..cache_infocsRddgdd<ddWddS1s"wYdS)z$Clear the cache and cache statisticsNrF)clearr&)rrrrrrVr&r' cache_clearts "z'_lru_cache_wrapper..cache_clear)rLrr__len__rrr)rrrrr rrr&)rrrrrrrrrrrrrrrVrrrr'r s* *9 r)rcCstdd|S)z@Simple lightweight unbounded cache. Sometimes called "memoize".N)r)r)rr&r&r'rrrcCsg} dd|D}|s|S|D]}|d}|D]}||ddvr&d}nqnq|dur2td|||D] }|d|krD|d=q9q)zMerges MROs in *sequences* to a single MRO using the C3 algorithm. Adapted from https://www.python.org/download/releases/2.3/mro/. TcSsg|]}|r|qSr&r&rMsr&r&r' sz_c3_merge..rrNzInconsistent hierarchy) RuntimeErrorappend) sequencesrs1 candidates2seqr&r&r' _c3_merges,  rNc stt|jD]\}tdrt|j|}nqd}r"tngt|jd|}g}t|j|d}D]t|rRtfdd|jDsR|q:|D] qUfdd|D}fdd|D}fd d|D} t |gg||| |g|g|gS) aComputes the method resolution order using extended C3 linearization. If no *abcs* are given, the algorithm works exactly like the built-in C3 linearization used for method resolution. If given, *abcs* is a list of abstract base classes that should be inserted into the resulting MRO. Unrelated ABCs are ignored and don't end up in the result. The algorithm inserts ABCs where their functionality is introduced, i.e. issubclass(cls, abc) returns True for the class itself but returns False for all its direct base classes. Implicit ABCs for a given class (either registered or inferred from the presence of a special method like __len__) are inserted directly after the last ABC explicitly listed in the MRO of said class. If two implicit ABCs end up next to each other in the resulting MRO, their ordering depends on the order of types in *abcs*. __abstractmethods__rNc3s|]}t|VqdSrK) issubclass)rMb)baser&r'r}s  z_c3_mro..cg|]}t|dqSabcs_c3_mrorMrrr&r'rz_c3_mro..crrrrrr&r'rrcrrrrrr&r'rr) enumeratereversed __bases__rtrlistranyrremover) rPriboundaryexplicit_basesabstract_bases other_basesexplicit_c3_mrosabstract_c3_mros other_c3_mrosr&)rrr'rsH   rcstjfddfddDfddfddDtg}D]C}g}|D]}|vrLt|rL|fdd|jDq4|sU||q,|jtd d |D]}|D] }||vrm||qbq^q,t|d S) zCalculates the method resolution order for a given class *cls*. Includes relevant abstract base classes (with their respective bases) from the *types* iterable. Uses a modified C3 linearization algorithm. cs(|vot|dot|t ot|S)N__mro__)rtrrr)typ)basesrPr&r' is_relateds  z _compose_mro..is_relatedcsg|]}|r|qSr&r&rMn)rr&r'rrz _compose_mro..cs&D]}||kr||jvrdSqdS)NTF)r)rr/)typesr&r'is_strict_bases z$_compose_mro..is_strict_basecsg|]}|s|qSr&r&r)rr&r'rrcsg|]}|vr|qSr&r&r)type_setr&r'rrT)rreverser)setr__subclasses__rrsortrr)rPrmrorfoundsubsubclsr&)rrPrrrrr' _compose_mros2      r cCstt||}d}|D])}|dur.||vr,||jvr,||jvr,t||s,td||n||vr4|}q ||S)a^Returns the best matching implementation from *registry* for type *cls*. Where there is no registered implementation for a specific type, its method resolution order is used to find a more generic implementation. Note: if *registry* does not contain an implementation for the base *object* type, this function may return None. NzAmbiguous dispatch: {} or {})r keysrrrrr)rPregistryrmatchtr&r&r' _find_impls    r%csddl}ddl}i|dfddddd fdd fd d }t|d d |t<|_|_||_j |_ t |||S)akSingle-dispatch generic function decorator. Transforms a function into a generic function, which can have different behaviours depending upon the type of its first argument. The decorated function acts as the default implementation, and additional implementations can be registered using the register() attribute of the generic function. rNc sxdurt}|kr|z|}W|Sty;z|}Wnty3t|}Ynw||<Y|Sw)zgeneric_func.dispatch(cls) -> Runs the dispatch algorithm to return the best available implementation for the given *cls* registered on *generic_func*. N)rrKeyErrorr%)rP current_tokenimpl) cache_tokendispatch_cacher"r&r'dispatch2s"     z singledispatch..dispatchcSst|to t|t SrK)rr+rrOr&r&r'_is_valid_dispatch_typeIsz/singledispatch.._is_valid_dispatch_typecsr|durfddSn?|durtddtdi}|s,tdd}d d lm}tt||\}sOtd |d d|<dur_td r_t |S)zgeneric_func.register(cls, func) -> func Registers a new implementation for the given *cls* on a *generic_func*. Ncs |SrKr&)f)rPregisterr&r'rUrz2singledispatch..register..z(Invalid first argument to `register()`. z is not a class.rz(Invalid first argument to `register()`: zS. Use either `@register(some_class)` or plain `@register` on an annotated function.r)get_type_hintszInvalid annotation for z. r) rirtypingr/rgrerrtrr)rProannr/argname)r,r)r*r.r"rOr'r.Ls:   z singledispatch..registercs*|s td|dj|i|S)Nz( requires at least 1 positional argumentr)rirx)rpkw)r+funcnamer&r'r tszsingledispatch..wrapperrzsingledispatch functionrK) rweakrefWeakKeyDictionaryrrLr.r+MappingProxyTyper"r _clear_cacher)rorr5r r&)r,r)r+r*r4r.r"r'r s  (   r c@s8eZdZdZddZd ddZd ddZed d ZdS) r zSingle-dispatch generic method descriptor. Supports wrapping existing descriptors and handles non-descriptor callables as instance methods. cCs4t|st|dst|dt||_||_dS)Nrz is not callable or a descriptor)rsrtrir dispatcherror.ror&r&r'r[s  zsingledispatchmethod.__init__NcCs|jj||dS)zgeneric_method.register(cls, func) -> func Registers a new implementation for the given *cls* on a *generic_method*. r)r9r.)r.rPmethodr&r&r'r.szsingledispatchmethod.registercs0fdd}j|_j|_t|j|S)Ncs(j|dj}||i|Sr\)r9r+rxr)rpkwargsr;rPrYr.r&r'rsz-singledispatchmethod.__get__.._method)rr.rro)r.rYrPrr&r=r'rs  zsingledispatchmethod.__get__cCrrrrr&r&r'rrz)singledispatchmethod.__isabstractmethod__rK) rrrrr[r.rrrr&r&r&r'r s   r c@s.eZdZddZddZdddZeeZdS) rcCs ||_d|_|j|_t|_dSrK)roattrnamerrrr:r&r&r'r[s zcached_property.__init__cCs:|jdur ||_dS||jkrtd|jd|ddS)Nz?Cannot assign the same cached_property to two different names (z and z).)r>ri)r.ownernamer&r&r' __set_name__s   zcached_property.__set_name__Nc Cs|dur|S|jdurtdz|j}Wnty-dt|jd|jd}t|dw||jt}|tur|jB||jt}|turn| |}z|||j<Wn!tymdt|jd|jd}t|dwWd|SWd|S1swY|S)NzGCannot use cached_property instance without calling __set_name__ on it.zNo '__dict__' attribute on z instance to cache z property.zThe '__dict__' attribute on z7 instance does not support item assignment for caching ) r>rirrr+rr _NOT_FOUNDrro)r.instancer?rmsgvalr&r&r'rsL            zcached_property.__get__rK) rrrr[rArrrrr&r&r&r'rs  r)rFrK)s                       A J  .t -*f(