main commit
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-10-16 16:30:25 +09:00
parent 91c7e04474
commit 537e7b363f
1146 changed files with 45926 additions and 77196 deletions

View File

@@ -5,7 +5,6 @@ from contextlib import contextmanager
import logging
import sys
import textwrap
from typing import Iterator
from typing import Optional
from typing import TextIO
from typing import Union
@@ -13,6 +12,8 @@ import warnings
from sqlalchemy.engine import url
from . import sqla_compat
log = logging.getLogger(__name__)
# disable "no handler found" errors
@@ -52,9 +53,7 @@ def write_outstream(
@contextmanager
def status(
status_msg: str, newline: bool = False, quiet: bool = False
) -> Iterator[None]:
def status(status_msg: str, newline: bool = False, quiet: bool = False):
msg(status_msg + " ...", newline, flush=True, quiet=quiet)
try:
yield
@@ -67,24 +66,21 @@ def status(
write_outstream(sys.stdout, " done\n")
def err(message: str, quiet: bool = False) -> None:
def err(message: str, quiet: bool = False):
log.error(message)
msg(f"FAILED: {message}", quiet=quiet)
sys.exit(-1)
def obfuscate_url_pw(input_url: str) -> str:
return url.make_url(input_url).render_as_string(hide_password=True)
u = url.make_url(input_url)
return sqla_compat.url_render_as_string(u, hide_password=True)
def warn(msg: str, stacklevel: int = 2) -> None:
warnings.warn(msg, UserWarning, stacklevel=stacklevel)
def warn_deprecated(msg: str, stacklevel: int = 2) -> None:
warnings.warn(msg, DeprecationWarning, stacklevel=stacklevel)
def msg(
msg: str, newline: bool = True, flush: bool = False, quiet: bool = False
) -> None:
@@ -96,17 +92,11 @@ def msg(
write_outstream(sys.stdout, "\n")
else:
# left indent output lines
indent = " "
lines = textwrap.wrap(
msg,
TERMWIDTH,
initial_indent=indent,
subsequent_indent=indent,
)
lines = textwrap.wrap(msg, TERMWIDTH)
if len(lines) > 1:
for line in lines[0:-1]:
write_outstream(sys.stdout, line, "\n")
write_outstream(sys.stdout, lines[-1], ("\n" if newline else ""))
write_outstream(sys.stdout, " ", line, "\n")
write_outstream(sys.stdout, " ", lines[-1], ("\n" if newline else ""))
if flush:
sys.stdout.flush()