Browse Source

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

develop
Jonathan Golder 8 years ago
parent
commit
a2dfffc74b
  1. 62
      redfam.py

62
redfam.py

@ -382,62 +382,46 @@ 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
@param str line String to search in
@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
@param str line String to search in
@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 ):

Loading…
Cancel
Save