Implement parsing process in RED_PAGE.parse()
This commit is contained in:
54
red_page.py
54
red_page.py
@@ -2,6 +2,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from mysql_red import MYSQL_RED_PAGE
|
from mysql_red import MYSQL_RED_PAGE
|
||||||
|
from red_fam import RED_FAM_PARSER
|
||||||
|
|
||||||
class RED_PAGE:
|
class RED_PAGE:
|
||||||
"""Class for handling redundance discussion pages and archives"""
|
"""Class for handling redundance discussion pages and archives"""
|
||||||
@@ -62,8 +63,59 @@ class RED_PAGE:
|
|||||||
"""
|
"""
|
||||||
Handles the parsing process
|
Handles the parsing process
|
||||||
"""
|
"""
|
||||||
pass
|
|
||||||
|
|
||||||
|
# Since @param text is a string we need to split it in lines
|
||||||
|
text_lines = self.page.text.split( "\n" )
|
||||||
|
|
||||||
|
# Initialise line counter
|
||||||
|
i = 0
|
||||||
|
fam_heading = None
|
||||||
|
beginning = None
|
||||||
|
ending = None
|
||||||
|
|
||||||
|
# Set line for last detected Redundance-Family to 0
|
||||||
|
last_fam = 0
|
||||||
|
|
||||||
|
# Iterate over the lines of the page
|
||||||
|
for line in text_lines:
|
||||||
|
|
||||||
|
# Check wether we have an "Redundance-Family"-Section heading (Level 3)
|
||||||
|
if RED_FAM_PARSER.is_sectionheading( line ):
|
||||||
|
|
||||||
|
# Before working with next red_fam create the object for the one before (if one)
|
||||||
|
if( fam_heading and beginning ):
|
||||||
|
try:
|
||||||
|
red_fam = RED_FAM_PARSER( fam_heading, self.page._pageid, self.is_archive, beginning, ending )
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Save line number for last detected Redundance-Family
|
||||||
|
last_fam = i
|
||||||
|
# Save heading
|
||||||
|
fam_heading = line
|
||||||
|
|
||||||
|
# Defined (re)initialisation of dates
|
||||||
|
beginning = None
|
||||||
|
ending = None
|
||||||
|
|
||||||
|
# Check wether we are currently in an "Redundance-Family"-Section Body
|
||||||
|
if i > last_fam and last_fam > 0:
|
||||||
|
|
||||||
|
# Check if we have alredy recognized the beginning date of the discussion (in former iteration) or if we have a done-notice
|
||||||
|
if not beginning:
|
||||||
|
beginning = RED_FAM_PARSER.is_beginning( line )
|
||||||
|
else:
|
||||||
|
ending = RED_FAM_PARSER.is_ending( line )
|
||||||
|
|
||||||
|
# Increment line counter
|
||||||
|
i += 1
|
||||||
|
else:
|
||||||
|
# For the last red_fam create the object
|
||||||
|
if( fam_heading and beginning ):
|
||||||
|
try:
|
||||||
|
red_fam = RED_FAM_PARSER( fam_heading, self.page._pageid, self.is_archive, beginning, ending )
|
||||||
|
except:
|
||||||
|
pass
|
||||||
def __update_db( self ):
|
def __update_db( self ):
|
||||||
"""
|
"""
|
||||||
Updates the page meta data in mysql db
|
Updates the page meta data in mysql db
|
||||||
|
|||||||
Reference in New Issue
Block a user