File: convplugins.pl

package info (click to toggle)
josm 0.0.svn19369%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 243,336 kB
  • sloc: java: 490,598; xml: 201,669; perl: 10,314; jsp: 265; sh: 199; makefile: 120; javascript: 74; python: 60
file content (41 lines) | stat: -rw-r--r-- 1,024 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#! /usr/bin/perl -w

# Written by Dirk Stöcker <openstreetmap@dstoecker.de>
# Public domain, no rights reserved.

use strict;

# This is a simple conversion and in no way a complete XML parser
# but it works with a default Perl installation

# Print a header to write valid Java code.
print "class trans_plugins { void tr(String s){} void f() {\n";

foreach my $arg (@ARGV)
{
  foreach my $name (glob $arg)
  {
    my $printed = 0;
    die "Can't open $name." if !(open FILE,"<",$name);
    my $plugin = $name;
    while(my $line = <FILE>)
    {
      chomp($line);
      if($line =~ /name=\"[Pp]lugin.[Dd]escription\" +value=\"(.*)\"/)
      {
        my $descr = $1;
        next if $descr eq '${plugin.description}';
        $printed = 1;
        print "/* Plugin $plugin */\ntr(\"$descr\");\n" if($plugin ne "myPluginName");
      }
      elsif($line =~ /project name=\"(.*?)\"/)
      {
        $plugin = $1;
      }
    }
    close FILE;
    print "/* File $name had no data */\n" if(!$printed);
  }
}

print "}}\n";