Bugzilla – Attachment 28449 Details for
Bug 12292
Members are restricted even if the debarment is ended - moremember.pl
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.30 KB, created by
Bernardo Gonzalez Kriegel
on 2014-05-23 01:17:23 UTC
(
hide
)
Description:
Bug 12061 - tmpl_process3.pl - Include/exclude file by name
Filename:
MIME Type:
Creator:
Bernardo Gonzalez Kriegel
Created:
2014-05-23 01:17:23 UTC
Size:
6.30 KB
patch
obsolete
>From bd8369ec75bae3f83d3c98325d4f86f6ab945d61 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 an option to tmpl_process3.pl >for exclude some files by matching their >names. Also modifies current code to include >only selected files to check only filenames. >Checking is case insensitive !! > >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 -f 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 -f 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 -f 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 "-f patron -f user -f bottom" (or use -n) >or mixed "-f marc -n normarc", do create/install and look filenames > >Changed to adapt current functionality (-f) > >http://bugs.koha-community.org/show_bug.cgi?id=12292 >--- > misc/translator/tmpl_process3.pl | 27 +++++++++++++++++---------- > 1 file changed, 17 insertions(+), 10 deletions(-) > >diff --git a/misc/translator/tmpl_process3.pl b/misc/translator/tmpl_process3.pl >index 4c23a8f..3609600 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 @nofilenames $str_file $out_dir $quiet ); > use vars qw( @excludes $exclude_regex ); > use vars qw( $recursive_p ); > use vars qw( $pedantic_p ); >@@ -133,7 +133,9 @@ sub text_replace (**) { > } > > sub listfiles { >- my($dir, $type, $action, $filenames) = @_; >+ my($dir, $type, $action) = @_; >+ my $filenames = join ('|', @filenames); >+ my $nofilenames = join ('|', @nofilenames); > my @it = (); > if (opendir(DIR, $dir)) { > my @dirent = readdir DIR; # because DIR is shared when recursing >@@ -144,12 +146,13 @@ 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 ) ) >+ if ( not @filenames or $basename =~ /($filenames)/i ) >+ and ( not @nofilenames or $basename !~ /($nofilenames)/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 +170,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 +195,13 @@ 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. >+ -n, --nofilename=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 +226,7 @@ sub usage_error (;$) { > GetOptions( > 'input|i=s' => \@in_dirs, > 'filename|f=s' => \@filenames, >+ 'nofilename|n=s' => \@nofilenames, > 'outputdir|o=s' => \$out_dir, > 'recursive|r' => \$recursive_p, > 'str-file|s=s' => \$str_file, >@@ -260,13 +266,14 @@ my @in_files; > # Generate the list of input files if a directory is specified > # input is a directory, generates list of files to process > >-for my $fn ( @filenames ) { >+for my $fn ( ( @filenames, @nofilenames ) ) { > die "You cannot specify input files and directories at the same time.\n" > if -d $fn; > } > 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, \@filenames, \@nofilenames) ); >+ @in_files = ( @in_files, listfiles($in_dir, $type, $action)); > } > > # restores the string list from file >-- >1.7.9.5
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 12292
:
28368
|
28439
|
28440
|
28449