Skip to content

Commit 5501162

Browse files
committed
version 1.1.0
1 parent c8c5372 commit 5501162

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

dlr/ki/logging/utils.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
from importlib.metadata import metadata, Distribution
5-
from os import get_terminal_size
5+
import os
66
from textwrap import wrap
77

88

@@ -54,7 +54,7 @@ def welcome(
5454
description = metadata(module_name).get("summary", "") # type: ignore[attr-defined]
5555

5656
logo = [" __/|__", "/_/_/_/", " |/ DLR"]
57-
text_width = min(max_width, get_terminal_size().columns) - 13
57+
text_width = min(max_width, _get_terminal_size().columns) - 13
5858
desc = ["\033[1;36m" + name + "\033[0m", *wrap(description or "", text_width)]
5959

6060
if len(desc) < 3:
@@ -63,9 +63,9 @@ def welcome(
6363
logo.insert(0, "")
6464
(desc if len(desc) < len(logo) else logo).extend([""] * abs(len(desc) - len(logo)))
6565

66-
welcome_msg = []
66+
welcome_msg: list[str] = []
6767
for logo_part, text_part in zip(logo, desc, strict=True):
68-
welcome_msg.append(f"{logo_part:<12} {text_part}")
68+
welcome_msg.append(f"{logo_part:<12} {text_part}".rstrip())
6969
if (leading_empty_line is None and print_to_stdout) or leading_empty_line:
7070
welcome_msg.insert(0, "")
7171
if (tailing_empty_line is None and print_to_stdout) or tailing_empty_line:
@@ -75,3 +75,11 @@ def welcome(
7575
if print_to_stdout:
7676
print(msg)
7777
return msg
78+
79+
80+
def _get_terminal_size() -> os.terminal_size:
81+
try:
82+
# this will throw an error during unit tests since no TTY is available
83+
return os.get_terminal_size()
84+
except OSError:
85+
return os.terminal_size((80, 24))

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ name = "dlr-logging" # Required
1818
#
1919
# For a discussion on single-sourcing the version, see
2020
# https://packaging.python.org/guides/single-sourcing-package-version/
21-
version = "1.0.1" # Required
21+
version = "1.1.0" # Required
2222

2323
# This is a one-line description or tagline of what your project does. This
2424
# corresponds to the "Summary" metadata field:

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)