MCPcopy Create free account
hub / github.com/mitmproxy/mitmproxy / transform_field

Method transform_field

examples/contrib/jsondump.py:144–154  ·  view source on GitHub ↗

Apply a transformation function `func` to a value under the specified `path` in the `obj` dictionary.

(obj, path, func)

Source from the content-addressed store, hash-verified

142
143 @staticmethod
144 def transform_field(obj, path, func):
145 """
146 Apply a transformation function `func` to a value
147 under the specified `path` in the `obj` dictionary.
148 """
149 for key in path[:-1]:
150 if not (key in obj and obj[key]):
151 return
152 obj = obj[key]
153 if path[-1] in obj and obj[path[-1]]:
154 obj[path[-1]] = func(obj[path[-1]])
155
156 @classmethod
157 def convert_to_strings(cls, obj):

Callers 1

dumpMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected