From 581b6941a688d56dacf0d407317428ecd01cfb2c Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Sun, 16 Apr 2023 21:06:04 +0200 Subject: [PATCH] parent id 75% --- lib/WPImport.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/WPImport.py b/lib/WPImport.py index 5cd0ac7..4760aa5 100644 --- a/lib/WPImport.py +++ b/lib/WPImport.py @@ -226,7 +226,6 @@ class WPimport: ## Check class name def _hasClassName(self, tag, className): - print(tag["class"]) for i in tag["class"]: if i == className: return True @@ -256,24 +255,20 @@ class WPimport: comment_content = comment_content + comment_item[j] + "
" comment_content = comment_content + "

" parent = -1 - parent_class = "level-1" - print(self._hasClassName(comment[i], parent_class)) - if self._hasClassName(comment[i], parent_class) is False: + if self._hasClassName(comment[i], "level-1") is False: block = False className = self._getClassName(comment[i], "level-").split("-") level = 1 if len(className) > 0: level = int(className[1]) - for j in range(i-1, 0): + for j in range(i-1, 0, -1): if block is False: levelName = "level-{0}".format(level - 1) - print(levelName) - if self._hasClassName(comment[j], levelName): + if self._hasClassName(comment[j], levelName) is True: parent = j - parent_class = levelName block = True - comment_post.append({"author": comment_author, "date": comment_date, "content": comment_content, "parent_id":parent, "parent_class": parent_class}) + comment_post.append({"author": comment_author, "date": comment_date, "content": comment_content, "parent_id":parent}) return comment_post ## Add or Update post