Select Git revision
cmsprint.php
parse_othes_index.pl 7.27 KiB
#!/usr/bin/perl
use strict;
use Data::Dumper;
$Data::Dumper::Indent= 1;
$Data::Dumper::Sortkeys= 1;
use FileHandle;
binmode( STDIN, ':utf8' );
binmode( STDOUT, ':utf8' ); autoflush STDOUT 1;
binmode( STDERR, ':utf8' ); autoflush STDERR 1;
use HTML::TreeBuilder 5 -weak; # Ensure weak references in use
use Util::JSON;
use FindBin;
use lib join('/', $FindBin::Bin, 'lib');
use IRMA::db;
my $config_fnm= '/etc/irma/eprints.json';
my $force= 0;
my @PARS;
my $arg;
while (defined ($arg= shift (@ARGV)))
{
if ($arg eq '--') { push (@PARS, @ARGV); @ARGV= (); }
elsif ($arg =~ /^--(.+)/)
{
my ($opt, $val)= split ('=', $1, 2);
if ($opt eq 'help') { usage(); }
elsif ($opt eq 'force') { $force= (defined ($val)) ? $val : 1; }
else { usage(); }
}
elsif ($arg =~ /^-(.+)/)
{
foreach my $opt (split ('', $1))
{
if ($opt eq 'h') { usage(); exit (0); }
elsif ($opt eq 'F') { $force= 1; }
else { usage(); }
}
}
else
{
push (@PARS, $arg);
}
}
my $cnf= Util::JSON::read_json_file ($config_fnm);
my $ot2ut= IRMA::db::get_any_db($cnf, 'ot2ut_database');
my $col_othes_policy= $ot2ut->get_collection('othes.policy');
# print __LINE__, " ot2ut=[$ot2ut]\n";
PAR: foreach my $fnm (@PARS)
{
update_file($fnm);
}
exit(0);
sub update_file
{
my $fnm= shift;
my @fnm= split('/', $fnm);
my $last= pop (@fnm);