def create_outline(self, outline_spec):
        """
        After parsing a text file, calculating the indent level and extracting the text from each line, we can now
        construct the outline itself.

        In an opml file, the outline nodes at the top of the tree hang off the body element.  But in order to simplify
        the use of recursion to generate the tree, we will initially generate the tree hanging from an outline element,
        and then once the tree is created, create the well-formed xml tree to correctly drive the Outline object.

        :param outline_spec:
        :return:
        """

        top_level_node = self.create_outline_element(None)

        self.add_child_nodes(top_level_node, 0, outline_spec, 0)
        outline_child_nodes = [
            outline_element for outline_element in top_level_node
        ]

        return Outline.from_scratch(outline_child_nodes)
Exemplo n.º 2
0
def generate_outline_from_test_data():

    # First add all the top level nodes as they are supplied when creating the outline
    top_level_nodes = []
    for record in [
            item for item in outline_expected_node_results if item[1] == 0
    ]:
        _, _, _, text, note = record
        top_level_nodes.append(
            OutlineNode.create_outline_node(text, note)._node)

    # Now create the outline before adding other nodes
    new_outline = Outline.from_scratch(top_level_nodes)

    # Now add other nodes but skipping records for top level ones
    for record in [
            item for item in outline_expected_node_results if item[1] != 0
    ]:
        node_sequence_number, parent_node_number, level, text, note = record

        parent_node = new_outline.get_node(parent_node_number).node()
        parent_node.add_node(text, note)

    new_outline.write_opml(test_opml_path)
Exemplo n.º 3
0
 def pre_process_outline(self):
     # Replace with actual code
     return Outline.from_scratch()