omextra 0.0.0.dev472__py3-none-any.whl → 0.0.0.dev492__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.
- omextra/README.md +14 -0
- omextra/__about__.py +2 -0
- omextra/collections/__init__.py +0 -0
- omextra/collections/hamt/LICENSE +35 -0
- omextra/collections/hamt/__init__.py +0 -0
- omextra/collections/hamt/_hamt.c +3621 -0
- omextra/formats/goyaml/LICENSE +16 -0
- omextra/formats/goyaml/__init__.py +29 -0
- omextra/formats/goyaml/ast.py +2217 -0
- omextra/formats/goyaml/errors.py +49 -0
- omextra/formats/goyaml/parsing.py +2332 -0
- omextra/formats/goyaml/scanning.py +1888 -0
- omextra/formats/goyaml/tokens.py +998 -0
- omextra/text/abnf/LICENSE +16 -0
- omextra/text/abnf/__init__.py +79 -0
- omextra/text/abnf/base.py +313 -0
- omextra/text/abnf/core.py +141 -0
- omextra/text/abnf/errors.py +10 -0
- omextra/text/abnf/meta.py +583 -0
- omextra/text/abnf/parsers.py +343 -0
- omextra/text/abnf/utils.py +76 -0
- omextra/text/abnf/visitors.py +55 -0
- {omextra-0.0.0.dev472.dist-info → omextra-0.0.0.dev492.dist-info}/METADATA +8 -5
- {omextra-0.0.0.dev472.dist-info → omextra-0.0.0.dev492.dist-info}/RECORD +28 -7
- {omextra-0.0.0.dev472.dist-info → omextra-0.0.0.dev492.dist-info}/WHEEL +0 -0
- {omextra-0.0.0.dev472.dist-info → omextra-0.0.0.dev492.dist-info}/entry_points.txt +0 -0
- {omextra-0.0.0.dev472.dist-info → omextra-0.0.0.dev492.dist-info}/licenses/LICENSE +0 -0
- {omextra-0.0.0.dev472.dist-info → omextra-0.0.0.dev492.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# ruff: noqa: UP007
|
|
2
|
+
# @omlish-lite
|
|
3
|
+
import abc
|
|
4
|
+
import dataclasses as dc
|
|
5
|
+
import typing as ta
|
|
6
|
+
|
|
7
|
+
from omlish.lite.abstract import Abstract
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
T = ta.TypeVar('T')
|
|
11
|
+
|
|
12
|
+
YamlErrorOr = ta.Union['YamlError', T] # ta.TypeAlias
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
##
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class YamlError(Abstract):
|
|
19
|
+
@property
|
|
20
|
+
@abc.abstractmethod
|
|
21
|
+
def message(self) -> str:
|
|
22
|
+
raise NotImplementedError
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class EofYamlError(YamlError):
|
|
26
|
+
@property
|
|
27
|
+
def message(self) -> str:
|
|
28
|
+
return 'eof'
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@dc.dataclass(frozen=True)
|
|
32
|
+
class GenericYamlError(YamlError):
|
|
33
|
+
obj: ta.Union[str, Exception]
|
|
34
|
+
|
|
35
|
+
@property
|
|
36
|
+
def message(self) -> str:
|
|
37
|
+
if isinstance(self.obj, str):
|
|
38
|
+
return self.obj
|
|
39
|
+
else:
|
|
40
|
+
return str(self.obj)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def yaml_error(obj: ta.Union[YamlError, str, Exception]) -> YamlError:
|
|
44
|
+
if isinstance(obj, YamlError):
|
|
45
|
+
return obj
|
|
46
|
+
elif isinstance(obj, (str, Exception)):
|
|
47
|
+
return GenericYamlError(obj)
|
|
48
|
+
else:
|
|
49
|
+
raise TypeError(obj)
|