source: osm/applications/editors/josm/i18n/convwiki.pl@ 34320

Last change on this file since 34320 was 33841, checked in by stoecker, 7 years ago

fix recent parsing errors

File size: 1.4 KB
RevLine 
[31111]1#! /usr/bin/perl -w
2
3# Written by Dirk Stöcker <openstreetmap@dstoecker.de>
4# Public domain, no rights reserved.
5
6use strict;
7use LWP::Simple;
8use open qw/:std :encoding(utf8)/;
9
10my $filename;
11my $dir = $ARGV[1] || "build/josmfiles";
[33234]12print "$ARGV[0]\n";
[33756]13if($ARGV[0] && $ARGV[0] =~ /^https?:\/\//)
[31111]14{
15 $filename = $ARGV[2] || "build/josmfiles.zip";
16 my $content = get($ARGV[0]);
17 die "Couldn't get $ARGV[0]" unless defined $content;
18 open FILE,">:raw",$filename or die "Could not open $filename";
19 print FILE $content;
20 close FILE
21}
22else
23{
24 $filename = $ARGV[0];
25}
26system "rm -rf $dir/";
27print "Extracting to $dir\n";
28mkdir $dir;
29system "unzip -q -d $dir $filename";
30foreach my $name (glob "$dir/*")
31{
32 if($name =~ /^(.*?)([^\/]+-preset\.xml)$/)
33 {
[33841]34 system "mv \"$name\" \"$name.orig\"";
[31111]35 my ($path, $xmlname) = ($1, $2);
[33841]36 my $res = `xmllint --format --schema ../core/data/tagging-preset.xsd \"$name.orig\" --encode utf-8 --output \"$name\" 2>&1`;
[31111]37 print $res if $res !~ /\.orig validates/;
[33841]38 system "perl convpreset.pl \"$name\" >\"${path}trans_$xmlname\"";
[31111]39 unlink "$name.orig";
40 }
41 elsif($name =~ /^(.*?)([^\/]+-style\.xml$)/)
42 {
[33841]43 system "perl convstyle.pl \"$name\" >${1}trans_$2";
[31111]44 }
45 elsif($name =~ /^(.*?)([^\/]+\.mapcss)$/)
46 {
[33841]47 system "perl convcss.pl \"$name\" >${1}trans_$2";
[31111]48 }
49 else
50 {
[33841]51 die "Unknown file type \"$name\".";
[31111]52 }
53 unlink $name;
54}
Note: See TracBrowser for help on using the repository browser.