[PerlWikiBot] SF.net SVN: perlwikibot:[47] trunk/no-interwiki/prepare_noiw_list.pl
Status: Pre-Alpha
Brought to you by:
rotemliss
From: <am...@us...> - 2008-07-30 16:14:27
|
Revision: 47 http://perlwikibot.svn.sourceforge.net/perlwikibot/?rev=47&view=rev Author: amire80 Date: 2008-07-30 16:14:36 +0000 (Wed, 30 Jul 2008) Log Message: ----------- Unsorted lists go to a separate dir. 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-29 08:56:15 UTC (rev 46) +++ trunk/no-interwiki/prepare_noiw_list.pl 2008-07-30 16:14:36 UTC (rev 47) @@ -55,7 +55,8 @@ my %PATTERN; Readonly my $WIKITEXT_EXT => 'wiki.txt'; -Readonly my $UNSORTED_EXT => "unsorted.$WIKITEXT_EXT"; +Readonly my $OUT_DIR => 'out'; +Readonly my $UNSORTED_DIR => "$OUT_DIR/unsorted"; Readonly my $ALT_SEP => q{|}; Readonly my $FIELD_SEP => qq{\t}; Readonly my $LINK_SEP => q{|}; @@ -287,13 +288,14 @@ } # TODO: Make smarter, configurable, whatever -Readonly my $OUT_DIR => 'out'; -if (-d $OUT_DIR) { - unlink glob "$OUT_DIR/*"; +foreach my $out_dir ($OUT_DIR, $UNSORTED_DIR) { + if (-d $out_dir) { + unlink glob "$out_dir/*$WIKITEXT_EXT"; + } + else { + mkdir $out_dir; + } } -else { - mkdir $OUT_DIR; -} my $dump = Parse::MediaWikiDump::Pages->new($dump_fn); @@ -903,7 +905,7 @@ # Run over page types UNSORTED_TYPE_FN: - foreach my $unsorted_type_fn (glob "$OUT_DIR/*$UNSORTED_EXT") { + foreach my $unsorted_type_fn (glob "$UNSORTED_DIR/*") { my %all_pages_in_type = (); open my $unsorted_type_file, '<', $unsorted_type_fn or croak(file_error('opening', $unsorted_type_fn, 'reading')); @@ -1063,7 +1065,6 @@ my $STRINGS_FN = "$lang.strings.txt"; - # TODO: Refactor or upgrade to Locale::Maketext open my $STRINGS_FILE, '<:utf8', $STRINGS_FN or croak(file_error('opening', $STRINGS_FN, 'reading')); my @strings_file_lines = <$STRINGS_FILE>; @@ -1100,11 +1101,11 @@ #my $transliterated_type = $TRANSLITERATOR->translit($type); my $transliterated_type = $type; - my $ext = $unsorted ? $UNSORTED_EXT : $WIKITEXT_EXT; - my $type_fn = "$transliterated_type.$ext"; + my $type_fn = "$transliterated_type.$WIKITEXT_EXT"; $type_fn =~ s{$PATTERN{invalid_filename_char}}{-}xmsgo; - $type_fn = "$OUT_DIR/$type_fn"; + my $dir = $unsorted ? $UNSORTED_DIR : $OUT_DIR; + $type_fn = "$dir/$type_fn"; return $type_fn; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |