Let old date-extracting methods use dates_extract and mark them as deprecated

This commit is contained in:
2016-03-03 17:23:44 +01:00
parent 163972c924
commit a2dfffc74b

View File

@@ -382,6 +382,7 @@ Maximum number of articles in red_fam exceeded, maximum number is 8, \
return (beginning, ending) return (beginning, ending)
@classmethod @classmethod
@deprecated( extract_dates )
def is_beginning( cls, line ): def is_beginning( cls, line ):
""" """
Returns the first timestamp found in line, otherwise None Returns the first timestamp found in line, otherwise None
@@ -391,36 +392,27 @@ Maximum number of articles in red_fam exceeded, maximum number is 8, \
@returns str Timestamp, otherwise None @returns str Timestamp, otherwise None
""" """
match = cls.__timestamp_pat.search( line ) return cls.extract_dates( line )[0]
if match:
# Since some timestamps are broken we need to reconstruct them
# by regex match groups
result = match.group(1) + ", " + match.group(2) + ". " +\
match.group(3) + ". " + match.group(4)
return result
else:
return None
@classmethod @classmethod
def is_ending( cls, line ): @deprecated( extract_dates )
def is_ending( cls, line, isarchive=False ):
""" """
Returns the timestamp of done notice ( if one ), otherwise None Returns the timestamp of done notice ( if one ), otherwise None
@param str line String to search in
@returns str Timestamp, otherwise None @param line String to search in
@type line str
@param isarchive If true skip searching done notice (on archivepages)
@type isarchive bool
@returns Timestamp, otherwise None
@returntype str
""" """
if ( cls.__done_notice in line ) or ( cls.__done_notice2 in line ): return cls.extract_dates( line )[1]
match = cls.__timestamp_pat.search( line )
if match:
# Since some timestamps are broken we need to reconstruct them
# by regex match groups
result = match.group(1) + ", " + match.group(2) + ". " +\
match.group(3) + ". " + match.group(4)
return result
return None
@classmethod @classmethod
@deprecated( extract_dates )
def is_ending2( cls, line ): def is_ending2( cls, line ):
""" """
Returns the last timestamp found in line, otherwise None Returns the last timestamp found in line, otherwise None
@@ -429,15 +421,7 @@ Maximum number of articles in red_fam exceeded, maximum number is 8, \
@returns str Timestamp, otherwise None @returns str Timestamp, otherwise None
""" """
matches = cls.__timestamp_pat.findall( line ) return cls.extract_dates( line, True )[1]
if matches:
# Since some timestamps are broken we need to reconstruct them
# by regex match groups
result = matches[-1][0] + ", " + matches[-1][1] + ". " +\
matches[-1][2] + ". " + matches[-1][3]
return result
else:
return None
class RedFamWorker( RedFam ): class RedFamWorker( RedFam ):