Move parsing of redfams from RedPageParser to RedFamParser.parser so RedPageParse won't do anything with redfams

except for returning a generator of text-sections
This commit is contained in:
2016-03-03 20:41:14 +01:00
parent 7422307985
commit 0af7eb11d6
2 changed files with 38 additions and 18 deletions

View File

@@ -325,6 +325,7 @@ class RedFamParser( RedFam ):
self._status )
@classmethod
@deprecated
def is_sectionheading( cls, line ):
"""
Checks wether given line is a red_fam section heading
@@ -339,6 +340,28 @@ class RedFamParser( RedFam ):
else:
return False
@classmethod
def parser( cls, text, pageid, isarchive=False ):
"""
Handles parsing of redfam section
@param text Text of RedFam-Section
@type text wikicode or mwparser-parseable
"""
# Parse heading with mwparse if needed
if not isinstance( text, mwparser.wikicode.Wikicode ):
text = mwparser.parse( text )
# Extract heading text
heading = next( text.ifilter_headings() ).title
# Extract beginnig and maybe ending
(beginning, ending) = RedFamParser.extract_dates( text, isarchive )
# Create the RedFam object
RedFamParser( heading, pageid, isarchive, beginning, ending )
@classmethod
def extract_dates( cls, text, isarchive=False ):
"""