Fix MOTD for extra data

This commit is contained in:
Adam Hopkins 2023-08-21 16:37:55 +03:00
parent 16256522f6
commit f651f7436f
No known key found for this signature in database
GPG Key ID: 9F85EE6C807303FB
2 changed files with 10 additions and 2 deletions

View File

@ -73,6 +73,14 @@ class MOTDTTY(MOTD):
self.value_width = min(
max(map(len, self.data.values())), self.max_value_width
)
if self.extra:
self.key_width = max(
self.key_width, max(map(len, self.extra.keys()))
)
self.value_width = min(
max((*map(len, self.extra.values()), self.value_width)),
self.max_value_width,
)
self.logo_lines = self.logo.split("\n") if self.logo else []
self.logo_line_length = 24
self.centering_length = (

View File

@ -3,7 +3,6 @@ from __future__ import annotations
import os
import platform
import sys
from asyncio import (
AbstractEventLoop,
CancelledError,
@ -71,7 +70,6 @@ from sanic.worker.multiplexer import WorkerMultiplexer
from sanic.worker.reloader import Reloader
from sanic.worker.serve import worker_serve
if TYPE_CHECKING:
from sanic import Sanic
from sanic.application.state import ApplicationState
@ -90,6 +88,7 @@ else: # no cov
class StartupMixin(metaclass=SanicMeta):
_app_registry: ClassVar[Dict[str, Sanic]]
name: str
config: Config
listeners: Dict[str, List[ListenerType[Any]]]
state: ApplicationState
@ -605,6 +604,7 @@ class StartupMixin(metaclass=SanicMeta):
server = "ASGI" if self.asgi else "unknown" # type: ignore
display = {
"app": self.name,
"mode": " ".join(mode),
"server": server,
"python": platform.python_version(),