lib.FileContext.root: Add property

Add a .root property, returning the path part of the instantiating
URI. Nothing meaningful beyond returning it is done with it so far.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-04-22 07:03:01 +02:00
commit b52264dfad
Signed by: jan
GPG key ID: 3750640C9E25DD61

View file

@ -16,6 +16,7 @@ class FileContext(abc.ABC):
def __init__(self, uri: str, interactive: bool|None=None, verbose_default=False):
self.__uri = uri
self.__id, self.__root = self.split_uri(uri)
self.__interactive = interactive
self.__verbose_default = verbose_default
self.__log_name: str|None = None
@ -40,15 +41,18 @@ class FileContext(abc.ABC):
netloc = p.netloc if p.netloc else ''
return f'{cls.schema_from_uri(uri)}://{netloc}', p.path
@cached_property
def id(self) -> str:
id, path = self.split_uri(self.__uri)
return id
@property
def uri(self) -> str:
return self.__uri
@property
def id(self) -> str:
return self.__id
@property
def root(self) -> str:
return self.__root
@property
def log_name(self) -> str:
if self.__log_name is None: