Mercurial > bins
comparison tools/bins_addtext @ 0:a84c32f131df 1.1.29
Import vendor version
author | Peter Gervai <grin@grin.hu> |
---|---|
date | Wed, 15 Oct 2008 23:28:56 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:a84c32f131df |
---|---|
1 #!/usr/bin/perl -w | |
2 #-*- mode: perl -*- | |
3 | |
4 sub process_file { | |
5 my ($dir, $file, $title, $desc) = @_; | |
6 chomp $desc; | |
7 #print "File: $file\n\tTitle: $title\n\tDesc: $desc\n"; | |
8 #print "\n$file\n"; | |
9 if($file eq "album") { | |
10 ($longdesc, $shortdesc, $sample) = split /\|/, $desc; | |
11 if($sample) { | |
12 $cmd_str = "bins_edit -a -m --sample \"$sample\" $dir"; | |
13 print "$cmd_str\n"; | |
14 `$cmd_str`; | |
15 } | |
16 if($shortdesc) { | |
17 $cmd_str = "bins_edit -a -m --shortdesc \"$shortdesc\" $dir"; | |
18 print "$cmd_str\n"; | |
19 `$cmd_str`; | |
20 } | |
21 if($longdesc) { | |
22 $cmd_str = "bins_edit -a -m --longdesc \"$longdesc\" $dir"; | |
23 print "$cmd_str\n"; | |
24 `$cmd_str`; | |
25 } | |
26 #print "\t$cmd_str\n"; | |
27 $cmd_str = "bins_edit -a -m --title \"$title\" $dir"; | |
28 print "$cmd_str\n"; | |
29 `$cmd_str`; | |
30 } | |
31 else { | |
32 $cmd_str = "bins_edit -m -t \"$title\" $dir/$file"; | |
33 print "$cmd_str\n"; | |
34 `$cmd_str`; | |
35 #print "\t$cmd_str\n"; | |
36 $cmd_str = "bins_edit -m -d \"$desc\" $dir/$file"; | |
37 print "$cmd_str\n"; | |
38 `$cmd_str`; | |
39 #print "\t$cmd_str\n\n"; | |
40 } | |
41 } | |
42 | |
43 $inc_file = "include_images.txt"; | |
44 | |
45 for($i=0; $i<=$#ARGV; $i++) { | |
46 $dir = $ARGV[$i]; | |
47 if($dir eq "-f" && $i<$#ARGV ) { | |
48 $i++; | |
49 $inc_file=$ARGV[$i]; | |
50 next; | |
51 } | |
52 | |
53 open(FILE, "$dir/$inc_file") or die "Could not open: $dir/$inc_file"; | |
54 | |
55 $title = ""; | |
56 $desc = ""; | |
57 $img_file = "album"; | |
58 $section = 1; | |
59 | |
60 while(<FILE>) | |
61 { | |
62 chomp; | |
63 $line=$_; | |
64 if(substr($line, 0 , 1) eq "") { | |
65 next; | |
66 } | |
67 | |
68 if(substr($line, 0 , 1) ne "#") { | |
69 process_file($dir, $img_file, $title, $desc); | |
70 $img_file = $line; | |
71 $title = ""; | |
72 $desc = ""; | |
73 $section = 1; | |
74 } | |
75 else { | |
76 if ($section == 1) { | |
77 $title = substr($line, 1); | |
78 $section++; | |
79 } | |
80 elsif ($section == 2) { | |
81 $desc .= substr($line, 1)."\n"; | |
82 } | |
83 } | |
84 | |
85 } | |
86 | |
87 if($section) { | |
88 process_file($dir, $img_file, $title, $desc); | |
89 } | |
90 | |
91 close(FILE) ; | |
92 } |