def peek(self, dag):
    # TODO(cs): optimization: write the prefix trie to a file, in case we want to run
    # FindMCS again?
    if len(dag.input_events) == 0:
      # Postcondition: input_events[-1] is not None
      #                and self._events_list[-1] is not None
      return dag

    # dag.input_events returns only prunable input events. We also need
    # include ConnectToControllers, which is a non-prunable input event.
    if not isinstance(dag.events[0], ConnectToControllers):
      raise ValueError("First event must be ConnectToControllers")
    assert(dag.input_events[0] != dag.events[0])
    input_events = [dag.events[0]] + dag.input_events

    # Initilize current_input_prefix to the longest_match prefix we've
    # inferred previously (or [] if this is an entirely new prefix)
    current_input_prefix = list(self._prefix_trie\
                                .longest_prefix(input_events, default=[]))
    log.debug("Current input prefix: %s" % str(current_input_prefix))

    # The value is both internal events and input events (values of the trie)
    # leading up, but not including the next input following the tail of the
    # prefix.
    # Note that we assume that there are no internal events before the first
    # input event (i.e. we assume quiescence)
    inferred_events = list(self._prefix_trie\
                           .longest_prefix_value(input_events, default=[]))
    log.debug("Current inferred_events: %s" % str(inferred_events))
    inject_input_idx = len(current_input_prefix)

    # While we still have inputs to inject
    while inject_input_idx < len(input_events):
      # The input we're about to inject
      inject_input = input_events[inject_input_idx]
      following_input = get_following_input(inject_input_idx, dag.input_events)

      # The input following the one we're going to inject
      log.debug("peek()'ing after input %d" % (inject_input_idx))

      expected_internal_events = \
        get_expected_internal_events(inject_input, following_input, dag.events)

      # Optimization: if no internal events occured between this input and the
      # next, no need to peek()
      if expected_internal_events == []:
        log.debug("Optimization: no expected internal events")
        newly_inferred_events = []
        Peeker.ambiguous_counts[0.0] += 1
      else:
        wait_time_seconds = self.get_wait_time_seconds(inject_input, following_input)
        # We inject a NOPInput with the same timestamp as inject_input
        # to ensure that the timing is the same before peek()ing, then replay
        # inject_input in play_forward()
        fencepost = NOPInput(time=inject_input.time, round=inject_input.round)
        replay_dag = EventDag(inferred_events + [ fencepost ])
        found_events = self.find_internal_events(replay_dag, inject_input, wait_time_seconds)
        newly_inferred_events = match_and_filter(found_events, expected_internal_events)

      (current_input_prefix,
       inferred_events) = self._update_trie(current_input_prefix, inject_input,
                                            inferred_events, newly_inferred_events)
      inject_input_idx += 1

    return EventDag(inferred_events)
Uploads a server certificate entity for the AWS Account.
dataset/ETHPy150Open ucb-sts/sts/sts/control_flow/peeker.py/PrefixPeeker.peek--crossover with--dataset/ETHPy150Open darcyliu/storyboard/boto/iam/connection.py/IAMConnection.upload_server_cert