cXtddlZddlZddlZddlZddlZddlZddlZejdZejddefdZ dZ ejej fdZ ejdde fdZ ejdZGd d ZGd d ejejZGd dejZdS)Nc#Ktj}tj| |Vtj|dS#tj|wxYwN)osgetcwdchdir)dirorigs F/usr/lib/python3/dist-packages/pkg_resources/_vendor/jaraco/context.pypushdr sO 9;;DHSMMM  s AAc #K|Gtj|dddd}| t jt jd}|djd it d}d }d ||f}||jd d t|it||5|Vdddn #1swxYwY|d jd itdS#|d jd itwxYw)z Get a tarball, extract it, change to that directory, yield, then clean up. `runner` is the function to invoke commands. `pushd` is a context manager for changing the directory. Nz.tar.gzz.tgzT)shellzmkdir {target_dir}zwget {url} -O -z7tar x{compression} --strip-components=1 -C {target_dir}z | compressionzrm -Rf {target_dir}) rpathbasenamereplace functoolspartial subprocess check_callformatvarsjoininfer_compression)url target_dirrunnerr getterextractcmds r tarball_contextr"sW%%c**229bAAII&RTUU  ~":#8EEE  F &  & 0 0 0 01117"Kjj&'*++zszGG&7&<&<GGGHHH U:                       +$+55dff5566666+$+55dff556666s1AD((C9- D(9C==D(C=D(($E cf|dd}tddd}||dS)zF Given a URL or filename, infer the compression code for tar. NzjJ)gzbzxz)dictget)rcompression_indicatormappings r rr0s;  Hccc***G ;;,c 2 22c#pKtj} |V||dS#||wxYw)zk Create a temporary directory context. Pass a custom remover to override the removal behavior. N)tempfilemkdtemp)removertemp_dirs r r4r4;sP !!Hs( 5Tc#Kd|vrdnd}|5}|d||g}|r|d|gttjjd}|r|nd}t j|||VddddS#1swxYwYdS)z Check out the repo indicated by url. If dest_ctx is supplied, it should be a context manager to yield the target directory for the check out. githgclonez--branchwN)stdout)extendopenrrdevnullrr) rbranchquietdest_ctxexerepo_dirr!r=r:s r repo_contextrCHsC<<%%TC xGS(+  - JJ F+ , , ,rw,,!+tc&1111sABBBc#KdVdSrrrr/r nullrE[s EEEEEr/ceZdZdZdZeffdZdZedZ edZ edZ dZ d Z ed d Zd Zd S) ExceptionTrapaG A context manager that will catch certain exceptions and provide an indication they occurred. >>> with ExceptionTrap() as trap: ... raise Exception() >>> bool(trap) True >>> with ExceptionTrap() as trap: ... pass >>> bool(trap) False >>> with ExceptionTrap(ValueError) as trap: ... raise ValueError("1 + 1 is not 3") >>> bool(trap) True >>> with ExceptionTrap(ValueError) as trap: ... raise Exception() Traceback (most recent call last): ... Exception >>> bool(trap) False )NNNc||_dSr) exceptions)selfrIs r __init__zExceptionTrap.__init__s $r/c|SrrrJs r __enter__zExceptionTrap.__enter__ r/c|jdSNrexc_inforMs r typezExceptionTrap.type}Qr/c|jdS)NrRrMs r valuezExceptionTrap.valuerUr/c|jdS)NrRrMs r tbzExceptionTrap.tbrUr/cV|d}|ot||j}|r||_|SrQ) issubclassrIrS)rJrSrTmatchess r __exit__zExceptionTrap.__exit__s5{<:dDO<<  %$DMr/c*t|jSr)boolrTrMs r __bool__zExceptionTrap.__bool__sDIr/_testcNtjfd}|S)a Wrap func and replace the result with the truth value of the trap (True if an exception occurred). First, give the decorator an alias to support Python 3.8 Syntax. >>> raises = ExceptionTrap(ValueError).raises Now decorate a function that always fails. >>> @raises ... def fail(): ... raise ValueError('failed') >>> fail() True ctj5}|i|dddn #1swxYwY|Sr)rGrI)argskwargstraprdfuncrJs r wrapperz%ExceptionTrap.raises..wrapperst// &4d%f%%% & & & & & & & & & & & & & & &5;; s +//)rwraps)rJrjrdrks``` r raiseszExceptionTrap.raisessF&             r/cD||tjS)a Wrap func and replace the result with the truth value of the trap (True if no exception). First, give the decorator an alias to support Python 3.8 Syntax. >>> passes = ExceptionTrap(ValueError).passes Now decorate a function that always fails. >>> @passes ... def fail(): ... raise ValueError('failed') >>> fail() False rc)rmoperatornot_)rJrjs r passeszExceptionTrap.passess&{{4x}{555r/N)__name__ __module__ __qualname____doc__rS ExceptionrKrNpropertyrTrXr[r_rbrarmrqrr/r rGrG`s: H#,,%%%%  X   X   X %)666666r/rGceZdZdZdS)suppressz A version of contextlib.suppress with decorator support. >>> @suppress(KeyError) ... def key_error(): ... {}[''] >>> key_error() N)rrrsrtrurr/r ryrysr/ryc*eZdZdZ ddZdZdZdS) on_interrupta Replace a KeyboardInterrupt with SystemExit(1) >>> def do_interrupt(): ... raise KeyboardInterrupt() >>> on_interrupt('error')(do_interrupt)() Traceback (most recent call last): ... SystemExit: 1 >>> on_interrupt('error', code=255)(do_interrupt)() Traceback (most recent call last): ... SystemExit: 255 >>> on_interrupt('suppress')(do_interrupt)() >>> with __import__('pytest').raises(KeyboardInterrupt): ... on_interrupt('ignore')(do_interrupt)() errorrWc"||_||_dSr)actioncode)rJr~rs r rKzon_interrupt.__init__s  r/c|SrrrMs r rNzon_interrupt.__enter__rOr/c|tus |jdkrdS|jdkrt|j||jdkS)Nignorer|ry)KeyboardInterruptr~ SystemExitr)rJexctypeexcinstexctbs r r_zon_interrupt.__exit__sK + + +t{h/F/F F [G # #TY''W 4{j((r/N)r|rW)rrrsrtrurKrNr_rr/r r{r{sZ( )))))r/r{)rr contextlibrr1shutilrocontextmanagerr r"rrmtreer4rCrErGryContextDecoratorr{rr/r rs    $(U77776333 ]     !$    j6j6j6j6j6j6j6j6Zz"J$?%)%)%)%)%):.%)%)%)%)%)r/