parent and children array

This commit is contained in:
Valentin CZERYBA 2023-07-11 21:39:41 +02:00
parent 5059a15826
commit bca529f3c3

View File

@ -109,10 +109,7 @@ class WPMenu:
href = anchor.find("a").get("href")
if href == "{0}://{1}/".format(self._protocol_canalblog, self._canalblog):
parent = "home"
itemMenu = {"id":"", "type":"", "title": parent, "children":list()}
#menu = self._child(parent, parent)
itemMenu = {"id":"", "type":"", "title": parent, "children":list()}
if href == "#":
li = anchor.find("ul").find_all("li")
for child in li:
@ -122,13 +119,16 @@ class WPMenu:
menu.append(itemMenu)
for i in range(0, len(children)-1):
self._logger.info("{0} : Child {1}".format(self._name, children[i]))
for j in range(0, len(menu)-1):
if menu[j]["title"] == children[i]["title"]:
self._logger.info("{0} : Parent {1}".format(self._name, menu[j]))
del menu[j]
for j in range(0, len(menu)-1):
for i in range(0, len(children)):
self._logger.info("{0} : Child {1} {2}".format(self._name, children[i], i))
for j in range(0, len(menu)):
if j < len(menu):
if menu[j]["title"] == children[i]["title"]:
self._logger.info("{0} : Parent {1} {2}".format(self._name, menu[j], j))
del menu[j]
for j in range(0, len(menu)):
self._logger.info("{0} : Children for : {1}".format(self._name, menu[j]["title"]))
if menu[j]["title"] == children[i]["parent"]:
menu[j]["children"].append({"id":"", "title":children[i]["title"], "parent": children[i]["parent"]})