Format: application/octet-stream
⬇ Download File (9.5 KB)
   1  from datetime import datetime
   2  from gzip import GzipFile
   3  from httplib import HTTPConnection, HTTPResponse, HTTPSConnection
   4  from ssl import SSLContext
   5  from StringIO import StringIO
   6  from time import struct_time
   7  from types import InstanceType
   8  from typing import IO, Any, AnyStr, Callable, Iterable, List, Mapping, MutableMapping, Optional, Tuple, Type, TypeVar, Union
   9  
  10  _Unmarshaller = Any
  11  _timeTuple = Tuple[int, int, int, int, int, int, int, int, int]
  12  # Represents types that can be compared against a DateTime object
  13  _dateTimeComp = Union[unicode, DateTime, datetime]
  14  # A "host description" used by Transport factories
  15  _hostDesc = Union[str, Tuple[str, Mapping[Any, Any]]]
  16  
  17  def escape(s: AnyStr, replace: Callable[[AnyStr, AnyStr, AnyStr], AnyStr] = ...) -> AnyStr: ...
  18  
  19  MAXINT: int
  20  MININT: int
  21  PARSE_ERROR: int
  22  SERVER_ERROR: int
  23  APPLICATION_ERROR: int
  24  SYSTEM_ERROR: int
  25  TRANSPORT_ERROR: int
  26  NOT_WELLFORMED_ERROR: int
  27  UNSUPPORTED_ENCODING: int
  28  INVALID_ENCODING_CHAR: int
  29  INVALID_XMLRPC: int
  30  METHOD_NOT_FOUND: int
  31  INVALID_METHOD_PARAMS: int
  32  INTERNAL_ERROR: int
  33  
  34  class Error(Exception): ...
  35  
  36  class ProtocolError(Error):
  37      url: str
  38      errcode: int
  39      errmsg: str
  40      headers: Any
  41      def __init__(self, url: str, errcode: int, errmsg: str, headers: Any) -> None: ...
  42  
  43  class ResponseError(Error): ...
  44  
  45  class Fault(Error):
  46      faultCode: Any
  47      faultString: str
  48      def __init__(self, faultCode: Any, faultString: str, **extra: Any) -> None: ...
  49  
  50  boolean: Type[bool]
  51  Boolean: Type[bool]
  52  
  53  class DateTime:
  54      value: str
  55      def __init__(self, value: Union[str, unicode, datetime, float, int, _timeTuple, struct_time] = ...) -> None: ...
  56      def make_comparable(self, other: _dateTimeComp) -> Tuple[unicode, unicode]: ...
  57      def __lt__(self, other: _dateTimeComp) -> bool: ...
  58      def __le__(self, other: _dateTimeComp) -> bool: ...
  59      def __gt__(self, other: _dateTimeComp) -> bool: ...
  60      def __ge__(self, other: _dateTimeComp) -> bool: ...
  61      def __eq__(self, other: _dateTimeComp) -> bool: ...  # type: ignore
  62      def __ne__(self, other: _dateTimeComp) -> bool: ...  # type: ignore
  63      def timetuple(self) -> struct_time: ...
  64      def __cmp__(self, other: _dateTimeComp) -> int: ...
  65      def decode(self, data: Any) -> None: ...
  66      def encode(self, out: IO[str]) -> None: ...
  67  
  68  class Binary:
  69      data: str
  70      def __init__(self, data: Optional[str] = ...) -> None: ...
  71      def __cmp__(self, other: Any) -> int: ...
  72      def decode(self, data: str) -> None: ...
  73      def encode(self, out: IO[str]) -> None: ...
  74  
  75  WRAPPERS: Tuple[Type[Any], ...]
  76  
  77  # Still part of the public API, but see http://bugs.python.org/issue1773632
  78  FastParser: None
  79  FastUnmarshaller: None
  80  FastMarshaller: None
  81  
  82  # xmlrpclib.py will leave ExpatParser undefined if it can't import expat from
  83  # xml.parsers. Because this is Python 2.7, the import will succeed.
  84  class ExpatParser:
  85      def __init__(self, target: _Unmarshaller) -> None: ...
  86      def feed(self, data: str): ...
  87      def close(self): ...
  88  
  89  # TODO: Add xmllib.XMLParser as base class
  90  class SlowParser:
  91      handle_xml: Callable[[str, bool], None]
  92      unknown_starttag: Callable[[str, Any], None]
  93      handle_data: Callable[[str], None]
  94      handle_cdata: Callable[[str], None]
  95      unknown_endtag: Callable[[str, Callable[[Iterable[str], str], str]], None]
  96      def __init__(self, target: _Unmarshaller) -> None: ...
  97  
  98  class Marshaller:
  99      memo: MutableMapping[int, Any]
 100      data: Optional[str]
 101      encoding: Optional[str]
 102      allow_none: bool
 103      def __init__(self, encoding: Optional[str] = ..., allow_none: bool = ...) -> None: ...
 104      dispatch: Mapping[type, Callable[[Marshaller, str, Callable[[str], None]], None]]
 105      def dumps(
 106          self,
 107          values: Union[
 108              Iterable[
 109                  Union[
 110                      None,
 111                      int,
 112                      bool,
 113                      long,
 114                      float,
 115                      str,
 116                      unicode,
 117                      List[Any],
 118                      Tuple[Any, ...],
 119                      Mapping[Any, Any],
 120                      datetime,
 121                      InstanceType,
 122                  ]
 123              ],
 124              Fault,
 125          ],
 126      ) -> str: ...
 127      def dump_nil(self, value: None, write: Callable[[str], None]) -> None: ...
 128      def dump_int(self, value: int, write: Callable[[str], None]) -> None: ...
 129      def dump_bool(self, value: bool, write: Callable[[str], None]) -> None: ...
 130      def dump_long(self, value: long, write: Callable[[str], None]) -> None: ...
 131      def dump_double(self, value: float, write: Callable[[str], None]) -> None: ...
 132      def dump_string(
 133          self,
 134          value: str,
 135          write: Callable[[str], None],
 136          escape: Callable[[AnyStr, Callable[[AnyStr, AnyStr, AnyStr], AnyStr]], AnyStr] = ...,
 137      ) -> None: ...
 138      def dump_unicode(
 139          self,
 140          value: unicode,
 141          write: Callable[[str], None],
 142          escape: Callable[[AnyStr, Callable[[AnyStr, AnyStr, AnyStr], AnyStr]], AnyStr] = ...,
 143      ) -> None: ...
 144      def dump_array(self, value: Iterable[Any], write: Callable[[str], None]) -> None: ...
 145      def dump_struct(
 146          self,
 147          value: Mapping[unicode, Any],
 148          write: Callable[[str], None],
 149          escape: Callable[[AnyStr, Callable[[AnyStr, AnyStr, AnyStr], AnyStr]], AnyStr] = ...,
 150      ) -> None: ...
 151      def dump_datetime(self, value: datetime, write: Callable[[str], None]) -> None: ...
 152      def dump_instance(self, value: InstanceType, write: Callable[[str], None]) -> None: ...
 153  
 154  class Unmarshaller:
 155      def append(self, object: Any) -> None: ...
 156      def __init__(self, use_datetime: bool = ...) -> None: ...
 157      def close(self) -> Tuple[Any, ...]: ...
 158      def getmethodname(self) -> Optional[str]: ...
 159      def xml(self, encoding: str, standalone: bool) -> None: ...
 160      def start(self, tag: str, attrs: Any) -> None: ...
 161      def data(self, text: str) -> None: ...
 162      def end(self, tag: str, join: Callable[[Iterable[str], str], str] = ...) -> None: ...
 163      def end_dispatch(self, tag: str, data: str) -> None: ...
 164      dispatch: Mapping[str, Callable[[Unmarshaller, str], None]]
 165      def end_nil(self, data: str): ...
 166      def end_boolean(self, data: str) -> None: ...
 167      def end_int(self, data: str) -> None: ...
 168      def end_double(self, data: str) -> None: ...
 169      def end_string(self, data: str) -> None: ...
 170      def end_array(self, data: str) -> None: ...
 171      def end_struct(self, data: str) -> None: ...
 172      def end_base64(self, data: str) -> None: ...
 173      def end_dateTime(self, data: str) -> None: ...
 174      def end_value(self, data: str) -> None: ...
 175      def end_params(self, data: str) -> None: ...
 176      def end_fault(self, data: str) -> None: ...
 177      def end_methodName(self, data: str) -> None: ...
 178  
 179  class _MultiCallMethod:
 180      def __init__(self, call_list: List[Tuple[str, Tuple[Any, ...]]], name: str) -> None: ...
 181  
 182  class MultiCallIterator:
 183      def __init__(self, results: List[Any]) -> None: ...
 184  
 185  class MultiCall:
 186      def __init__(self, server: ServerProxy) -> None: ...
 187      def __getattr__(self, name: str) -> _MultiCallMethod: ...
 188      def __call__(self) -> MultiCallIterator: ...
 189  
 190  def getparser(use_datetime: bool = ...) -> Tuple[Union[ExpatParser, SlowParser], Unmarshaller]: ...
 191  def dumps(
 192      params: Union[Tuple[Any, ...], Fault],
 193      methodname: Optional[str] = ...,
 194      methodresponse: Optional[bool] = ...,
 195      encoding: Optional[str] = ...,
 196      allow_none: bool = ...,
 197  ) -> str: ...
 198  def loads(data: str, use_datetime: bool = ...) -> Tuple[Tuple[Any, ...], Optional[str]]: ...
 199  def gzip_encode(data: str) -> str: ...
 200  def gzip_decode(data: str, max_decode: int = ...) -> str: ...
 201  
 202  class GzipDecodedResponse(GzipFile):
 203      stringio: StringIO[Any]
 204      def __init__(self, response: HTTPResponse) -> None: ...
 205      def close(self): ...
 206  
 207  class _Method:
 208      def __init__(self, send: Callable[[str, Tuple[Any, ...]], Any], name: str) -> None: ...
 209      def __getattr__(self, name: str) -> _Method: ...
 210      def __call__(self, *args: Any) -> Any: ...
 211  
 212  class Transport:
 213      user_agent: str
 214      accept_gzip_encoding: bool
 215      encode_threshold: Optional[int]
 216      def __init__(self, use_datetime: bool = ...) -> None: ...
 217      def request(self, host: _hostDesc, handler: str, request_body: str, verbose: bool = ...) -> Tuple[Any, ...]: ...
 218      verbose: bool
 219      def single_request(self, host: _hostDesc, handler: str, request_body: str, verbose: bool = ...) -> Tuple[Any, ...]: ...
 220      def getparser(self) -> Tuple[Union[ExpatParser, SlowParser], Unmarshaller]: ...
 221      def get_host_info(self, host: _hostDesc) -> Tuple[str, Optional[List[Tuple[str, str]]], Optional[Mapping[Any, Any]]]: ...
 222      def make_connection(self, host: _hostDesc) -> HTTPConnection: ...
 223      def close(self) -> None: ...
 224      def send_request(self, connection: HTTPConnection, handler: str, request_body: str) -> None: ...
 225      def send_host(self, connection: HTTPConnection, host: str) -> None: ...
 226      def send_user_agent(self, connection: HTTPConnection) -> None: ...
 227      def send_content(self, connection: HTTPConnection, request_body: str) -> None: ...
 228      def parse_response(self, response: HTTPResponse) -> Tuple[Any, ...]: ...
 229  
 230  class SafeTransport(Transport):
 231      def __init__(self, use_datetime: bool = ..., context: Optional[SSLContext] = ...) -> None: ...
 232      def make_connection(self, host: _hostDesc) -> HTTPSConnection: ...
 233  
 234  class ServerProxy:
 235      def __init__(
 236          self,
 237          uri: str,
 238          transport: Optional[Transport] = ...,
 239          encoding: Optional[str] = ...,
 240          verbose: bool = ...,
 241          allow_none: bool = ...,
 242          use_datetime: bool = ...,
 243          context: Optional[SSLContext] = ...,
 244      ) -> None: ...
 245      def __getattr__(self, name: str) -> _Method: ...
 246      def __call__(self, attr: str) -> Optional[Transport]: ...
 247  
 248  Server = ServerProxy
 249