add href
This commit is contained in:
parent
0445054dc8
commit
5fe4b1f786
@ -74,6 +74,24 @@ class WPMenu:
|
|||||||
except Exception as err:
|
except Exception as err:
|
||||||
self._logger.error("{0} : Exception error for get url {1} : {2}".format(self._name, canalblog, err))
|
self._logger.error("{0} : Exception error for get url {1} : {2}".format(self._name, canalblog, err))
|
||||||
|
|
||||||
|
def _getIdFromPost(self, href):
|
||||||
|
idMenu = 0
|
||||||
|
return idMenu
|
||||||
|
|
||||||
|
def _getIdFromReverse(self, title, href):
|
||||||
|
self._logger.info("{0} : get title {1} from href {2}".format(self._name, title, href))
|
||||||
|
idMenu = 0
|
||||||
|
if href != "#":
|
||||||
|
title = href[::-1]
|
||||||
|
link = title.split("/")[0]
|
||||||
|
link = link[::-1]
|
||||||
|
title = title.split("/")[1]
|
||||||
|
title = title[::-1]
|
||||||
|
self._logger.info("{0} link {1} title {2}".format(self._name, link, title))
|
||||||
|
if link == "index.html":
|
||||||
|
idMenu = self._getId(title)
|
||||||
|
return idMenu
|
||||||
|
|
||||||
def _getId(self, title):
|
def _getId(self, title):
|
||||||
idMenu = 0
|
idMenu = 0
|
||||||
exist = False
|
exist = False
|
||||||
@ -138,7 +156,7 @@ class WPMenu:
|
|||||||
for j in range(0, len(menu)):
|
for j in range(0, len(menu)):
|
||||||
self._logger.info("{0} : Children for : {1}".format(self._name, menu[j]["title"]))
|
self._logger.info("{0} : Children for : {1}".format(self._name, menu[j]["title"]))
|
||||||
if menu[j]["title"] == children[i]["parent"]:
|
if menu[j]["title"] == children[i]["parent"]:
|
||||||
menu[j]["children"].append({"id":"", "title":children[i]["title"], "parent": children[i]["parent"]})
|
menu[j]["children"].append({"id":"", "title":children[i]["title"], "parent": children[i]["parent"], "href":children[i]["href"]})
|
||||||
|
|
||||||
for i in range(0, len(menu)):
|
for i in range(0, len(menu)):
|
||||||
self._logger.info("{0} : Menu {1} {2}".format(self._name, menu[i]["title"], len(menu[i]["children"])))
|
self._logger.info("{0} : Menu {1} {2}".format(self._name, menu[i]["title"], len(menu[i]["children"])))
|
||||||
@ -146,17 +164,14 @@ class WPMenu:
|
|||||||
for j in range(0, len(menu[i]["children"])):
|
for j in range(0, len(menu[i]["children"])):
|
||||||
idMenu = self._getId(menu[i]["children"][j]["title"])
|
idMenu = self._getId(menu[i]["children"][j]["title"])
|
||||||
if idMenu == 0:
|
if idMenu == 0:
|
||||||
title = href[::-1]
|
self._logger.debug("{0} : content children {1}".format(self._name, menu[i]["children"][j]))
|
||||||
link = title.split("/")[0]
|
idMenu = self._getIdFromReverse(menu[i]["children"][j]["title"], menu[i]["children"][j]["href"])
|
||||||
link = link[::-1]
|
|
||||||
title = title.split("/")[1]
|
|
||||||
title = title[::-1]
|
|
||||||
self._logger.info("{0} link {1} title {2}".format(self._name, link, title))
|
|
||||||
if link == "index.html":
|
|
||||||
idMenu = self._getId(title)
|
|
||||||
if idMenu != 0:
|
if idMenu != 0:
|
||||||
menu[i]["children"][j] = {"id":idMenu, "title": menu[i]["children"][j]["title"], "parent": menu[i]["children"][j]["parent"]}
|
menu[i]["children"][j] = {"id":idMenu, "title": menu[i]["children"][j]["title"], "parent": menu[i]["children"][j]["parent"]}
|
||||||
idMenu = self._getId(menu[i]["title"])
|
idMenu = self._getId(menu[i]["title"])
|
||||||
|
self._logger.debug("{0} : content parent {1}".format(self._name, menu[i]))
|
||||||
|
if idMenu == 0:
|
||||||
|
idMenu = self._getIdFromReverse(menu[i]["title"], menu[i]["href"])
|
||||||
if idMenu != 0:
|
if idMenu != 0:
|
||||||
menu[i] = {"id":idMenu, "title":menu[i]["title"], "children": menu[i]["children"]}
|
menu[i] = {"id":idMenu, "title":menu[i]["title"], "children": menu[i]["children"]}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user