21 lines
517 B
Python
21 lines
517 B
Python
from books.models import Module
|
||
import json
|
||
|
||
def categorize_modules():
|
||
all_nodes = []
|
||
|
||
for module in Module.objects.all():
|
||
print(f"{module.get_parent() } {module.meta_title} : {module.title}")
|
||
|
||
nodes = [i.strip() for i in [module.get_parent().title] + module.meta_title.split(' – ')]
|
||
all_nodes.append(nodes)
|
||
|
||
print("")
|
||
|
||
for i in range(3):
|
||
leafs = [node[i] for node in all_nodes if len(node) > i+1]
|
||
leafs.sort()
|
||
print(f"{i}.: {set(leafs)}")
|
||
|
||
|