Get level comment 50%
This commit is contained in:
parent
b54785c455
commit
0e15e88f31
@ -223,6 +223,23 @@ class WPimport:
|
||||
if page.status_code == 201:
|
||||
self._logger.info("Commentaire ajoute pour {0}".format(title))
|
||||
|
||||
## Check class name
|
||||
|
||||
def _hasClassName(self, tag, className):
|
||||
for i in tag["class"]:
|
||||
if i == className:
|
||||
return True
|
||||
return False
|
||||
|
||||
## Get class name
|
||||
|
||||
def _getClassName(self, tag, className):
|
||||
for i in tag["class"]:
|
||||
if re.match(className, i):
|
||||
return i
|
||||
return ""
|
||||
|
||||
## Get all comments
|
||||
|
||||
def _getComment(self, comment):
|
||||
comment_post = []
|
||||
@ -239,8 +256,21 @@ class WPimport:
|
||||
comment_content = comment_content + "</p>"
|
||||
parent = -1
|
||||
parent_class = "level-1"
|
||||
if self._hasClassName(i, parent_class) is False:
|
||||
block = False
|
||||
className = self._getClassName(tag, "level-").split("-")
|
||||
level = 1
|
||||
if len(className) > 0:
|
||||
level = int(className[1])
|
||||
for j in range(i-1, 0):
|
||||
if block is False:
|
||||
levelName = "level-{0}".format(level - 1)
|
||||
if self._hasClassName(comment[j], levelName):
|
||||
parent = j
|
||||
parent_class = levelName
|
||||
block = True
|
||||
|
||||
comment_post.append({"author": comment_author, "date": comment_date, "content": comment_content})
|
||||
comment_post.append({"author": comment_author, "date": comment_date, "content": comment_content, "parent_id":parent, "parent_class": parent_class})
|
||||
return comment_post
|
||||
## Add or Update post
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user