Merge branch 'fs#78-redfam-section-false-positives' into fs#70-refactoring
This commit is contained in:
16
redfam.py
16
redfam.py
@@ -341,6 +341,22 @@ class RedFamParser( RedFam ):
|
||||
else:
|
||||
return False
|
||||
|
||||
@classmethod
|
||||
def is_section_redfam_cb( cls, heading ):
|
||||
"""
|
||||
Used as callback for wikicode.get_sections in redpage.parse to
|
||||
select sections which are redfams
|
||||
"""
|
||||
# Because of strange behavior in some cases, parse heading again
|
||||
# (Task FS#77)
|
||||
heading = mwparser.parse( str( heading ) )
|
||||
|
||||
# Make sure we have min. two wikilinks in heading to assume a redfam
|
||||
if len( heading.filter_wikilinks() ) >= 2:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
@classmethod
|
||||
def parser( cls, text, page, isarchive=False ):
|
||||
"""
|
||||
|
||||
@@ -28,9 +28,10 @@ Provides a class for handling redundance discussion pages and archives
|
||||
import pywikibot # noqa
|
||||
import mwparserfromhell as mwparser
|
||||
|
||||
import jogobot
|
||||
import jogobot # noqa
|
||||
|
||||
from mysqlred import MysqlRedPage
|
||||
from redfam import RedFamParser
|
||||
|
||||
|
||||
class RedPage:
|
||||
@@ -116,7 +117,7 @@ class RedPage:
|
||||
# include_lead = if true include first section (intro)
|
||||
# include_heading = if true include heading
|
||||
fams = self.wikicode.get_sections(
|
||||
matches=jogobot.config["redundances"]["section_heading_regex"],
|
||||
matches=RedFamParser.is_section_redfam_cb,
|
||||
include_lead=False, include_headings=True )
|
||||
|
||||
# Iterate over RedFam
|
||||
|
||||
Reference in New Issue
Block a user