def update_material(self, material): """ Update a material Parameters ---------- material : Material the material to be updated. Raises ------ ValueError: If a material with this uid does not exist """ self._materials[material.uid] = Material.from_material(material)
def get_material(self, uid): """ Get the material Parameters ---------- uid: uuid.UUID the id of the material to be retrieved. Returns ------- material Raises ------ KeyError: If there is no material with the given uid """ return Material.from_material(self._materials[uid])
def add_material(self, material): """Add a material Parameters ---------- material : Material the material to be added. Raises ------ ValueError: If a material with the same uid already exists """ if material.uid in self._materials: raise ValueError( "Material (uid:{}) already exists.".format(material.uid)) else: self._materials[material.uid] = Material.from_material(material)