change return getId

This commit is contained in:
Valentin CZERYBA 2023-07-11 21:42:50 +02:00
parent bca529f3c3
commit dded126926

View File

@ -74,8 +74,8 @@ 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 _getId(self, title, parent): def _getId(self, title):
menu = {"id":"", "type":"", "title": "", "parent":"", "children": []} idMenu = 0
exist = False exist = False
for i in ["categories", "tags"]: for i in ["categories", "tags"]:
if exist is False: if exist is False:
@ -85,7 +85,7 @@ class WPMenu:
if page.status_code == 200: if page.status_code == 200:
result = page.json() result = page.json()
if len(result) > 0: if len(result) > 0:
menu = {"id":result[0]["id"], "type":i, "title": title, "parent":parent, "children": []} idMenu = result[0]["id"]
exist = True exist = True
else: else:
self._logger.error("{0} : {2} didn't get due status code : {1}".format(self._name, page.status_code, i)) self._logger.error("{0} : {2} didn't get due status code : {1}".format(self._name, page.status_code, i))
@ -95,7 +95,7 @@ class WPMenu:
exit(1) exit(1)
except Exception as err: except Exception as err:
self._logger.error("{0} : Exception error for get url {1} : {2}".format(self._name, "{2}://{0}/wp-json/wp/v2/{1}".format(self._wordpress, i, self._protocol_wordpress), err)) self._logger.error("{0} : Exception error for get url {1} : {2}".format(self._name, "{2}://{0}/wp-json/wp/v2/{1}".format(self._wordpress, i, self._protocol_wordpress), err))
return menu return idMenu
def _menu(self, content): def _menu(self, content):
@ -132,5 +132,6 @@ class WPMenu:
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"]})
for i in menu: for i in range(0, len(menu)):
self._logger.info("{0} : Menu {1} {2}".format(self._name, i["title"], len(i["children"]))) self._logger.info("{0} : Menu {1} {2}".format(self._name, menu[i]["title"], len(menu[i]["children"])))