Changeset 13556 in josm for trunk/scripts


Ignore:
Timestamp:
2018-03-24T14:49:15+01:00 (7 years ago)
Author:
stoecker
Message:

see #16123 - extend HTTPS test script to plugin/style/rule/preset

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/scripts/TestHTTPS.pl

    r13555 r13556  
    55use open qw/:std :encoding(utf8)/;
    66use Net::HTTPS;
    7 
    87use XML::LibXML;
    98
    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');
    139my %urls;
    1410
    15 foreach my $entry ($xpc->findnodes("//j:entry"))
     11sub getmaps
    1612{
    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"))
    1917  {
    20     if($e->textContent =~ /^http:\/\/(.*?)[\/]/)
     18    my $name = $xpc->findvalue("./j:name", $entry);
     19    for my $e ($xpc->findnodes(".//j:*", $entry))
    2120    {
    22       my $u = $1;
    23       if($u =~ /^(.*)\{switch:(.*)\}(.*)$/)
     21      if($e->textContent =~ /^http:\/\/(.*?)[\/]/)
    2422      {
    25         my ($f,$switch,$e) = ($1, $2, $3);
    26         for my $s (split(",", $switch))
     23        my $u = $1;
     24        if($u =~ /^(.*)\{switch:(.*)\}(.*)$/)
    2725        {
    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"}++;
    2935        }
    3036      }
    31       else
    32       {
    33         $urls{$u}{$name}++;
    34       }
    3537    }
     38  }
     39}
     40
     41sub 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
     59print "Options: PLUGIN, STYLE, RULE, PRESET, MAP, GETPLUGIN, GETSTYLE, GETRULE, GETPRESET, GETMAP, LOCAL\n" if !@ARGV;
     60
     61my $local = 0;
     62for 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); }
    3674  }
    3775}
     
    4078{
    4179  my $i = join(" # ", sort keys %{$urls{$url}});
     80  if($local) # skip test
     81  {
     82    print "* $url:$i\n";
     83    next;
     84  }
    4285  eval
    4386  {
Note: See TracChangeset for help on using the changeset viewer.