Changeset 13556 in josm for trunk/scripts
- Timestamp:
- 2018-03-24T14:49:15+01:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/scripts/TestHTTPS.pl
r13555 r13556 5 5 use open qw/:std :encoding(utf8)/; 6 6 use Net::HTTPS; 7 8 7 use XML::LibXML; 9 8 10 my $dom = XML::LibXML->load_xml(location => "imagery_josm.imagery.xml");11 my $xpc = XML::LibXML::XPathContext->new($dom);12 $xpc->registerNs('j', 'http://josm.openstreetmap.de/maps-1.0');13 9 my %urls; 14 10 15 foreach my $entry ($xpc->findnodes("//j:entry")) 11 sub getmaps 16 12 { 17 my $name = $xpc->findvalue("./j:name", $entry); 18 for my $e ($xpc->findnodes(".//j:*", $entry)) 13 my $dom = XML::LibXML->load_xml(location => "imagery_josm.imagery.xml"); 14 my $xpc = XML::LibXML::XPathContext->new($dom); 15 $xpc->registerNs('j', 'http://josm.openstreetmap.de/maps-1.0'); 16 foreach my $entry ($xpc->findnodes("//j:entry")) 19 17 { 20 if($e->textContent =~ /^http:\/\/(.*?)[\/]/) 18 my $name = $xpc->findvalue("./j:name", $entry); 19 for my $e ($xpc->findnodes(".//j:*", $entry)) 21 20 { 22 my $u = $1; 23 if($u =~ /^(.*)\{switch:(.*)\}(.*)$/) 21 if($e->textContent =~ /^http:\/\/(.*?)[\/]/) 24 22 { 25 my ($f,$switch,$e) = ($1, $2, $3);26 for my $s (split(",", $switch))23 my $u = $1; 24 if($u =~ /^(.*)\{switch:(.*)\}(.*)$/) 27 25 { 28 $urls{"$f$s$e"}{$name}++; 26 my ($f,$switch,$e) = ($1, $2, $3); 27 for my $s (split(",", $switch)) 28 { 29 $urls{"$f$s$e"}{"MAP:$name"}++; 30 } 31 } 32 else 33 { 34 $urls{$u}{"MAP:$name"}++; 29 35 } 30 36 } 31 else32 {33 $urls{$u}{$name}++;34 }35 37 } 38 } 39 } 40 41 sub getfile($$) 42 { 43 my ($type, $file) = @_; 44 open FILE,"<:encoding(utf-8)",$file or die; 45 my $name; 46 for my $line (<FILE>) 47 { 48 if($line =~ /^([^ \t].*);/) 49 { 50 $name = $1; 51 } 52 if($line =~ /http:\/\/(.*?)[\/]/) 53 { 54 $urls{$1}{"$type:$name"}++; 55 } 56 } 57 } 58 59 print "Options: PLUGIN, STYLE, RULE, PRESET, MAP, GETPLUGIN, GETSTYLE, GETRULE, GETPRESET, GETMAP, LOCAL\n" if !@ARGV; 60 61 my $local = 0; 62 for my $ARG (@ARGV) 63 { 64 if($ARG eq "LOCAL") {$local = 1; } 65 if($ARG eq "GETMAP") { system "curl https://josm.openstreetmap.de/maps -o imagery_josm.imagery.xml"; getmaps();} 66 if($ARG eq "MAP") { getmaps(); } 67 for my $x ("PLUGIN", "STYLE", "RULE", "PRESET") 68 { 69 my $t = lc($x); 70 my $url = $x eq "PLUGIN" ? $t : "${t}s"; 71 my $file = "josm_$t.xml"; 72 if($ARG eq "GET$x") { system "curl https://josm.openstreetmap.de/$url -o $file"; getfile($x, $file);} 73 if($ARG eq $x) { getfile($x, $file); } 36 74 } 37 75 } … … 40 78 { 41 79 my $i = join(" # ", sort keys %{$urls{$url}}); 80 if($local) # skip test 81 { 82 print "* $url:$i\n"; 83 next; 84 } 42 85 eval 43 86 {
Note:
See TracChangeset
for help on using the changeset viewer.