/usr/bin/lr_spec2pot is in lire 2:2.1.1-2.1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | #! /usr/bin/perl -w
# vim:syntax=perl
use strict;
use lib '/usr/share/perl5';
use Locale::TextDomain qw/lire/;
use Lire::Logger;
use Lire::Config;
use Lire::Config::SpecParser;
use Lire::Error qw/ an_error_occured /;
use Lire::DlfSchema;
use Lire::ReportSpec;
use Lire::FilterSpec;
use Lire::ReportConfig;
use Lire::XMLSpecI18N;
use Lire::PluginManager;
use Getopt::Long;
use Lire::Utils qw/file_content/;
sub usage {
lr_err( @_,
__(
"Usage: lr_spec2pot [--cfgspecdir <dir>]*
[--reportsdir <dir>]*
[--filtersdir <dir>]*
[--pluginsdir <dir>]*
[--schemasdir <dir>]* <SPECS>+\n" ) );
}
sub setup_cfg_paths {
my $specdirs = $_[0];
# Clear the spec path
foreach my $dir ( Lire::Config->config_spec_path() ) {
Lire::Config->del_config_spec_path_dir( $dir );
}
foreach my $dir ( @$specdirs ) {
Lire::Config->add_config_spec_path_dir( $dir );
}
Lire::Config->init();
return;
}
sub setup_cfg_var {
my ( $listname, $varname, $dirs ) = @_;
return unless defined $dirs;
my $path = Lire::Config->get_var( $listname );
my $dir_spec = $path->spec()->get( $varname );
# Clear the path
$path->clear();
# Adds the new dirs
foreach my $dir ( @$dirs ) {
$path->append( $dir_spec->instance( 'value' => $dir ) );
}
return;
}
sub setup_plugins {
my ( $pluginsdirs ) = @_;
return unless $pluginsdirs;
foreach my $dir ( @$pluginsdirs ) {
opendir my $dh, $dir
or die( "opendir '$dir' failed: $!\n" );
foreach my $basename ( readdir $dh ) {
next unless $basename =~ /_init$/;
eval file_content( "$dir/$basename" );
die( "error loading '$dir/$basename': $@\n" )
if $@;
}
closedir $dh;
my $parser = new Lire::Config::SpecParser();
$parser->{'_spec'} = Lire::Config->config_spec();
$parser->merge_specifications_dir( "$dir" );
}
}
sub load_templates {
my $file = $_[0];
my $parser = new Lire::Config::SpecParser();
my $spec = $parser->parsefile( $file );
my @templates = ();
foreach my $comp ( $spec->components() ) {
my $cfg = $comp->instance()->as_value();
$cfg->filename( $file );
push @templates, $cfg;
}
return @templates;
}
sub load_spec {
my $spec = $_[0];
if ( $spec =~ /^filter:(.*?):(.*)/ ) {
return Lire::FilterSpec->load( $1, $2 );
} elsif ( $spec =~ /^report:(.*?):(.*)/ ) {
return Lire::ReportSpec->load( $1, $2 );
} elsif ( $spec =~ /^report_cfg:(.+)/ ) {
return load_templates( $1 );
} elsif ( $spec =~ /^schema:(.*)/ ) {
return Lire::DlfSchema::load_schema( $1 );
} elsif ( $spec =~ /^config_spec:(.*)/ ) {
my $file = $1;
my $parser = new Lire::Config::SpecParser();
$parser->merge_specification( $file );
my $obj = $parser->configspec();
$obj->xml_file( $file );
return $obj;
} else {
die __( "specs are strings of the form schema:<id>, filter:<schema>:<id>, report:<schema>:<id>, config_spec:<file> or report_cfg:<file>\n" );
}
}
my %opts = ();
my $success = GetOptions( \%opts, 'cfgspecdir=s@', 'reportsdir=s@',
'filtersdir=s@', 'schemasdir=s@',
'pluginsdir=s@' );
setup_cfg_paths( $opts{'cfgspecdir'} )
if ( defined $opts{'cfgspecdir'} );
usage() unless $success;
usage( "missing one or more spec arguments\n" )
unless @ARGV;
# Since this script is used from the source tree before any Lire installation
# exists, we cannot 'use' Lire::Program. Otherwise it will try to parse the
# not-yet installed configuration files.
require Lire::Program;
eval {
setup_cfg_var( 'lr_schemas_path', 'schemas', $opts{'schemasdir'} );
setup_cfg_var( 'lr_reports_path', 'reports', $opts{'reportsdir'} );
setup_cfg_var( 'lr_filters_path', 'filters', $opts{'filtersdir'} );
setup_plugins( $opts{'pluginsdir'} );
};
lr_err( an_error_occured( $@ ) ) if $@;
my @specs = ();
foreach my $spec ( @ARGV ) {
eval {
push @specs, load_spec( $spec );
};
lr_warn( __x( "Error loading spec '{spec}': {error}",
'spec' => $spec, 'error' => $@ ) )
if $@;
}
eval {
my $extractor = new Lire::XMLSpecI18N( @specs );
$extractor->generate_catalog();
};
lr_err( an_error_occured( $@ ) ) if $@;
# Local Variables:
# mode: cperl
# End:
__END__
=pod
=head1 NAME
lr_spec2pot - extracts strings for L10N from Lire XML specifications
=head1 SYNOPSIS
FIXME
=head1 DESCRIPTION
FIXME
=head1 VERSION
$Id: lr_spec2pot.in,v 1.7 2006/07/23 13:16:33 vanbaal Exp $
=head1 AUTHORS
Francis J. Lacoste <flacoste@logreport.org>
Wolfgang Sourdeau <wolfgang@logreport.org>
=head1 COPYRIGHT
Copyright (C) 2004 Stichting LogReport Foundation LogReport@LogReport.org
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program (see COPYING); if not, check with
http://www.gnu.org/copyleft/gpl.html.
=cut
|