MCPcopy Create free account
hub / github.com/ceph/ceph / from_json

Method from_json

src/python-common/ceph/deployment/inventory.py:105–120  ·  view source on GitHub ↗
(cls, input)

Source from the content-addressed store, hash-verified

103
104 @classmethod
105 def from_json(cls, input):
106 # type: (Dict[str, Any]) -> Device
107 if not isinstance(input, dict):
108 raise ValueError('Device: Expected dict. Got `{}...`'.format(json.dumps(input)[:10]))
109 ret = cls(
110 **{
111 key: (input.get(key, None) if key != 'created'
112 or not input.get(key, None)
113 else str_to_datetime(input.get(key, None)))
114 for key in Device.report_fields
115 if key != 'human_readable_type'
116 }
117 )
118 if ret.rejected_reasons:
119 ret.rejected_reasons = sorted(ret.rejected_reasons)
120 return ret
121
122 @property
123 def human_readable_type(self):

Callers 1

from_jsonMethod · 0.45

Calls 4

str_to_datetimeFunction · 0.90
sortedFunction · 0.85
formatMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected