a0bi$SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKr\RS5r \RSS\ 4Sj5r Sr \R\R4Sj5r \RSS\ 4Sj5r\RS5r"S S 5r"S S \R"\R$5r"S S\R$5rg)Nc## [R"5n[R"U5 Uv [R"U5 g![R"U5 f=f7f)z >>> tmp_path = getfixture('tmp_path') >>> with pushd(tmp_path): ... assert os.getcwd() == os.fspath(tmp_path) >>> assert os.getcwd() != os.fspath(tmp_path) N)osgetcwdchdir)dirorigs ښ/builddir/build/BUILDROOT/alt-python313-setuptools-69.0.2-3.el8.x86_64/opt/alt/python313/lib/python3.13/site-packages/setuptools/_vendor/jaraco/context.pypushdr s= 99;DHHSM  s,A%A A% A""A%c ## Uc?[RRU5RSS5RSS5nUc$[R "[ RSS9nO[R"S[5 U"SR"S0[5D65 S nS nS RXE45nU"UR"SS [U50[5D65 U"U5 Uv SSS5 U"S R"S0[5D65 g!,(df  N/=f!U"S R"S0[5D65 f=f7f)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)shellzrunner parameter is deprecatedzmkdir {target_dir}zwget {url} -O -z7tar x{compression} --strip-components=1 -C {target_dir}z | compressionzrm -Rf {target_dir})rpathbasenamereplace functoolspartial subprocess check_callwarningswarnDeprecationWarningformatvarsjoininfer_compression)url target_dirrunnerr getterextractcmds r tarball_contextr$sWW%%c*229bAII&RTU  ~"":#8#8E 68JK   & & 0 017"Kjj&*+szzG&7&<GGH :   $++5df56  $++5df56s7B%E(A D01D6D0>!E D-)D00"EEcFUSSn[SSSS9nURUS5$)z Given a URL or filename, infer the compression code for tar. >>> infer_compression('http://foo/bar.tar.gz') 'z' >>> infer_compression('http://foo/bar.tgz') 'z' >>> infer_compression('file.bz') 'j' >>> infer_compression('file.xz') 'J' NzjJ)gzbzxz)dictget)rcompression_indicatormappings r rr:s0 Hccc*G ;;,c 22c#j# [R"5nUv U"U5 g!U"U5 f=f7f)a. Create a temporary directory context. Pass a custom remover to override the removal behavior. >>> import pathlib >>> with temp_dir() as the_dir: ... assert os.path.isdir(the_dir) ... _ = pathlib.Path(the_dir).joinpath('somefile').write_text('contents') >>> assert not os.path.exists(the_dir) N)tempfilemkdtemp)removertemp_dirs r r6r6Ns/!Hs3& 3 03Tc#.# SU;aSOSnU"5nUSX/nU(aURSU/5 [[RRS5nU(aUOSn[ R "XhS9 Uv SSS5 g!,(df  g=f7f)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_contextrEastC<%TC xGS+  JJ F+ ,rww,!tc1 sBA'B; B BBc## Sv g7f)zw A null context suitable to stand in for a meaningful context. >>> with null() as value: ... assert value is None Nrrr1r nullrGts  sc\rSrSrSrSr\44SjrSr\ S5r \ S5r \ S5r S r S r\S .S jrS rSrg) ExceptionTrapaA 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 >>> trap.value ValueError('1 + 1 is not 3') >>> trap.tb >>> with ExceptionTrap(ValueError) as trap: ... raise Exception() Traceback (most recent call last): ... Exception >>> bool(trap) False )NNNcXlgN) exceptions)selfrMs r __init__ExceptionTrap.__init__s$r1cU$rLrrNs r __enter__ExceptionTrap.__enter__ r1c URS$Nrexc_inforRs r typeExceptionTrap.type}}Qr1c URS$)NrXrRs r valueExceptionTrap.valuer\r1c URS$)NrXrRs r tbExceptionTrap.tbr\r1cfUSnU=(a [X R5nU(aXlU$rW) issubclassrMrY)rNrYrZmatchess r __exit__ExceptionTrap.__exit__s+{<:dOO< $Mr1c,[UR5$rL)boolrZrRs r __bool__ExceptionTrap.__bool__sDIIr1_testcN^^^[R"T5UUU4Sj5nU$)aQ 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 c>[TR5nT"U0UD6 SSS5 T"W5$!,(df  N=frL)rIrM)argskwargstraprofuncrNs r wrapper%ExceptionTrap.raises..wrappers6t/4d%f%0; 0/s 0 >)rwraps)rNrurorvs``` r raisesExceptionTrap.raisess'&      r1c>URU[RS9$)aJ 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 rn)ryoperatornot_)rNrus r passesExceptionTrap.passess&{{4x}}{55r1)rYrMN)__name__ __module__ __qualname____firstlineno____doc__rY ExceptionrOrSpropertyrZr_rcrhrlrkryr~__static_attributes__rr1r rIrIssB H#,,%      %)66r1rIc\rSrSrSrSrg)suppressz A version of contextlib.suppress with decorator support. >>> @suppress(KeyError) ... def key_error(): ... {}[''] >>> key_error() rN)rrrrrrrr1r rrsr1rc2\rSrSrSrSSjrSrSrSrg) 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)() cXlX lgrLactioncode)rNrrs r rOon_interrupt.__init__s  r1cU$rLrrRs r rSon_interrupt.__enter__rUr1cU[LdURS:XagURS:Xa[UR5UeURS:H$)Nignoreerrorr)KeyboardInterruptr SystemExitr)rNexctypeexcinstexctbs r rhon_interrupt.__exit__sE + +t{{h/F  [[G #TYY'W 4{{j((r1rN)rr^) rrrrrrOrSrhrrr1r rrs ( )r1r)rr contextlibrr3shutilr|rcontextmanagerr r$rrmtreer6rErGrIrContextDecoratorrrr1r rs       $(U77:3( ]]$ !$   n6n6bz""J$?$?%):..%)r1