parent id 75%

This commit is contained in:
Valentin CZERYBA 2023-04-16 21:06:04 +02:00
parent bd8ac241c1
commit 581b6941a6

View File

@ -226,7 +226,6 @@ class WPimport:
## Check class name ## Check class name
def _hasClassName(self, tag, className): def _hasClassName(self, tag, className):
print(tag["class"])
for i in tag["class"]: for i in tag["class"]:
if i == className: if i == className:
return True return True
@ -256,24 +255,20 @@ class WPimport:
comment_content = comment_content + comment_item[j] + "<br />" comment_content = comment_content + comment_item[j] + "<br />"
comment_content = comment_content + "</p>" comment_content = comment_content + "</p>"
parent = -1 parent = -1
parent_class = "level-1" if self._hasClassName(comment[i], "level-1") is False:
print(self._hasClassName(comment[i], parent_class))
if self._hasClassName(comment[i], parent_class) is False:
block = False block = False
className = self._getClassName(comment[i], "level-").split("-") className = self._getClassName(comment[i], "level-").split("-")
level = 1 level = 1
if len(className) > 0: if len(className) > 0:
level = int(className[1]) level = int(className[1])
for j in range(i-1, 0): for j in range(i-1, 0, -1):
if block is False: if block is False:
levelName = "level-{0}".format(level - 1) levelName = "level-{0}".format(level - 1)
print(levelName) if self._hasClassName(comment[j], levelName) is True:
if self._hasClassName(comment[j], levelName):
parent = j parent = j
parent_class = levelName
block = True 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 return comment_post
## Add or Update post ## Add or Update post