<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def update_with_result(self, result):
 """Update item-model with result from host State is sent from host after processing had taken place and represents the events that took place; including log messages and completion status. Arguments: result (dict):
 Dictionary following the Result schema """


        assert isinstance(result, dict), "%s is not a dictionary" % result

        for type in ("instance", "plugin"):
            id = (result[type] or {}).get("id")

            is_context = not id
            if is_context:
                item = self.instances[0]
            else:
                item = self.items.get(id)

            if item is None:
                # If an item isn't there yet
                # no worries. It's probably because
                # reset is still running and the
                # item in question is a new instance
                # not yet added to the model.
                continue

            item.isProcessing = False
            item.currentProgress = 1
            item.processed = True
            item.hasWarning = item.hasWarning or any([
                record["levelno"] == logging.WARNING
                for record in result["records"]
            ])

            if result.get("error"):
                item.hasError = True
                item.amountFailed += 1

            else:
                item.succeeded = True
                item.amountPassed += 1

            item.duration += result["duration"]
            item.finishedAt = time.time()

            if item.itemType == "plugin" and not item.actionsIconVisible:

                actions = list(item.actions)

                # Context specific actions
                for action in list(actions):
                    if action["on"] == "failed" and not item.hasError:
                        actions.remove(action)
                    if action["on"] == "succeeded" and not item.succeeded:
                        actions.remove(action)
                    if action["on"] == "processed" and not item.processed:
                        actions.remove(action)

                if actions:
                    item.actionsIconVisible = True

            # Update section item
            class DummySection(object):
                hasWarning = False
                hasError = False
                succeeded = False

            section_item = DummySection()
            for section in self.sections:
                if item.itemType == "plugin" and section.name == item.verb:
                    section_item = section
                if (item.itemType == "instance" and
                        section.name == item.category):
                    section_item = section

            section_item.hasWarning = (
                section_item.hasWarning or item.hasWarning
            )
            section_item.hasError = section_item.hasError or item.hasError
            section_item.succeeded = section_item.succeeded or item.succeeded
            section_item.isProcessing = False