mirror of
https://gitlab.com/chicken-riders/RcGcDb.git
synced 2025-02-23 00:54:09 +00:00
Fixed compatibility issues with newer MediaWiki
By using my ability "Steal code" from RcGcDw
This commit is contained in:
parent
8a26be8906
commit
812493f304
18
src/misc.py
18
src/misc.py
|
@ -106,6 +106,17 @@ def profile_field_name(name, embed, lang):
|
||||||
return _("unknown")
|
return _("unknown")
|
||||||
|
|
||||||
|
|
||||||
|
def class_searcher(attribs: list) -> str:
|
||||||
|
"""Function to return classes of given element in HTMLParser on handle_starttag
|
||||||
|
|
||||||
|
:returns a string with all of the classes of element
|
||||||
|
"""
|
||||||
|
for attr in attribs:
|
||||||
|
if attr[0] == "class":
|
||||||
|
return attr[1]
|
||||||
|
return ""
|
||||||
|
|
||||||
|
|
||||||
class ContentParser(HTMLParser):
|
class ContentParser(HTMLParser):
|
||||||
current_tag = ""
|
current_tag = ""
|
||||||
last_ins = None
|
last_ins = None
|
||||||
|
@ -121,15 +132,16 @@ class ContentParser(HTMLParser):
|
||||||
self.del_length = len(self.more)
|
self.del_length = len(self.more)
|
||||||
|
|
||||||
def handle_starttag(self, tagname, attribs):
|
def handle_starttag(self, tagname, attribs):
|
||||||
|
classes = class_searcher(attribs).split(' ')
|
||||||
if tagname == "ins" or tagname == "del":
|
if tagname == "ins" or tagname == "del":
|
||||||
self.current_tag = tagname
|
self.current_tag = tagname
|
||||||
if tagname == "td" and "diff-addedline" in attribs[0] and self.ins_length <= 1000:
|
if tagname == "td" and "diff-addedline" in classes and self.ins_length <= 1000:
|
||||||
self.current_tag = "tda"
|
self.current_tag = "tda"
|
||||||
self.last_ins = ""
|
self.last_ins = ""
|
||||||
if tagname == "td" and "diff-deletedline" in attribs[0] and self.del_length <= 1000:
|
if tagname == "td" and "diff-deletedline" in classes and self.del_length <= 1000:
|
||||||
self.current_tag = "tdd"
|
self.current_tag = "tdd"
|
||||||
self.last_del = ""
|
self.last_del = ""
|
||||||
if tagname == "td" and "diff-empty" in attribs[0]:
|
if tagname == "td" and "diff-empty" in classes:
|
||||||
self.empty = True
|
self.empty = True
|
||||||
|
|
||||||
def handle_data(self, data):
|
def handle_data(self, data):
|
||||||
|
|
Loading…
Reference in a new issue