Commit 4e9c137a authored by Matthieu Boileau's avatar Matthieu Boileau

Some cosmetics

parent 6a707beb
......@@ -5,7 +5,7 @@ Convert spip YAML content to markdown following
https://github.com/nhoizey/spip2markdown/blob/master/spip2markdown_options.php
"""
from anytree import Node, RenderTree
import anytree
import argparse
from ruamel.yaml import YAML
import bs4
......@@ -521,10 +521,10 @@ class Website:
if len(node):
# node is a real Tree, not a leaf
name = list(node.keys())[0]
nodes[name] = Node(name, parent=parent)
anytree_nodes[name] = anytree.Node(name, parent=parent)
children = list(node.values())[0]
for k, v in children.items():
walk({k: v}, nodes[name])
walk({k: v}, anytree_nodes[name])
data = [] # a list of Tree nodes
tree = Tree() # a Tree object to store rubrique structure as a nested dict
......@@ -549,13 +549,14 @@ class Website:
tree.insert(node['node'], node['ancestors'])
# Create a dictionary of anytree.Node objects
nodes = {get_label(0): Node(get_label(0))}
anytree_nodes = {get_label(0): anytree.Node(get_label(0))} # create root node
walk(tree) # walk tree to insert other nodes
walk(tree)
# Render the anytree.Node object like the bash "tree" command would do
for pre, fill, anytree_node in anytree.RenderTree(anytree_nodes['0: root']):
print(f"{pre}{anytree_node.name}")
# Render the anytree object like the bash "tree" command would do
for pre, fill, node in RenderTree(nodes['0: root']):
print(f"{pre}{node.name}")
return anytree_nodes['0: root']
def _build_doc_index(self):
"""Build the index dictionary: {id_doc: file_path}"""
......@@ -645,6 +646,6 @@ if __name__ == '__main__':
website.read_spip()
if args.rubriques:
# Show only Spip rubrique structure
website.print_rubrique_tree()
tree = website.print_rubrique_tree()
else:
website.export_to_pelican()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment