File: make-sheet

package info (click to toggle)
dia 0.97.3%2Bgit20160930-6
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 52,952 kB
  • ctags: 17,146
  • sloc: ansic: 155,065; xml: 16,326; python: 6,641; cpp: 4,935; makefile: 3,826; sh: 540; perl: 137; sed: 19
file content (36 lines) | stat: -rwxr-xr-x 818 bytes parent folder | download | duplicates (6)
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
#!/usr/bin/perl -w

use strict;
use English;

my $dir = $ARGV[0];
if (!$dir) {
    $dir = $ENV{"PWD"};
}

$dir =~ /([^\/]*)\/?$/;
my $name = $1;

print "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?> <!-- -*- xml -*- -->\n";
print "\n";

print "<sheet xmlns=\"http://www.lysator.liu.se/~alla/dia/dia-sheet-ns\">\n";

print "  <name>$name</name>\n";
print "  <description>DESCRIBE $name</description>\n";

print "  <contents>\n";

opendir(DIR, $dir) || die "can't opendir $dir: $!";
my @shapes = grep { /\.shape$/ && -f "$dir/$_" } readdir(DIR);
closedir DIR;

foreach my $shape (@shapes) {
    $shape =~ s/(.*)\.shape$/$1/;
    print "    <object name=\"$name - $shape\">\n";
    print "      <description>DESCRIBE $shape</description>\n";
    print "    </object>\n";
}

print "  </contents>\n";
print "</sheet>\n";