lib.base.Result.__repr__(): Add method
Add __repr__() to Result to make it more meaningful in log messages.
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
1999f85645
commit
6874a90bb4
1 changed files with 18 additions and 1 deletions
|
|
@ -1,7 +1,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from enum import Enum, auto
|
||||
from typing import NamedTuple, TypeAlias, TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING, NamedTuple, TypeAlias
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import os
|
||||
|
|
@ -54,6 +54,23 @@ class Result:
|
|||
def encoding(self, value: str) -> None:
|
||||
self.__encoding = value
|
||||
|
||||
def __stdout_footprint(self, quote = False) -> str:
|
||||
if self.__stdout is None:
|
||||
ret = ''
|
||||
else:
|
||||
ret = self.stdout_str[:20]
|
||||
if quote:
|
||||
ret = '"{ret}"'
|
||||
return ret
|
||||
|
||||
def __repr__(self) -> str:
|
||||
ret = f'{self.__status}:'
|
||||
if self.status != 0:
|
||||
ret += f' err: {self.stderr_str_or_none}'
|
||||
else:
|
||||
ret += f' out: {self.__stdout_footprint(quote=True)}'
|
||||
return ret
|
||||
|
||||
@property
|
||||
def strip(self) -> bool:
|
||||
return self.__strip
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue