gigl.common.types.uri.LocalUri#
- class gigl.common.types.uri.local_uri.LocalUri(uri: str | Path | Uri)#
Bases:
Uri
,PathLike
Represents a local URI (Uniform Resource Identifier) that extends the Uri class and implements the os.PathLike interface.
Methods
Returns an absolute LocalUri object.
The base name is the final component of the path, effectively extracting the file or directory name from a full path string.
Checks if the given URI is valid.
Joins multiple URI tokens together and returns a new LocalUri object.
- classmethod __class_getitem__()#
Represent a PEP 585 generic type
E.g. for t = list[int], t.__origin__ is list and t.__args__ is (int,).
- __eq__(other: Any) bool #
Return self==value.
- __fspath__()#
Return the file system path representation of the object. Needed for os.PathLike interface.
- Returns:
str: The file system path representation of the object.
- __hash__() int #
Return hash(self).
- __repr__() str #
Returns a string representation of the LocalUri object.
- Returns:
str: The string representation of the LocalUri object.
- classmethod __subclasshook__(subclass)#
Abstract classes can override this to customize issubclass().
This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).
- __weakref__#
list of weak references to the object (if defined)
- absolute() LocalUri #
Returns an absolute LocalUri object.
- Returns:
LocalUri: An absolute LocalUri object.
- get_basename() str #
The base name is the final component of the path, effectively extracting the file or directory name from a full path string. i.e. get_basename(“/foo/bar.txt”) -> bar.txt get_basename(“gs://bucket/foo”) -> foo
- classmethod is_valid(uri: str | Path | Uri, raise_exception: bool | None = False) bool #
Checks if the given URI is valid.
- Args:
uri (Union[str, Path, Uri]): The URI to check. raise_exception (Optional[bool]): Whether to raise an exception if the URI is invalid. Defaults to False.
- Returns:
bool: True if the URI is valid, False otherwise.
- classmethod join(token: str | Path | Uri, *tokens: str | Path | Uri) LocalUri #
Joins multiple URI tokens together and returns a new LocalUri object.
- Args:
token (Union[str, Path, Uri]): The first URI token to join. *tokens (Union[str, Path, Uri]): Additional URI tokens to join.
- Returns:
LocalUri: A new LocalUri object representing the joined URI.