mirror of
ssh://git.janware.com/janware/proj/jw-pkg
synced 2026-04-24 09:13:37 +02:00
lib.ExecContext.log_name: Add property
Add a .log_name property to be used in log messages. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
1214451c15
commit
4f17a9cc93
1 changed files with 11 additions and 0 deletions
|
|
@ -169,6 +169,7 @@ class ExecContext(abc.ABC):
|
|||
self.__uri = uri
|
||||
self.__interactive = interactive
|
||||
self.__verbose_default = verbose_default
|
||||
self.__log_name: str|None = None
|
||||
assert verbose_default is not None
|
||||
|
||||
async def __aenter__(self):
|
||||
|
|
@ -181,6 +182,16 @@ class ExecContext(abc.ABC):
|
|||
def uri(self) -> str:
|
||||
return self.__uri
|
||||
|
||||
@property
|
||||
def log_name(self) -> str:
|
||||
if self.__log_name is None:
|
||||
from urllib.parse import urlparse
|
||||
parsed = urlparse(self.__uri)
|
||||
scheme = 'local' if parsed.scheme is None else parsed.scheme
|
||||
hostname = '' if parsed.hostname is None else ''
|
||||
self.__log_name = f'{scheme}://{hostname}'
|
||||
return self.__log_name
|
||||
|
||||
@property
|
||||
def interactive(self) -> bool|None:
|
||||
return self.__interactive
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue