Changeset 9951


Ignore:
Timestamp:
2005-05-25T17:06:20+12:00 (19 years ago)
Author:
davidb
Message:

import.pl and export.pl share much in common with their abilities to save
documents in different formats (GA, METS, DSpace ...). The code was a bit
repeatative in places and in others not the most consistent. These changes
bring thing in to line more.

Location:
trunk/gsdl/bin/script
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/bin/script/export.pl

    r9854 r9951  
    143143    'modegli' => "3" },
    144144      $saveas_argument,
    145 #      { 'name' => "statsfile",
    146 #   'desc' => "{export.statsfile}",
    147 #   'type' => "string",
    148 #   'deft' => "STDERR",
    149 #   'reqd' => "no",
    150 #        'hiddengli' => "yes" },
     145      { 'name' => "statsfile",
     146    'desc' => "{export.statsfile}",
     147    'type' => "string",
     148    'deft' => "STDERR",
     149    'reqd' => "no",
     150        'hiddengli' => "yes" },
    151151      { 'name' => "verbosity",
    152152    'desc' => "{export.verbosity}",
     
    175175sub main {
    176176    my ($verbosity, $importdir, $archivedir, $keepold, $listall,
    177     $removeold, $saveas, $gzip, $groupsize, $OIDtype, $debug,
     177    $removeold, $saveas, $version,
     178    $gzip, $groupsize, $OIDtype, $debug,
    178179    $maxdocs, $collection, $configfilename,
    179     $pluginfo, $sortmeta, $export_info_filename,
     180    $pluginfo, $sortmeta,
     181    $export_info_filename, $statsfile,
    180182    $export_info, $processor, $out, $faillog, $collectdir, $gli);
    181183
     
    195197             'keepold', \$keepold,
    196198             'removeold', \$removeold,
    197              'saveas/^(DSpace|METS)$/METS', \$saveas,
     199             'saveas/^(DSpace|METS|GA)$/METS', \$saveas,
     200             'version/.*/', \$version,
    198201             'debug', \$debug,
    199202             'maxdocs/^\-?\d+/', \$maxdocs,
    200203             'collectdir/.*/', \$collectdir,
    201204             'out/.*/STDERR', \$out,
    202 #            'statsfile/.*/STDERR', \$statsfile,
     205             'statsfile/.*/STDERR', \$statsfile,
    203206             'faillog/.*/', \$faillog,
    204207             'gli', \$gli,
     
    415418        $processor->set_OIDtype ($OIDtype);
    416419        $processor->set_saveas ($saveas);
     420        $processor->set_saveas_version ($version);
    417421        } else {
    418422        $processor = new docprint ();
     
    434438        }
    435439       
    436 #    # write out export stats
    437 #    my $close_stats = 0;
    438 #    if ($statsfile !~ /^(STDERR|STDOUT)$/i) {
    439 #   if (open (STATS, ">$statsfile")) {
    440 #       $statsfile = 'import::STATS';
    441 #       $close_stats = 1;
    442 #   } else {
    443 #       &gsprintf($out, "{import.cannot_open_stats_file}", $statsfile);
    444 #       &gsprintf($out, "{import.stats_backup}\n");
    445 #       $statsfile = 'STDERR';
    446 #   }
    447 #    }
     440        # write out export stats
     441        my $close_stats = 0;
     442        if ($statsfile !~ /^(STDERR|STDOUT)$/i) {
     443        if (open (STATS, ">$statsfile")) {
     444            $statsfile = 'import::STATS';
     445            $close_stats = 1;
     446        } else {
     447            &gsprintf($out, "{import.cannot_open_stats_file}", $statsfile);
     448            &gsprintf($out, "{import.stats_backup}\n");
     449            $statsfile = 'STDERR';
     450        }
     451        }
     452
     453        &gsprintf($out, "\n");
     454        &gsprintf($out, "*********************************************\n");
     455
     456        &plugin::write_stats($pluginfo, $statsfile, $faillogname, $gli);
     457        if ($close_stats) {
     458        close STATS;
     459        }
     460
     461        &gsprintf($out, "*********************************************\n");
     462
     463        close OUT if $close_out;
     464
    448465        close FAILLOG;
    449466    };
     467
     468    if ($@) {
     469        print STDERR $@;
     470    }
    450471
    451472##  $ENV{'GSDLCOLLECTION'} = undef;
     
    457478    &gsprintf($out, "\n");
    458479    &gsprintf($out, "*********************************************\n");
    459     &gsprintf($out, "{export.complete}\n");
    460     &gsprintf($out, "*********************************************\n");
    461    
    462 #    &plugin::write_stats($pluginfo, $statsfile, $faillogname, $gli);
    463 #    if ($close_stats) {
    464 #   close STATS;
    465 #    }
    466 
    467     close OUT if $close_out;
    468 
     480    &gsprintf($out, "* {export.complete}\n");
     481    &gsprintf($out, "*********************************************\n");   
    469482
    470483}
  • trunk/gsdl/bin/script/import.pl

    r9854 r9951  
    201201sub main {
    202202    my ($verbosity, $importdir, $archivedir, $keepold,
    203     $removeold, $saveas, $gzip, $groupsize, $OIDtype, $debug,
     203    $removeold, $saveas, $version,
     204    $gzip, $groupsize, $OIDtype, $debug,
    204205    $maxdocs, $collection, $configfilename, $collectcfg,
    205206    $pluginfo, $sortmeta, $removeprefix, $removesuffix,
     
    221222             'keepold', \$keepold,
    222223             'removeold', \$removeold,
    223              'saveas/^(GA|METS)$/', \$saveas,
     224             'saveas/^(GA|METS|DSpace)$/GA', \$saveas,
     225             'version/.*/', \$version,
    224226             'gzip', \$gzip,
    225227             'groupsize/\d+/1', \$groupsize,
     
    433435    $processor->set_OIDtype ($OIDtype);
    434436    $processor->set_saveas ($saveas);
     437    $processor->set_saveas_version ($version);
     438
    435439    } else {
    436440    $processor = new docprint ();
Note: See TracChangeset for help on using the changeset viewer.