SILENT KILLERPanel

Current Path: > > opt > > hc_python > > lib > python3.12 > site-packages > > pre_commit


Operation   : Linux premium131.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
Software     : Apache
Server IP    : 162.0.232.56 | Your IP: 216.73.216.111
Domains      : 1034 Domain(s)
Permission   : [ 0755 ]

Files and Folders in: //opt//hc_python//lib/python3.12/site-packages//pre_commit

NameTypeSizeLast ModifiedActions
__pycache__ Directory - -
commands Directory - -
languages Directory - -
meta_hooks Directory - -
resources Directory - -
__init__.py File 0 bytes April 04 2025 08:02:35.
__main__.py File 127 bytes April 04 2025 08:02:35.
all_languages.py File 1412 bytes April 04 2025 08:02:35.
clientlib.py File 15282 bytes April 04 2025 08:02:35.
color.py File 3219 bytes April 04 2025 08:02:35.
constants.py File 282 bytes April 04 2025 08:02:35.
envcontext.py File 1593 bytes April 04 2025 08:02:35.
error_handler.py File 2621 bytes April 04 2025 08:02:35.
errors.py File 78 bytes April 04 2025 08:02:35.
file_lock.py File 2342 bytes April 04 2025 08:02:35.
git.py File 8524 bytes April 04 2025 08:02:35.
hook.py File 1513 bytes April 04 2025 08:02:35.
lang_base.py File 5238 bytes April 04 2025 08:02:35.
logging_handler.py File 1019 bytes April 04 2025 08:02:35.
main.py File 15564 bytes April 04 2025 08:02:35.
output.py File 911 bytes April 04 2025 08:02:35.
parse_shebang.py File 2481 bytes April 04 2025 08:02:35.
prefix.py File 495 bytes April 04 2025 08:02:35.
repository.py File 7608 bytes April 04 2025 08:02:35.
staged_files_only.py File 4155 bytes April 04 2025 08:02:35.
store.py File 9392 bytes April 04 2025 08:02:35.
util.py File 7038 bytes April 04 2025 08:02:35.
xargs.py File 5541 bytes April 04 2025 08:02:35.
yaml.py File 561 bytes April 04 2025 08:02:35.
yaml_rewrite.py File 1337 bytes April 04 2025 08:02:35.

Reading File: //opt//hc_python//lib/python3.12/site-packages//pre_commit/envcontext.py

from __future__ import annotations

import contextlib
import enum
import os
from collections.abc import Generator
from collections.abc import MutableMapping
from typing import NamedTuple
from typing import Union

_Unset = enum.Enum('_Unset', 'UNSET')
UNSET = _Unset.UNSET


class Var(NamedTuple):
    name: str
    default: str = ''


SubstitutionT = tuple[Union[str, Var], ...]
ValueT = Union[str, _Unset, SubstitutionT]
PatchesT = tuple[tuple[str, ValueT], ...]


def format_env(parts: SubstitutionT, env: MutableMapping[str, str]) -> str:
    return ''.join(
        env.get(part.name, part.default) if isinstance(part, Var) else part
        for part in parts
    )


@contextlib.contextmanager
def envcontext(
        patch: PatchesT,
        _env: MutableMapping[str, str] | None = None,
) -> Generator[None]:
    """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
    """
    env = os.environ if _env is None else _env
    before = dict(env)

    for k, v in patch:
        if v is UNSET:
            env.pop(k, None)
        elif isinstance(v, tuple):
            env[k] = format_env(v, before)
        else:
            env[k] = v

    try:
        yield
    finally:
        env.clear()
        env.update(before)

SILENT KILLER Tool