Lines 22-28
use VerboseWarnings qw( :warn :die );
Link Here
|
22 |
|
22 |
|
23 |
############################################################################### |
23 |
############################################################################### |
24 |
|
24 |
|
25 |
use vars qw( @in_dirs @filenames $str_file $out_dir $quiet ); |
25 |
use vars qw( @in_dirs @filenames @nofilenames $str_file $out_dir $quiet ); |
26 |
use vars qw( @excludes $exclude_regex ); |
26 |
use vars qw( @excludes $exclude_regex ); |
27 |
use vars qw( $recursive_p ); |
27 |
use vars qw( $recursive_p ); |
28 |
use vars qw( $pedantic_p ); |
28 |
use vars qw( $pedantic_p ); |
Lines 133-139
sub text_replace (**) {
Link Here
|
133 |
} |
133 |
} |
134 |
|
134 |
|
135 |
sub listfiles { |
135 |
sub listfiles { |
136 |
my($dir, $type, $action, $filenames) = @_; |
136 |
my($dir, $type, $action) = @_; |
|
|
137 |
my $filenames = join ('|', @filenames); |
138 |
my $nofilenames = join ('|', @nofilenames); |
137 |
my @it = (); |
139 |
my @it = (); |
138 |
if (opendir(DIR, $dir)) { |
140 |
if (opendir(DIR, $dir)) { |
139 |
my @dirent = readdir DIR; # because DIR is shared when recursing |
141 |
my @dirent = readdir DIR; # because DIR is shared when recursing |
Lines 144-155
sub listfiles {
Link Here
|
144 |
|| (defined $exclude_regex && $dirent =~ /^(?:$exclude_regex)$/)) { |
146 |
|| (defined $exclude_regex && $dirent =~ /^(?:$exclude_regex)$/)) { |
145 |
; |
147 |
; |
146 |
} elsif (-f $path) { |
148 |
} elsif (-f $path) { |
147 |
my $basename = basename $path; |
149 |
my $basename = fileparse( $path ); |
148 |
push @it, $path |
150 |
push @it, $path |
149 |
if ( not @$filenames or ( grep { $path =~ /$_/ } @$filenames ) ) |
151 |
if ( not @filenames or $basename =~ /($filenames)/i ) |
|
|
152 |
and ( not @nofilenames or $basename !~ /($nofilenames)/i ) # files not to include |
150 |
and (!defined $type || $dirent =~ /\.(?:$type)$/) || $action eq 'install'; |
153 |
and (!defined $type || $dirent =~ /\.(?:$type)$/) || $action eq 'install'; |
151 |
} elsif (-d $path && $recursive_p) { |
154 |
} elsif (-d $path && $recursive_p) { |
152 |
push @it, listfiles($path, $type, $action, $filenames); |
155 |
push @it, listfiles($path, $type, $action); |
153 |
} |
156 |
} |
154 |
} |
157 |
} |
155 |
} else { |
158 |
} else { |
Lines 167-173
sub mkdir_recursive ($) {
Link Here
|
167 |
my ($prefix, $basename) = ($dir =~ /\/([^\/]+)$/s)? ($`, $1): ('.', $dir); |
170 |
my ($prefix, $basename) = ($dir =~ /\/([^\/]+)$/s)? ($`, $1): ('.', $dir); |
168 |
mkdir_recursive($prefix) if $prefix ne '.' && !-d $prefix; |
171 |
mkdir_recursive($prefix) if $prefix ne '.' && !-d $prefix; |
169 |
if (!-d $dir) { |
172 |
if (!-d $dir) { |
170 |
print STDERR "Making directory $dir..." unless $quiet; |
173 |
print STDERR "Making directory $dir...\n" unless $quiet; |
171 |
# creates with rwxrwxr-x permissions |
174 |
# creates with rwxrwxr-x permissions |
172 |
mkdir($dir, 0775) || warn_normal "$dir: $!", undef; |
175 |
mkdir($dir, 0775) || warn_normal "$dir: $!", undef; |
173 |
} |
176 |
} |
Lines 192-202
Create or update PO files from templates, or install translated templates.
Link Here
|
192 |
--pedantic-warnings Issue warnings even for detected problems |
195 |
--pedantic-warnings Issue warnings even for detected problems |
193 |
which are likely to be harmless |
196 |
which are likely to be harmless |
194 |
-r, --recursive SOURCE in the -i option is a directory |
197 |
-r, --recursive SOURCE in the -i option is a directory |
195 |
-f, --filename=FILE FILE is a specific filaneme. |
198 |
-f, --filename=FILE FILE is a specific filename or part of it. |
196 |
If given, only these files will be processed. |
199 |
If given, only these files will be processed. |
|
|
200 |
-n, --nofilename=FILE FILE is a specific filename or part of it. |
201 |
If given, these files will not be processed. |
197 |
-s, --str-file=FILE Specify FILE as the translation (po) file |
202 |
-s, --str-file=FILE Specify FILE as the translation (po) file |
198 |
for input (install) or output (create, update) |
203 |
for input (install) or output (create, update) |
199 |
-x, --exclude=REGEXP Exclude files matching the given REGEXP |
204 |
-x, --exclude=REGEXP Exclude dirs matching the given REGEXP |
200 |
--help Display this help and exit |
205 |
--help Display this help and exit |
201 |
-q, --quiet no output to screen (except for errors) |
206 |
-q, --quiet no output to screen (except for errors) |
202 |
|
207 |
|
Lines 221-226
sub usage_error (;$) {
Link Here
|
221 |
GetOptions( |
226 |
GetOptions( |
222 |
'input|i=s' => \@in_dirs, |
227 |
'input|i=s' => \@in_dirs, |
223 |
'filename|f=s' => \@filenames, |
228 |
'filename|f=s' => \@filenames, |
|
|
229 |
'nofilename|n=s' => \@nofilenames, |
224 |
'outputdir|o=s' => \$out_dir, |
230 |
'outputdir|o=s' => \$out_dir, |
225 |
'recursive|r' => \$recursive_p, |
231 |
'recursive|r' => \$recursive_p, |
226 |
'str-file|s=s' => \$str_file, |
232 |
'str-file|s=s' => \$str_file, |
Lines 260-272
my @in_files;
Link Here
|
260 |
# Generate the list of input files if a directory is specified |
266 |
# Generate the list of input files if a directory is specified |
261 |
# input is a directory, generates list of files to process |
267 |
# input is a directory, generates list of files to process |
262 |
|
268 |
|
263 |
for my $fn ( @filenames ) { |
269 |
for my $fn ( ( @filenames, @nofilenames ) ) { |
264 |
die "You cannot specify input files and directories at the same time.\n" |
270 |
die "You cannot specify input files and directories at the same time.\n" |
265 |
if -d $fn; |
271 |
if -d $fn; |
266 |
} |
272 |
} |
267 |
for my $in_dir ( @in_dirs ) { |
273 |
for my $in_dir ( @in_dirs ) { |
268 |
$in_dir =~ s/\/$//; # strips the trailing / if any |
274 |
$in_dir =~ s/\/$//; # strips the trailing / if any |
269 |
@in_files = ( @in_files, listfiles($in_dir, $type, $action, \@filenames) ); |
275 |
#@in_files = ( @in_files, listfiles($in_dir, $type, $action, \@filenames, \@nofilenames) ); |
|
|
276 |
@in_files = ( @in_files, listfiles($in_dir, $type, $action)); |
270 |
} |
277 |
} |
271 |
|
278 |
|
272 |
# restores the string list from file |
279 |
# restores the string list from file |
273 |
- |
|
|