5 from datetime import datetime
6 from typing import Any, Callable, Dict, Iterable, List, Mapping, Pattern, Protocol, Tuple, Type, Union
7 from xmlrpc.client import Fault
9 # TODO: Recursive type on tuple, list, dict
10 _Marshallable = Union[None, bool, int, float, str, bytes, Tuple[Any, ...], List[Any], Dict[Any, Any], datetime]
12 # The dispatch accepts anywhere from 0 to N arguments, no easy way to allow this in mypy
13 class _DispatchArity0(Protocol):
14 def __call__(self) -> _Marshallable: ...
16 class _DispatchArity1(Protocol):
17 def __call__(self, __arg1: _Marshallable) -> _Marshallable: ...
19 class _DispatchArity2(Protocol):
20 def __call__(self, __arg1: _Marshallable, __arg2: _Marshallable) -> _Marshallable: ...
22 class _DispatchArity3(Protocol):
23 def __call__(self, __arg1: _Marshallable, __arg2: _Marshallable, __arg3: _Marshallable) -> _Marshallable: ...
25 class _DispatchArity4(Protocol):
27 self, __arg1: _Marshallable, __arg2: _Marshallable, __arg3: _Marshallable, __arg4: _Marshallable
28 ) -> _Marshallable: ...
30 class _DispatchArityN(Protocol):
31 def __call__(self, *args: _Marshallable) -> _Marshallable: ...
33 _DispatchProtocol = Union[_DispatchArity0, _DispatchArity1, _DispatchArity2, _DispatchArity3, _DispatchArity4, _DispatchArityN]
35 def resolve_dotted_attribute(obj: Any, attr: str, allow_dotted_names: bool = ...) -> Any: ... # undocumented
36 def list_public_methods(obj: Any) -> list[str]: ... # undocumented
38 class SimpleXMLRPCDispatcher: # undocumented
40 funcs: dict[str, _DispatchProtocol]
44 use_builtin_types: bool
45 def __init__(self, allow_none: bool = ..., encoding: str | None = ..., use_builtin_types: bool = ...) -> None: ...
46 def register_instance(self, instance: Any, allow_dotted_names: bool = ...) -> None: ...
47 if sys.version_info >= (3, 7):
48 def register_function(self, function: _DispatchProtocol | None = ..., name: str | None = ...) -> Callable[..., Any]: ...
50 def register_function(self, function: _DispatchProtocol, name: str | None = ...) -> Callable[..., Any]: ...
51 def register_introspection_functions(self) -> None: ...
52 def register_multicall_functions(self) -> None: ...
53 def _marshaled_dispatch(
56 dispatch_method: Callable[[str | None, Tuple[_Marshallable, ...]], Fault | Tuple[_Marshallable, ...]] | None = ...,
57 path: Any | None = ...,
58 ) -> str: ... # undocumented
59 def system_listMethods(self) -> list[str]: ... # undocumented
60 def system_methodSignature(self, method_name: str) -> str: ... # undocumented
61 def system_methodHelp(self, method_name: str) -> str: ... # undocumented
62 def system_multicall(self, call_list: list[dict[str, _Marshallable]]) -> list[_Marshallable]: ... # undocumented
63 def _dispatch(self, method: str, params: Iterable[_Marshallable]) -> _Marshallable: ... # undocumented
65 class SimpleXMLRPCRequestHandler(http.server.BaseHTTPRequestHandler):
67 rpc_paths: tuple[str, str]
68 encode_threshold: int # undocumented
69 aepattern: Pattern[str] # undocumented
70 def accept_encodings(self) -> dict[str, float]: ...
71 def is_rpc_path_valid(self) -> bool: ...
72 def do_POST(self) -> None: ...
73 def decode_request_content(self, data: bytes) -> bytes | None: ...
74 def report_404(self) -> None: ...
75 def log_request(self, code: int | str = ..., size: int | str = ...) -> None: ...
77 class SimpleXMLRPCServer(socketserver.TCPServer, SimpleXMLRPCDispatcher):
79 allow_reuse_address: bool
80 _send_traceback_handler: bool
83 addr: tuple[str, int],
84 requestHandler: Type[SimpleXMLRPCRequestHandler] = ...,
85 logRequests: bool = ...,
86 allow_none: bool = ...,
87 encoding: str | None = ...,
88 bind_and_activate: bool = ...,
89 use_builtin_types: bool = ...,
92 class MultiPathXMLRPCServer(SimpleXMLRPCServer): # undocumented
94 dispatchers: dict[str, SimpleXMLRPCDispatcher]
99 addr: tuple[str, int],
100 requestHandler: Type[SimpleXMLRPCRequestHandler] = ...,
101 logRequests: bool = ...,
102 allow_none: bool = ...,
103 encoding: str | None = ...,
104 bind_and_activate: bool = ...,
105 use_builtin_types: bool = ...,
107 def add_dispatcher(self, path: str, dispatcher: SimpleXMLRPCDispatcher) -> SimpleXMLRPCDispatcher: ...
108 def get_dispatcher(self, path: str) -> SimpleXMLRPCDispatcher: ...
109 def _marshaled_dispatch(
112 dispatch_method: Callable[[str | None, Tuple[_Marshallable, ...]], Fault | Tuple[_Marshallable, ...]] | None = ...,
113 path: Any | None = ...,
116 class CGIXMLRPCRequestHandler(SimpleXMLRPCDispatcher):
117 def __init__(self, allow_none: bool = ..., encoding: str | None = ..., use_builtin_types: bool = ...) -> None: ...
118 def handle_xmlrpc(self, request_text: str) -> None: ...
119 def handle_get(self) -> None: ...
120 def handle_request(self, request_text: str | None = ...) -> None: ...
122 class ServerHTMLDoc(pydoc.HTMLDoc): # undocumented
123 def docroutine(self, object: object, name: str, mod: str | None = ..., funcs: Mapping[str, str] = ..., classes: Mapping[str, str] = ..., methods: Mapping[str, str] = ..., cl: type | None = ...) -> str: ... # type: ignore
124 def docserver(self, server_name: str, package_documentation: str, methods: dict[str, str]) -> str: ...
126 class XMLRPCDocGenerator: # undocumented
129 server_documentation: str
131 def __init__(self) -> None: ...
132 def set_server_title(self, server_title: str) -> None: ...
133 def set_server_name(self, server_name: str) -> None: ...
134 def set_server_documentation(self, server_documentation: str) -> None: ...
135 def generate_html_documentation(self) -> str: ...
137 class DocXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
138 def do_GET(self) -> None: ...
140 class DocXMLRPCServer(SimpleXMLRPCServer, XMLRPCDocGenerator):
143 addr: tuple[str, int],
144 requestHandler: Type[SimpleXMLRPCRequestHandler] = ...,
145 logRequests: bool = ...,
146 allow_none: bool = ...,
147 encoding: str | None = ...,
148 bind_and_activate: bool = ...,
149 use_builtin_types: bool = ...,
152 class DocCGIXMLRPCRequestHandler(CGIXMLRPCRequestHandler, XMLRPCDocGenerator):
153 def __init__(self) -> None: ...