~ubuntu-branches/ubuntu/quantal/gallery2/quantal

« back to all changes in this revision

Viewing changes to lib/tools/bin/extractClassXml.pl

  • Committer: Bazaar Package Importer
  • Author(s): Michael C. Schultheiss
  • Date: 2007-09-10 20:22:19 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070910202219-0jsuntvqge4ade6b
Tags: 2.2.3-2
Add Slovak translation of Debconf templates.  (Thanks to 
Ivan Masá.  Closes: #441671)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/perl
2
 
#
3
 
use strict;
4
 
use File::Basename;
5
 
use Getopt::Long;
6
 
 
7
 
my $DTD;
8
 
my $OUTFILE;
9
 
my $STUB_OK = 0;
10
 
my $QUIET = 0;
11
 
my $OUT_DIR;
12
 
 
13
 
GetOptions("dtd:s" => \$DTD,
14
 
           "out:s" => \$OUTFILE,
15
 
           "out-dir:s" => \$OUT_DIR,
16
 
           "stub-ok+" => \$STUB_OK,
17
 
           "quiet!" => \$QUIET);
18
 
 
19
 
foreach my $file (@ARGV) {
20
 
  my $tagCount = 0;
21
 
  my $base = basename($file);
22
 
  $base =~ s/\..*?$//;
23
 
  my $xml = $OUTFILE || "$OUT_DIR/$base.xml";
24
 
  my $schemaName = undef;
25
 
 
26
 
  open(IFD, "<$file") || die;
27
 
  open(OFD, ">$xml") || die;
28
 
  print OFD "<!DOCTYPE class SYSTEM \"$DTD\">\n";
29
 
  print OFD "<class>\n";
30
 
  while (<IFD>) {
31
 
    if (s/.*\@g2\s*//) {
32
 
      $tagCount++;
33
 
      print OFD $_;
34
 
 
35
 
      # NOTE!  Keep this in sync with the similar block in generate-entities.php
36
 
      # and generate-maps.php
37
 
      if (m|<class-name>(.*)</class-name>|) {
38
 
        ($schemaName = $1) =~ s/^Gallery//;
39
 
        # Shorten some table names to fit Oracle's 30 char name limit..
40
 
        $schemaName =~ s/Preferences/Prefs/;
41
 
        $schemaName =~ s/Toolkit/Tk/;
42
 
        $schemaName =~ s/TkOperation/TkOperatn/;
43
 
      }
44
 
 
45
 
      if (m|<schema>|) {
46
 
        print OFD "<schema-name>$schemaName</schema-name>\n";
47
 
      }
48
 
    }
49
 
  }
50
 
  close(IFD);
51
 
  print OFD "</class>\n";
52
 
  close(OFD);
53
 
 
54
 
  # It's gotta have more than the class-name, schema-version tags.
55
 
  #
56
 
  if ($tagCount == 0 || ($tagCount <= 2 && !$STUB_OK)) {
57
 
    print STDERR "No tags detected\n" unless ($QUIET);
58
 
    unlink($xml);
59
 
  }
60
 
}
61
 
 
62
 
exit 0;