fameio 2.3.0__py3-none-any.whl → 3.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. CHANGELOG.md +28 -0
  2. fameio/__init__.py +4 -1
  3. fameio/{source/cli → cli}/__init__.py +2 -0
  4. fameio/{source/cli → cli}/convert_results.py +8 -8
  5. fameio/{source/cli → cli}/make_config.py +5 -5
  6. fameio/{source/cli → cli}/options.py +0 -8
  7. fameio/{source/cli → cli}/parser.py +26 -63
  8. fameio/input/__init__.py +27 -0
  9. fameio/input/loader/__init__.py +68 -0
  10. fameio/input/loader/controller.py +129 -0
  11. fameio/input/loader/loader.py +109 -0
  12. fameio/input/metadata.py +149 -0
  13. fameio/input/resolver.py +44 -0
  14. fameio/{source → input}/scenario/__init__.py +1 -2
  15. fameio/{source → input}/scenario/agent.py +24 -38
  16. fameio/input/scenario/attribute.py +203 -0
  17. fameio/{source → input}/scenario/contract.py +50 -61
  18. fameio/{source → input}/scenario/exception.py +8 -13
  19. fameio/{source → input}/scenario/fameiofactory.py +6 -6
  20. fameio/{source → input}/scenario/generalproperties.py +22 -47
  21. fameio/{source → input}/scenario/scenario.py +34 -31
  22. fameio/input/scenario/stringset.py +48 -0
  23. fameio/{source → input}/schema/__init__.py +2 -2
  24. fameio/input/schema/agenttype.py +125 -0
  25. fameio/input/schema/attribute.py +268 -0
  26. fameio/{source → input}/schema/java_packages.py +26 -22
  27. fameio/{source → input}/schema/schema.py +25 -22
  28. fameio/{source → input}/validator.py +32 -35
  29. fameio/{source → input}/writer.py +86 -86
  30. fameio/{source/logs.py → logs.py} +25 -9
  31. fameio/{source/results → output}/agent_type.py +21 -22
  32. fameio/{source/results → output}/conversion.py +34 -31
  33. fameio/{source/results → output}/csv_writer.py +7 -7
  34. fameio/{source/results → output}/data_transformer.py +24 -24
  35. fameio/{source/results → output}/input_dao.py +51 -49
  36. fameio/{source/results → output}/output_dao.py +16 -17
  37. fameio/{source/results → output}/reader.py +30 -31
  38. fameio/{source/results → output}/yaml_writer.py +2 -3
  39. fameio/scripts/__init__.py +2 -2
  40. fameio/scripts/convert_results.py +16 -15
  41. fameio/scripts/make_config.py +9 -9
  42. fameio/{source/series.py → series.py} +28 -26
  43. fameio/{source/time.py → time.py} +8 -8
  44. fameio/{source/tools.py → tools.py} +2 -2
  45. {fameio-2.3.0.dist-info → fameio-3.0.0.dist-info}/METADATA +277 -72
  46. fameio-3.0.0.dist-info/RECORD +56 -0
  47. fameio/source/__init__.py +0 -8
  48. fameio/source/loader.py +0 -181
  49. fameio/source/metadata.py +0 -32
  50. fameio/source/path_resolver.py +0 -34
  51. fameio/source/scenario/attribute.py +0 -130
  52. fameio/source/scenario/stringset.py +0 -51
  53. fameio/source/schema/agenttype.py +0 -132
  54. fameio/source/schema/attribute.py +0 -203
  55. fameio/source/schema/exception.py +0 -9
  56. fameio-2.3.0.dist-info/RECORD +0 -55
  57. /fameio/{source/results → output}/__init__.py +0 -0
  58. {fameio-2.3.0.dist-info → fameio-3.0.0.dist-info}/LICENSE.txt +0 -0
  59. {fameio-2.3.0.dist-info → fameio-3.0.0.dist-info}/LICENSES/Apache-2.0.txt +0 -0
  60. {fameio-2.3.0.dist-info → fameio-3.0.0.dist-info}/LICENSES/CC-BY-4.0.txt +0 -0
  61. {fameio-2.3.0.dist-info → fameio-3.0.0.dist-info}/LICENSES/CC0-1.0.txt +0 -0
  62. {fameio-2.3.0.dist-info → fameio-3.0.0.dist-info}/WHEEL +0 -0
  63. {fameio-2.3.0.dist-info → fameio-3.0.0.dist-info}/entry_points.txt +0 -0
@@ -1,203 +0,0 @@
1
- # SPDX-FileCopyrightText: 2023 German Aerospace Center <fame@dlr.de>
2
- #
3
- # SPDX-License-Identifier: Apache-2.0
4
- from __future__ import annotations
5
-
6
- import typing
7
- from enum import Enum, auto
8
- from typing import Any, Dict
9
-
10
- from fameio.source.logs import log
11
- from fameio.source.schema.exception import SchemaException
12
- from fameio.source.time import FameTime
13
- from fameio.source.tools import keys_to_lower
14
-
15
-
16
- class AttributeType(Enum):
17
- """Specifies known types that Attributes can take"""
18
-
19
- INTEGER = auto()
20
- DOUBLE = auto()
21
- LONG = auto()
22
- TIME_STAMP = auto()
23
- STRING = auto()
24
- STRING_SET = auto()
25
- ENUM = auto()
26
- TIME_SERIES = auto()
27
- BLOCK = auto()
28
-
29
- def convert_string_to_type(self, value: str):
30
- """Converts a given string to this AttributeType's data format"""
31
- if self is AttributeType.INTEGER or self is AttributeType.LONG:
32
- return int(value)
33
- elif self is AttributeType.DOUBLE:
34
- return float(value)
35
- elif self is AttributeType.TIME_STAMP:
36
- return FameTime.convert_string_if_is_datetime(value)
37
- elif self is AttributeType.ENUM or self is AttributeType.STRING or self is AttributeType.STRING_SET:
38
- return str(value)
39
- elif self is AttributeType.TIME_SERIES:
40
- return float(value)
41
- else:
42
- raise ValueError("String conversion not supported for '{}'.".format(self))
43
-
44
-
45
- class AttributeSpecs:
46
- """Schema Definition of a single Attribute (with possible inner Attributes) of an agent"""
47
-
48
- _MISSING_SPEC_DEFAULT = "Missing '{}' specification for Attribute '{}' - assuming {}."
49
- _MISSING_TYPE = "'AttributeType' not declare for Attribute '{}'."
50
- _INVALID_TYPE = "'{}' is not a valid type for an Attribute."
51
- _DEFAULT_NOT_LIST = "Attribute is list, but provided Default '{}' is not a list."
52
- _DEFAULT_INCOMPATIBLE = "Default '{}' can not be converted to AttributeType '{}'."
53
- _DEFAULT_DISALLOWED = "Default '{}' is not an allowed value."
54
- _LIST_DISALLOWED = "Attribute '{}' of type TIME_SERIES cannot be a list."
55
- _VALUES_ILL_FORMAT = "Only List and Dictionary is supported for 'Values' but was: {}"
56
-
57
- _KEY_MANDATORY = "Mandatory".lower()
58
- _KEY_LIST = "List".lower()
59
- _KEY_TYPE = "AttributeType".lower()
60
- _KEY_NESTED = "NestedAttributes".lower()
61
- _KEY_VALUES = "Values".lower()
62
- _KEY_DEFAULT = "Default".lower()
63
- _KEY_HELP = "Help".lower()
64
-
65
- def __init__(self, name: str, definition: dict):
66
- """Loads Attribute from given `definition`"""
67
- self._full_name = name
68
- definition = keys_to_lower(definition)
69
-
70
- if AttributeSpecs._KEY_MANDATORY in definition:
71
- self._is_mandatory = definition[AttributeSpecs._KEY_MANDATORY]
72
- else:
73
- self._is_mandatory = True
74
- log().warning(AttributeSpecs._MISSING_SPEC_DEFAULT.format(AttributeSpecs._KEY_MANDATORY, name, True))
75
-
76
- if AttributeSpecs._KEY_LIST in definition:
77
- self._is_list = definition[AttributeSpecs._KEY_LIST]
78
- else:
79
- self._is_list = False
80
- log().warning(AttributeSpecs._MISSING_SPEC_DEFAULT.format(AttributeSpecs._KEY_LIST, name, False))
81
-
82
- if AttributeSpecs._KEY_TYPE in definition:
83
- self._attr_type = AttributeSpecs._get_type_for_name(definition[AttributeSpecs._KEY_TYPE])
84
- else:
85
- log().error(AttributeSpecs._MISSING_TYPE.format(name))
86
- raise SchemaException(AttributeSpecs._MISSING_TYPE.format(name))
87
-
88
- if self._attr_type == AttributeType.TIME_SERIES and self._is_list:
89
- raise SchemaException(AttributeSpecs._LIST_DISALLOWED.format(name))
90
-
91
- self._values = []
92
- if AttributeSpecs._KEY_VALUES in definition:
93
- value_definition = definition[AttributeSpecs._KEY_VALUES]
94
- if value_definition:
95
- self._values = self._read_values(value_definition)
96
-
97
- self._default_value = None
98
- if AttributeSpecs._KEY_DEFAULT in definition:
99
- provided_value = definition[AttributeSpecs._KEY_DEFAULT]
100
- if self._is_list:
101
- self._default_value = self._convert_list(provided_value)
102
- else:
103
- self._default_value = self._convert_to_data_type(provided_value)
104
-
105
- self._nested_attributes = {}
106
- if AttributeSpecs._KEY_NESTED in definition:
107
- for nested_name, nested_details in definition[AttributeSpecs._KEY_NESTED].items():
108
- full_name = name + "." + nested_name
109
- self._nested_attributes[nested_name] = AttributeSpecs(full_name, nested_details)
110
-
111
- self._help = None
112
- if AttributeSpecs._KEY_HELP in definition:
113
- self._help = definition[AttributeSpecs._KEY_HELP]
114
-
115
- @staticmethod
116
- def _read_values(definition: Any) -> list:
117
- """Returns list of values extracted from given `definition` if it is a list or dict"""
118
- if isinstance(definition, list):
119
- return definition
120
- elif isinstance(definition, dict):
121
- return [key for key in definition.keys()]
122
- else:
123
- raise SchemaException(AttributeSpecs._VALUES_ILL_FORMAT.format(definition))
124
-
125
- def _convert_list(self, values) -> list:
126
- """Converts all entries in given `values` list to this attribute data type and returns this new list"""
127
- if isinstance(values, list):
128
- return [self._convert_to_data_type(item) for item in values]
129
- else:
130
- raise SchemaException(AttributeSpecs._DEFAULT_NOT_LIST.format(values))
131
-
132
- def _convert_to_data_type(self, value: str):
133
- """Converts a given single `value` to this Attribute's data type"""
134
- try:
135
- converted = self._attr_type.convert_string_to_type(value)
136
- if self._values and converted not in self._values:
137
- raise SchemaException(AttributeSpecs._DEFAULT_DISALLOWED.format(value))
138
- return converted
139
- except ValueError:
140
- raise SchemaException(AttributeSpecs._DEFAULT_INCOMPATIBLE.format(value, self._attr_type))
141
-
142
- @property
143
- def attr_type(self) -> AttributeType:
144
- """Returns AttributeType of this attribute"""
145
- return self._attr_type
146
-
147
- @property
148
- def values(self) -> list:
149
- """Returns the list of allowed values for this attribute"""
150
- return self._values
151
-
152
- @property
153
- def is_list(self) -> bool:
154
- """Return True if this attribute type is a list"""
155
- return self._is_list
156
-
157
- @property
158
- def has_nested_attributes(self) -> bool:
159
- """Returns True if nested attributes are defined"""
160
- return bool(self._nested_attributes)
161
-
162
- @property
163
- def nested_attributes(self) -> Dict[str, "AttributeSpecs"]:
164
- """Returns list of nested Attributes of this Attribute or an empty dict if no nested attributes are defined"""
165
- return self._nested_attributes
166
-
167
- @property
168
- def has_default_value(self) -> bool:
169
- """Return True if a default value is available"""
170
- return self._default_value is not None
171
-
172
- @property
173
- def default_value(self) -> typing.Optional[typing.Any]:
174
- """Return the default value of this attribute, if any"""
175
- return self._default_value
176
-
177
- @property
178
- def is_mandatory(self) -> bool:
179
- """Return True if this attribute is mandatory"""
180
- return self._is_mandatory
181
-
182
- @property
183
- def full_name(self) -> str:
184
- """Returns name including name of enclosing parent attributes"""
185
- return self._full_name
186
-
187
- @staticmethod
188
- def _get_type_for_name(name: str) -> AttributeType:
189
- """Returns the AttributeType matching the given `name` converted to upper case"""
190
- try:
191
- return AttributeType[name.upper()]
192
- except KeyError:
193
- raise SchemaException(AttributeSpecs._INVALID_TYPE.format(name))
194
-
195
- @property
196
- def has_help_text(self) -> bool:
197
- """Return True if a help_text is available"""
198
- return bool(self._help)
199
-
200
- @property
201
- def help_text(self) -> str:
202
- """Return the help_text of this attribute, if any, otherwise an empty string"""
203
- return self._help if self.has_help_text else ""
@@ -1,9 +0,0 @@
1
- # SPDX-FileCopyrightText: 2023 German Aerospace Center <fame@dlr.de>
2
- #
3
- # SPDX-License-Identifier: Apache-2.0
4
-
5
-
6
- class SchemaException(Exception):
7
- """An exception that occurred while parsing a Schema"""
8
-
9
- pass
@@ -1,55 +0,0 @@
1
- CHANGELOG.md,sha256=vchfAyV552_Bsstyp995JpN4XAMzX9VhibbY_UqVLTQ,11827
2
- fameio/__init__.py,sha256=IQm0MNOXkhBexiMXBoNZDK5xHUYgazH7oXm-lc0Vm04,109
3
- fameio/scripts/__init__.py,sha256=Bdu79kajJvvmPWdSP82Y6G8MCpP4n9ftTR-snWSbMJY,741
4
- fameio/scripts/__init__.py.license,sha256=2-OqCNxP4504xY2XQqseYypJi1_Qx4xJSzO3t7c3ACM,107
5
- fameio/scripts/convert_results.py,sha256=ljrfPTwhauW98w-wJs4Fu4vtTreGzsMEd-io33UC1z0,4189
6
- fameio/scripts/convert_results.py.license,sha256=2-OqCNxP4504xY2XQqseYypJi1_Qx4xJSzO3t7c3ACM,107
7
- fameio/scripts/make_config.py,sha256=KQsj-aPXXtch8ITITCOcQUj6nYhvDs9LO7tdSikUe6w,1388
8
- fameio/scripts/make_config.py.license,sha256=2-OqCNxP4504xY2XQqseYypJi1_Qx4xJSzO3t7c3ACM,107
9
- fameio/source/__init__.py,sha256=14CnWOIkdSeKQg6FioQSgO7UtEFF6pO4MUtDAUfwNmA,278
10
- fameio/source/cli/__init__.py,sha256=UqrdWnYMoy-o2--m0a4c-MtAorsc4eILXaPq27EXM1Q,112
11
- fameio/source/cli/convert_results.py,sha256=LY9ySXs3dAyyos0yoc-bY8M1Z9Oti-AgGYEEK5K-Ctg,3412
12
- fameio/source/cli/make_config.py,sha256=phZKimvItl538xnwv9IhBoDkh__YqNlRk4YNDyTOFaA,2738
13
- fameio/source/cli/options.py,sha256=5DOFq4LMcObrSOlbt74HGE1vghByn-I30YY46tm5Snc,1422
14
- fameio/source/cli/parser.py,sha256=cVC6j_oy3lBQOC7nrk5oF2m5CpcohOh5y689lhvu4gw,9726
15
- fameio/source/loader.py,sha256=-Y0j3OrV2MwAlfxFP2YA3ZwZhP-eFVlT6hdHO4Qze2U,7536
16
- fameio/source/logs.py,sha256=9Iq9jcglGyALYir-Luxfa-m4uUJX074JkUM0uMwzPNc,3684
17
- fameio/source/metadata.py,sha256=zdqKEIEQ0NKqEmBTBdPEq0fw1MdsXwCpzs1O6rFTq_Y,1024
18
- fameio/source/path_resolver.py,sha256=cIEVvz7Eh4e3Rh87XkwyGiyj9iKxUI7TzWtq6ClhLd8,1321
19
- fameio/source/results/__init__.py,sha256=IQm0MNOXkhBexiMXBoNZDK5xHUYgazH7oXm-lc0Vm04,109
20
- fameio/source/results/agent_type.py,sha256=pW5cLduLlNOcBBvS6sCLpTpZt3D6B8UMsizEZhe5lJ0,4321
21
- fameio/source/results/conversion.py,sha256=5s6gPWNIOOLKn0O0-9gVvmJ8wq7m0Dh5NgtXIe1PIJs,3683
22
- fameio/source/results/csv_writer.py,sha256=lp5fhnhD99ksYLJwUguC9o8mujM8tkyCfq2vQ5LT1zw,5152
23
- fameio/source/results/data_transformer.py,sha256=tz58m7_TZPE3YjBoDyiMWiP_sz9mWaj1JfW2FjKLVhY,5490
24
- fameio/source/results/input_dao.py,sha256=5V_7dUhO1XZGNuwH5041HnMGCcQjC9d9_TBR4FZ9QJE,6919
25
- fameio/source/results/output_dao.py,sha256=-tMewCUS4m3RebTAf8Z33gtlj-SxqRdxnzvGIkg6Ah0,4106
26
- fameio/source/results/reader.py,sha256=g3cfbNq7eHO98dxtpqjjPE8_YJVM56Wp0MCnNi3ds5g,5054
27
- fameio/source/results/yaml_writer.py,sha256=rOAbeZQgRojYvofUcXreIdIJtdSbOrHAohiNLkmPgCI,837
28
- fameio/source/scenario/__init__.py,sha256=YfJvz275GWX8kVWMSMRcF3KsUQNqSAPrwBgNV7tqBTY,372
29
- fameio/source/scenario/agent.py,sha256=Z8jfMfUjrTJ4R1rEpwNdKCblhEx6-9xioewxGuajuqw,4713
30
- fameio/source/scenario/attribute.py,sha256=X63ZFpAdObTjMHpf0FD_H3v9sfOOqn7KDdjiGmyMZj4,4899
31
- fameio/source/scenario/contract.py,sha256=lM2NN_CUDh9iqDghq_F6JE9rEW3ZGUhBJOD0qkjuKBU,9442
32
- fameio/source/scenario/exception.py,sha256=7MYN4h40ptMZFD1lLtnK5PWXbAGlsmUSDmUQ5FAKeN8,1554
33
- fameio/source/scenario/fameiofactory.py,sha256=kV2GXGjNxYrt4lv5KoK8wYN6lfN3Z3hWaRNOl89gYv8,1654
34
- fameio/source/scenario/generalproperties.py,sha256=TkQV9dEo5zMfNiFITolJU1rQUBi-yDJLpoello39e_0,4796
35
- fameio/source/scenario/scenario.py,sha256=w64SHQXpRFIMhDUNOIRkuK81jY_cXvT_M4CNhtULbMQ,4585
36
- fameio/source/scenario/stringset.py,sha256=ZfObpTbAsYZcTti-1xoq3KaZf3D59fMToRkkZaTXIcc,1920
37
- fameio/source/schema/__init__.py,sha256=ZGTyliDbjlYGPAjB9bbggzACOYWdhm4I1VSmm7YGmTk,270
38
- fameio/source/schema/agenttype.py,sha256=fe6GWJwl2S-J7KmH_eR5Y8Ieez1difez1w7v-r26yGU,5183
39
- fameio/source/schema/attribute.py,sha256=wzu4563_zUU863dhjZQOuoPBBW4a7TjED5orKWuEujM,8357
40
- fameio/source/schema/exception.py,sha256=NMftGnrFOaS3MwrjZl8qbx3bi6KYUxhzHJIX1v--B5M,224
41
- fameio/source/schema/java_packages.py,sha256=-2ZbAG_htEowB-fBSMizsLWrphyiKfESDDHspzdEQP4,2656
42
- fameio/source/schema/schema.py,sha256=-J8VtO4W9Z-OnTV7MFO1umZWIC_epbLCYd6-q4lNQ8Y,2975
43
- fameio/source/series.py,sha256=wwq7Nm0i0mOvMOjmqPW5x1gSDnhpWEy14VLceUhWcYw,9041
44
- fameio/source/time.py,sha256=Vsd95nTubL8x5cwiznJYeti6clZCCHHJv7xjSpYqkF0,6984
45
- fameio/source/tools.py,sha256=B94U7Idq9ZuvsQmc9HOti016z4jn2oTTMIElWhs-5_w,1062
46
- fameio/source/validator.py,sha256=44wAlSxzSlaP9cm3YpNXOcs_kXIUNagctHLguY6H3T4,18596
47
- fameio/source/writer.py,sha256=d35rZGPLil3yku8_N6l1B45J4agKemBhAHJJPynQiJE,12499
48
- fameio-2.3.0.dist-info/entry_points.txt,sha256=jvQVfwJjZXPWQjJlhj1Dt6PTeblryTc1GxjKeK90twI,123
49
- fameio-2.3.0.dist-info/LICENSE.txt,sha256=eGHBZnhr9CWjE95SWjRfmhtK1lvVn5X4Fpf3KrrAZDg,10391
50
- fameio-2.3.0.dist-info/LICENSES/Apache-2.0.txt,sha256=eGHBZnhr9CWjE95SWjRfmhtK1lvVn5X4Fpf3KrrAZDg,10391
51
- fameio-2.3.0.dist-info/LICENSES/CC-BY-4.0.txt,sha256=y9WvMYKGt0ZW8UXf9QkZB8wj1tjJrQngKR7CSXeSukE,19051
52
- fameio-2.3.0.dist-info/LICENSES/CC0-1.0.txt,sha256=9Ofzc7m5lpUDN-jUGkopOcLZC3cl6brz1QhKInF60yg,7169
53
- fameio-2.3.0.dist-info/METADATA,sha256=meORlVQz4DNt17J2YC61Ioew13vSOPh1hFMYFjJUr8A,32471
54
- fameio-2.3.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
55
- fameio-2.3.0.dist-info/RECORD,,
File without changes
File without changes