U üeLã@sèddlmZddlZddlZddlZddlmZddlmZddlmZddlm Z ddlm Z e  dd ¡Z e j Z Gd d „d eƒZe e eefd fZe ee efZe e eefd fZd dddœdd„Zejdddddœdd„ƒZdS)é)Ú annotationsN)Ú Generator)ÚMutableMapping)Ú NamedTuple)ÚTuple)ÚUnionÚ_UnsetÚUNSETc@s"eZdZUded<dZded<dS)ÚVarÚstrÚnameÚÚdefaultN)Ú__name__Ú __module__Ú __qualname__Ú__annotations__r©rrúC/opt/hc_python/lib/python3.8/site-packages/pre_commit/envcontext.pyr s r .Ú SubstitutionTzMutableMapping[str, str]r )ÚpartsÚenvÚreturncsd ‡fdd„|Dƒ¡S)Nr c3s,|]$}t|tƒr ˆ |j|j¡n|VqdS)N)Ú isinstancer Úgetr r)Ú.0Úpart©rrrÚ sÿzformat_env..)Újoin)rrrrrÚ format_envsþr ÚPatchesTzMutableMapping[str, str] | NonezGenerator[(None, None, None)])ÚpatchÚ_envrc cs„|dkrtjn|}t|ƒ}|D]@\}}|tkr<| |d¡qt|tƒrVt||ƒ||<q|||<qz dVW5| ¡|  |¡XdS)a¥In this context, `os.environ` is modified according to `patch`. `patch` is an iterable of 2-tuples (key, value): `key`: string `value`: - string: `environ[key] == value` inside the context. - UNSET: `key not in environ` inside the context. - template: A template is a tuple of strings and Var which will be replaced with the previous environment N) ÚosÚenvironÚdictr ÚpoprÚtupler ÚclearÚupdate)r"r#rÚbeforeÚkÚvrrrÚ envcontext!s    r.)N)Ú __future__rÚ contextlibÚenumr$ÚtypingrrrrrÚEnumrr r r rZValueTr!r Úcontextmanagerr.rrrrÚs$       þ