| 1 |
|
| 2 |
) |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
from .entity import Entity |
| 11 |
from .data_array import DataArray |
| 12 |
from .data_frame import DataFrame |
| 13 |
from .tag import Tag |
| 14 |
from .multi_tag import MultiTag |
| 15 |
from .container import LinkContainer |
| 16 |
from .source_link_container import SourceLinkContainer |
| 17 |
from .section import Section |
| 18 |
|
| 19 |
|
| 20 |
class Group(Entity): |
| 21 |
|
| 22 |
def __init__(self, nixfile, nixparent, h5group): |
| 23 |
super(Group, self).__init__(nixfile, nixparent, h5group) |
| 24 |
self._data_arrays = None |
| 25 |
self._data_frames = None |
| 26 |
self._tags = None |
| 27 |
self._multi_tags = None |
| 28 |
self._sources = None |
| 29 |
|
| 30 |
@classmethod |
| 31 |
def create_new(cls, nixfile, nixparent, h5parent, name, type_): |
| 32 |
newentity = super(Group, cls).create_new(nixfile, nixparent, h5parent, |
| 33 |
name, type_) |
| 34 |
return newentity |
| 35 |
|
| 36 |
@property |
| 37 |
def data_arrays(self): |
| 38 |
""" |
| 39 |
A property containing all data arrays referenced by the group. |
| 40 |
Referenced data arrays can be obtained by index or their id. References |
| 41 |
can be removed from the list, removing a referenced DataArray will not |
| 42 |
remove it from the file. New references can be added using the append |
| 43 |
method of the list. |
| 44 |
This is a read only attribute. |
| 45 |
""" |
| 46 |
if self._data_arrays is None: |
| 47 |
self._data_arrays = LinkContainer("data_arrays", self, DataArray, |
| 48 |
self._parent.data_arrays) |
| 49 |
return self._data_arrays |
| 50 |
|
| 51 |
@property |
| 52 |
def data_frames(self): |
| 53 |
""" |
| 54 |
A property containing all data frames referenced by the group. |
| 55 |
Referenced data frames can be obtained by index or their id. References |
| 56 |
can be removed from the list, removing a referenced DataFrame will not |
| 57 |
remove it from the file. New references can be added using the append |
| 58 |
method of the list. |
| 59 |
This is a read only attribute. |
| 60 |
""" |
| 61 |
if self._data_frames is None: |
| 62 |
self._data_frames = LinkContainer("data_frames", self, DataFrame, |
| 63 |
self._parent.data_frames) |
| 64 |
return self._data_frames |
| 65 |
|
| 66 |
@property |
| 67 |
def tags(self): |
| 68 |
""" |
| 69 |
A property containing all tags referenced by the group. Tags can be |
| 70 |
obtained by index or their id. Tags can be removed from the list, |
| 71 |
removing a referenced Tag will not remove it from the file. |
| 72 |
New Tags can be added using the append method of the list. |
| 73 |
This is a read only attribute. |
| 74 |
""" |
| 75 |
if self._tags is None: |
| 76 |
self._tags = LinkContainer("tags", self, Tag, self._parent.tags) |
| 77 |
return self._tags |
| 78 |
|
| 79 |
@property |
| 80 |
def multi_tags(self): |
| 81 |
""" |
| 82 |
A property containing all MultiTags referenced by the group. MultiTags |
| 83 |
can be obtained by index or their id. MultiTags can be removed from the |
| 84 |
list, removing a referenced MultiTag will not remove it from the file. |
| 85 |
New MultiTags can be added using the append method of the list. |
| 86 |
This is a read only attribute. |
| 87 |
""" |
| 88 |
if self._multi_tags is None: |
| 89 |
self._multi_tags = LinkContainer("multi_tags", self, MultiTag, |
| 90 |
self._parent.multi_tags) |
| 91 |
return self._multi_tags |
| 92 |
|
| 93 |
@property |
| 94 |
def sources(self): |
| 95 |
""" |
| 96 |
A property containing all Sources referenced by the Group. Sources |
| 97 |
can be obtained by index or their id. Sources can be removed from the |
| 98 |
list, but removing a referenced Source will not remove it from the |
| 99 |
file. New Sources can be added using the append method of the list. |
| 100 |
This is a read only attribute. |
| 101 |
""" |
| 102 |
if self._sources is None: |
| 103 |
self._sources = SourceLinkContainer(self) |
| 104 |
return self._sources |
| 105 |
|
| 106 |
|
| 107 |
@property |
| 108 |
def metadata(self): |
| 109 |
""" |
| 110 |
|
| 111 |
Associated metadata of the entity. Sections attached to the entity via |
| 112 |
this attribute can provide additional annotations. This is an optional |
| 113 |
read-write property, and can be None if no metadata is available. |
| 114 |
|
| 115 |
:type: nixio.Section |
| 116 |
""" |
| 117 |
if "metadata" in self._h5group: |
| 118 |
return Section(self.file, None, |
| 119 |
self._h5group.open_group("metadata")) |
| 120 |
else: |
| 121 |
return None |
| 122 |
|
| 123 |
@metadata.setter |
| 124 |
def metadata(self, sect): |
| 125 |
if not isinstance(sect, Section): |
| 126 |
raise TypeError("{} is not of type Section".format(sect)) |
| 127 |
self._h5group.create_link(sect, "metadata") |
| 128 |
|
| 129 |
@metadata.deleter |
| 130 |
def metadata(self): |
| 131 |
if "metadata" in self._h5group: |
| 132 |
self._h5group.delete("metadata") |