MCPcopy Index your code
hub / github.com/MongoEngine/mongoengine / _format_errors

Method _format_errors

mongoengine/errors.py:144–159  ·  view source on GitHub ↗

Returns a string listing all errors within a document

(self)

Source from the content-addressed store, hash-verified

142 return build_dict(self.errors)
143
144 def _format_errors(self):
145 """Returns a string listing all errors within a document"""
146
147 def generate_key(value, prefix=""):
148 if isinstance(value, list):
149 value = " ".join([generate_key(k) for k in value])
150 elif isinstance(value, dict):
151 value = " ".join([generate_key(v, k) for k, v in value.items()])
152
153 results = f"{prefix}.{value}" if prefix else value
154 return results
155
156 error_dict = defaultdict(list)
157 for k, v in self.to_dict().items():
158 error_dict[generate_key(v)].append(k)
159 return " ".join([f"{k}: {v}" for k, v in error_dict.items()])
160
161
162class DeprecatedError(MongoEngineException):

Callers 1

__getattribute__Method · 0.95

Calls 3

to_dictMethod · 0.95
itemsMethod · 0.80
joinMethod · 0.80

Tested by

no test coverage detected