str-to-obj 2024.3__tar.gz → 2024.5__tar.gz

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 (47) hide show
  1. {str_to_obj-2024.3 → str_to_obj-2024.5}/PKG-INFO +52 -31
  2. {str_to_obj-2024.3 → str_to_obj-2024.5}/README.rst +50 -30
  3. {str_to_obj-2024.3 → str_to_obj-2024.5}/setup.py +53 -30
  4. str_to_obj-2024.5/str_to_obj/__init__.py +59 -0
  5. str_to_obj-2024.5/str_to_obj/catalog/boolean.py +99 -0
  6. str_to_obj-2024.5/str_to_obj/catalog/callable.py +99 -0
  7. str_to_obj-2024.5/str_to_obj/catalog/choices.py +99 -0
  8. {str_to_obj-2024.3 → str_to_obj-2024.5}/str_to_obj/catalog/collection.py +64 -41
  9. {str_to_obj-2024.3 → str_to_obj-2024.5}/str_to_obj/catalog/number.py +63 -41
  10. str_to_obj-2024.5/str_to_obj/catalog/path.py +117 -0
  11. str_to_obj-2024.5/str_to_obj/interface/console.py +78 -0
  12. str_to_obj-2024.5/str_to_obj/main.py +87 -0
  13. str_to_obj-2024.5/str_to_obj/runtime/type.py +58 -0
  14. str_to_obj-2024.5/str_to_obj/runtime/value.py +56 -0
  15. {str_to_obj-2024.3 → str_to_obj-2024.5}/str_to_obj/task/casting.py +52 -30
  16. str_to_obj-2024.5/str_to_obj/task/comparison.py +90 -0
  17. str_to_obj-2024.5/str_to_obj/task/inspection.py +88 -0
  18. {str_to_obj-2024.3 → str_to_obj-2024.5}/str_to_obj/type/hint_tree.py +5 -3
  19. str_to_obj-2024.5/str_to_obj/version.py +54 -0
  20. {str_to_obj-2024.3 → str_to_obj-2024.5}/str_to_obj.egg-info/PKG-INFO +52 -31
  21. str_to_obj-2024.5/str_to_obj.egg-info/requires.txt +2 -0
  22. str_to_obj-2024.3/str_to_obj/__init__.py +0 -37
  23. str_to_obj-2024.3/str_to_obj/catalog/boolean.py +0 -73
  24. str_to_obj-2024.3/str_to_obj/catalog/callable.py +0 -75
  25. str_to_obj-2024.3/str_to_obj/catalog/choices.py +0 -76
  26. str_to_obj-2024.3/str_to_obj/catalog/path.py +0 -94
  27. str_to_obj-2024.3/str_to_obj/interface/console.py +0 -55
  28. str_to_obj-2024.3/str_to_obj/main.py +0 -65
  29. str_to_obj-2024.3/str_to_obj/runtime/type.py +0 -36
  30. str_to_obj-2024.3/str_to_obj/runtime/value.py +0 -34
  31. str_to_obj-2024.3/str_to_obj/task/comparison.py +0 -68
  32. str_to_obj-2024.3/str_to_obj/task/inspection.py +0 -66
  33. str_to_obj-2024.3/str_to_obj/version.py +0 -34
  34. str_to_obj-2024.3/str_to_obj.egg-info/requires.txt +0 -1
  35. {str_to_obj-2024.3 → str_to_obj-2024.5}/MANIFEST.in +0 -0
  36. {str_to_obj-2024.3 → str_to_obj-2024.5}/README-COPYRIGHT-utf8.txt +0 -0
  37. {str_to_obj-2024.3 → str_to_obj-2024.5}/README-LICENCE-utf8.txt +0 -0
  38. {str_to_obj-2024.3 → str_to_obj-2024.5}/documentation/wiki/description.asciidoc +0 -0
  39. {str_to_obj-2024.3 → str_to_obj-2024.5}/pyproject.toml +0 -0
  40. {str_to_obj-2024.3 → str_to_obj-2024.5}/setup.cfg +0 -0
  41. {str_to_obj-2024.3 → str_to_obj-2024.5}/str_to_obj/type/annotation.py +0 -0
  42. {str_to_obj-2024.3 → str_to_obj-2024.5}/str_to_obj/type/hint.py +0 -0
  43. {str_to_obj-2024.3 → str_to_obj-2024.5}/str_to_obj/type/type.py +0 -0
  44. {str_to_obj-2024.3 → str_to_obj-2024.5}/str_to_obj/type/value.py +0 -0
  45. {str_to_obj-2024.3 → str_to_obj-2024.5}/str_to_obj.egg-info/SOURCES.txt +0 -0
  46. {str_to_obj-2024.3 → str_to_obj-2024.5}/str_to_obj.egg-info/dependency_links.txt +0 -0
  47. {str_to_obj-2024.3 → str_to_obj-2024.5}/str_to_obj.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: str-to-obj
3
- Version: 2024.3
3
+ Version: 2024.5
4
4
  Summary: Convert strings to Python objects guided by (potentially annotated) type hints
5
5
  Home-page: https://src.koda.cnrs.fr/eric.debreuve/str-to-obj/
6
6
  Author: Eric Debreuve
@@ -16,39 +16,13 @@ Classifier: Programming Language :: Python :: 3.11
16
16
  Classifier: Development Status :: 4 - Beta
17
17
  Requires-Python: >=3.11
18
18
  Description-Content-Type: text/x-rst
19
+ Requires-Dist: logger_36
19
20
  Requires-Dist: rich
20
21
 
21
22
  ..
22
- Copyright CNRS/Inria/UCA
23
- Contributor(s): Eric Debreuve (since 2023)
24
-
25
- eric.debreuve@cnrs.fr
26
-
27
- This software is governed by the CeCILL license under French law and
28
- abiding by the rules of distribution of free software. You can use,
29
- modify and/ or redistribute the software under the terms of the CeCILL
30
- license as circulated by CEA, CNRS and INRIA at the following URL
31
- "http://www.cecill.info".
32
-
33
- As a counterpart to the access to the source code and rights to copy,
34
- modify and redistribute granted by the license, users are provided only
35
- with a limited warranty and the software's author, the holder of the
36
- economic rights, and the successive licensors have only limited
37
- liability.
38
-
39
- In this respect, the user's attention is drawn to the risks associated
40
- with loading, using, modifying and/or developing or reproducing the
41
- software by the user in light of its specific status of free software,
42
- that may mean that it is complicated to manipulate, and that also
43
- therefore means that it is reserved for developers and experienced
44
- professionals having in-depth computer knowledge. Users are therefore
45
- encouraged to load and test the software's suitability as regards their
46
- requirements in conditions enabling the security of their systems and/or
47
- data to be ensured and, more generally, to use and operate it in the
48
- same conditions as regards security.
49
-
50
- The fact that you are presently reading this means that you have had
51
- knowledge of the CeCILL license and that you accept its terms.
23
+ Copyright CNRS/Inria/UniCA
24
+ Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
25
+ SEE COPYRIGHT NOTICE BELOW
52
26
 
53
27
  .. |PROJECT_NAME| replace:: Str-to-Obj
54
28
  .. |SHORT_DESCRIPTION| replace:: Convert strings to Python objects guided by (potentially annotated) type hints
@@ -113,3 +87,50 @@ The development relies on several open-source packages
113
87
  The code is formatted by `Black <https://github.com/psf/black/>`_, *The Uncompromising Code Formatter*.
114
88
 
115
89
  The imports are ordered by `isort <https://github.com/timothycrosley/isort/>`_... *your imports, so you don't have to*.
90
+
91
+
92
+
93
+ ..
94
+ COPYRIGHT NOTICE
95
+
96
+ This software is governed by the CeCILL license under French law and
97
+ abiding by the rules of distribution of free software. You can use,
98
+ modify and/ or redistribute the software under the terms of the CeCILL
99
+ license as circulated by CEA, CNRS and INRIA at the following URL
100
+ "http://www.cecill.info".
101
+
102
+ As a counterpart to the access to the source code and rights to copy,
103
+ modify and redistribute granted by the license, users are provided only
104
+ with a limited warranty and the software's author, the holder of the
105
+ economic rights, and the successive licensors have only limited
106
+ liability.
107
+
108
+ In this respect, the user's attention is drawn to the risks associated
109
+ with loading, using, modifying and/or developing or reproducing the
110
+ software by the user in light of its specific status of free software,
111
+ that may mean that it is complicated to manipulate, and that also
112
+ therefore means that it is reserved for developers and experienced
113
+ professionals having in-depth computer knowledge. Users are therefore
114
+ encouraged to load and test the software's suitability as regards their
115
+ requirements in conditions enabling the security of their systems and/or
116
+ data to be ensured and, more generally, to use and operate it in the
117
+ same conditions as regards security.
118
+
119
+ The fact that you are presently reading this means that you have had
120
+ knowledge of the CeCILL license and that you accept its terms.
121
+
122
+ SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
123
+
124
+ This software is being developed by Eric Debreuve, a CNRS employee and
125
+ member of team Morpheme.
126
+ Team Morpheme is a joint team between Inria, CNRS, and UniCA.
127
+ It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
128
+ I3S, and Laboratory iBV.
129
+
130
+ CNRS: https://www.cnrs.fr/index.php/en
131
+ Inria: https://www.inria.fr/en/
132
+ UniCA: https://univ-cotedazur.eu/
133
+ Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
134
+ I3S: https://www.i3s.unice.fr/en/
135
+ iBV: http://ibv.unice.fr/
136
+ Team Morpheme: https://team.inria.fr/morpheme/
@@ -1,34 +1,7 @@
1
1
  ..
2
- Copyright CNRS/Inria/UCA
3
- Contributor(s): Eric Debreuve (since 2023)
4
-
5
- eric.debreuve@cnrs.fr
6
-
7
- This software is governed by the CeCILL license under French law and
8
- abiding by the rules of distribution of free software. You can use,
9
- modify and/ or redistribute the software under the terms of the CeCILL
10
- license as circulated by CEA, CNRS and INRIA at the following URL
11
- "http://www.cecill.info".
12
-
13
- As a counterpart to the access to the source code and rights to copy,
14
- modify and redistribute granted by the license, users are provided only
15
- with a limited warranty and the software's author, the holder of the
16
- economic rights, and the successive licensors have only limited
17
- liability.
18
-
19
- In this respect, the user's attention is drawn to the risks associated
20
- with loading, using, modifying and/or developing or reproducing the
21
- software by the user in light of its specific status of free software,
22
- that may mean that it is complicated to manipulate, and that also
23
- therefore means that it is reserved for developers and experienced
24
- professionals having in-depth computer knowledge. Users are therefore
25
- encouraged to load and test the software's suitability as regards their
26
- requirements in conditions enabling the security of their systems and/or
27
- data to be ensured and, more generally, to use and operate it in the
28
- same conditions as regards security.
29
-
30
- The fact that you are presently reading this means that you have had
31
- knowledge of the CeCILL license and that you accept its terms.
2
+ Copyright CNRS/Inria/UniCA
3
+ Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
4
+ SEE COPYRIGHT NOTICE BELOW
32
5
 
33
6
  .. |PROJECT_NAME| replace:: Str-to-Obj
34
7
  .. |SHORT_DESCRIPTION| replace:: Convert strings to Python objects guided by (potentially annotated) type hints
@@ -93,3 +66,50 @@ The development relies on several open-source packages
93
66
  The code is formatted by `Black <https://github.com/psf/black/>`_, *The Uncompromising Code Formatter*.
94
67
 
95
68
  The imports are ordered by `isort <https://github.com/timothycrosley/isort/>`_... *your imports, so you don't have to*.
69
+
70
+
71
+
72
+ ..
73
+ COPYRIGHT NOTICE
74
+
75
+ This software is governed by the CeCILL license under French law and
76
+ abiding by the rules of distribution of free software. You can use,
77
+ modify and/ or redistribute the software under the terms of the CeCILL
78
+ license as circulated by CEA, CNRS and INRIA at the following URL
79
+ "http://www.cecill.info".
80
+
81
+ As a counterpart to the access to the source code and rights to copy,
82
+ modify and redistribute granted by the license, users are provided only
83
+ with a limited warranty and the software's author, the holder of the
84
+ economic rights, and the successive licensors have only limited
85
+ liability.
86
+
87
+ In this respect, the user's attention is drawn to the risks associated
88
+ with loading, using, modifying and/or developing or reproducing the
89
+ software by the user in light of its specific status of free software,
90
+ that may mean that it is complicated to manipulate, and that also
91
+ therefore means that it is reserved for developers and experienced
92
+ professionals having in-depth computer knowledge. Users are therefore
93
+ encouraged to load and test the software's suitability as regards their
94
+ requirements in conditions enabling the security of their systems and/or
95
+ data to be ensured and, more generally, to use and operate it in the
96
+ same conditions as regards security.
97
+
98
+ The fact that you are presently reading this means that you have had
99
+ knowledge of the CeCILL license and that you accept its terms.
100
+
101
+ SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
102
+
103
+ This software is being developed by Eric Debreuve, a CNRS employee and
104
+ member of team Morpheme.
105
+ Team Morpheme is a joint team between Inria, CNRS, and UniCA.
106
+ It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
107
+ I3S, and Laboratory iBV.
108
+
109
+ CNRS: https://www.cnrs.fr/index.php/en
110
+ Inria: https://www.inria.fr/en/
111
+ UniCA: https://univ-cotedazur.eu/
112
+ Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
113
+ I3S: https://www.i3s.unice.fr/en/
114
+ iBV: http://ibv.unice.fr/
115
+ Team Morpheme: https://team.inria.fr/morpheme/
@@ -1,33 +1,8 @@
1
- # Copyright CNRS/Inria/UCA
2
- # Contributor(s): Eric Debreuve (since 2023)
3
- #
4
- # eric.debreuve@cnrs.fr
5
- #
6
- # This software is governed by the CeCILL license under French law and
7
- # abiding by the rules of distribution of free software. You can use,
8
- # modify and/ or redistribute the software under the terms of the CeCILL
9
- # license as circulated by CEA, CNRS and INRIA at the following URL
10
- # "http://www.cecill.info".
11
- #
12
- # As a counterpart to the access to the source code and rights to copy,
13
- # modify and redistribute granted by the license, users are provided only
14
- # with a limited warranty and the software's author, the holder of the
15
- # economic rights, and the successive licensors have only limited
16
- # liability.
17
- #
18
- # In this respect, the user's attention is drawn to the risks associated
19
- # with loading, using, modifying and/or developing or reproducing the
20
- # software by the user in light of its specific status of free software,
21
- # that may mean that it is complicated to manipulate, and that also
22
- # therefore means that it is reserved for developers and experienced
23
- # professionals having in-depth computer knowledge. Users are therefore
24
- # encouraged to load and test the software's suitability as regards their
25
- # requirements in conditions enabling the security of their systems and/or
26
- # data to be ensured and, more generally, to use and operate it in the
27
- # same conditions as regards security.
28
- #
29
- # The fact that you are presently reading this means that you have had
30
- # knowledge of the CeCILL license and that you accept its terms.
1
+ """
2
+ Copyright CNRS/Inria/UniCA
3
+ Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
4
+ SEE COPYRIGHT NOTICE BELOW
5
+ """
31
6
 
32
7
  import re as rgex
33
8
  from pathlib import Path as path_t
@@ -167,6 +142,54 @@ if __name__ == "__main__":
167
142
  entry_points=ENTRY_POINTS,
168
143
  python_requires=f">={PY_VERSION}",
169
144
  install_requires=[
145
+ "logger_36",
170
146
  "rich",
171
147
  ],
172
148
  )
149
+
150
+
151
+ """
152
+ COPYRIGHT NOTICE
153
+
154
+ This software is governed by the CeCILL license under French law and
155
+ abiding by the rules of distribution of free software. You can use,
156
+ modify and/ or redistribute the software under the terms of the CeCILL
157
+ license as circulated by CEA, CNRS and INRIA at the following URL
158
+ "http://www.cecill.info".
159
+
160
+ As a counterpart to the access to the source code and rights to copy,
161
+ modify and redistribute granted by the license, users are provided only
162
+ with a limited warranty and the software's author, the holder of the
163
+ economic rights, and the successive licensors have only limited
164
+ liability.
165
+
166
+ In this respect, the user's attention is drawn to the risks associated
167
+ with loading, using, modifying and/or developing or reproducing the
168
+ software by the user in light of its specific status of free software,
169
+ that may mean that it is complicated to manipulate, and that also
170
+ therefore means that it is reserved for developers and experienced
171
+ professionals having in-depth computer knowledge. Users are therefore
172
+ encouraged to load and test the software's suitability as regards their
173
+ requirements in conditions enabling the security of their systems and/or
174
+ data to be ensured and, more generally, to use and operate it in the
175
+ same conditions as regards security.
176
+
177
+ The fact that you are presently reading this means that you have had
178
+ knowledge of the CeCILL license and that you accept its terms.
179
+
180
+ SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
181
+
182
+ This software is being developed by Eric Debreuve, a CNRS employee and
183
+ member of team Morpheme.
184
+ Team Morpheme is a joint team between Inria, CNRS, and UniCA.
185
+ It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
186
+ I3S, and Laboratory iBV.
187
+
188
+ CNRS: https://www.cnrs.fr/index.php/en
189
+ Inria: https://www.inria.fr/en/
190
+ UniCA: https://univ-cotedazur.eu/
191
+ Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
192
+ I3S: https://www.i3s.unice.fr/en/
193
+ iBV: http://ibv.unice.fr/
194
+ Team Morpheme: https://team.inria.fr/morpheme/
195
+ """
@@ -0,0 +1,59 @@
1
+ """
2
+ Copyright CNRS/Inria/UniCA
3
+ Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
4
+ SEE COPYRIGHT NOTICE BELOW
5
+ """
6
+
7
+ from str_to_obj.main import ObjectFromStr
8
+ from str_to_obj.runtime.value import INVALID_VALUE
9
+ from str_to_obj.task.casting import CastValue
10
+ from str_to_obj.type.annotation import annotation_t
11
+ from str_to_obj.type.type import type_t
12
+ from str_to_obj.version import __version__
13
+
14
+
15
+ """
16
+ COPYRIGHT NOTICE
17
+
18
+ This software is governed by the CeCILL license under French law and
19
+ abiding by the rules of distribution of free software. You can use,
20
+ modify and/ or redistribute the software under the terms of the CeCILL
21
+ license as circulated by CEA, CNRS and INRIA at the following URL
22
+ "http://www.cecill.info".
23
+
24
+ As a counterpart to the access to the source code and rights to copy,
25
+ modify and redistribute granted by the license, users are provided only
26
+ with a limited warranty and the software's author, the holder of the
27
+ economic rights, and the successive licensors have only limited
28
+ liability.
29
+
30
+ In this respect, the user's attention is drawn to the risks associated
31
+ with loading, using, modifying and/or developing or reproducing the
32
+ software by the user in light of its specific status of free software,
33
+ that may mean that it is complicated to manipulate, and that also
34
+ therefore means that it is reserved for developers and experienced
35
+ professionals having in-depth computer knowledge. Users are therefore
36
+ encouraged to load and test the software's suitability as regards their
37
+ requirements in conditions enabling the security of their systems and/or
38
+ data to be ensured and, more generally, to use and operate it in the
39
+ same conditions as regards security.
40
+
41
+ The fact that you are presently reading this means that you have had
42
+ knowledge of the CeCILL license and that you accept its terms.
43
+
44
+ SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
45
+
46
+ This software is being developed by Eric Debreuve, a CNRS employee and
47
+ member of team Morpheme.
48
+ Team Morpheme is a joint team between Inria, CNRS, and UniCA.
49
+ It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
50
+ I3S, and Laboratory iBV.
51
+
52
+ CNRS: https://www.cnrs.fr/index.php/en
53
+ Inria: https://www.inria.fr/en/
54
+ UniCA: https://univ-cotedazur.eu/
55
+ Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
56
+ I3S: https://www.i3s.unice.fr/en/
57
+ iBV: http://ibv.unice.fr/
58
+ Team Morpheme: https://team.inria.fr/morpheme/
59
+ """
@@ -0,0 +1,99 @@
1
+ """
2
+ Copyright CNRS/Inria/UniCA
3
+ Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
4
+ SEE COPYRIGHT NOTICE BELOW
5
+ """
6
+
7
+ import dataclasses as d
8
+ import typing as h
9
+ from enum import Enum as enum_t
10
+
11
+ from logger_36.format import FormattedMessage
12
+ from str_to_obj.type.annotation import annotation_t
13
+ from str_to_obj.type.hint import annotated_hint_t
14
+
15
+
16
+ class boolean_mode_e(enum_t):
17
+ # True value must be listed first.
18
+ true_false = ("True", "False")
19
+ yes_no = ("Yes", "No")
20
+ on_off = ("On", "Off")
21
+
22
+
23
+ _BOOLEAN_MODES = tuple(boolean_mode_e.__members__.keys())
24
+
25
+
26
+ @d.dataclass(slots=True, repr=False, eq=False)
27
+ class boolean_t(annotation_t):
28
+
29
+ ACCEPTED_TYPES: h.ClassVar[tuple[type, ...]] = (bool,)
30
+
31
+ mode: boolean_mode_e = boolean_mode_e.true_false
32
+
33
+ @classmethod
34
+ def NewAnnotatedType(
35
+ cls, /, *, mode: boolean_mode_e | str | None = None
36
+ ) -> annotated_hint_t:
37
+ """"""
38
+ if mode is None:
39
+ mode = boolean_mode_e.true_false
40
+ elif isinstance(mode, str):
41
+ if mode in _BOOLEAN_MODES:
42
+ mode = boolean_mode_e[mode].value
43
+ else:
44
+ raise ValueError(
45
+ FormattedMessage(
46
+ "Invalid boolean mode",
47
+ actual=mode,
48
+ expected=" or ".join(_BOOLEAN_MODES),
49
+ )
50
+ )
51
+
52
+ return h.Annotated[bool, cls(mode=mode)]
53
+
54
+
55
+ """
56
+ COPYRIGHT NOTICE
57
+
58
+ This software is governed by the CeCILL license under French law and
59
+ abiding by the rules of distribution of free software. You can use,
60
+ modify and/ or redistribute the software under the terms of the CeCILL
61
+ license as circulated by CEA, CNRS and INRIA at the following URL
62
+ "http://www.cecill.info".
63
+
64
+ As a counterpart to the access to the source code and rights to copy,
65
+ modify and redistribute granted by the license, users are provided only
66
+ with a limited warranty and the software's author, the holder of the
67
+ economic rights, and the successive licensors have only limited
68
+ liability.
69
+
70
+ In this respect, the user's attention is drawn to the risks associated
71
+ with loading, using, modifying and/or developing or reproducing the
72
+ software by the user in light of its specific status of free software,
73
+ that may mean that it is complicated to manipulate, and that also
74
+ therefore means that it is reserved for developers and experienced
75
+ professionals having in-depth computer knowledge. Users are therefore
76
+ encouraged to load and test the software's suitability as regards their
77
+ requirements in conditions enabling the security of their systems and/or
78
+ data to be ensured and, more generally, to use and operate it in the
79
+ same conditions as regards security.
80
+
81
+ The fact that you are presently reading this means that you have had
82
+ knowledge of the CeCILL license and that you accept its terms.
83
+
84
+ SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
85
+
86
+ This software is being developed by Eric Debreuve, a CNRS employee and
87
+ member of team Morpheme.
88
+ Team Morpheme is a joint team between Inria, CNRS, and UniCA.
89
+ It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
90
+ I3S, and Laboratory iBV.
91
+
92
+ CNRS: https://www.cnrs.fr/index.php/en
93
+ Inria: https://www.inria.fr/en/
94
+ UniCA: https://univ-cotedazur.eu/
95
+ Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
96
+ I3S: https://www.i3s.unice.fr/en/
97
+ iBV: http://ibv.unice.fr/
98
+ Team Morpheme: https://team.inria.fr/morpheme/
99
+ """
@@ -0,0 +1,99 @@
1
+ """
2
+ Copyright CNRS/Inria/UniCA
3
+ Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
4
+ SEE COPYRIGHT NOTICE BELOW
5
+ """
6
+
7
+ import dataclasses as d
8
+ import typing as h
9
+
10
+ from str_to_obj.catalog.choices import choices_t
11
+ from str_to_obj.type.annotation import annotation_t
12
+ from str_to_obj.type.hint import annotated_hint_t
13
+
14
+
15
+ @d.dataclass(slots=True, repr=False, eq=False)
16
+ class callable_t(annotation_t):
17
+ ACCEPTED_TYPES: h.ClassVar[tuple[type, ...]] = (str,)
18
+
19
+ DUMMY_ENTRY: h.ClassVar[str] = "Dummy entry"
20
+ SEPARATOR: h.ClassVar[str] = ":"
21
+
22
+ kind: h.Literal["class", "function"]
23
+ choices: choices_t | None = None
24
+ allow_external: bool = False
25
+
26
+ @classmethod
27
+ def NewAnnotatedType(
28
+ cls,
29
+ /,
30
+ *,
31
+ kind: h.Literal["class", "function"] = "function",
32
+ catalog: h.Sequence[str] | bool | None = None,
33
+ allow_external: bool = False,
34
+ ) -> annotated_hint_t:
35
+ """"""
36
+ if catalog is None:
37
+ annotation = cls(kind=kind, allow_external=allow_external)
38
+ elif isinstance(catalog, bool):
39
+ if catalog:
40
+ annotation = cls(
41
+ kind=kind,
42
+ choices=choices_t((cls.DUMMY_ENTRY,)),
43
+ allow_external=allow_external,
44
+ )
45
+ else:
46
+ annotation = cls(kind=kind, allow_external=allow_external)
47
+ else:
48
+ annotation = cls(
49
+ kind=kind, choices=choices_t(catalog), allow_external=allow_external
50
+ )
51
+
52
+ return h.Annotated[str, annotation]
53
+
54
+
55
+ """
56
+ COPYRIGHT NOTICE
57
+
58
+ This software is governed by the CeCILL license under French law and
59
+ abiding by the rules of distribution of free software. You can use,
60
+ modify and/ or redistribute the software under the terms of the CeCILL
61
+ license as circulated by CEA, CNRS and INRIA at the following URL
62
+ "http://www.cecill.info".
63
+
64
+ As a counterpart to the access to the source code and rights to copy,
65
+ modify and redistribute granted by the license, users are provided only
66
+ with a limited warranty and the software's author, the holder of the
67
+ economic rights, and the successive licensors have only limited
68
+ liability.
69
+
70
+ In this respect, the user's attention is drawn to the risks associated
71
+ with loading, using, modifying and/or developing or reproducing the
72
+ software by the user in light of its specific status of free software,
73
+ that may mean that it is complicated to manipulate, and that also
74
+ therefore means that it is reserved for developers and experienced
75
+ professionals having in-depth computer knowledge. Users are therefore
76
+ encouraged to load and test the software's suitability as regards their
77
+ requirements in conditions enabling the security of their systems and/or
78
+ data to be ensured and, more generally, to use and operate it in the
79
+ same conditions as regards security.
80
+
81
+ The fact that you are presently reading this means that you have had
82
+ knowledge of the CeCILL license and that you accept its terms.
83
+
84
+ SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
85
+
86
+ This software is being developed by Eric Debreuve, a CNRS employee and
87
+ member of team Morpheme.
88
+ Team Morpheme is a joint team between Inria, CNRS, and UniCA.
89
+ It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
90
+ I3S, and Laboratory iBV.
91
+
92
+ CNRS: https://www.cnrs.fr/index.php/en
93
+ Inria: https://www.inria.fr/en/
94
+ UniCA: https://univ-cotedazur.eu/
95
+ Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
96
+ I3S: https://www.i3s.unice.fr/en/
97
+ iBV: http://ibv.unice.fr/
98
+ Team Morpheme: https://team.inria.fr/morpheme/
99
+ """
@@ -0,0 +1,99 @@
1
+ """
2
+ Copyright CNRS/Inria/UniCA
3
+ Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
4
+ SEE COPYRIGHT NOTICE BELOW
5
+ """
6
+
7
+ import dataclasses as d
8
+ import typing as h
9
+
10
+ from logger_36 import LOGGER
11
+ from str_to_obj.type.annotation import annotation_t
12
+ from str_to_obj.type.hint import annotated_hint_t
13
+
14
+
15
+ @d.dataclass(slots=True, repr=False, eq=False)
16
+ class choices_t(annotation_t):
17
+ ACCEPTED_TYPES: h.ClassVar[tuple[type, ...]] = (str,)
18
+
19
+ options: h.Sequence[str]
20
+
21
+ def __post_init__(self) -> None:
22
+ """"""
23
+ with LOGGER.AddedContextLevel("Choices Annotation"):
24
+ for option in self.options:
25
+ if not isinstance(option, str):
26
+ LOGGER.StageIssue(
27
+ f'Invalid type of option "{option}"',
28
+ actual=type(option).__name__,
29
+ expected="str",
30
+ )
31
+
32
+ @classmethod
33
+ def NewAnnotatedType(cls, options: h.Sequence[str], /) -> annotated_hint_t:
34
+ """"""
35
+ return h.Annotated[str, cls(tuple(options))]
36
+
37
+ def ValueIssues(self, value: str | h.Any, /) -> list[str]:
38
+ """"""
39
+ issues = annotation_t.ValueIssues(self, value)
40
+ if issues.__len__() > 0:
41
+ return issues
42
+
43
+ if (self.options.__len__() == 0) or (value in self.options):
44
+ # Options can be empty for a controlling parameter whose controlled section
45
+ # has not been specified. In a GUI context, such controlled section should
46
+ # have been populated programmatically.
47
+ return []
48
+
49
+ options = map(lambda _elm: f'"{_elm}"', self.options)
50
+ options = " or ".join(options)
51
+
52
+ return [f"Invalid choice: Actual={value}; Expected={options}."]
53
+
54
+
55
+ """
56
+ COPYRIGHT NOTICE
57
+
58
+ This software is governed by the CeCILL license under French law and
59
+ abiding by the rules of distribution of free software. You can use,
60
+ modify and/ or redistribute the software under the terms of the CeCILL
61
+ license as circulated by CEA, CNRS and INRIA at the following URL
62
+ "http://www.cecill.info".
63
+
64
+ As a counterpart to the access to the source code and rights to copy,
65
+ modify and redistribute granted by the license, users are provided only
66
+ with a limited warranty and the software's author, the holder of the
67
+ economic rights, and the successive licensors have only limited
68
+ liability.
69
+
70
+ In this respect, the user's attention is drawn to the risks associated
71
+ with loading, using, modifying and/or developing or reproducing the
72
+ software by the user in light of its specific status of free software,
73
+ that may mean that it is complicated to manipulate, and that also
74
+ therefore means that it is reserved for developers and experienced
75
+ professionals having in-depth computer knowledge. Users are therefore
76
+ encouraged to load and test the software's suitability as regards their
77
+ requirements in conditions enabling the security of their systems and/or
78
+ data to be ensured and, more generally, to use and operate it in the
79
+ same conditions as regards security.
80
+
81
+ The fact that you are presently reading this means that you have had
82
+ knowledge of the CeCILL license and that you accept its terms.
83
+
84
+ SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
85
+
86
+ This software is being developed by Eric Debreuve, a CNRS employee and
87
+ member of team Morpheme.
88
+ Team Morpheme is a joint team between Inria, CNRS, and UniCA.
89
+ It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
90
+ I3S, and Laboratory iBV.
91
+
92
+ CNRS: https://www.cnrs.fr/index.php/en
93
+ Inria: https://www.inria.fr/en/
94
+ UniCA: https://univ-cotedazur.eu/
95
+ Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
96
+ I3S: https://www.i3s.unice.fr/en/
97
+ iBV: http://ibv.unice.fr/
98
+ Team Morpheme: https://team.inria.fr/morpheme/
99
+ """