def loadEquipment(equipmentData): """Returns an Equipment object for the given data""" e = Equipment() e.equipmentId = equipmentData["equipmentId"] e.name = equipmentData["name"] if "abbreviation" in equipmentData: e.abbreviation = equipmentData["abbreviation"] return e
def createEquipment(equipmentData): #check that equipmentData is valid if not ("name" in equipmentData and type(equipmentData["name"]) == str and len(equipmentData["name"]) > 0): raise errors.BadRequestError( "Equipment must have attribute 'name' (type=str and length>0)") #construct the equipment e = Equipment() e.name = equipmentData["name"] if "abbreviation" in equipmentData: e.abbreviation = equipmentData["abbreviation"] #create the equipment EquipmentTable.put_item(Item=e.toDynamo()) return e