|
1 | | -# Copyright (C) 2021 Fraunhofer Institut IOSB, Fraunhoferstr. 1, D 76131 |
2 | | -# Karlsruhe, Germany. |
3 | | -# |
4 | | -# This program is free software: you can redistribute it and/or modify |
5 | | -# it under the terms of the GNU Lesser General Public License as published by |
6 | | -# the Free Software Foundation, either version 3 of the License, or |
7 | | -# (at your option) any later version. |
8 | | -# |
9 | | -# This program is distributed in the hope that it will be useful, |
10 | | -# but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | | -# GNU Lesser General Public License for more details. |
13 | | -# |
14 | | -# You should have received a copy of the GNU Lesser General Public License |
15 | | -# along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | | -from .data_array_value import DataArrayValue |
17 | | - |
18 | | - |
19 | | -class DataArrayDocument: |
20 | | - def __init__(self, count=-1, next_link = None, value=None): |
21 | | - if value is None: |
22 | | - value = [] |
23 | | - self._count = count |
24 | | - self._next_link = next_link |
25 | | - self._value = value |
26 | | - |
27 | | - @property |
28 | | - def count(self): |
29 | | - return self._count |
30 | | - |
31 | | - @count.setter |
32 | | - def count(self, value): |
33 | | - if type(value) == int or value is None: |
34 | | - self._count = value |
35 | | - else: |
36 | | - raise TypeError('count should be of type int') |
37 | | - |
38 | | - @property |
39 | | - def next_link(self): |
40 | | - return self._next_link |
41 | | - |
42 | | - @next_link.setter |
43 | | - def next_link(self, value): |
44 | | - if type(value) == str or value is None: |
45 | | - self._next_link = value |
46 | | - else: |
47 | | - raise TypeError('nextLink should be of type str') |
48 | | - |
49 | | - @property |
50 | | - def value(self): |
51 | | - return self._value |
52 | | - |
53 | | - @value.setter |
54 | | - def value(self, value): |
55 | | - if type(value) == list and all(isinstance(x, DataArrayValue) for x in value): |
56 | | - self._value = value |
57 | | - else: |
58 | | - raise TypeError('value should be a list of type DataArrayValue') |
59 | | - |
60 | | - def get_observations(self): |
61 | | - obs_list = [] |
62 | | - for dav in self.value: |
63 | | - obs_list.concat(dav.get_observations()) |
64 | | - return obs_list |
65 | | - |
66 | | - def add_data_array_value(self, dav): |
67 | | - self.value.append(dav) |
68 | | - |
| 1 | +# Copyright (C) 2021 Fraunhofer Institut IOSB, Fraunhoferstr. 1, D 76131 |
| 2 | +# Karlsruhe, Germany. |
| 3 | +# |
| 4 | +# This program is free software: you can redistribute it and/or modify |
| 5 | +# it under the terms of the GNU Lesser General Public License as published by |
| 6 | +# the Free Software Foundation, either version 3 of the License, or |
| 7 | +# (at your option) any later version. |
| 8 | +# |
| 9 | +# This program is distributed in the hope that it will be useful, |
| 10 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | +# GNU Lesser General Public License for more details. |
| 13 | +# |
| 14 | +# You should have received a copy of the GNU Lesser General Public License |
| 15 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | +from .data_array_value import DataArrayValue |
| 17 | + |
| 18 | + |
| 19 | +class DataArrayDocument: |
| 20 | + def __init__(self, count=-1, next_link = None, value=None): |
| 21 | + if value is None: |
| 22 | + value = [] |
| 23 | + self._count = count |
| 24 | + self._next_link = next_link |
| 25 | + self._value = value |
| 26 | + |
| 27 | + @property |
| 28 | + def count(self): |
| 29 | + return self._count |
| 30 | + |
| 31 | + @count.setter |
| 32 | + def count(self, value): |
| 33 | + if type(value) == int or value is None: |
| 34 | + self._count = value |
| 35 | + else: |
| 36 | + raise TypeError('count should be of type int') |
| 37 | + |
| 38 | + @property |
| 39 | + def next_link(self): |
| 40 | + return self._next_link |
| 41 | + |
| 42 | + @next_link.setter |
| 43 | + def next_link(self, value): |
| 44 | + if type(value) == str or value is None: |
| 45 | + self._next_link = value |
| 46 | + else: |
| 47 | + raise TypeError('nextLink should be of type str') |
| 48 | + |
| 49 | + @property |
| 50 | + def value(self): |
| 51 | + return self._value |
| 52 | + |
| 53 | + @value.setter |
| 54 | + def value(self, value): |
| 55 | + if type(value) == list and all(isinstance(x, DataArrayValue) for x in value): |
| 56 | + self._value = value |
| 57 | + else: |
| 58 | + raise TypeError('value should be a list of type DataArrayValue') |
| 59 | + |
| 60 | + def get_observations(self): |
| 61 | + obs_list = [] |
| 62 | + for dav in self.value: |
| 63 | + obs_list.extend(dav.observations) |
| 64 | + return obs_list |
| 65 | + |
| 66 | + def add_data_array_value(self, dav): |
| 67 | + self.value.append(dav) |
0 commit comments