def accum_append(self, val, raw=False):
        raw = raw or (not self.cooked)
        
        # Check the node type. Break types output nothing; they just change
        # the current state.
        if isinstance(val, GenNodeClass):
            nodtyp = type(val)
            if nodtyp in (RunOnNode, RunOnExplicitNode, CommaNode, SemiNode, StopNode, ParaNode):
                # Retain the more severe break form.
                if self.textstate.precedence < nodtyp.precedence:
                    self.textstate = nodtyp
                return
        else:
            assert (type(val) is str)
            if not val:
                return
            nodtyp = WordNode
            
        docap = False

        # Based on the current state, add a space or punctuation or
        # whatever before the new text.
        if self.textstate in (RunOnNode, RunOnExplicitNode):
            pass
        elif self.textstate in (BeginNode, StopNode, ParaNode):
            if self.textstate is StopNode:
                self.accum.append('. ')
            elif self.textstate is ParaNode:
                self.accum.append('.')
                self.accum.append(['para']) # see interp.ParaBreak
            docap = True
        elif self.textstate is SemiNode:
            self.accum.append('; ')
        elif self.textstate is CommaNode:
            self.accum.append(', ')
        elif self.textstate is RunOnCapNode:
            docap = True
        elif self.textstate is ANode:
            if nodtyp is AFormNode:
                self.accum.append(' ')
            elif nodtyp is AnFormNode:
                self.accum.append('n ')
            elif nodtyp is WordNode and re_vowelstart.match(val):
                self.accum.append('n ')
            else:
                self.accum.append(' ')
        else:
            self.accum.append(' ')

        # Add the new text. We may have to capitalize it, depending on
        # what the last state was. This sets the next state, most commonly
        # to WordNode.
        if nodtyp is WordNode:
            if docap:
                self.accum.append(val[0].upper())
                self.accum.append(val[1:])
            else:                   
                self.accum.append(val)
            if raw:
                self.textstate = RunOnNode
            else:
                self.textstate = WordNode
        elif nodtyp is ANode:
            if docap:
                self.accum.append('A')
            else:
                self.accum.append('a')
            self.textstate = ANode
        elif nodtyp in (AFormNode, AnFormNode):
            if docap:
                self.textstate = RunOnCapNode
            else:
                self.textstate = RunOnNode
        else:
            self.accum.append('[Unsupported GenNodeClass: %s]' % (nodtyp.__name__,))
A list filter that filters the queryset by default gives the correct
dataset/ETHPy150Open erkyrath/tworld/lib/two/evalctx.py/EvalPropContext.accum_append--crossover with--dataset/ETHPy150Open django/django/tests/admin_filters/tests.py/ListFiltersTests.test_list_filter_queryset_filtered_by_default