MCPcopy Index your code
hub / github.com/python/cpython / dumps

Function dumps

Lib/xmlrpc/client.py:918–982  ·  view source on GitHub ↗

data [,options] -> marshalled data Convert an argument tuple or a Fault instance to an XML-RPC request (or response, if the methodresponse option is used). In addition to the data object, the following options can be given as keyword arguments: methodname: the method name

(params, methodname=None, methodresponse=None, encoding=None,
          allow_none=False)

Source from the content-addressed store, hash-verified

916# @return A string containing marshalled data.
917
918def dumps(params, methodname=None, methodresponse=None, encoding=None,
919 allow_none=False):
920 """data [,options] -> marshalled data
921
922 Convert an argument tuple or a Fault instance to an XML-RPC
923 request (or response, if the methodresponse option is used).
924
925 In addition to the data object, the following options can be given
926 as keyword arguments:
927
928 methodname: the method name for a methodCall packet
929
930 methodresponse: true to create a methodResponse packet.
931 If this option is used with a tuple, the tuple must be
932 a singleton (i.e. it can contain only one element).
933
934 encoding: the packet encoding (default is UTF-8)
935
936 All byte strings in the data structure are assumed to use the
937 packet encoding. Unicode strings are automatically converted,
938 where necessary.
939 """
940
941 assert isinstance(params, (tuple, Fault)), "argument must be tuple or Fault instance"
942 if isinstance(params, Fault):
943 methodresponse = 1
944 elif methodresponse and isinstance(params, tuple):
945 assert len(params) == 1, "response tuple must be a singleton"
946
947 if not encoding:
948 encoding = "utf-8"
949
950 if FastMarshaller:
951 m = FastMarshaller(encoding)
952 else:
953 m = Marshaller(encoding, allow_none)
954
955 data = m.dumps(params)
956
957 if encoding != "utf-8":
958 xmlheader = "<?xml version='1.0' encoding='%s'?>\n" % str(encoding)
959 else:
960 xmlheader = "<?xml version='1.0'?>\n" # utf-8 is default
961
962 # standard XML-RPC wrappings
963 if methodname:
964 # a method call
965 data = (
966 xmlheader,
967 "<methodCall>\n"
968 "<methodName>", methodname, "</methodName>\n",
969 data,
970 "</methodCall>\n"
971 )
972 elif methodresponse:
973 # a method response, or a fault structure
974 data = (
975 xmlheader,

Callers 3

_marshaled_dispatchMethod · 0.90
_marshaled_dispatchMethod · 0.90
__requestMethod · 0.70

Calls 4

dumpsMethod · 0.95
MarshallerClass · 0.85
strFunction · 0.85
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…