Voice et bot modif
This commit is contained in:
parent
189d56026b
commit
7333a22bcd
10774 changed files with 634644 additions and 933308 deletions
|
|
@ -1,5 +1,3 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import contextlib
|
||||
import errno
|
||||
import logging
|
||||
|
|
@ -7,11 +5,10 @@ import logging.handlers
|
|||
import os
|
||||
import sys
|
||||
import threading
|
||||
from collections.abc import Generator
|
||||
from dataclasses import dataclass
|
||||
from io import TextIOWrapper
|
||||
from logging import Filter
|
||||
from typing import Any, ClassVar
|
||||
from typing import Any, ClassVar, Generator, List, Optional, TextIO, Type
|
||||
|
||||
from pip._vendor.rich.console import (
|
||||
Console,
|
||||
|
|
@ -32,8 +29,6 @@ from pip._internal.utils.deprecation import DEPRECATION_MSG_PREFIX
|
|||
from pip._internal.utils.misc import ensure_dir
|
||||
|
||||
_log_state = threading.local()
|
||||
_stdout_console = None
|
||||
_stderr_console = None
|
||||
subprocess_logger = getLogger("pip.subprocessor")
|
||||
|
||||
|
||||
|
|
@ -43,7 +38,7 @@ class BrokenStdoutLoggingError(Exception):
|
|||
"""
|
||||
|
||||
|
||||
def _is_broken_pipe_error(exc_class: type[BaseException], exc: BaseException) -> bool:
|
||||
def _is_broken_pipe_error(exc_class: Type[BaseException], exc: BaseException) -> bool:
|
||||
if exc_class is BrokenPipeError:
|
||||
return True
|
||||
|
||||
|
|
@ -142,28 +137,12 @@ class IndentedRenderable:
|
|||
yield Segment("\n")
|
||||
|
||||
|
||||
class PipConsole(Console):
|
||||
def on_broken_pipe(self) -> None:
|
||||
# Reraise the original exception, rich 13.8.0+ exits by default
|
||||
# instead, preventing our handler from firing.
|
||||
raise BrokenPipeError() from None
|
||||
|
||||
|
||||
def get_console(*, stderr: bool = False) -> Console:
|
||||
if stderr:
|
||||
assert _stderr_console is not None, "stderr rich console is missing!"
|
||||
return _stderr_console
|
||||
else:
|
||||
assert _stdout_console is not None, "stdout rich console is missing!"
|
||||
return _stdout_console
|
||||
|
||||
|
||||
class RichPipStreamHandler(RichHandler):
|
||||
KEYWORDS: ClassVar[list[str] | None] = []
|
||||
KEYWORDS: ClassVar[Optional[List[str]]] = []
|
||||
|
||||
def __init__(self, console: Console) -> None:
|
||||
def __init__(self, stream: Optional[TextIO], no_color: bool) -> None:
|
||||
super().__init__(
|
||||
console=console,
|
||||
console=Console(file=stream, no_color=no_color, soft_wrap=True),
|
||||
show_time=False,
|
||||
show_level=False,
|
||||
show_path=False,
|
||||
|
|
@ -172,11 +151,11 @@ class RichPipStreamHandler(RichHandler):
|
|||
|
||||
# Our custom override on Rich's logger, to make things work as we need them to.
|
||||
def emit(self, record: logging.LogRecord) -> None:
|
||||
style: Style | None = None
|
||||
style: Optional[Style] = None
|
||||
|
||||
# If we are given a diagnostic error to present, present it with indentation.
|
||||
assert isinstance(record.args, tuple)
|
||||
if getattr(record, "rich", False):
|
||||
assert isinstance(record.args, tuple)
|
||||
(rich_renderable,) = record.args
|
||||
assert isinstance(
|
||||
rich_renderable, (ConsoleRenderable, RichCast, str)
|
||||
|
|
@ -233,6 +212,7 @@ class MaxLevelFilter(Filter):
|
|||
|
||||
|
||||
class ExcludeLoggerFilter(Filter):
|
||||
|
||||
"""
|
||||
A logging Filter that excludes records from a logger (or its children).
|
||||
"""
|
||||
|
|
@ -243,7 +223,7 @@ class ExcludeLoggerFilter(Filter):
|
|||
return not super().filter(record)
|
||||
|
||||
|
||||
def setup_logging(verbosity: int, no_color: bool, user_log_file: str | None) -> int:
|
||||
def setup_logging(verbosity: int, no_color: bool, user_log_file: Optional[str]) -> int:
|
||||
"""Configures and sets up all of the logging
|
||||
|
||||
Returns the requested logging level, as its integer value.
|
||||
|
|
@ -280,6 +260,10 @@ def setup_logging(verbosity: int, no_color: bool, user_log_file: str | None) ->
|
|||
vendored_log_level = "WARNING" if level in ["INFO", "ERROR"] else "DEBUG"
|
||||
|
||||
# Shorthands for clarity
|
||||
log_streams = {
|
||||
"stdout": "ext://sys.stdout",
|
||||
"stderr": "ext://sys.stderr",
|
||||
}
|
||||
handler_classes = {
|
||||
"stream": "pip._internal.utils.logging.RichPipStreamHandler",
|
||||
"file": "pip._internal.utils.logging.BetterRotatingFileHandler",
|
||||
|
|
@ -287,9 +271,6 @@ def setup_logging(verbosity: int, no_color: bool, user_log_file: str | None) ->
|
|||
handlers = ["console", "console_errors", "console_subprocess"] + (
|
||||
["user_log"] if include_user_log else []
|
||||
)
|
||||
global _stdout_console, stderr_console
|
||||
_stdout_console = PipConsole(file=sys.stdout, no_color=no_color, soft_wrap=True)
|
||||
_stderr_console = PipConsole(file=sys.stderr, no_color=no_color, soft_wrap=True)
|
||||
|
||||
logging.config.dictConfig(
|
||||
{
|
||||
|
|
@ -324,14 +305,16 @@ def setup_logging(verbosity: int, no_color: bool, user_log_file: str | None) ->
|
|||
"console": {
|
||||
"level": level,
|
||||
"class": handler_classes["stream"],
|
||||
"console": _stdout_console,
|
||||
"no_color": no_color,
|
||||
"stream": log_streams["stdout"],
|
||||
"filters": ["exclude_subprocess", "exclude_warnings"],
|
||||
"formatter": "indent",
|
||||
},
|
||||
"console_errors": {
|
||||
"level": "WARNING",
|
||||
"class": handler_classes["stream"],
|
||||
"console": _stderr_console,
|
||||
"no_color": no_color,
|
||||
"stream": log_streams["stderr"],
|
||||
"filters": ["exclude_subprocess"],
|
||||
"formatter": "indent",
|
||||
},
|
||||
|
|
@ -340,7 +323,8 @@ def setup_logging(verbosity: int, no_color: bool, user_log_file: str | None) ->
|
|||
"console_subprocess": {
|
||||
"level": level,
|
||||
"class": handler_classes["stream"],
|
||||
"console": _stderr_console,
|
||||
"stream": log_streams["stderr"],
|
||||
"no_color": no_color,
|
||||
"filters": ["restrict_to_subprocess"],
|
||||
"formatter": "indent",
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue