(self, parser, group)
return group
This filter sorts nodes in a flat group into "required", "optional",
        and "banned" subgroups based on the presence of plus and minus nodes.
This filter sorts nodes in a flat group into "required", "optional",
        and "banned" subgroups based on the presence of plus and minus nodes.
This filter sorts nodes in a flat group into required optional and banned subgroups based on the presence of plus and minus nodes .
def do_plusminus(self, parser, group):
        """This filter sorts nodes in a flat group into "required", "optional",
        and "banned" subgroups based on the presence of plus and minus nodes.
        """

        required = syntax.AndGroup()
        optional = syntax.OrGroup()
        banned = syntax.OrGroup()

        # Which group to put the next node we see into
        next = optional
        for node in group:
            if isinstance(node, self.Plus):
                # +: put the next node in the required group
                next = required
            elif isinstance(node, self.Minus):
                # -: put the next node in the banned group
                next = banned
            else:
                # Anything else: put it in the appropriate group
                next.append(node)
                # Reset to putting things in the optional group by default
                next = optional

        group = optional
        if required:
            group = syntax.AndMaybeGroup([required, group])
        if banned:
            group = syntax.AndNotGroup([group, banned])
        return group
def do_plusminus ( self , parser , group ) : required = syntax . AndGroup ( ) optional = syntax . OrGroup ( ) banned = syntax . OrGroup ( ) # Which group to put the next node we see into next = optional for node in group : if isinstance ( node , self . Plus ) : # +: put the next node in the required group next = required elif isinstance ( node , self . Minus ) : # -: put the next node in the banned group next = banned else : # Anything else: put it in the appropriate group next . append ( node ) # Reset to putting things in the optional group by default next = optional group = optional if required : group = syntax . AndMaybeGroup ( [ required , group ] ) if banned : group = syntax . AndNotGroup ( [ group , banned ] ) return group