/[pub]/suikawiki/script/tool/ywinfo2meta.pl
Suika

Contents of /suikawiki/script/tool/ywinfo2meta.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download)
Fri Mar 12 05:04:42 2004 UTC (21 years, 3 months ago) by wakaba
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -0 lines
File MIME type: text/plain
FILE REMOVED
Obsoleted

1 #!/usr/bin/perl
2 use strict;
3 my $dir = './';
4 opendir INFOBASE, $dir;
5 my @key = grep {s/^([0-9A-Fa-f]+)\.txt$/$1/} readdir INFOBASE;
6 close INFOBASE;
7 use Time::Local;
8
9 my %meta;
10 for my $key (@key) {
11 open INFO, $dir.$key.'.txt';
12 local $/ = undef;
13 $key =~ s/([0-9A-Fa-f]{2})/chr hex $1/ge;
14 for (split /\x0D?\x0A/, <INFO>) {
15 my ($name => $value) = split /=/, $_, 2;
16 if ($name eq 'LastModified' && $value =~ /... (...) ([\d\s]{2}) (\d\d):(\d\d):(\d\d) (\d{4})/) {
17 $value = timegm ($5,$4,$3,$2,{qw/Jan 0 Feb 1 Mar 2 Apr 3 May 4 Jun 5 Jul 6 Aug 7 Sep 8 Oct 9 Nov 10 Dec 11/}->{$1},$6-1900);
18 } elsif ($name eq 'IsFrozen' && !$value) {
19 $value = undef;
20 }
21 $meta{$name}->{$key} = $value if length $value;
22 }
23 close INFO;
24 }
25
26 for my $name (keys %meta) {
27 my $ename = $name; $ename =~ s/(.)/sprintf '%02X', ord $1/ge;
28 open META, "> ${dir}mt--${ename}.dat";
29 binmode META;
30 print META "#?SuikaWikiMetaInfo/0.9\n\x02".join "\x1E", map {$_."\x1F".$meta{$name}->{$_}} keys %{$meta{$name}};
31 close META;
32 }
33
34 =head1 NAME
35
36 ywinfo2meta.pl --- SuikaWiki: InfoBase of YukiWiki2 to Meta-information database
37 of Yuki::YukiWikiDBMeta converter
38
39 =head1 DESCRIPTION
40
41 This script converts information database of YukiWiki2 (implemented with Yuki::YukiWikiDB)
42 to meta-information database of Yuki::YukiWikiDBMeta.
43
44 =head1 USAGE
45
46 $ cd /peth/to/infobase
47 $ perl ykwinfo2meta.pl
48 (You can find files named as ./mt--[keyname].dat)
49
50 =head1 LICENSE
51
52 Copyright 2003 Wakaba <w@suika.fam.cx>
53
54 This program is free software; you can redistribute it and/or
55 modify it under the same terms as Perl itself.
56
57 =cut

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24