Repository navigation
Expand file tree
/
Copy path_native.pyi
More file actions
96 lines (75 loc) · 3.31 KB
/
Copy path_native.pyi
File metadata and controls
96 lines (75 loc) · 3.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
from collections.abc import Mapping, Sequence
from os import PathLike
from typing import Any, TypeVar, final, overload
from numpy.typing import NDArray
from gecode_iris._data import Entry, Value
from gecode_iris.build import Field
_T = TypeVar("_T")
@final
class Spec:
"""A parsed and checked reader spec.
One ``Spec`` can read any number of inputs, and threads can share it.
"""
@staticmethod
def parse(text: str | bytes | bytearray, origin: str = "<string>") -> Spec:
"""Parse and check a reader spec given as ``str`` or ``bytes``."""
@staticmethod
def _parse_built(text: str, origin: str, call_sites: Any) -> Spec: ...
@property
def _call_sites(self) -> Any: ...
@staticmethod
def load(path: str | PathLike[str]) -> Spec:
"""Read and parse a reader spec file; the path is the error origin."""
def read(
self,
source: bytes | bytearray | str | PathLike[str],
params: Mapping[str, str] | None = None,
*,
origin: str | None = None,
) -> Data:
"""Read one instance from input bytes or from a path."""
def catalog(
self,
source: bytes | bytearray | str | PathLike[str],
params: Mapping[str, str] | None = None,
*,
origin: str | None = None,
) -> Data:
"""List the instances in the input, with the same arguments as ``read``."""
@final
class Data:
"""The data from one read or catalog.
``data[name]`` returns an entry's value and ``name in data`` tests for an
entry. Values are copied into Python objects on each access: an ``int``,
``float`` or ``str`` at depth 0, and nested lists at greater depths.
A handle from ``gecode_iris.build`` can stand for the name, and then
``data[handle]`` has the handle's type: ``None`` when an optional entry is
absent. A handle whose entry has another value type or depth, because a
later statement redefined its name or the handle belongs to another reader
spec, raises ``TypeError``.
"""
@property
def entries(self) -> tuple[Entry, ...]:
"""The entries in the order their names were defined."""
@overload
def __getitem__(self, key: str, /) -> Value: ...
@overload
def __getitem__(self, key: Field[_T], /) -> _T: ...
def __getitem__(self, key: str | Field[Any], /) -> Any:
"""The whole value of an entry; raises ``KeyError`` for an unknown name."""
def __contains__(self, key: object, /) -> bool: ...
def ints(self, key: str | Field[Any], /, *path: int) -> list[int]:
"""The integer row of an entry at a path."""
def array(self, key: str | Field[Any], /, *path: int) -> NDArray[Any] | list[Value]:
"""An array of an entry, or of its row at a path.
The result is a ``numpy.ndarray`` when numpy is importable and the
array is rectangular, and nested lists otherwise.
"""
def to_dict(self) -> dict[str, Value]:
"""All entries as a ``dict`` from name to value, in entry order."""
def to_json(self) -> str:
"""The canonical JSON document, ending in a newline."""
def to_dzn(self) -> str:
"""The MiniZinc data text defined in the Specification's appendix B."""
def run_cli(argv: Sequence[str]) -> int:
"""Run the ``iris`` command line on ``argv``, program name first; return its exit status."""