Changeset 6921


Ignore:
Timestamp:
2004-03-04T15:47:20+13:00 (20 years ago)
Author:
mdewsnip
Message:

Updated to use gsprintf in preparation for adding the French/Spanish/Russian translations.

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

Legend:

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

    r6407 r6921  
    152152        'args' => $arguments };
    153153
    154 
    155 sub print_xml_usage
     154sub gsprintf
    156155{
    157     local $language = shift(@_);
    158 
    159     &PrintUsage::print_xml_header();
    160 
    161     print STDERR "<Info>\n";
    162     print STDERR "  <Name>$options->{'name'}</Name>\n";
    163     print STDERR "  <Desc>" . &lookup_string($options->{'desc'}) . "</Desc>\n";
    164     print STDERR "  <Arguments>\n";
    165     if (defined($options->{'args'})) {
    166     &PrintUsage::print_options_xml($language, $options->{'args'});
    167     }
    168     print STDERR "  </Arguments>\n";
    169     print STDERR "</Info>\n";
    170 }
    171 
    172 
    173 sub print_txt_usage
    174 {
    175     local $language = shift(@_);
    176 
    177     local $programname = $options->{'name'};
    178     local $programargs = $options->{'args'};
    179 
    180     # Find the length of the longest option string
    181     local $descoffset = 0;
    182     if (defined($programargs)) {
    183     $descoffset = &PrintUsage::find_longest_option_string($programargs);
    184     }
    185 
    186     # Produce the usage information using the data structure above
    187     print STDERR " " . &lookup_string("{common.usage}") . ": $programname";
    188     print STDERR " " . &lookup_string("{buildcol.params}") . "\n\n";
    189 
    190     # Display the program options, if there are some
    191     if (defined($programargs)) {
    192     # Calculate the column offset of the option descriptions
    193     local $optiondescoffset = $descoffset + 2;  # 2 spaces between options & descriptions
    194 
    195     print STDERR " " . &lookup_string("{common.options}") . ":\n";
    196 
    197     # Display the program options
    198     &PrintUsage::print_options_txt($language, $programargs, $optiondescoffset);
    199     }
    200 }
    201 
    202 
    203 sub lookup_string
    204 {
    205     return &gsprintf::lookup_string($language, shift(@_));
     156    return &gsprintf::gsprintf(@_);
    206157}
    207158
     
    283234             'gli', \$gli,
    284235             q^xml^, \$xml)) {
    285     &print_txt_usage($language);
     236    &PrintUsage::print_txt_usage($language, $options, "{buildcol.params}");
    286237    die "\n";
    287238    }
    288239
    289240    if ($xml) {
    290         &print_xml_usage($language);
     241        &PrintUsage::print_xml_usage($language, $options);
    291242    die "\n";
    292243    }
     
    296247    if ($out !~ /^(STDERR|STDOUT)$/i) {
    297248    open (OUT, ">$out") ||
    298         die &lookup_string("{common.cannot_open_output_file}") . " $out\n";
     249        (&gsprintf(STDERR, "{common.cannot_open_output_file}\n", $out) && die);
    299250    $out = "buildcol::OUT";
    300251    $close_out = 1;
     
    304255    # get and check the collection
    305256    if (($collection = &util::use_collection(@ARGV, $collectdir)) eq "") {
    306     &print_txt_usage($language);
     257    &PrintUsage::print_txt_usage($language, $options, "{buildcol.params}");
    307258    die "\n";
    308259    }
     
    314265    # this could potentially create a situation where the faillog keeps being added
    315266    # to over multiple builds (if the import process is being skipped)
    316     open (FAILLOG, ">>$faillog")
    317     || die &lookup_string("{common.cannot_open_fail_log}") . " $faillog\n";
     267    open (FAILLOG, ">>$faillog") ||
     268    (&gsprintf(STDERR, "{common.cannot_open_fail_log}\n", $faillog) && die);
    318269    $faillog = 'buildcol::FAILLOG';
    319270    $faillog->autoflush(1);
     
    393344   
    394345    } else {
    395     die &lookup_string("{common.cannot_find_cfg_file}") . " $configfilename\n";
     346    &gsprintf($out, "{common.cannot_find_cfg_file}\n", $configfilename) && die;
    396347    }
    397348
     
    429380    # update the archive cache if needed
    430381    if ($cachedir) {
    431     print $out &lookup_string("{buildcol.updating_archive_cache}") . "\n"
     382    &gsprintf($out, "{buildcol.updating_archive_cache}\n")
    432383        if ($verbosity >= 1);
    433384
     
    491442    $builder->make_infodatabase();
    492443    } else {
    493     die &lookup_string("{buildcol.unknown_mode}") . " $mode\n";
     444    (&gsprintf(STDERR, "{buildcol.unknown_mode}\n", $mode) && die);
    494445    }
    495446
     
    498449   
    499450    if (($realbuilddir ne $builddir) && !$debug) {
    500     print $out &lookup_string("{buildcol.copying_back_cached_build}") . "\n"
     451    &gsprintf($out, "{buildcol.copying_back_cached_build}\n")
    501452        if ($verbosity >= 1);
    502453    &util::rm_r ($builddir);
     
    515466    my $image_script = &util::filename_cat ($ENV{'GSDLHOME'}, "bin", "script", "gimp", "title_icon-1.2.pl");
    516467    if (!-e $image_script) {
    517     print $out &lookup_string("{buildcol.no_image_script}") . ": $image_script.";
    518     print $out &lookup_string("{buildcol.no_default_images}") . "\n\n";
     468    &gsprintf($out, "{buildcol.no_image_script}", $image_script);
     469    &gsprintf($out, "{buildcol.no_default_images}\n\n");
    519470    return;
    520471    }
     
    531482    # to be changed when the config file format changes)
    532483    if (!open (CFGFILE, $configfilename)) {
    533     print $out &lookup_string("{buildcol.cannot_open_cfg_file}") . ": $configfilename\n";
    534     print $out &lookup_string("{buildcol.unlinked_col_images}") . "\n";
     484    &gsprintf($out, "{buildcol.cannot_open_cfg_file}\n", $configfilename);
     485    &gsprintf($out, "{buildcol.unlinked_col_images}\n");
    535486    return;
    536487    }
     
    554505
    555506    if (!open (CFGFILE, ">$configfilename")) {
    556     print $out &lookup_string("{buildcol.cannot_open_cfg_file}") . ": $configfilename\n";
    557     print $out &lookup_string("{buildcol.unlinked_col_images}") . "\n";
     507    &gsprintf($out, "{buildcol.cannot_open_cfg_file}\n", $configfilename);
     508    &gsprintf($out, "{buildcol.unlinked_col_images}\n");
    558509    return;
    559510    }
  • trunk/gsdl/bin/script/classinfo.pl

    r5882 r6921  
    6161        'args' => $arguments };
    6262
    63 
    64 sub lookup_string
     63sub gsprintf
    6564{
    66     return &gsprintf::lookup_string($language, shift(@_));
    67 }
    68 
    69 
    70 sub print_txt_usage
    71 {
    72     local $language = shift(@_);
    73 
    74     local $programname = $options->{'name'};
    75     local $programargs = $options->{'args'};
    76 
    77     # Find the length of the longest option string
    78     local $descoffset = 0;
    79     if (defined($programargs)) {
    80     $descoffset = &PrintUsage::find_longest_option_string($programargs);
    81     }
    82 
    83     # Produce the usage information using the data structure above
    84     print STDERR $programname . ": " . &lookup_string($options->{'desc'}) . "\n\n";
    85     print STDERR " " . &lookup_string("{common.usage}") . ": $programname";
    86     print STDERR " " . &lookup_string("{classinfo.params}") . "\n\n";
    87 
    88     # Display the program options, if there are some
    89     if (defined($programargs)) {
    90     # Calculate the column offset of the option descriptions
    91     local $optiondescoffset = $descoffset + 2;  # 2 spaces between options & descriptions
    92 
    93     print STDERR " " . &lookup_string("{common.options}") . ":\n";
    94 
    95     # Display the program options
    96     &PrintUsage::print_options_txt($language, $programargs, $optiondescoffset);
    97     }
     65    return &gsprintf::gsprintf(@_);
    9866}
    9967
     
    12896             q^language/.*/^, \$language))
    12997    {
    130     &print_txt_usage($language);
     98    &PrintUsage::print_txt_usage($language, $options, "{classinfo.params}", 1);
    13199    die "\n";
    132100    }
     
    135103    my $classifier = shift (@ARGV);
    136104    if (!defined $classifier || $classifier eq "") {
    137     print STDERR &lookup_string("{classinfo.no_classifier_name}") . "\n\n";
    138     &print_txt_usage($language);
     105    &gsprintf(STDERR, "{classinfo.no_classifier_name}\n\n");
     106    &PrintUsage::print_txt_usage($language, $options, "{classinfo.params}", 1);
    139107    die "\n";
    140108    }
     
    154122    }
    155123    else {
    156     print STDERR "\n$classifier " . &lookup_string("{classinfo.info}") . ":\n\n";
    157     print STDERR &lookup_string("{classinfo.passing_options}") . "\n\n";
    158     print STDERR &lookup_string("{classinfo.option_types}") . ":\n\n";
    159     print STDERR &lookup_string("{classinfo.specific_options}") . "\n\n";
    160     print STDERR &lookup_string("{classinfo.general_options}") . "\n\n";
     124    &gsprintf(STDERR, "\n$classifier {classinfo.info}:\n\n");
     125    &gsprintf(STDERR, "{classinfo.passing_options}\n\n");
     126    &gsprintf(STDERR, "{classinfo.option_types}:\n\n");
     127    &gsprintf(STDERR, "{classinfo.specific_options}\n\n");
     128    &gsprintf(STDERR, "{classinfo.general_options}\n\n");
    161129
    162130    $classobj->print_txt_usage($language);
  • trunk/gsdl/bin/script/exportcol.pl

    r6813 r6921  
    3636
    3737my $arguments =
    38     [ { 'name' => "out",
     38    [ { 'name' => "language",
     39    'desc' => "{scripts.language}",
     40    'type' => "string",
     41    'reqd' => "no" },
     42      { 'name' => "out",
    3943    'desc' => "{exportcol.out}",
    4044    'type' => "string",
     
    5155        'args' => $arguments };
    5256
    53 sub print_xml_usage
    54 {
    55     local $language = shift(@_);
    56 
    57     &PrintUsage::print_xml_header();
    58 
    59     print STDERR "<Info>\n";
    60     print STDERR "  <Name>$options->{'name'}</Name>\n";
    61     print STDERR "  <Desc>" . &lookup_string($options->{'desc'}) . "</Desc>\n";
    62     print STDERR "  <Arguments>\n";
    63     if (defined($options->{'args'})) {
    64     &PrintUsage::print_options_xml($language, $options->{'args'});
    65     }
    66     print STDERR "  </Arguments>\n";
    67     print STDERR "</Info>\n";
    68 }
    69 
    70 sub print_txt_usage
    71 {
    72     local $language = shift(@_);
    73 
    74     local $programname = $options->{'name'};
    75     local $programargs = $options->{'args'};
    76 
    77     # Find the length of the longest option string
    78     local $descoffset = 0;
    79     if (defined($programargs)) {
    80     $descoffset = &PrintUsage::find_longest_option_string($programargs);
    81     }
    82 
    83     # Produce the usage information using the data structure above
    84     print STDERR " " . &lookup_string("{common.usage}") . ": $programname";
    85     print STDERR " " . &lookup_string("{exportcol.params}") . "\n\n";
    86 
    87     # Display the program options, if there are some
    88     if (defined($programargs)) {
    89     # Calculate the column offset of the option descriptions
    90     local $optiondescoffset = $descoffset + 2;  # 2 spaces between options & descriptions
    91 
    92     print STDERR " " . &lookup_string("{common.options}") . ":\n";
    93 
    94     # Display the program options
    95     &PrintUsage::print_options_txt($language, $programargs, $optiondescoffset);
    96     }
    97 }
    98 
    99 
    100 sub lookup_string
    101 {
    102     return &gsprintf::lookup_string($language, shift(@_));
    103 }
    104 
    10557sub gsprintf
    10658{
    10759    return &gsprintf::gsprintf(@_);
    10860}
     61
    10962
    11063#sub print_usage {
     
    12477
    12578    my $xml = 0;
    126    
    127     if (!parsargv::parse(\@ARGV,
     79
     80    if (!parsargv::parse(\@ARGV,
     81             'language/.*/', \$language,
    12882             'out/.*/STDERR', \$out,
    12983             'cdname/.*/', \$cdname,
    13084             q^xml^, \$xml)) {
    131    
    132     &print_txt_usage();
     85
     86    &PrintUsage::print_txt_usage($language, $options, "{exportcol.params}");
    13387    die "\n";
    13488    }
    13589
    13690    if ($xml) {
    137         &print_xml_usage($language);
    138     die "\n";
    139     }
    140    
     91        &PrintUsage::print_xml_usage($language, $options);
     92    die "\n";
     93    }
     94
    14195    my $dirname="";
    14296    if ($cdname eq "") {
     
    152106
    153107    if (not @coll_list) { # empty list
    154     &print_txt_usage();
     108    &PrintUsage::print_txt_usage($language, $options, "{exportcol.params}");
    155109    exit(1);
    156110    }
    157    
     111
    158112    my $close_out = 0;
    159113    if ($out !~ /^(STDERR|STDOUT)$/i) {
    160114    open (OUT, ">$out") ||
    161         die &lookup_string("{common.cannot_open_output_file}") . " $out\n";
     115        (&gsprintf(STDERR, "{common.cannot_open_output_file}\n", $out) && die);
    162116    $out = OUT;
    163117    $close_out = 1;
     
    176130    if ((!-d $colindexdir) || (!-d $coletcdir)) {
    177131        &gsprintf($out, "{exportcol.coll_dirs_not_found}\n", $c);
    178         print $out "  $colindexdir\n";
    179         print $out "  $coletcdir\n";
     132        &gsprintf($out, "  $colindexdir\n");
     133        &gsprintf($out, "  $coletcdir\n");
    180134        next;
    181135    }
    182136    # the collection seems ok, we add it to the valid coll list
    183137    push @valid_coll_list, $c;
    184    
    185138    }
    186139
    187140    if (not @valid_coll_list) {
    188141    # no valid colls left
    189     &gsprintf($out, "{exportcol.fail}");
    190     &gsprintf($out, "{exportcol.no_valid_colls}\n");
     142    &gsprintf($out, "{exportcol.fail} {exportcol.no_valid_colls}\n");
    191143    die "\n";
    192144    }
     
    196148    &util::mk_all_dir ($topdir);
    197149    if (!-d $topdir) {
    198     &gsprintf($out, "{exportcol.fail}");
    199     &gsprintf($out, "{exportcol.couldnt_create_dir}\n", $topdir);
     150    &gsprintf($out, "{exportcol.fail} {exportcol.couldnt_create_dir}\n", $topdir);
    200151    die "\n";
    201152    }
     
    215166    my $installcfg = &util::filename_cat ($topdir, "install.cfg");
    216167    if (!open (INSTALLCFG, ">$installcfg")) {
    217     &gsprintf($out, "{exportcol.fail}");
    218     &gsprintf($out, "{exportcol.couldnt_create_file}\n", $installcfg );
     168    &gsprintf($out, "{exportcol.fail} {exportcol.couldnt_create_file}\n", $installcfg);
    219169    die "\n";
    220170    }
     
    230180    my $manifestcfg = &util::filename_cat ($topdir, "manifest.cfg");
    231181    if (!open (MANIFESTCFG, ">$manifestcfg")) {
    232     &gsprintf($out, "{exportcol.fail}");
    233     &gsprintf($out, "{exportcol.couldnt_create_file}\n", $manifestcfg );
     182    &gsprintf($out, "{exportcol.fail} {exportcol.couldnt_create_file}\n", $manifestcfg);
    234183    die "\n";
    235184    }
     
    251200    my $autoruninf = &util::filename_cat ($topdir, "Autorun.inf");
    252201    if (!open (AUTORUNINF, ">$autoruninf")) {
    253     &gsprintf($out, "{exportcol.fail}");
    254     &gsprintf($out, "{exportcol.couldnt_create_file}\n", $autoruninf );
    255     die "\n";
    256     }
    257    
     202    &gsprintf($out, "{exportcol.fail} {exportcol.couldnt_create_file}\n", $autoruninf);
     203    die "\n";
     204    }
     205
    258206    print AUTORUNINF "[autorun]\n";
    259207    print AUTORUNINF "OPEN=Setup.exe\n";
    260208    close AUTORUNINF;
    261    
     209
    262210    # copy the necessary stuff from GSDLHOME
    263211    my $imagesdir = &util::filename_cat ($ENV{'GSDLHOME'}, "images");
     
    279227    (!-d $net16dir) || (!-d $netscapedir) || (!-d $win32sdir) || (!-e $phindjar) ||
    280228    (!-e $gsdlcollageappletjar)) {
    281     &gsprintf($out, "{exportcol.fail}");
    282     &gsprintf($out, "{exportcol.non_exist_files}\n");
    283     print $out "  $imagesdir\n";
    284     print $out "  $macrosdir\n";
    285     print $out "  $mappingsdir\n";
    286     print $out "  $maincfg\n";
    287     print $out "  $serverexe\n";
    288     print $out "  $gssetupexe\n";
    289     print $out "  $setupexe\n";
    290     print $out "  $net32dir\n";
    291     print $out "  $net16dir\n";
    292     print $out "  $netscapedir\n";
    293     print $out "  $win32sdir\n";
    294     print $out "  $phindjar\n";
    295     print $out "  $gsdlcollageappletjar\n";
     229    &gsprintf($out, "{exportcol.fail} {exportcol.non_exist_files}\n");
     230    &gsprintf($out, "  $imagesdir\n");
     231    &gsprintf($out, "  $macrosdir\n");
     232    &gsprintf($out, "  $mappingsdir\n");
     233    &gsprintf($out, "  $maincfg\n");
     234    &gsprintf($out, "  $serverexe\n");
     235    &gsprintf($out, "  $gssetupexe\n");
     236    &gsprintf($out, "  $setupexe\n");
     237    &gsprintf($out, "  $net32dir\n");
     238    &gsprintf($out, "  $net16dir\n");
     239    &gsprintf($out, "  $netscapedir\n");
     240    &gsprintf($out, "  $win32sdir\n");
     241    &gsprintf($out, "  $phindjar\n");
     242    &gsprintf($out, "  $gsdlcollageappletjar\n");
    296243    die "\n";
    297244    }
     
    335282    &util::cp_r ($colimagesdir, $newcoldir) if (-e $colimagesdir);
    336283
    337     # now we need to check the collect.cfg file to make sure its public
     284    # now we need to check the collect.cfg file to make sure it's public
    338285    my $collectcfg = &util::filename_cat ($newcoldir, "etc", "collect.cfg");
    339286    open INFILE, "<$collectcfg";
     
    356303    }
    357304    &gsprintf($out, "{exportcol.success}");
     305
    358306    my $successcolls = "";
    359307    my $first = 1;
     
    365313    }
    366314    $successcolls .= "$c";
    367    
    368315    }
    369316
  • trunk/gsdl/bin/script/import.pl

    r6775 r6921  
    6666my $arguments =
    6767    [ { 'name' => "archivedir",
    68     'desc' => "{import.achivedir}",
     68    'desc' => "{import.archivedir}",
    6969    'type' => "string",
    7070    'reqd' => "no",
     
    159159        'args' => $arguments };
    160160
    161 
    162 sub print_xml_usage
     161sub gsprintf
    163162{
    164     local $language = shift(@_);
    165 
    166     &PrintUsage::print_xml_header();
    167 
    168     print STDERR "<Info>\n";
    169     print STDERR "  <Name>$options->{'name'}</Name>\n";
    170     print STDERR "  <Desc>" . &lookup_string($options->{'desc'}) . "</Desc>\n";
    171     print STDERR "  <Arguments>\n";
    172     if (defined($options->{'args'})) {
    173     &PrintUsage::print_options_xml($language, $options->{'args'});
    174     }
    175     print STDERR "  </Arguments>\n";
    176     print STDERR "</Info>\n";
    177 }
    178 
    179 
    180 sub print_txt_usage
    181 {
    182     local $language = shift(@_);
    183 
    184     local $programname = $options->{'name'};
    185     local $programargs = $options->{'args'};
    186 
    187     # Find the length of the longest option string
    188     local $descoffset = 0;
    189     if (defined($programargs)) {
    190     $descoffset = &PrintUsage::find_longest_option_string($programargs);
    191     }
    192 
    193     # Produce the usage information using the data structure above
    194     print STDERR " " . &lookup_string("{common.usage}") . ": $programname";
    195     print STDERR " " . &lookup_string("{import.params}") . "\n\n";
    196 
    197     # Display the program options, if there are some
    198     if (defined($programargs)) {
    199     # Calculate the column offset of the option descriptions
    200     local $optiondescoffset = $descoffset + 2;  # 2 spaces between options & descriptions
    201 
    202     print STDERR " " . &lookup_string("{common.options}") . ":\n";
    203 
    204     # Display the program options
    205     &PrintUsage::print_options_txt($language, $programargs, $optiondescoffset);
    206     }
    207 }
    208 
    209 
    210 sub lookup_string
    211 {
    212     return &gsprintf::lookup_string($language, shift(@_));
     163    return &gsprintf::gsprintf(@_);
    213164}
    214165
     
    293244             'gli', \$gli,
    294245             q^xml^, \$xml)) {
    295     &print_txt_usage($language);
     246    &PrintUsage::print_txt_usage($language, $options, "{import.params}");
    296247    die "\n";
    297248    }
    298249
    299250    if ($xml) {
    300         &print_xml_usage($language);
     251        &PrintUsage::print_xml_usage($language, $options);
    301252    die "\n";
    302253    }
     
    305256    if ($out !~ /^(STDERR|STDOUT)$/i) {
    306257    open (OUT, ">$out") ||
    307         die &lookup_string("{common.cannot_open_output_file}") . " $out\n";
     258        (&gsprintf(STDERR, "{common.cannot_open_output_file}\n", $out) && die);
    308259    $out = 'import::OUT';
    309260    $close_out = 1;
     
    316267    # get and check the collection name
    317268    if (($collection = &util::use_collection(@ARGV, $collectdir)) eq "") {
    318     &print_txt_usage($language);
     269    &PrintUsage::print_txt_usage($language, $options, "{import.params}");
    319270    die "\n";
    320271    }
     
    324275    }
    325276    open (FAILLOG, ">$faillog") ||
    326     die &lookup_string("{import.cannot_open_fail_log}") . " $faillog\n";
     277    (&gsprintf(STDERR, "{import.cannot_open_fail_log}\n", $faillog) && die);
    327278    my $faillogname = $faillog;
    328279    $faillog = 'import::FAILLOG';
     
    332283    $sortmeta = undef unless defined $sortmeta && $sortmeta =~ /\S/;
    333284    if (defined $sortmeta && $groupsize > 1) {
    334     print $out &lookup_string("{import.cannot_sort}") . "\n\n";
     285    &gsprintf($out, "{import.cannot_sort}\n\n");
    335286    $sortmeta = undef;
    336287    }
     
    424375
    425376    } else {
    426     die &lookup_string("{common.cannot_find_cfg_file}") . " $configfilename\n";
     377    (&gsprintf($out, "{common.cannot_find_cfg_file}\n", $configfilename) && die);
    427378    }
    428379
     
    443394    $pluginfo = &plugin::load_plugins ($plugins, $verbosity, $out, $faillog, \@global_opts);
    444395    if (scalar(@$pluginfo) == 0) {
    445     print $out &lookup_string("{import.no_plugins_loaded}") . "\n";
     396    &gsprintf($out, "{import.no_plugins_loaded}\n");
    446397    die "\n";
    447398    }
     
    449400    # remove the old contents of the archives directory if needed
    450401    if ($removeold && -e $archivedir) {
    451     print $out &lookup_string("{import.removing_archives}") . "\n";
     402    &gsprintf($out, "{import.removing_archives}\n");
    452403    sleep(3); # just in case...
    453404    &util::rm_r ($archivedir);
    454405    }
    455    
     406
    456407    # read the archive information file
    457408    if (!$debug) {
     
    489440        $close_stats = 1;
    490441    } else {
    491         print $out &lookup_string("{import.cannot_open_stats_file}") . " $statsfile.";
    492         print $out &lookup_string("{import.stats_backup}") . "\n";
     442        &gsprintf($out, "{import.cannot_open_stats_file}", $statsfile);
     443        &gsprintf($out, "{import.stats_backup}\n");
    493444        $statsfile = 'STDERR';
    494445    }
    495446    }
    496447
    497     print $out "\n";
    498     print $out "*********************************************\n";
    499     print $out &lookup_string("{import.complete}") . "\n";
    500     print $out "*********************************************\n";
     448    &gsprintf($out, "\n");
     449    &gsprintf($out, "*********************************************\n");
     450    &gsprintf($out, "{import.complete}\n");
     451    &gsprintf($out, "*********************************************\n");
    501452
    502453    &plugin::write_stats($pluginfo, $statsfile, $faillogname, $gli);
  • trunk/gsdl/bin/script/mkcol.pl

    r6108 r6921  
    9393        'args' => $arguments };
    9494
    95 
    96 sub print_xml_usage
     95sub gsprintf
    9796{
    98     local $language = shift(@_);
    99 
    100     &PrintUsage::print_xml_header();
    101 
    102     print STDERR "<Info>\n";
    103     print STDERR "  <Name>$options->{'name'}</Name>\n";
    104     print STDERR "  <Desc>" . &lookup_string($options->{'desc'}) . "</Desc>\n";
    105     print STDERR "  <Arguments>\n";
    106     if (defined($options->{'args'})) {
    107     &PrintUsage::print_options_xml($language, $options->{'args'});
    108     }
    109     print STDERR "  </Arguments>\n";
    110     print STDERR "</Info>\n";
    111 }
    112 
    113 
    114 sub print_txt_usage
    115 {
    116     local $language = shift(@_);
    117 
    118     local $programname = $options->{'name'};
    119     local $programargs = $options->{'args'};
    120 
    121     # Find the length of the longest option string
    122     local $descoffset = 0;
    123     if (defined($programargs)) {
    124     $descoffset = &PrintUsage::find_longest_option_string($programargs);
    125     }
    126 
    127     # Produce the usage information using the data structure above
    128     print STDERR " " . &lookup_string("{common.usage}") . ": $programname";
    129     print STDERR " " . &lookup_string("{mkcol.params}") . "\n\n";
    130 
    131     # Display the program options, if there are some
    132     if (defined($programargs)) {
    133     # Calculate the column offset of the option descriptions
    134     local $optiondescoffset = $descoffset + 2;  # 2 spaces between options & descriptions
    135 
    136     print STDERR " " . &lookup_string("{common.options}") . ":\n";
    137 
    138     # Display the program options
    139     &PrintUsage::print_options_txt($language, $programargs, $optiondescoffset);
    140     }
    141 }
    142 
    143 
    144 sub lookup_string
    145 {
    146     return &gsprintf::lookup_string($language, shift(@_));
     97    return &gsprintf::gsprintf(@_);
    14798}
    14899
     
    191142    }
    192143
    193     opendir(DIR, $modeldir)
    194     || die &lookup_string("{common.cannot_read}") . " $modeldir";
     144    opendir(DIR, $modeldir) ||
     145    (&gsprintf(STDERR, "{common.cannot_read}\n", $modeldir) && die);
    195146    my @files = grep(!/^(\.\.?|CVS)$/, readdir(DIR));
    196147    closedir(DIR);
     
    207158        $destfile =~ s/^modelcol/$collection/;
    208159        $destfile =~ s/^MODELCOL/$capcollection/;
    209         print STDOUT "  " . &lookup_string("{mkcol.doing_replacements}") . " $destfile\n"
     160        &gsprintf(STDOUT, "{mkcol.doing_replacements}\n", $destfile)
    210161        unless $quiet;
    211162        $destfile = &util::filename_cat ($coldir, $destfile);
    212163
    213164        open (INFILE, $thisfile) ||
    214         die &lookup_string("{common.cannot_read_file}") . " $thisfile";
     165        (&gsprintf(STDERR, "{common.cannot_read_file}\n", $thisfile) && die);
    215166        open (OUTFILE, ">$destfile") ||
    216         die &lookup_string("{common.cannot_create_file}") . " $destfile";
     167        (&gsprintf(STDERR, "{common.cannot_create_file}\n", $destfile) && die);
    217168
    218169        while (defined ($line = <INFILE>)) {
     
    251202              q^xml^, \$xml
    252203              )) {
    253     &print_txt_usage($language);
     204    &PrintUsage::print_txt_usage($language, $options, "{mkcol.params}");
    254205    die "\n";
    255206    }
     
    261212
    262213    if ($xml) {
    263     &print_xml_usage($language);
     214    &PrintUsage::print_xml_usage($language, $options);
    264215    die "\n";
    265216    }
     
    267218    if ($optionfile =~ /\w/) {
    268219    open (OPTIONS, $optionfile) ||
    269         die &lookup_string("{common.cannot_open}") . " $optionfile\n";
     220        (&gsprintf(STDERR, "{common.cannot_open}\n", $optionfile) && die);
    270221    my $line = [];
    271222    my $options = [];
     
    286237    ($collection) = @ARGV;
    287238    if (!defined($collection)) {
    288     print STDOUT &lookup_string("{mkcol.no_colname}") . "\n";
    289     &print_txt_usage($language);
     239    &gsprintf(STDOUT, "{mkcol.no_colname}\n");
     240    &PrintUsage::print_txt_usage($language, $options, "{mkcol.params}");
    290241    die "\n";
    291242    }
    292243
    293244    if (length($collection) > 8) {
    294     print STDOUT &lookup_string("{mkcol.long_colname}") . "\n";
     245    &gsprintf(STDOUT, "{mkcol.long_colname}\n");
    295246    die "\n";
    296247    }
    297248
    298249    if ($collection eq "modelcol") {
    299     print STDOUT &lookup_string("{mkcol.bad_name_modelcol}") . "\n";
     250    &gsprintf(STDOUT, "{mkcol.bad_name_modelcol}\n");
    300251    die "\n";
    301252    }
    302253
    303254    if ($collection eq "CVS") {
    304     print STDOUT &lookup_string("{mkcol.bad_name_cvs}") . "\n";
     255    &gsprintf(STDOUT, "{mkcol.bad_name_cvs}\n");
    305256    die "\n";
    306257    }
     
    308259    # We don't want creator to be required anymore - John Thompson 28-11-2003
    309260    #if (!defined($creator) || $creator eq "") {
    310     #   print STDOUT &lookup_string("{mkcol.creator_undefined}") . "\n";
     261    #   &gsprintf(STDOUT, "{mkcol.creator_undefined}\n");
    311262    #   die "\n";
    312263    #}
     
    336287    if (defined $collectdir && $collectdir =~ /\w/) {
    337288    if (!-d $collectdir) {
    338         print STDOUT &lookup_string("{mkcol.no_collectdir}") . ": $collectdir\n";
     289        &gsprintf(STDOUT, "{mkcol.no_collectdir}\n", $collectdir);
    339290        die "\n";
    340291    }
     
    345296
    346297    # make sure the model collection exists
    347     die &lookup_string("{mkcol.cannot_find_modelcol}") . " $mdir" unless (-d $mdir);
     298    (&gsprintf(STDERR, "{mkcol.cannot_find_modelcol}\n", $mdir) && die) unless (-d $mdir);
    348299
    349300    # make sure this collection does not already exist
    350301    if (-e $cdir) {
    351     print STDOUT &lookup_string("{mkcol.col_already_exists}") . "\n";
     302    &gsprintf(STDOUT, "{mkcol.col_already_exists}\n");
    352303    die "\n";
    353304    }
    354305
    355306    # start creating the collection
    356     print STDOUT "\n" . &lookup_string("{mkcol.creating_col}") . " $collection...\n"
     307    &gsprintf(STDOUT, "\n{mkcol.creating_col}...\n", $collection)
    357308    unless $quiet;
    358309    &traverse_dir ($mdir, $cdir);
    359     print STDOUT "\n" . &lookup_string("{mkcol.success}") . "\n$cdir\n"
     310    &gsprintf(STDOUT, "\n{mkcol.success}\n", $cdir)
    360311    unless $quiet;
    361312}
  • trunk/gsdl/bin/script/pluginfo.pl

    r5882 r6921  
    6363        'args' => $arguments };
    6464
    65 
    66 sub lookup_string
     65sub gsprintf
    6766{
    68     return &gsprintf::lookup_string($language, shift(@_));
     67    return &gsprintf::gsprintf(@_);
    6968}
    70 
    71 
    72 sub print_txt_usage
    73 {
    74     local $language = shift(@_);
    75 
    76     local $programname = $options->{'name'};
    77     local $programargs = $options->{'args'};
    78 
    79     # Find the length of the longest option string
    80     local $descoffset = 0;
    81     if (defined($programargs)) {
    82     $descoffset = &PrintUsage::find_longest_option_string($programargs);
    83     }
    84 
    85     # Produce the usage information using the data structure above
    86     print STDERR $programname . ": " . &lookup_string($options->{'desc'}) . "\n\n";
    87     print STDERR " " . &lookup_string("{common.usage}") . ": $programname";
    88     print STDERR " " . &lookup_string("{pluginfo.params}") . "\n\n";
    89 
    90     # Display the program options, if there are some
    91     if (defined($programargs)) {
    92     # Calculate the column offset of the option descriptions
    93     local $optiondescoffset = $descoffset + 2;  # 2 spaces between options & descriptions
    94 
    95     print STDERR " " . &lookup_string("{common.options}") . ":\n";
    96 
    97     # Display the program options
    98     &PrintUsage::print_options_txt($language, $programargs, $optiondescoffset);
    99     }
    100 }
    101 
    10269
    10370
     
    11279             q^language/.*/^, \$language))
    11380    {
    114     &print_txt_usage($language);
     81    &PrintUsage::print_txt_usage($language, $options, "{pluginfo.params}", 1);
    11582    die "\n";
    11683    }
     
    11885    my $plugin = shift (@ARGV);
    11986    if (!defined $plugin || $plugin eq "") {
    120     print STDERR &lookup_string("{pluginfo.no_plugin_name}") . "\n\n";
    121     &print_txt_usage($language);
     87    &gsprintf(STDERR, "{pluginfo.no_plugin_name}\n\n");
     88    &PrintUsage::print_txt_usage($language, $options, "{pluginfo.params}", 1);
    12289    die "\n";
    12390    }
     
    136103    }
    137104    else {
    138     print STDERR "\n$plugin " . &lookup_string("{pluginfo.info}") . ":\n\n";
    139     print STDERR &lookup_string("{pluginfo.passing_options}") . "\n\n";
    140     print STDERR &lookup_string("{pluginfo.option_types}") . ":\n\n";
    141     print STDERR &lookup_string("{pluginfo.specific_options}") . "\n\n";
    142     print STDERR &lookup_string("{pluginfo.general_options}") . "\n\n";
     105    &gsprintf(STDERR, "\n$plugin {pluginfo.info}:\n\n");
     106    &gsprintf(STDERR, "{pluginfo.passing_options}\n\n");
     107    &gsprintf(STDERR, "{pluginfo.option_types}:\n\n");
     108    &gsprintf(STDERR, "{pluginfo.specific_options}\n\n");
     109    &gsprintf(STDERR, "{pluginfo.general_options}\n\n");
    143110
    144111    $plugobj->print_txt_usage($language);
     
    155122    $pid = open(STDIN, "-|"); # this does a fork... see man perlipc(1)
    156123    if (!defined $pid) {
    157     print STDERR "pluginfo.pl - can't fork: $!";
     124    &gsprintf(STDERR, "pluginfo.pl - can't fork: $!");
    158125    } else {
    159126    if ($pid != 0) { # parent (ie forking) process. child gets 0
Note: See TracChangeset for help on using the changeset viewer.