def _normalize_query(self):
        num_phases = len(self._phases)

        # If there are no phases, return the keys as links
        if num_phases is 0:
            link_results_flag = True
        else:
            link_results_flag = False

        # Convert all phases to associative arrays. Also,
        # if none of the phases are accumulating, then set the last one to
        # accumulate.
        keep_flag = False
        query = []
        for i in range(num_phases):
            phase = self._phases[i]
            if (i == (1 - num_phases)) and (not keep_flag):
                phase._keep = True
            if phase._keep:
                keep_flag = True
            query.append(phase.to_array())

        # Is this a bucket-only input? If so, we need to switch
        # to be a string or array, i.e., no keyword (to keep Riak happy)
        # Also add the key filter, if necessary
        if isinstance(self._inputs, dict) and len(self._inputs) == 1:
            if len(self._key_filters) > 0:
                self._inputs['key_filters'] = self._key_filters
            else:
                self._inputs = self._inputs['bucket']

        return query, link_results_flag

    ##
    # Start Shortcuts to built-ins
    ##
dataset/ETHPy150Open basho/riak-python-client/riak/mapreduce.py/RiakMapReduce._normalize_query/swapped operands of `-`