def _xml_to_obj(cls, serialized_str): """ @summary: Returns an instance of a Cell. @param serialized_str: xml serialized string. @type serialized_str: String. @return: Cell. @rtype: Cell. """ element = ET.fromstring(serialized_str) capacity = element.find('capacities') ram_capacity_xml = capacity.find('ram_free') ram_capacity = CellCapacity._xml_to_obj(ram_capacity_xml) disk_capacity_xml = capacity.find("disk_free") disk_capacity = CellCapacity._xml_to_obj(disk_capacity_xml) cell = Cell(disk_capacity, ram_capacity) return cell
def _xml_to_obj(cls, serialized_str): """ @summary: Returns an instance of a Cell. @param serialized_str: xml serialized string. @type serialized_str: String. @return: Cell. @rtype: Cell. """ element = ET.fromstring(serialized_str) capacity = element.find('capacities') ram_capacity_xml = capacity.find('ram_free') ram_capacity = CellCapacity._xml_to_obj(ram_capacity_xml) disk_capacity_xml = capacity.find("disk_free") disk_capacity = CellCapacity._xml_to_obj(disk_capacity_xml) cell = Cell(disk_capacity, ram_capacity) return cell
def _json_to_obj(cls, serialized_str): """ @summary: Returns an instance of a Cell or a collection of Cells based on the json serialized_str passed in. @param serialized_str: json serialized string. @type serialized_str: String. @return: Cell. @rtype: Cell. """ json_dict = json.loads(serialized_str) disk_capacity_dict = json_dict.get('cell').\ get('capacities').get('disk_free') disk_capacity = CellCapacity._dict_to_obj(disk_capacity_dict) ram_capacity_dict = json_dict.get('cell').\ get('capacities').get('ram_free') ram_capacity = CellCapacity._dict_to_obj(ram_capacity_dict) cell = Cell(disk_capacity, ram_capacity) return cell
def _json_to_obj(cls, serialized_str): """ @summary: Returns an instance of a Cell or a collection of Cells based on the json serialized_str passed in. @param serialized_str: json serialized string. @type serialized_str: String. @return: Cell. @rtype: Cell. """ json_dict = json.loads(serialized_str) disk_capacity_dict = json_dict.get('cell').\ get('capacities').get('disk_free') disk_capacity = CellCapacity._dict_to_obj(disk_capacity_dict) ram_capacity_dict = json_dict.get('cell').\ get('capacities').get('ram_free') ram_capacity = CellCapacity._dict_to_obj(ram_capacity_dict) cell = Cell(disk_capacity, ram_capacity) return cell