Bugzilla – Attachment 30966 Details for
Bug 12061
tmpl_process3.pl new features
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12061 - tmpl_process3.pl - Include/exclude file by name
Bug-12061---tmplprocess3pl---Includeexclude-file-b.patch (text/plain), 6.60 KB, created by
Jonathan Druart
on 2014-08-19 08:33:00 UTC
(
hide
)
Description:
Bug 12061 - tmpl_process3.pl - Include/exclude file by name
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2014-08-19 08:33:00 UTC
Size:
6.60 KB
patch
obsolete
>From d941ce20de7481c98a4985e051abb390d8f47060 Mon Sep 17 00:00:00 2001 >From: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> >Date: Wed, 9 Apr 2014 22:30:35 -0300 >Subject: [PATCH] Bug 12061 - tmpl_process3.pl - Include/exclude file by name > >This patch adds options to include/exclude files by matching their names. >Also modifies current code to check only filenames (not dirs) >Checking is case insensitive !! > >NOTE: The difference between -f and -m is subtle, but important. >They differs mainly on update,: -f do a merge, -m a replace > >To test after patch: > >A) Include only 'normarc' >1. create >cd misc/translator >perl tmpl_process3.pl create -i ../../koha-tmpl/opac-tmpl/bootstrap/en -s normarc.po -r -m normarc >- check provenance of strings >egrep "^#:" normarc.po | cut -d":" -f2 | sort | uniq >- only files with normarc in their names must be present > >2. update >perl tmpl_process3.pl update -i ../../koha-tmpl/opac-tmpl/bootstrap/en -s normarc.po -r -m normarc >- repeat check > >3. install >mkdir test >perl tmpl_process3.pl install -i ../../koha-tmpl/opac-tmpl/bootstrap/en -o ./test -s normarc.po -r -m normarc >- check name of created files > >rm -rf test normarc.po > >B) Exclude >4. create >perl tmpl_process3.pl create -i ../../koha-tmpl/opac-tmpl/bootstrap/en -s xnormarc.po -r -n normarc >- check provenance >egrep "^#:" xnormarc.po | cut -d":" -f2 | sort | uniq | grep -i normarc >- there must be no results > >5. update >perl tmpl_process3.pl update -i ../../koha-tmpl/opac-tmpl/bootstrap/en -s xnormarc.po -r -n normarc >- check provenance > >6. install >mkdir test >perl tmpl_process3.pl install -i ../../koha-tmpl/opac-tmpl/bootstrap/en -o ./test -s xnormarc.po -r -n normarc >- check files >find test | grep -i normarc >- there must be no results > >You can also try another combination, use for example "-m patron -m user -m bottom" (or use -n) >or mixed "-m marc -n normarc", do create/install and look filenames > >Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com> > >Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com> >--- > misc/translator/tmpl_process3.pl | 32 ++++++++++++++++++++++---------- > 1 file changed, 22 insertions(+), 10 deletions(-) > >diff --git a/misc/translator/tmpl_process3.pl b/misc/translator/tmpl_process3.pl >index 4c23a8f..cb671ae 100755 >--- a/misc/translator/tmpl_process3.pl >+++ b/misc/translator/tmpl_process3.pl >@@ -22,7 +22,7 @@ use VerboseWarnings qw( :warn :die ); > > ############################################################################### > >-use vars qw( @in_dirs @filenames $str_file $out_dir $quiet ); >+use vars qw( @in_dirs @filenames @match @nomatch $str_file $out_dir $quiet ); > use vars qw( @excludes $exclude_regex ); > use vars qw( $recursive_p ); > use vars qw( $pedantic_p ); >@@ -133,7 +133,10 @@ sub text_replace (**) { > } > > sub listfiles { >- my($dir, $type, $action, $filenames) = @_; >+ my($dir, $type, $action) = @_; >+ my $filenames = join ('|', @filenames); # used to update strings from this file >+ my $match = join ('|', @match); # use only this files >+ my $nomatch = join ('|', @nomatch); # do no use this files > my @it = (); > if (opendir(DIR, $dir)) { > my @dirent = readdir DIR; # because DIR is shared when recursing >@@ -144,12 +147,14 @@ sub listfiles { > || (defined $exclude_regex && $dirent =~ /^(?:$exclude_regex)$/)) { > ; > } elsif (-f $path) { >- my $basename = basename $path; >+ my $basename = fileparse( $path ); > push @it, $path >- if ( not @$filenames or ( grep { $path =~ /$_/ } @$filenames ) ) >- and (!defined $type || $dirent =~ /\.(?:$type)$/) || $action eq 'install'; >+ if ( not @filenames or $basename =~ /($filenames)/i ) >+ and ( not @match or $basename =~ /($match)/i ) # files to include >+ and ( not @nomatch or $basename !~ /($nomatch)/i ) # files not to include >+ and (!defined $type || $dirent =~ /\.(?:$type)$/) || $action eq 'install'; > } elsif (-d $path && $recursive_p) { >- push @it, listfiles($path, $type, $action, $filenames); >+ push @it, listfiles($path, $type, $action); > } > } > } else { >@@ -167,7 +172,7 @@ sub mkdir_recursive ($) { > my ($prefix, $basename) = ($dir =~ /\/([^\/]+)$/s)? ($`, $1): ('.', $dir); > mkdir_recursive($prefix) if $prefix ne '.' && !-d $prefix; > if (!-d $dir) { >- print STDERR "Making directory $dir..." unless $quiet; >+ print STDERR "Making directory $dir...\n" unless $quiet; > # creates with rwxrwxr-x permissions > mkdir($dir, 0775) || warn_normal "$dir: $!", undef; > } >@@ -192,11 +197,16 @@ Create or update PO files from templates, or install translated templates. > --pedantic-warnings Issue warnings even for detected problems > which are likely to be harmless > -r, --recursive SOURCE in the -i option is a directory >- -f, --filename=FILE FILE is a specific filaneme. >+ -f, --filename=FILE FILE is a specific filename or part of it. > If given, only these files will be processed. >+ On update only relevant strings will be updated. >+ -m, --match=FILE FILE is a specific filename or part of it. >+ If given, only these files will be processed. >+ -n, --nomatch=FILE FILE is a specific filename or part of it. >+ If given, these files will not be processed. > -s, --str-file=FILE Specify FILE as the translation (po) file > for input (install) or output (create, update) >- -x, --exclude=REGEXP Exclude files matching the given REGEXP >+ -x, --exclude=REGEXP Exclude dirs matching the given REGEXP > --help Display this help and exit > -q, --quiet no output to screen (except for errors) > >@@ -221,6 +231,8 @@ sub usage_error (;$) { > GetOptions( > 'input|i=s' => \@in_dirs, > 'filename|f=s' => \@filenames, >+ 'match|m=s' => \@match, >+ 'nomatch|n=s' => \@nomatch, > 'outputdir|o=s' => \$out_dir, > 'recursive|r' => \$recursive_p, > 'str-file|s=s' => \$str_file, >@@ -266,7 +278,7 @@ for my $fn ( @filenames ) { > } > for my $in_dir ( @in_dirs ) { > $in_dir =~ s/\/$//; # strips the trailing / if any >- @in_files = ( @in_files, listfiles($in_dir, $type, $action, \@filenames) ); >+ @in_files = ( @in_files, listfiles($in_dir, $type, $action)); > } > > # restores the string list from file >-- >2.0.0.rc2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 12061
:
26943
|
26944
|
26945
|
28443
|
28444
|
28445
|
28450
|
28451
|
28643
|
28644
|
28645
|
28735
|
28736
|
28737
|
30148
| 30966