MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / sanitize_cmd

Function sanitize_cmd

test/helpers_shared.py:155–173  ·  view source on GitHub ↗
(cmd)

Source from the content-addressed store, hash-verified

153
154
155def sanitize_cmd(cmd):
156 cp = cmd.copy()
157 cp.pop("$clusterTime", None)
158 cp.pop("$db", None)
159 cp.pop("$readPreference", None)
160 cp.pop("lsid", None)
161 if MONGODB_API_VERSION:
162 # Stable API parameters
163 cp.pop("apiVersion", None)
164 # OP_MSG encoding may move the payload type one field to the
165 # end of the command. Do the same here.
166 name = next(iter(cp))
167 try:
168 identifier = message._FIELD_MAP[name]
169 docs = cp.pop(identifier)
170 cp[identifier] = docs
171 except KeyError:
172 pass
173 return cp
174
175
176def sanitize_reply(reply):

Callers 6

test_insert_manyMethod · 0.90
assertEqualCommandMethod · 0.90
assertEqualCommandMethod · 0.90
test_insert_manyMethod · 0.85

Calls 4

nextFunction · 0.85
iterFunction · 0.85
copyMethod · 0.80
popMethod · 0.45

Tested by 4

test_insert_manyMethod · 0.72
test_insert_manyMethod · 0.68