From dded126926d4380906df8c4cfe7000dde9940a8f Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Tue, 11 Jul 2023 21:42:50 +0200 Subject: [PATCH] change return getId --- lib/WPMenu.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/WPMenu.py b/lib/WPMenu.py index fa739d7..5883808 100644 --- a/lib/WPMenu.py +++ b/lib/WPMenu.py @@ -74,8 +74,8 @@ class WPMenu: except Exception as err: self._logger.error("{0} : Exception error for get url {1} : {2}".format(self._name, canalblog, err)) - def _getId(self, title, parent): - menu = {"id":"", "type":"", "title": "", "parent":"", "children": []} + def _getId(self, title): + idMenu = 0 exist = False for i in ["categories", "tags"]: if exist is False: @@ -85,7 +85,7 @@ class WPMenu: if page.status_code == 200: result = page.json() if len(result) > 0: - menu = {"id":result[0]["id"], "type":i, "title": title, "parent":parent, "children": []} + idMenu = result[0]["id"] exist = True else: 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) 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)) - return menu + return idMenu def _menu(self, content): @@ -132,5 +132,6 @@ class WPMenu: if menu[j]["title"] == children[i]["parent"]: menu[j]["children"].append({"id":"", "title":children[i]["title"], "parent": children[i]["parent"]}) - for i in menu: - self._logger.info("{0} : Menu {1} {2}".format(self._name, i["title"], len(i["children"]))) \ No newline at end of file + for i in range(0, len(menu)): + self._logger.info("{0} : Menu {1} {2}".format(self._name, menu[i]["title"], len(menu[i]["children"]))) + \ No newline at end of file