def _set_scriptlet_metadata( self, metadata: snapcraft.extractors.ExtractedMetadata): step = self.next_step() # First, ensure the metadata set here doesn't conflict with metadata # already set for this step conflicts = metadata.overlap(self._scriptlet_metadata[step]) if len(conflicts) > 0: raise errors.ScriptletDuplicateDataError(step, step, list(conflicts)) last_step = self.last_step() if last_step: # Now ensure the metadata from this step doesn't conflict with # metadata from any other step index = common.COMMAND_ORDER.index(last_step) for index in reversed(range(0, index + 1)): other_step = common.COMMAND_ORDER[index] state = states.get_state(self.plugin.statedir, other_step) conflicts = metadata.overlap(state.scriptlet_metadata) if len(conflicts) > 0: raise errors.ScriptletDuplicateDataError( step, other_step, list(conflicts)) self._scriptlet_metadata[step].update(metadata)
def _set_scriptlet_metadata(self, metadata: snapcraft.extractors.ExtractedMetadata): step = self.next_step() # First, ensure the metadata set here doesn't conflict with metadata # already set for this step conflicts = metadata.overlap(self._scriptlet_metadata[step]) if len(conflicts) > 0: raise errors.ScriptletDuplicateDataError(step, step, list(conflicts)) # Now ensure the metadata from this step doesn't conflict with # metadata from any other step (if any) with contextlib.suppress(errors.NoLatestStepError): latest_step = self.latest_step() required_steps = latest_step.previous_steps() + [latest_step] for other_step in reversed(required_steps): state = states.get_state(self.plugin.statedir, other_step) conflicts = metadata.overlap(state.scriptlet_metadata) if len(conflicts) > 0: raise errors.ScriptletDuplicateDataError( step, other_step, list(conflicts) ) self._scriptlet_metadata[step].update(metadata)