Changeset 1346
- Timestamp:
- 11/12/07 23:58:50 (6 years ago)
- Location:
- lang/perl/HTTP-MobileAgent/trunk/bin
- Files:
-
- 2 modified
-
makedocomomap (modified) (3 diffs)
-
makexmldocomomap (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/HTTP-MobileAgent/trunk/bin/makedocomomap
r1328 r1346 1 1 #!/usr/bin/perl -w 2 2 use strict; 3 use utf8; 3 4 use FindBin; 4 use Jcode;5 5 use LWP::Simple; 6 6 use Data::Dumper; 7 7 use HTTP::MobileAgent; 8 use Encode; 9 use File::Spec; 8 10 9 my $URL = 'http://www.nttdocomo.co.jp/service/imode/make/content/spec/screen_area/index.html'; 11 my $URL = 12 'http://www.nttdocomo.co.jp/service/imode/make/content/spec/screen_area/index.html'; 10 13 11 14 do_task(@ARGV); 12 15 13 16 sub do_task { 14 my $html = Jcode->new(get($URL))->tr('��-��', '0-9')->euc;17 my $html = decode( 'cp932', get($URL) ); 15 18 $html =~ s/(?:\r?\n)+/\n/g; 16 19 my $re = regexp(); 17 20 my %map; 18 while ( $html =~ /$re/igs) {19 my($model, $width, $height, $color, $depth) = ($1, $2, $3, $4, $5);20 $map{uc($model)} = {21 width=> $width,22 height => $height,23 color => $color eq '���顼',24 depth=> $depth,25 };21 while ( $html =~ /$re/igs ) { 22 my ( $model, $width, $height, $color, $depth ) = ( $1, $2, $3, $4, $5 ); 23 $map{ uc($model) } = { 24 width => $width, 25 height => $height, 26 color => $color eq 'カラー', 27 depth => $depth, 28 }; 26 29 } 27 30 my $overwrite = $ARGV[0] && $ARGV[0] eq '-o'; 28 output_code( \%map, $overwrite);31 output_code( \%map, $overwrite ); 29 32 } 30 33 31 34 sub output_code { 32 my($map, $overwrite) = @_; 35 my ( $map, $overwrite ) = @_; 36 my $fh; 33 37 if ($overwrite) { 34 open MAP, "> $FindBin::Bin/../lib/HTTP/MobileAgent/DoCoMoDisplayMap.pm" or die $!; 35 select MAP; 38 open $fh, '>', File::Spec->catfile($FindBin::Bin, qw/ .. lib HTTP MobileAgent DoCoMoDisplayMap.pm/) 39 or die $!; 40 select $fh; 36 41 } 37 42 $Data::Dumper::Indent = 1; 38 43 $Data::Dumper::Terse = 1; 39 printf <<'TEMPLATE', Data::Dumper->Dump( [ $map ]);44 printf <<'TEMPLATE', Data::Dumper->Dump( [$map] ); 40 45 package HTTP::MobileAgent::DoCoMoDisplayMap; 41 46 # This file is autogenerated by makedocomomap … … 75 80 1; 76 81 TEMPLATE 77 ;78 82 if ($overwrite) { 79 close MAP;83 close $fh; 80 84 } 81 85 } … … 86 90 <td><span class="txt">.*?(?:</span></td>)? 87 91 <td><span class="txt">.*?(?:</span></td>)? 88 <td><span class="txt">.*?(\d+) ��\d+).*?</span></td>92 <td><span class="txt">.*?(\d+)×(\d+).*?</span></td> 89 93 <td>.*?</td> 90 <td><span class="txt">( ����顼)(?:.*?)(\d+)(?:��|��Ĵ)</span></td>94 <td><span class="txt">(白黒|カラー)(?:.*?)(\d+)(?:色|階調)</span></td> 91 95 RE 92 ;93 96 } -
lang/perl/HTTP-MobileAgent/trunk/bin/makexmldocomomap
r1328 r1346 1 1 #!/usr/bin/perl -w 2 2 use strict; 3 use Jcode; 3 use warnings; 4 use utf8; 4 5 use LWP::Simple; 5 use Data::Dumper; 6 use HTTP::MobileAgent; 7 require XML::Simple; 6 use XML::Simple (); 7 use Encode; 8 8 9 my $URL = 'http://www.nttdocomo.co.jp/service/imode/make/content/spec/screen_area/index.html'; 9 my $URL = 10 'http://www.nttdocomo.co.jp/service/imode/make/content/spec/screen_area/index.html'; 10 11 11 12 do_task(@ARGV); 12 13 13 14 sub do_task { 14 my $html = Jcode->new(get($URL))->tr('��-��', '0-9')->euc;15 my $html = decode( 'cp932', get($URL) ); 15 16 $html =~ s/(?:\r?\n)+/\n/g; 16 17 my $re = regexp(); 17 18 my %map; 18 while ($html =~ /$re/igs) { 19 my($model, $width, $height, $color, $depth) = ($1, $2, $3, $4, $5); 20 push @{$map{terminal}}, { 21 model => uc($model), 22 width => $width, 23 height => $height, 24 color => $color eq '���顼', 25 depth => $depth, 26 }; 19 while ( $html =~ /$re/igs ) { 20 my ( $model, $width, $height, $color, $depth ) = ( $1, $2, $3, $4, $5 ); 21 push @{ $map{terminal} }, 22 { 23 model => uc($model), 24 width => $width, 25 height => $height, 26 color => $color eq 'カラー', 27 depth => $depth, 28 }; 27 29 } 28 output_code( \%map);30 output_code( \%map ); 29 31 } 30 32 31 33 sub output_code { 32 my ($map) = @_;34 my ($map) = @_; 33 35 my $xml = XML::Simple->new; 34 36 printf <<'TEMPLATE', $xml->XMLout($map); … … 36 38 %s 37 39 TEMPLATE 38 ;39 40 } 40 41 … … 44 45 <td><span class="txt">.*?(?:</span></td>)? 45 46 <td><span class="txt">.*?(?:</span></td>)? 46 <td><span class="txt">.*?(\d+) ��\d+).*?</span></td>47 <td><span class="txt">.*?(\d+)×(\d+).*?</span></td> 47 48 <td>.*?</td> 48 <td><span class="txt">( ����顼)(?:.*?)(\d+)(?:��|��Ĵ)</span></td>49 <td><span class="txt">(白黒|カラー)(?:.*?)(\d+)(?:色|階調)</span></td> 49 50 RE 50 ;51 51 }
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)