9 Star 27 Fork 0

Gitee 极速下载/Webmin

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/webmin/webmin
克隆/下载
extract-module-info-langs.pl 1.83 KB
一键复制 编辑 原始数据 按行查看 历史
#!/usr/local/bin/perl
# For each given module.info file, create new module.info.XX files for each
# desc_XX= line in the original
if ($ARGV[0] eq "--dry-run") {
$dryrun = 1;
shift(@ARGV);
}
@files = @ARGV;
@files || die "usage: $0 [--dry-run] [module.info]+";
foreach my $f (@files) {
my %minfo;
$f =~ /^(\S+)\/([^\/]+)$/ || die "$f is not a full path";
my ($dir, $name) = ($1, $2);
&read_file($f, \%minfo) || die "failed to read $f : $!";
my @keys = keys %minfo;
my %extract;
foreach my $k (@keys) {
if ($k =~ /^(desc|longdesc)_(\S+)/) {
if (!$extract{$2}) {
$extract{$2} ||= { };
&read_file($f.".".$2, $extract{$2});
}
$extract{$2}->{$k} = $minfo{$k};
delete($minfo{$k});
}
}
if (%extract) {
# Write out new and old files
if ($dryrun) {
print STDERR "$f : create separate files for ",
join(" ", sort(keys %extract)),"\n";
}
else {
&write_file($f, \%minfo);
system("cd $dir && git add $name");
foreach my $l (keys %extract) {
&write_file($f.".".$l, $extract{$l});
system("cd $dir && git add $name.$l");
}
}
}
}
# read_file(file, &assoc, [&order], [lowercase])
# Fill an associative array with name=value pairs from a file
sub read_file
{
open(ARFILE, $_[0]) || return 0;
while(<ARFILE>) {
s/\r|\n//g;
if (!/^#/ && /^([^=]+)=(.*)$/) {
$_[1]->{$_[3] ? lc($1) : $1} = $2;
push(@{$_[2]}, $1) if ($_[2]);
}
}
close(ARFILE);
return 1;
}
# write_file(file, array)
# Write out the contents of an associative array as name=value lines
sub write_file
{
local(%old, @order);
&read_file($_[0], \%old, \@order);
open(ARFILE, ">$_[0]");
foreach $k (@order) {
print ARFILE $k,"=",$_[1]->{$k},"\n" if (exists($_[1]->{$k}));
}
foreach $k (keys %{$_[1]}) {
print ARFILE $k,"=",$_[1]->{$k},"\n" if (!exists($old{$k}));
}
close(ARFILE);
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Perl
1
https://gitee.com/mirrors/webmin.git
git@gitee.com:mirrors/webmin.git
mirrors
webmin
Webmin
master

搜索帮助