From a2dfffc74bfe834d2680dcbea30fef8a55092e42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?GOLDERWEB=20=E2=80=93=20Jonathan=20Golder?= Date: Thu, 3 Mar 2016 17:23:44 +0100 Subject: [PATCH] Let old date-extracting methods use dates_extract and mark them as deprecated --- redfam.py | 62 +++++++++++++++++++++---------------------------------- 1 file changed, 23 insertions(+), 39 deletions(-) diff --git a/redfam.py b/redfam.py index 2fcddba..c06e26a 100644 --- a/redfam.py +++ b/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 ):