codekingpro/portable-devtools
114k
1from _typeshed import FileDescriptorOrPath
2from collections.abc import Callable, Mapping
3from pprint import pprint as show
4from typing import Any, Final, Literal as L, Never, TypeAlias, TypeVar, overload
5
6from .cfuncs import errmess
7
8__all__ = [
9 "applyrules",
10 "containscommon",
11 "containsderivedtypes",
12 "debugcapi",
13 "dictappend",
14 "errmess",
15 "gentitle",
16 "get_f2py_modulename",
17 "getargs2",
18 "getcallprotoargument",
19 "getcallstatement",
20 "getdimension",
21 "getfortranname",
22 "getpymethoddef",
23 "getrestdoc",
24 "getuseblocks",
25 "getusercode",
26 "getusercode1",
27 "hasbody",
28 "hascallstatement",
29 "hascommon",
30 "hasexternals",
31 "hasinitvalue",
32 "hasnote",
33 "hasresultnote",
34 "isallocatable",
35 "isarray",
36 "isarrayofstrings",
37 "isattr_value",
38 "ischaracter",
39 "ischaracter_or_characterarray",
40 "ischaracterarray",
41 "iscomplex",
42 "iscomplexarray",
43 "iscomplexfunction",
44 "iscomplexfunction_warn",
45 "iscstyledirective",
46 "isdouble",
47 "isdummyroutine",
48 "isexternal",
49 "isfunction",
50 "isfunction_wrap",
51 "isint1",
52 "isint1array",
53 "isinteger",
54 "isintent_aux",
55 "isintent_c",
56 "isintent_callback",
57 "isintent_copy",
58 "isintent_dict",
59 "isintent_hide",
60 "isintent_in",
61 "isintent_inout",
62 "isintent_inplace",
63 "isintent_nothide",
64 "isintent_out",
65 "isintent_overwrite",
66 "islogical",
67 "islogicalfunction",
68 "islong_complex",
69 "islong_double",
70 "islong_doublefunction",
71 "islong_long",
72 "islong_longfunction",
73 "ismodule",
74 "ismoduleroutine",
75 "isoptional",
76 "isprivate",
77 "isrequired",
78 "isroutine",
79 "isscalar",
80 "issigned_long_longarray",
81 "isstring",
82 "isstring_or_stringarray",
83 "isstringarray",
84 "isstringfunction",
85 "issubroutine",
86 "issubroutine_wrap",
87 "isthreadsafe",
88 "isunsigned",
89 "isunsigned_char",
90 "isunsigned_chararray",
91 "isunsigned_long_long",
92 "isunsigned_long_longarray",
93 "isunsigned_short",
94 "isunsigned_shortarray",
95 "isvariable",
96 "l_and",
97 "l_not",
98 "l_or",
99 "outmess",
100 "process_f2cmap_dict",
101 "replace",
102 "show",
103 "stripcomma",
104 "throw_error",
105]
106
107###
108
109_VT = TypeVar("_VT")
110_RT = TypeVar("_RT")
111
112_Var: TypeAlias = Mapping[str, list[str]]
113_ROut: TypeAlias = Mapping[str, str]
114_F2CMap: TypeAlias = Mapping[str, Mapping[str, str]]
115
116_Bool: TypeAlias = bool | L[0, 1]
117_Intent: TypeAlias = L[
118 "INTENT_IN",
119 "INTENT_OUT",
120 "INTENT_INOUT",
121 "INTENT_C",
122 "INTENT_CACHE",
123 "INTENT_HIDE",
124 "INTENT_INPLACE",
125 "INTENT_ALIGNED4",
126 "INTENT_ALIGNED8",
127 "INTENT_ALIGNED16",
128 "OPTIONAL",
129]
130
131###
132
133isintent_dict: dict[Callable[[_Var], _Bool], _Intent]
134
135class F2PYError(Exception): ...
136
137class throw_error:
138 mess: Final[str]
139 def __init__(self, /, mess: str) -> None: ...
140 def __call__(self, /, var: _Var) -> Never: ... # raises F2PYError
141
142#
143def l_and(*f: tuple[str, Callable[[_VT], _RT]]) -> Callable[[_VT], _RT]: ...
144def l_or(*f: tuple[str, Callable[[_VT], _RT]]) -> Callable[[_VT], _RT]: ...
145def l_not(f: tuple[str, Callable[[_VT], _RT]]) -> Callable[[_VT], _RT]: ...
146
147#
148def outmess(t: str) -> None: ...
149def debugcapi(var: _Var) -> bool: ...
150
151#
152def hasinitvalue(var: _Var | str) -> bool: ...
153def hasnote(var: _Var | str) -> bool: ...
154def ischaracter(var: _Var) -> bool: ...
155def ischaracterarray(var: _Var) -> bool: ...
156def ischaracter_or_characterarray(var: _Var) -> bool: ...
157def isstring(var: _Var) -> bool: ...
158def isstringarray(var: _Var) -> bool: ...
159def isstring_or_stringarray(var: _Var) -> bool: ...
160def isarray(var: _Var) -> bool: ...
161def isarrayofstrings(var: _Var) -> bool: ...
162def isscalar(var: _Var) -> bool: ...
163def iscomplex(var: _Var) -> bool: ...
164def islogical(var: _Var) -> bool: ...
165def isinteger(var: _Var) -> bool: ...
166def isint1(var: _Var) -> bool: ...
167def isint1array(var: _Var) -> bool: ...
168def islong_long(var: _Var) -> _Bool: ...
169def isunsigned(var: _Var) -> _Bool: ...
170def isunsigned_char(var: _Var) -> _Bool: ...
171def isunsigned_chararray(var: _Var) -> bool: ...
172def isunsigned_short(var: _Var) -> _Bool: ...
173def isunsigned_shortarray(var: _Var) -> bool: ...
174def isunsigned_long_long(var: _Var) -> _Bool: ...
175def isunsigned_long_longarray(var: _Var) -> bool: ...
176def issigned_long_longarray(var: _Var) -> bool: ...
177def isdouble(var: _Var) -> _Bool: ...
178def islong_double(var: _Var) -> _Bool: ...
179def islong_complex(var: _Var) -> _Bool: ...
180def iscomplexarray(var: _Var) -> bool: ...
181def isallocatable(var: _Var) -> bool: ...
182def isattr_value(var: _Var) -> bool: ...
183def isoptional(var: _Var) -> bool: ...
184def isexternal(var: _Var) -> bool: ...
185def isrequired(var: _Var) -> bool: ...
186def isprivate(var: _Var) -> bool: ...
187def isvariable(var: _Var) -> bool: ...
188def isintent_in(var: _Var) -> _Bool: ...
189def isintent_inout(var: _Var) -> bool: ...
190def isintent_out(var: _Var) -> bool: ...
191def isintent_hide(var: _Var) -> bool: ...
192def isintent_nothide(var: _Var) -> bool: ...
193def isintent_c(var: _Var) -> bool: ...
194def isintent_cache(var: _Var) -> bool: ...
195def isintent_copy(var: _Var) -> bool: ...
196def isintent_overwrite(var: _Var) -> bool: ...
197def isintent_callback(var: _Var) -> bool: ...
198def isintent_inplace(var: _Var) -> bool: ...
199def isintent_aux(var: _Var) -> bool: ...
200
201#
202def containsderivedtypes(rout: _ROut) -> L[0, 1]: ...
203def containscommon(rout: _ROut) -> _Bool: ...
204def hasexternals(rout: _ROut) -> bool: ...
205def hasresultnote(rout: _ROut) -> _Bool: ...
206def hasbody(rout: _ROut) -> _Bool: ...
207def hascommon(rout: _ROut) -> bool: ...
208def hasderivedtypes(rout: _ROut) -> bool: ...
209def hascallstatement(rout: _ROut) -> bool: ...
210def isroutine(rout: _ROut) -> bool: ...
211def ismodule(rout: _ROut) -> bool: ...
212def ismoduleroutine(rout: _ROut) -> bool: ...
213def issubroutine(rout: _ROut) -> bool: ...
214def issubroutine_wrap(rout: _ROut) -> _Bool: ...
215def isfunction(rout: _ROut) -> bool: ...
216def isfunction_wrap(rout: _ROut) -> _Bool: ...
217def islogicalfunction(rout: _ROut) -> _Bool: ...
218def islong_longfunction(rout: _ROut) -> _Bool: ...
219def islong_doublefunction(rout: _ROut) -> _Bool: ...
220def iscomplexfunction(rout: _ROut) -> _Bool: ...
221def iscomplexfunction_warn(rout: _ROut) -> _Bool: ...
222def isstringfunction(rout: _ROut) -> _Bool: ...
223def isthreadsafe(rout: _ROut) -> bool: ...
224def isdummyroutine(rout: _ROut) -> _Bool: ...
225def iscstyledirective(f2py_line: str) -> bool: ...
226
227# .
228def getdimension(var: _Var) -> list[Any] | None: ...
229def getfortranname(rout: _ROut) -> str: ...
230def getmultilineblock(rout: _ROut, blockname: str, comment: _Bool = 1, counter: int = 0) -> str | None: ...
231def getcallstatement(rout: _ROut) -> str | None: ...
232def getcallprotoargument(rout: _ROut, cb_map: dict[str, str] = {}) -> str: ...
233def getusercode(rout: _ROut) -> str | None: ...
234def getusercode1(rout: _ROut) -> str | None: ...
235def getpymethoddef(rout: _ROut) -> str | None: ...
236def getargs(rout: _ROut) -> tuple[list[str], list[str]]: ...
237def getargs2(rout: _ROut) -> tuple[list[str], list[str]]: ...
238def getrestdoc(rout: _ROut) -> str | None: ...
239
240#
241def gentitle(name: str) -> str: ...
242def stripcomma(s: str) -> str: ...
243@overload
244def replace(str: str, d: list[str], defaultsep: str = "") -> list[str]: ...
245@overload
246def replace(str: list[str], d: str, defaultsep: str = "") -> list[str]: ...
247@overload
248def replace(str: str, d: str, defaultsep: str = "") -> str: ...
249
250#
251def dictappend(rd: Mapping[str, object], ar: Mapping[str, object] | list[Mapping[str, object]]) -> dict[str, Any]: ...
252def applyrules(rules: Mapping[str, object], d: Mapping[str, object], var: _Var = {}) -> dict[str, Any]: ...
253
254#
255def get_f2py_modulename(source: FileDescriptorOrPath) -> str: ...
256def getuseblocks(pymod: Mapping[str, Mapping[str, Mapping[str, str]]]) -> list[str]: ...
257def process_f2cmap_dict(
258 f2cmap_all: _F2CMap,
259 new_map: _F2CMap,
260 c2py_map: _F2CMap,
261 verbose: bool = False,
262) -> tuple[dict[str, dict[str, str]], list[str]]: ...
263 