# Copyright (c) 2022 Mira Geoscience Ltd.
#
# This file is part of geoh5py.
#
# geoh5py is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# geoh5py is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with geoh5py. If not, see <https://www.gnu.org/licenses/>.
from __future__ import annotations
import uuid
from abc import abstractmethod
from datetime import datetime
from typing import TYPE_CHECKING
from ..data import CommentsData, Data
from ..shared import Entity
from .group_type import GroupType
if TYPE_CHECKING:
from .. import workspace
[docs]class Group(Entity):
"""Base Group class"""
def __init__(self, group_type: GroupType, **kwargs):
assert group_type is not None
self._entity_type = group_type
super().__init__(**kwargs)
[docs] @classmethod
@abstractmethod
def default_type_uid(cls) -> uuid.UUID | None:
...
@property
def comments(self):
"""
Fetch a :obj:`~geoh5py.data.text_data.CommentsData` entity from children.
"""
for child in self.children:
if isinstance(child, CommentsData):
return child
return None
@property
def entity_type(self) -> GroupType:
return self._entity_type
[docs] @classmethod
def find_or_create_type(cls, workspace: workspace.Workspace, **kwargs) -> GroupType:
return GroupType.find_or_create(workspace, cls, **kwargs)