[Koha-cvs] CVS: koha/misc/translator tmpl_process3.pl,1.21,1.22 VerboseWarnings.pm,1.4,1.5

Paul POULAIN tipaul at users.sourceforge.net
Wed May 4 11:02:02 CEST 2005


Update of /cvsroot/koha/koha/misc/translator
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21182/misc/translator

Modified Files:
	tmpl_process3.pl VerboseWarnings.pm 
Log Message:
synch'ing 2.2 and head

Index: tmpl_process3.pl
===================================================================
RCS file: /cvsroot/koha/koha/misc/translator/tmpl_process3.pl,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -r1.21 -r1.22
*** tmpl_process3.pl	4 Feb 2005 03:49:33 -0000	1.21
--- tmpl_process3.pl	4 May 2005 09:01:59 -0000	1.22
***************
*** 21,25 ****
  ###############################################################################
  
! use vars qw( @in_files $in_dir $str_file $out_dir );
  use vars qw( @excludes $exclude_regex );
  use vars qw( $recursive_p );
--- 21,25 ----
  ###############################################################################
  
! use vars qw( @in_files $in_dir $str_file $out_dir $quiet );
  use vars qw( @excludes $exclude_regex );
  use vars qw( $recursive_p );
***************
*** 114,119 ****
  }
  
! sub listfiles ($$) {
!     my($dir, $type) = @_;
      my @it = ();
      if (opendir(DIR, $dir)) {
--- 114,119 ----
  }
  
! sub listfiles ($$$) {
!     my($dir, $type, $action) = @_;
      my @it = ();
      if (opendir(DIR, $dir)) {
***************
*** 126,132 ****
  		;
  	    } elsif (-f $path) {
! 		push @it, $path if !defined $type || $dirent =~ /\.(?:$type)$/;
  	    } elsif (-d $path && $recursive_p) {
! 		push @it, listfiles($path, $type);
  	    }
  	}
--- 126,132 ----
  		;
  	    } elsif (-f $path) {
! 		push @it, $path if (!defined $type || $dirent =~ /\.(?:$type)$/) || $action eq 'install';
  	    } elsif (-d $path && $recursive_p) {
! 		push @it, listfiles($path, $type, $action);
  	    }
  	}
***************
*** 146,150 ****
      mkdir_recursive($prefix) if $prefix ne '.' && !-d $prefix;
      if (!-d $dir) {
! 	print STDERR "Making directory $dir...";
  	# creates with rwxrwxr-x permissions
  	mkdir($dir, 0775) || warn_normal "$dir: $!", undef;
--- 146,150 ----
      mkdir_recursive($prefix) if $prefix ne '.' && !-d $prefix;
      if (!-d $dir) {
! 	print STDERR "Making directory $dir..." unless $quiet;
  	# creates with rwxrwxr-x permissions
  	mkdir($dir, 0775) || warn_normal "$dir: $!", undef;
***************
*** 174,183 ****
    -x, --exclude=REGEXP        Exclude files matching the given REGEXP
        --help                  Display this help and exit
  
  The -o option is ignored for the "create" and "update" actions.
! Try `perldoc $0' for perhaps more information.
  EOF
      exit($exitcode);
! }
  
  ###############################################################################
--- 174,184 ----
    -x, --exclude=REGEXP        Exclude files matching the given REGEXP
        --help                  Display this help and exit
+   -q, --quiet                 no output to screen (except for errors)
  
  The -o option is ignored for the "create" and "update" actions.
! Try `perldoc $0 for perhaps more information.
  EOF
      exit($exitcode);
! }#`
  
  ###############################################################################
***************
*** 187,191 ****
  	print STDERR "$msg\n";
      }
!     print STDERR "Try `$0 --help' for more information.\n";
      exit(-1);
  }
--- 188,192 ----
  	print STDERR "$msg\n";
      }
!     print STDERR "Try `$0 --help for more information.\n";
      exit(-1);
  }
***************
*** 199,202 ****
--- 200,204 ----
      'str-file|s=s'			=> \$str_file,
      'exclude|x=s'			=> \@excludes,
+ 	'quiet|q'				=> \$quiet,
      'pedantic-warnings|pedantic'	=> sub { $pedantic_p = 1 },
      'help'				=> \&usage,
***************
*** 237,241 ****
      $in_dir = $in_files[0];
      $in_dir =~ s/\/$//; # strips the trailing / if any
!     @in_files = listfiles($in_dir, $type);
  } else {
      for my $input (@in_files) {
--- 239,243 ----
      $in_dir = $in_files[0];
      $in_dir =~ s/\/$//; # strips the trailing / if any
!     @in_files = listfiles($in_dir, $type, $action);
  } else {
      for my $input (@in_files) {
***************
*** 360,378 ****
      # creates the new tmpl file using the new translation
      for my $input (@in_files) {
! 	die "Assertion failed"
! 		unless substr($input, 0, length($in_dir) + 1) eq "$in_dir/";
! 
! 	my $h = TmplTokenizer->new( $input );
! 	$h->set_allow_cformat( 1 );
! 	VerboseWarnings::set_input_file_name $input;
! 
! 	my $target = $out_dir . substr($input, length($in_dir));
! 	my $targetdir = $` if $target =~ /[^\/]+$/s;
! 	mkdir_recursive($targetdir) unless -d $targetdir;
! 	print STDERR "Creating $target...\n";
! 	open( OUTPUT, ">$target" ) || die "$target: $!\n";
! 	text_replace( $h, *OUTPUT );
! 	close OUTPUT;
!     }
  
  } else {
--- 362,389 ----
      # creates the new tmpl file using the new translation
      for my $input (@in_files) {
! 		die "Assertion failed"
! 			unless substr($input, 0, length($in_dir) + 1) eq "$in_dir/";
! # 		print "$input / $type\n";
! 		if (!defined $type || $input =~ /\.(?:$type)$/) {
! 			my $h = TmplTokenizer->new( $input );
! 			$h->set_allow_cformat( 1 );
! 			VerboseWarnings::set_input_file_name $input;
! 		
! 			my $target = $out_dir . substr($input, length($in_dir));
! 			my $targetdir = $` if $target =~ /[^\/]+$/s;
! 			mkdir_recursive($targetdir) unless -d $targetdir;
! 			print STDERR "Creating $target...\n" unless $quiet;
! 			open( OUTPUT, ">$target" ) || die "$target: $!\n";
! 			text_replace( $h, *OUTPUT );
! 			close OUTPUT;
! 		} else {
! 		# just copying the file
! 			my $target = $out_dir . substr($input, length($in_dir));
! 			my $targetdir = $` if $target =~ /[^\/]+$/s;
! 			mkdir_recursive($targetdir) unless -d $targetdir;
! 			system("cp -f $input $target");
! 			print STDERR "Copying $input...\n" unless $quiet;
! 		}
! 	}
  
  } else {
***************
*** 381,387 ****
  
  if ($st == 0) {
!     printf "The %s seems to be successful.\n", $action;
  } else {
!     printf "%s FAILED.\n", "\u$action";
  }
  exit 0;
--- 392,398 ----
  
  if ($st == 0) {
!     printf "The %s seems to be successful.\n", $action unless $quiet;
  } else {
!     printf "%s FAILED.\n", "\u$action" unless $quiet;
  }
  exit 0;

Index: VerboseWarnings.pm
===================================================================
RCS file: /cvsroot/koha/koha/misc/translator/VerboseWarnings.pm,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** VerboseWarnings.pm	25 Feb 2004 03:37:27 -0000	1.4
--- VerboseWarnings.pm	4 May 2005 09:01:59 -0000	1.5
***************
*** 39,43 ****
  ###############################################################################
  
! use vars qw( $appName $input $input_abbr $pedantic_p $pedantic_tag );
  use vars qw( $warned $erred );
  
--- 39,43 ----
  ###############################################################################
  
! use vars qw( $appName $input $input_abbr $pedantic_p $pedantic_tag $quiet);
  use vars qw( $warned $erred );
  
***************
*** 99,106 ****
      my $prefix = construct_warn_prefix("Warning$pedantic_tag", $lc);
      $msg .= "\n" unless $msg =~ /\n$/s;
!     warn "$prefix$msg" if $pedantic_p || !$$flag;
      if (!$pedantic_p) {
  	$prefix = construct_warn_prefix("Warning$pedantic_tag", undef);
! 	warn $prefix."Further similar negligible warnings will not be reported, use --pedantic for details\n" unless $$flag;
  	$$flag = 1;
      }
--- 99,106 ----
      my $prefix = construct_warn_prefix("Warning$pedantic_tag", $lc);
      $msg .= "\n" unless $msg =~ /\n$/s;
!     warn "$prefix$msg" if ($pedantic_p || !$$flag) && $quiet;
      if (!$pedantic_p) {
  	$prefix = construct_warn_prefix("Warning$pedantic_tag", undef);
! 	warn $prefix."Further similar negligible warnings will not be reported, use --pedantic for details\n" unless ($$flag || !$quiet);
  	$$flag = 1;
      }





More information about the Koha-cvs mailing list