summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2022-03-17 00:33:31 +0100
committerSébastien Helleu <flashcode@flashtux.org>2022-03-17 21:16:45 +0100
commit827db6dc313101c80c3cd8f766fa0b857df77015 (patch)
tree66ac2722c783698def7c9920bde5122ab4dfeea3
parent44e04149704e72062d3aea51a25eadde680fb043 (diff)
downloadweechat-827db6dc313101c80c3cd8f766fa0b857df77015.zip
core: Fix regex for constants in the Python stub generator
In Python raw strings, newlines can't be escaped with a backslash. If you do that, both the backslash and the newline become part of the string. This meant that the regex for constants both started and ended with a newline which caused every other constant to be skipped.
-rwxr-xr-xdoc/python_stub.py12
-rw-r--r--src/plugins/python/weechat.pyi18
2 files changed, 23 insertions, 7 deletions
diff --git a/doc/python_stub.py b/doc/python_stub.py
index 681533807..329f11473 100755
--- a/doc/python_stub.py
+++ b/doc/python_stub.py
@@ -38,16 +38,14 @@ STUB_HEADER = """\
from typing import Dict
"""
-CONSTANT_RE = r"""\
- `(?P<constant>WEECHAT_[A-Z0-9_]+)` \((?P<type>(string|integer))\)(?: \+)?\
-"""
+CONSTANT_RE = (
+ r""" `(?P<constant>WEECHAT_[A-Z0-9_]+)` \((?P<type>(string|integer))\)(?: \+)?"""
+)
-FUNCTION_RE = r"""\
-\[source,python\]
+FUNCTION_RE = r"""\[source,python\]
----
# prototype
-def (?P<function>\w+)(?P<args>[^)]*)(?P<return>\) -> [^:]+:) \.\.\.\
-"""
+def (?P<function>\w+)(?P<args>[^)]*)(?P<return>\) -> [^:]+:) \.\.\."""
def print_stub_constants() -> None:
diff --git a/src/plugins/python/weechat.pyi b/src/plugins/python/weechat.pyi
index 005daee3c..8dab95a99 100644
--- a/src/plugins/python/weechat.pyi
+++ b/src/plugins/python/weechat.pyi
@@ -6,26 +6,44 @@
from typing import Dict
WEECHAT_RC_OK: int
+WEECHAT_RC_OK_EAT: int
WEECHAT_RC_ERROR: int
WEECHAT_CONFIG_READ_OK: int
+WEECHAT_CONFIG_READ_MEMORY_ERROR: int
WEECHAT_CONFIG_READ_FILE_NOT_FOUND: int
+WEECHAT_CONFIG_WRITE_OK: int
WEECHAT_CONFIG_WRITE_ERROR: int
+WEECHAT_CONFIG_WRITE_MEMORY_ERROR: int
WEECHAT_CONFIG_OPTION_SET_OK_CHANGED: int
+WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE: int
WEECHAT_CONFIG_OPTION_SET_ERROR: int
+WEECHAT_CONFIG_OPTION_SET_OPTION_NOT_FOUND: int
WEECHAT_CONFIG_OPTION_UNSET_OK_NO_RESET: int
+WEECHAT_CONFIG_OPTION_UNSET_OK_RESET: int
WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED: int
+WEECHAT_CONFIG_OPTION_UNSET_ERROR: int
WEECHAT_LIST_POS_SORT: str
+WEECHAT_LIST_POS_BEGINNING: str
WEECHAT_LIST_POS_END: str
WEECHAT_HOTLIST_LOW: str
+WEECHAT_HOTLIST_MESSAGE: str
WEECHAT_HOTLIST_PRIVATE: str
+WEECHAT_HOTLIST_HIGHLIGHT: str
WEECHAT_HOOK_PROCESS_RUNNING: int
+WEECHAT_HOOK_PROCESS_ERROR: int
WEECHAT_HOOK_CONNECT_OK: int
+WEECHAT_HOOK_CONNECT_ADDRESS_NOT_FOUND: int
WEECHAT_HOOK_CONNECT_IP_ADDRESS_NOT_FOUND: int
+WEECHAT_HOOK_CONNECT_CONNECTION_REFUSED: int
WEECHAT_HOOK_CONNECT_PROXY_ERROR: int
+WEECHAT_HOOK_CONNECT_LOCAL_HOSTNAME_ERROR: int
WEECHAT_HOOK_CONNECT_GNUTLS_INIT_ERROR: int
+WEECHAT_HOOK_CONNECT_GNUTLS_HANDSHAKE_ERROR: int
WEECHAT_HOOK_CONNECT_MEMORY_ERROR: int
+WEECHAT_HOOK_CONNECT_TIMEOUT: int
WEECHAT_HOOK_CONNECT_SOCKET_ERROR: int
WEECHAT_HOOK_SIGNAL_STRING: str
+WEECHAT_HOOK_SIGNAL_INT: str
WEECHAT_HOOK_SIGNAL_POINTER: str