gigl.common#
Common utilities, services, and tools used throughout GiGL.
Submodules#
Classes#
| Represents a Google Cloud Storage (GCS) URI. | |
| Represents an HTTP URI. | |
| Represents a local URI (Uniform Resource Identifier) that extends the Uri class and implements the os.PathLike interface. | |
| A URI; currently supports GCS ('gs://foo/bar'), HTTP ('http://abc.com/xyz') or local ('/foo/bar'). | |
| Factory class to create the proper concrete Uri instance given an input. | 
Package Contents#
- class gigl.common.GcsUri(uri)[source]#
- Bases: - gigl.common.types.uri.uri.Uri- Represents a Google Cloud Storage (GCS) URI. - Parameters:
- uri (Union[str, Path, GcsUri]) – The URI string or path to initialize the GcsUri object. 
 - classmethod is_valid(uri, raise_exception=False)[source]#
- Check if the given URI is valid. - Parameters:
- uri (Union[str, Path, Uri]) – The URI to be validated. 
- raise_exception (Optiona[bool]) – Whether to raise an exception if the URI is invalid. Defaults to False. 
 
- Returns:
- True if the URI is valid, False otherwise. 
- Return type:
- bool 
 
 - property bucket: str#
- Return type:
- str 
 
 - property path: str#
- Return type:
- str 
 
 
- class gigl.common.HttpUri(uri)[source]#
- Bases: - gigl.common.types.uri.uri.Uri- Represents an HTTP URI. - Parameters:
- uri (Union[str, pathlib.Path, HttpUri]) 
 - classmethod is_valid(uri, raise_exception=False)[source]#
- Check if the URI is valid. - Parameters:
- uri (Union[str, pathlib.Path, gigl.common.types.uri.uri.Uri]) – The URI to check. 
- raise_exception (bool) – Whether to raise an exception if the URI is invalid. 
 
- Returns:
- True if the URI is valid, False otherwise. 
- Return type:
- bool 
 
 
- class gigl.common.LocalUri(uri)[source]#
- Bases: - gigl.common.types.uri.uri.Uri,- os.PathLike- Represents a local URI (Uniform Resource Identifier) that extends the Uri class and implements the os.PathLike interface. - Parameters:
- uri (_URI_LIKE) 
 - absolute()[source]#
- Returns an absolute LocalUri object. - Returns:
- An absolute LocalUri object. 
- Return type:
 
 - classmethod is_valid(uri, raise_exception=False)[source]#
- Checks if the given URI is valid. - Parameters:
- 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:
- True if the URI is valid, False otherwise. 
- Return type:
- bool 
 
 
- class gigl.common.Uri(uri)[source]#
- Bases: - object- A URI; currently supports GCS (‘gs://foo/bar’), HTTP (‘http://abc.com/xyz’) or local (‘/foo/bar’). - Parameters:
- uri (_URI_LIKE) 
 - get_basename()[source]#
- 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 - Return type:
- str 
 
 - classmethod is_valid(uri, raise_exception=False)[source]#
- Abstractmethod:
- Parameters:
- uri (_URI_LIKE) 
- raise_exception (bool) 
 
- Return type:
- bool 
 - Check if the given URI is valid. - Parameters:
- uri (_URI_LIKE) – The URI to check. 
- raise_exception (bool) – Whether to raise an exception if the URI is invalid. 
 
- Returns:
- True if the URI is valid, False otherwise. 
- Return type:
- bool 
 
 - classmethod join(token, *tokens)[source]#
- Join multiple tokens to create a new Uri instance. - Parameters:
- token (_URI_LIKE) – The first token to join. 
- tokens (_URI_LIKE) – Additional tokens to join. 
 
- Returns:
- A new Uri instance representing the joined URI. 
- Return type:
- typing_extensions.Self 
 
 - property uri#
 
