From a605f6507299c7355036edeab8ee88da19af82f9 Mon Sep 17 00:00:00 2001 From: Luc Didry Date: Fri, 30 Nov 2018 15:20:21 +0100 Subject: [PATCH] Fix code tidying --- src/lib/Sympa/List.pm | 98 ++++++++++++++++++------------------- src/lib/Sympa/Tools/Text.pm | 2 +- src/sbin/sympa.pl.in | 58 +++++++++++----------- 3 files changed, 78 insertions(+), 80 deletions(-) diff --git a/src/lib/Sympa/List.pm b/src/lib/Sympa/List.pm index 49659f3db..b7358e0cb 100644 --- a/src/lib/Sympa/List.pm +++ b/src/lib/Sympa/List.pm @@ -5794,25 +5794,24 @@ sub _load_list_members_from_include { } my $include_member; - my %parsing; + my %parsing; - $parsing{'data'} = $entry->{'source_parameters'}; - $parsing{'template'} = "$entry->{'source'}\.incl"; + $parsing{'data'} = $entry->{'source_parameters'}; + $parsing{'template'} = "$entry->{'source'}\.incl"; - my $name = "$entry->{'source'}\.incl"; + my $name = "$entry->{'source'}\.incl"; - my $include_path = $include_file; - if ($include_path =~ s/$name$//) { - $parsing{'include_path'} = $include_path; - $include_member = - $self->_load_include_admin_user_file($include_path, - \%parsing); - } else { - $log->syslog('err', - 'Errors to get path of the the file %s.incl', - $entry->{'source'}); - return undef; - } + my $include_path = $include_file; + if ($include_path =~ s/$name$//) { + $parsing{'include_path'} = $include_path; + $include_member = + $self->_load_include_admin_user_file($include_path, + \%parsing); + } else { + $log->syslog('err', 'Errors to get path of the the file %s.incl', + $entry->{'source'}); + return undef; + } if ($include_member and %$include_member) { foreach my $type (@sources_providing_listmembers) { @@ -6078,25 +6077,24 @@ sub _load_list_admin_from_include { } my $include_admin_user; - my %parsing; + my %parsing; - $parsing{'data'} = $entry->{'source_parameters'}; - $parsing{'template'} = "$entry->{'source'}\.incl"; + $parsing{'data'} = $entry->{'source_parameters'}; + $parsing{'template'} = "$entry->{'source'}\.incl"; - my $name = "$entry->{'source'}\.incl"; + my $name = "$entry->{'source'}\.incl"; - my $include_path = $include_file; - if ($include_path =~ s/$name$//) { - $parsing{'include_path'} = $include_path; - $include_admin_user = - $self->_load_include_admin_user_file($include_path, - \%parsing); - } else { - $log->syslog('err', - 'Errors to get path of the the file %s.incl', - $entry->{'source'}); - return undef; - } + my $include_path = $include_file; + if ($include_path =~ s/$name$//) { + $parsing{'include_path'} = $include_path; + $include_admin_user = + $self->_load_include_admin_user_file($include_path, + \%parsing); + } else { + $log->syslog('err', 'Errors to get path of the the file %s.incl', + $entry->{'source'}); + return undef; + } foreach my $type (@sources_providing_listmembers) { defined $total or last; @@ -6269,28 +6267,28 @@ sub _load_include_admin_user_file { my %include; my (@paragraphs); - my @data = split(',', $parsing->{'data'}) if defined $parsing->{'data'}; - my $vars = {'param' => \@data}; - my $output = ''; + my @data = split(',', $parsing->{'data'}) if defined $parsing->{'data'}; + my $vars = {'param' => \@data}; + my $output = ''; - my $template = - Sympa::Template->new(undef, - include_path => [$parsing->{'include_path'}]); - unless ($template->parse($vars, $parsing->{'template'}, \$output)) { - $log->syslog('err', 'Failed to parse %s', $parsing->{'template'}); - return undef; - } + my $template = + Sympa::Template->new(undef, + include_path => [$parsing->{'include_path'}]); + unless ($template->parse($vars, $parsing->{'template'}, \$output)) { + $log->syslog('err', 'Failed to parse %s', $parsing->{'template'}); + return undef; + } - my @lines = split('\n', $output); + my @lines = split('\n', $output); - my $i = 0; - foreach my $line (@lines) { - if ($line =~ /^\s*$/) { - $i++ if $paragraphs[$i]; - } else { - push @{$paragraphs[$i]}, $line; - } + my $i = 0; + foreach my $line (@lines) { + if ($line =~ /^\s*$/) { + $i++ if $paragraphs[$i]; + } else { + push @{$paragraphs[$i]}, $line; } + } for my $index (0 .. $#paragraphs) { my @paragraph = @{$paragraphs[$index]}; diff --git a/src/lib/Sympa/Tools/Text.pm b/src/lib/Sympa/Tools/Text.pm index 622867f21..99c177f50 100644 --- a/src/lib/Sympa/Tools/Text.pm +++ b/src/lib/Sympa/Tools/Text.pm @@ -160,7 +160,7 @@ sub encode_filesystem_safe { } sub encode_html { - my $str = shift; + my $str = shift; my $additional_unsafe = shift || ''; HTML::Entities::encode_entities($str, '<>&"' . $additional_unsafe); diff --git a/src/sbin/sympa.pl.in b/src/sbin/sympa.pl.in index 965137aa2..defc8bf3c 100644 --- a/src/sbin/sympa.pl.in +++ b/src/sbin/sympa.pl.in @@ -62,31 +62,32 @@ srand(time()); my %options; unless ( GetOptions( - \%main::options, 'dump=s', - 'debug|d', 'log_level=s', - 'config|f=s', 'lang|l=s', - 'mail|m', 'help|h', - 'version|v', 'import=s', - 'make_alias_file', 'lowercase', - 'sync_list_db', 'md5_encode_password', - 'close_list=s', 'rename_list=s', 'copy_list=s', - 'new_listname=s', 'new_listrobot=s', - 'purge_list=s', 'create_list', - 'instantiate_family=s', 'robot=s', - 'add_list=s', 'modify_list=s', - 'close_family=s', 'md5_digest=s', - 'change_user_email', 'current_email=s', - 'new_email=s', 'input_file=s', - 'sync_include=s', 'upgrade', - 'upgrade_shared', 'from=s', - 'to=s', 'reload_list_config', - 'list=s', 'quiet', - 'close_unknown', 'test_database_message_buffer', - 'conf_2_db', 'export_list', - 'health_check', 'send_digest', - 'keep_digest', 'upgrade_config_location', - 'role=s', 'dump_users', - 'restore_users', 'open_list=s', + \%main::options, 'dump=s', + 'debug|d', 'log_level=s', + 'config|f=s', 'lang|l=s', + 'mail|m', 'help|h', + 'version|v', 'import=s', + 'make_alias_file', 'lowercase', + 'sync_list_db', 'md5_encode_password', + 'close_list=s', 'rename_list=s', + 'copy_list=s', 'new_listname=s', + 'new_listrobot=s', 'purge_list=s', + 'create_list', 'instantiate_family=s', + 'robot=s', 'add_list=s', + 'modify_list=s', 'close_family=s', + 'md5_digest=s', 'change_user_email', + 'current_email=s', 'new_email=s', + 'input_file=s', 'sync_include=s', + 'upgrade', 'upgrade_shared', + 'from=s', 'to=s', + 'reload_list_config', 'list=s', + 'quiet', 'close_unknown', + 'test_database_message_buffer', 'conf_2_db', + 'export_list', 'health_check', + 'send_digest', 'keep_digest', + 'upgrade_config_location', 'role=s', + 'dump_users', 'restore_users', + 'open_list=s', ) ) { pod2usage(-exitval => 1, -output => \*STDERR); @@ -631,14 +632,13 @@ if ($main::options{'dump'} or $main::options{'dump_users'}) { exit 1; } exit 0; - + } elsif ($main::options{'copy_list'}) { my $current_list = Sympa::List->new(split(/\@/, $main::options{'copy_list'}, 2), {just_try => 1}); unless ($current_list) { - printf STDERR "Incorrect list name %s\n", - $main::options{'copy_list'}; + printf STDERR "Incorrect list name %s\n", $main::options{'copy_list'}; exit 1; } @@ -663,7 +663,7 @@ if ($main::options{'dump'} or $main::options{'dump_users'}) { action => 'move_list', current_list => $current_list, listname => $listname, - mode => 'copy', + mode => 'copy', sender => Sympa::get_address($robot_id, 'listmaster'), scenario_context => {skip => 1}, );