[r13118]: branches / phil_tmp / scripts / preset-xmlify Maximize Restore History

Download this file

preset-xmlify    45 lines (43 with data), 1.4 kB

#!/usr/bin/perl -w
use strict;
my $total = 0;
my $category = '';
my $ininstrument = 0;
my $incategory = 0;
print "<!-- THIS FILE WAS GENERATED AUTOMATICALLY FROM SOURCE.  DO NOT EDIT THIS FILE! -->\n";
print "<presets>\n";
while (<>) {
  chomp;
  /^#/ and next;
  /=/ or next;
  my ($key, $value) = split /\s*=\s*/;
  if ($key eq 'category') { 
    $ininstrument and print "    </instrument>\n";
    $ininstrument = 0;
    $incategory and print "  </category>\n";
    print "  <category name=\"$value\">\n";
    $incategory = 1;
  } elsif ($key eq 'name') {
    $ininstrument and print "    </instrument>\n";
    $value =~ s/^"(.*)"\s*$/$1/;
    $ininstrument = 1;
    print "    <instrument name=\"$value\">\n";
    $total++;
  } elsif ($key eq 'clef') {
    print "      <clef type=\"$value\" />\n";
  } elsif ($key eq 'transposition') {
    print "      <transpose value=\"$value\" />\n";
  } elsif ($key eq 'A lowest') {
    print "      <range class=\"amateur\" low=\"$value\" ";
  } elsif ($key eq 'P lowest') {
    print "      <range class=\"professional\" low=\"$value\" ";
  } elsif ($key eq 'A highest' or $key eq 'P highest') {
    print "high=\"$value\"/>\n";
  } else {
#    print "    <$key>$value</$key>\n";
  }
}
$ininstrument and print "    </instrument>\n";
$incategory and print "  </category>\n";
print "</presets>\n";
print "<!-- IMPORTED $total INSTRUMENTS -->\n";