MCPcopy Create free account
hub / github.com/python-cmd2/cmd2 / from_dict

Method from_dict

cmd2/history.py:123–131  ·  view source on GitHub ↗

Restore a HistoryItem from a dictionary. :param source_dict: source data dictionary (generated using to_dict()) :return: HistoryItem object :raises KeyError: if source_dict is missing required elements

(source_dict: dict[str, Any])

Source from the content-addressed store, hash-verified

121
122 @staticmethod
123 def from_dict(source_dict: dict[str, Any]) -> "HistoryItem":
124 """Restore a HistoryItem from a dictionary.
125
126 :param source_dict: source data dictionary (generated using to_dict())
127 :return: HistoryItem object
128 :raises KeyError: if source_dict is missing required elements
129 """
130 statement_dict = source_dict[HistoryItem._statement_field]
131 return HistoryItem(Statement.from_dict(statement_dict))
132
133
134class History(list[HistoryItem]):

Callers 1

from_jsonMethod · 0.45

Calls 1

HistoryItemClass · 0.85

Tested by

no test coverage detected