§ }BFjlãóP—dZddlmZddlZddlmZddlmZGd„d¦«ZdS)zMiscellaneous context managers.é)Ú annotationsN)Ú TracebackType)ÚAnycó*—eZdZdZdd„Zdd „Zdd„ZdS)Ú preserve_keysa Preserve a set of keys in a dictionary. Upon entering the context manager the current values of the keys will be saved. Upon exiting, the dictionary will be updated to restore the original value of the preserved keys. Preserved keys which did not exist when entering the context manager will be deleted. Examples -------- >>> d = {'a': 1, 'b': 2, 'c': 3} >>> with preserve_keys(d, 'b', 'c', 'd'): ... del d['a'] ... del d['b'] # will be reset to 2 ... d['c'] = None # will be reset to 3 ... d['d'] = 4 # will be deleted ... d['e'] = 5 ... print(sorted(d.items())) ... [('c', None), ('d', 4), ('e', 5)] >>> print(sorted(d.items())) [('b', 2), ('c', 3), ('e', 5)] Ú dictionaryúdict[Any, Any]ÚkeysrÚreturnÚNonecó"—||_||_dS©N)rr )Úselfrr s úDC:\PYTHON\_runtimes\venv\Lib\site-packages\IPython/utils/contexts.pyÚ__init__zpreserve_keys.__init__(s€Ø$ˆŒØˆŒ ˆ ˆ ócó–—g}i}|j}|jD]'}||vr ||||<Œ| |¦«Œ(||_||_dSr)rr ÚappendÚ to_deleteÚ to_update)rrrÚdÚks rÚ __enter__zpreserve_keys.__enter__,se€à!ˆ Ø$&ˆ à ŒOˆØ”ð $ð $ˆAØAˆvˆvØ  œt ˜!‘ à× Ò  Ñ#Ô#Ð#Ð#à"ˆŒØ"ˆŒˆˆrÚexc_typeútype[BaseException] | NoneÚexc_valúBaseException | NoneÚexc_tbúTracebackType | Nonecóˆ—|j}|jD]}| |d¦«Œ| |j¦«dSr)rrÚpopÚupdater)rrrrrrs rÚ__exit__zpreserve_keys.__exit__;sI€ð ŒOˆà”ð ð ˆAØ EŠE!T‰NŒNˆNˆNØ Š”Ñ Ô Ð Ð Ð rN)rr r rr r )r r )rrrrrrr r )Ú__name__Ú __module__Ú __qualname__Ú__doc__rrr#©rrrrsZ€€€€€ððð2ðððð #ð #ð #ð #ð !ð !ð !ð !ð !ð !rr) r'Ú __future__rÚwarningsÚtypesrÚtypingrrr(rrúr-s|ðà%Ð%à"Ð"Ð"Ð"Ð"Ð"à€€€ØÐÐÐÐÐØÐÐÐÐÐð 7!ð7!ð7!ð7!ð7!ñ7!ô7!ð7!ð7!ð7!r