Example #1
0
    def show(self):
        """
        This is where we go output the content of a block and any valid child
        block that it contains.

        """
        # Start by finalising the block.
        # Any active content is added to self.options
        if self.content:
            self.options.append(self.content)

        output = Composite()

        for index, option in enumerate(self.options):
            if index in self.valid_blocks:
                # A block may be valid but has a command that causes this to be
                # disregarded.
                if self.is_valid_by_command(index) is False:
                    continue
                # add the content of the block and any children
                # to the output
                for item in option:
                    if isinstance(item, Block):
                        output.append(item.show())
                    else:
                        output.append(item)
                break

        # Build up our output.
        self.process_composite_chunk_item(output.get_content())
        return output
Example #2
0
    def show(self):
        """
        This is where we go output the content of a block and any valid child
        block that it contains.

        """
        # Start by finalising the block.
        # Any active content is added to self.options
        if self.content:
            self.options.append(self.content)

        output = Composite()

        for index, option in enumerate(self.options):
            if index in self.valid_blocks:
                # A block may be valid but has a command that causes this to be
                # disregarded.
                if self.is_valid_by_command(index) is False:
                    continue
                # add the content of the block and any children
                # to the output
                for item in option:
                    if isinstance(item, Block):
                        output.append(item.show())
                    else:
                        output.append(item)
                break

        # Build up our output.
        self.process_composite_chunk_item(output.get_content())
        return output
def test_Composite_append_4():
    c = Composite("moo")
    c.append(Composite("moo"))
    result = c.get_content()
    assert result == [{"full_text": "moo"}, {"full_text": "moo"}]
Example #4
0
def test_Composite_append_4():
    c = Composite('moo')
    c.append(Composite('moo'))
    result = c.get_content()
    assert result == [{'full_text': 'moo'}, {'full_text': 'moo'}]