[PerlWikiBot] SF.net SVN: perlwikibot:[52] trunk/no-interwiki/prepare_noiw_list.pl
Status: Pre-Alpha
Brought to you by:
rotemliss
From: <am...@us...> - 2008-07-31 10:08:24
|
Revision: 52 http://perlwikibot.svn.sourceforge.net/perlwikibot/?rev=52&view=rev Author: amire80 Date: 2008-07-31 10:08:34 +0000 (Thu, 31 Jul 2008) Log Message: ----------- Refactored date handling + creating a list of pages with an invalid date. Modified Paths: -------------- trunk/no-interwiki/prepare_noiw_list.pl Modified: trunk/no-interwiki/prepare_noiw_list.pl =================================================================== --- trunk/no-interwiki/prepare_noiw_list.pl 2008-07-30 18:08:45 UTC (rev 51) +++ trunk/no-interwiki/prepare_noiw_list.pl 2008-07-31 10:08:34 UTC (rev 52) @@ -385,7 +385,7 @@ INFO('has template no_iw. trying to remove ...'); remove_tmpl_no_iw($page_text_ref); $statistics{'has both valid interwiki and template'}++; - special_cases_file('outdated_template', {}, $page); + special_cases_file('outdated_template', $page); } } else { # does not have iw @@ -432,7 +432,7 @@ if ($found_templates_count > 1) { WARN('many templates were found'); $statistics{'many templates'}++; - special_cases_file('many_templates', {}, $page); + special_cases_file('many_templates', $page); } else { INFO('good, found one template'); @@ -445,20 +445,30 @@ } if (defined $template) { + INFO('has template no_iw'); my $date_str = $template->{params}->{date}; - - INFO('has template no_iw. checking cooling date ... '); - if (not defined $date_str - or cooling_date_passed($date_str)) - { - INFO('cooling date passed, updating to today ...'); - update_cooling_date($page_text_ref); - $statistics{'cooling date passed'}++; + if (defined $date_str) { + INFO('checking cooling date'); + my $date_ref = parse_date($date_str); + if (not defined $date_ref) { + INFO("invalid date: '$date_str'"); + $statistics{'invalid date'}++; + special_cases_file('invalid_date', $page); + } + elsif (cooling_date_passed($date_ref)) { + INFO('cooling date passed, updating to today ...'); + update_cooling_date($page_text_ref); + $statistics{'cooling date passed'}++; + } + else { + INFO(q(cooling date did not pass.)); + $statistics{q(cooling date did not pass)}++; + } } else { - INFO(q(cooling date did not pass.)); - $statistics{q(cooling date did not pass)}++; + INFO('date not defined'); } + } my @all_types = get_all_types($template->{params}->{type}, $page); @@ -635,9 +645,6 @@ } return \%parsed_date; } - else { - INFO("invalid date: $date_str"); - } # Returns undef for an invalid date return; @@ -729,8 +736,8 @@ for my $special_case_name (keys %special_cases) { if (scalar %{ $special_cases{$special_case_name} }) { - special_cases_file($special_case_name, - $special_cases{$special_case_name}, $page); + special_cases_file($special_case_name, $page, + $special_cases{$special_case_name}); } } @@ -743,7 +750,8 @@ } sub special_cases_file { - my ($special_case_name, $special_cases_ref, $page) = @_; + my ($special_case_name, $page, $special_cases_ref) = @_; + $special_cases_ref //= {}; # / my $special_case_langs = join q{, }, sort keys %{$special_cases_ref}; if ($special_case_langs) { $special_case_langs = " ($special_case_langs)"; @@ -773,15 +781,8 @@ } sub cooling_date_passed { - my ($date_string) = @_; + my ($date_ref) = @_; - # $date is a hash ref - my $date_ref = parse_date($date_string); - if (not defined $date_ref) { - INFO('in cooling_date_passed invalid date'); - return 1; - } - my @page_times = @{$date_ref}{qw(sec min hour mday mon year)}; INFO("page times: @page_times"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |