auxfuncs.pyi 7.8 KB

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