auxfuncs.pyi 7.8 KB

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