Add workaround to detect ending datetime if there is no done notice
This commit is contained in:
16
red_fam.py
16
red_fam.py
@@ -65,7 +65,7 @@ class RED_FAM_PARSER( RED_FAM ):
|
||||
__sectionhead_pat = re.compile( r"^=+.*\[\[.+\]\].*\[\[.+\]\].*=+$" )
|
||||
|
||||
# Define timestamp re.pattern
|
||||
__timestamp_pat = re.compile( r"\d{2}:\d{2}, (\d{1,2}. (Jan|Feb|Mär|Apr|Mai|Jun|Jul|Aug|Sep|Okt|Nov|Dez).? \d{4}) \(CES?T\)" )
|
||||
__timestamp_pat = re.compile( r"(\d{2}:\d{2}, \d{1,2}. (Jan|Feb|Mär|Apr|Mai|Jun|Jul|Aug|Sep|Okt|Nov|Dez).? \d{4} \(CES?T\))" )
|
||||
|
||||
# Textpattern for recognisation of done-notices
|
||||
__done_notice = ":<small>Archivierung dieses Abschnittes wurde gewünscht von:"
|
||||
@@ -271,6 +271,20 @@ class RED_FAM_PARSER( RED_FAM ):
|
||||
return result.group()
|
||||
return None
|
||||
|
||||
@classmethod
|
||||
def is_ending2( cls, line ):
|
||||
"""
|
||||
Returns the last timestamp found in line, otherwise None
|
||||
@param str line String to search in
|
||||
|
||||
@returns str Timestamp, otherwise None
|
||||
"""
|
||||
result = cls.__timestamp_pat.findall( line )
|
||||
if result:
|
||||
return result[-1][0]
|
||||
else:
|
||||
return None
|
||||
|
||||
class RED_FAM_WORKER( RED_FAM ):
|
||||
"""
|
||||
Handles working with redundance families stored in database where discussion is finished
|
||||
|
||||
12
red_page.py
12
red_page.py
@@ -85,9 +85,15 @@ class RED_PAGE:
|
||||
|
||||
# Before working with next red_fam create the object for the one before (if one)
|
||||
if( fam_heading and beginning ):
|
||||
try:
|
||||
#Maybe we can find a ending by feed
|
||||
if not ending:
|
||||
j = i
|
||||
while (j > last_fam) and not ending:
|
||||
j -= 1
|
||||
ending = RED_FAM_PARSER.is_ending2( text_lines[ j ] )
|
||||
|
||||
|
||||
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
|
||||
@@ -116,6 +122,8 @@ class RED_PAGE:
|
||||
red_fam = RED_FAM_PARSER( fam_heading, self.page._pageid, self.is_archive(), beginning, ending )
|
||||
#~ except:
|
||||
#~ pass
|
||||
# Set status of red_page to parsed
|
||||
self.__parsed = True
|
||||
def __update_db( self ):
|
||||
"""
|
||||
Updates the page meta data in mysql db
|
||||
|
||||
Reference in New Issue
Block a user