Let old date-extracting methods use dates_extract and mark them as deprecated
This commit is contained in:
44
redfam.py
44
redfam.py
@@ -382,6 +382,7 @@ Maximum number of articles in red_fam exceeded, maximum number is 8, \
|
||||
return (beginning, ending)
|
||||
|
||||
@classmethod
|
||||
@deprecated( extract_dates )
|
||||
def is_beginning( cls, line ):
|
||||
"""
|
||||
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
|
||||
"""
|
||||
|
||||
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
|
||||
else:
|
||||
return None
|
||||
return cls.extract_dates( line )[0]
|
||||
|
||||
@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
|
||||
@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 ):
|
||||
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
|
||||
return cls.extract_dates( line )[1]
|
||||
|
||||
@classmethod
|
||||
@deprecated( extract_dates )
|
||||
def is_ending2( cls, line ):
|
||||
"""
|
||||
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
|
||||
"""
|
||||
|
||||
matches = cls.__timestamp_pat.findall( line )
|
||||
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
|
||||
return cls.extract_dates( line, True )[1]
|
||||
|
||||
|
||||
class RedFamWorker( RedFam ):
|
||||
|
||||
Reference in New Issue
Block a user