MCPcopy Create free account
hub / github.com/StackStorm/st2 / _to_trace_component_db

Function _to_trace_component_db

st2common/st2common/services/trace.py:400–420  ·  view source on GitHub ↗

Take the component as string or a dict and will construct a TraceComponentDB. :param component: Should identify the component. If a string should be id of the component. If a dict should contain id and the caused_by. :type component: ``bson.ObjectId`` or ``dict``

(component)

Source from the content-addressed store, hash-verified

398
399
400def _to_trace_component_db(component):
401 """
402 Take the component as string or a dict and will construct a TraceComponentDB.
403
404 :param component: Should identify the component. If a string should be id of the
405 component. If a dict should contain id and the caused_by.
406 :type component: ``bson.ObjectId`` or ``dict``
407
408 :rtype: ``TraceComponentDB``
409 """
410 if not isinstance(component, (six.string_types, dict)):
411 print(type(component))
412 raise ValueError("Expected component to be str or dict")
413
414 object_id = (
415 component if isinstance(component, six.string_types) else component["id"]
416 )
417 ref = component.get("ref", "") if isinstance(component, dict) else ""
418 caused_by = component.get("caused_by", {}) if isinstance(component, dict) else {}
419
420 return TraceComponentDB(object_id=object_id, ref=ref, caused_by=caused_by)

Callers 1

Calls 2

TraceComponentDBClass · 0.90
getMethod · 0.45

Tested by

no test coverage detected