__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
from __future__ import annotations
import contextlib
import functools
import os.path
import sys
import traceback
from collections.abc import Generator
from typing import IO
import pre_commit.constants as C
from pre_commit import output
from pre_commit.errors import FatalError
from pre_commit.store import Store
from pre_commit.util import cmd_output_b
from pre_commit.util import force_bytes
def _log_and_exit(
msg: str,
ret_code: int,
exc: BaseException,
formatted: str,
) -> None:
error_msg = f'{msg}: {type(exc).__name__}: '.encode() + force_bytes(exc)
output.write_line_b(error_msg)
_, git_version_b, _ = cmd_output_b('git', '--version', check=False)
git_version = git_version_b.decode(errors='backslashreplace').rstrip()
storedir = Store().directory
log_path = os.path.join(storedir, 'pre-commit.log')
with contextlib.ExitStack() as ctx:
if os.access(storedir, os.W_OK):
output.write_line(f'Check the log at {log_path}')
log: IO[bytes] = ctx.enter_context(open(log_path, 'wb'))
else: # pragma: win32 no cover
output.write_line(f'Failed to write to log at {log_path}')
log = sys.stdout.buffer
_log_line = functools.partial(output.write_line, stream=log)
_log_line_b = functools.partial(output.write_line_b, stream=log)
_log_line('### version information')
_log_line()
_log_line('```')
_log_line(f'pre-commit version: {C.VERSION}')
_log_line(f'git --version: {git_version}')
_log_line('sys.version:')
for line in sys.version.splitlines():
_log_line(f' {line}')
_log_line(f'sys.executable: {sys.executable}')
_log_line(f'os.name: {os.name}')
_log_line(f'sys.platform: {sys.platform}')
_log_line('```')
_log_line()
_log_line('### error information')
_log_line()
_log_line('```')
_log_line_b(error_msg)
_log_line('```')
_log_line()
_log_line('```')
_log_line(formatted.rstrip())
_log_line('```')
raise SystemExit(ret_code)
@contextlib.contextmanager
def error_handler() -> Generator[None]:
try:
yield
except (Exception, KeyboardInterrupt) as e:
if isinstance(e, FatalError):
msg, ret_code = 'An error has occurred', 1
elif isinstance(e, KeyboardInterrupt):
msg, ret_code = 'Interrupted (^C)', 130
else:
msg, ret_code = 'An unexpected error has occurred', 3
_log_and_exit(msg, ret_code, e, traceback.format_exc())
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| __pycache__ | Folder | 0755 |
|
|
| commands | Folder | 0755 |
|
|
| languages | Folder | 0755 |
|
|
| meta_hooks | Folder | 0755 |
|
|
| resources | Folder | 0755 |
|
|
| __init__.py | File | 0 B | 0644 |
|
| __main__.py | File | 127 B | 0644 |
|
| all_languages.py | File | 1.43 KB | 0644 |
|
| clientlib.py | File | 16.42 KB | 0644 |
|
| color.py | File | 3.14 KB | 0644 |
|
| constants.py | File | 282 B | 0644 |
|
| envcontext.py | File | 1.56 KB | 0644 |
|
| error_handler.py | File | 2.56 KB | 0644 |
|
| errors.py | File | 78 B | 0644 |
|
| file_lock.py | File | 2.3 KB | 0644 |
|
| git.py | File | 8.33 KB | 0644 |
|
| hook.py | File | 1.48 KB | 0644 |
|
| lang_base.py | File | 5.26 KB | 0644 |
|
| logging_handler.py | File | 1019 B | 0644 |
|
| main.py | File | 15.56 KB | 0644 |
|
| output.py | File | 911 B | 0644 |
|
| parse_shebang.py | File | 2.42 KB | 0644 |
|
| prefix.py | File | 495 B | 0644 |
|
| repository.py | File | 7.43 KB | 0644 |
|
| staged_files_only.py | File | 4.06 KB | 0644 |
|
| store.py | File | 8.27 KB | 0644 |
|
| util.py | File | 6.88 KB | 0644 |
|
| xargs.py | File | 5.42 KB | 0644 |
|
| yaml.py | File | 561 B | 0644 |
|
| yaml_rewrite.py | File | 1.31 KB | 0644 |
|