Changeset 12629


Ignore:
Timestamp:
2006-08-31T14:08:40+12:00 (18 years ago)
Author:
mdewsnip
Message:

Merged the "-listall" and "-describeall" code, and made both always produce XML. The format of the XML has changed slightly too.

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

Legend:

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

    r12625 r12629  
    140140    }
    141141 
    142     if ($listall) {
    143     my $class_dir = &util::filename_cat($ENV{'GSDLCOLLECTDIR'},"perllib","classify");
     142    if ($listall || $describeall) {
     143    my $class_dir = &util::filename_cat($ENV{'GSDLCOLLECTDIR'}, "perllib", "classify");
    144144    if (!opendir (INDIR, $class_dir)) {
    145145        print STDERR "classinfo.pl: could not open directory $class_dir\n";
    146146    }
    147147    else {
    148         my @class_list = grep (/\.pm$/, readdir (INDIR));
     148        my @classifier_list = grep (/\.pm$/, readdir (INDIR));
    149149        closedir (INDIR);
    150150
    151         if ($xml) {
    152         my $num_class = scalar(@class_list);
    153 
    154         print STDERR "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
    155         print STDERR "<ClassifyList length=\"$num_class\">\n";
    156         map { print STDERR "  <ClassifyName>$_</ClassifyName>\n"; } @class_list;
    157         print STDERR "</ClassifyList>\n";
     151        print STDERR "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
     152        print STDERR "<ClassifyList length=\"" . scalar(@classifier_list) . "\">\n";
     153        foreach my $classifier (@classifier_list) {
     154        $classifier =~ s/\.pm$//;
     155        my $classifierobj = &classify::load_classifier_for_info ($classifier);
     156        if ($describeall) {
     157            $classifierobj->print_xml_usage(0);
     158        }
     159        else {
     160            $classifierobj->print_xml_usage(0, 1);
     161        }
    158162        }
    159         else {
    160         print STDERR join(" ",@class_list), "\n";
    161         }
    162     }
    163     }
    164     elsif ($describeall) {
    165     my $class_dir = &util::filename_cat($ENV{'GSDLCOLLECTDIR'},"perllib","classify");
    166     my @class_list;
    167     if (!opendir (INDIR, $class_dir)) {
    168         print STDERR "classinfo.pl: could not open directory $class_dir\n";
    169     }
    170     else {
    171         @class_list = grep (/\.pm$/, readdir (INDIR));
    172         closedir (INDIR);
    173     }
    174     if ($xml) {
    175         my $num_class = scalar(@class_list);
    176         &PrintUsage::print_xml_header("classify", 1);
    177         print STDERR "<ClassInfoList length=\"$num_class\">\n";
    178     }
    179     foreach my $cl (@class_list) {
    180         $cl =~ s/\.pm$//;
    181         &print_single_classifier($cl, $xml, 0);
    182     }
    183     if ($xml) {
    184         print STDERR "</ClassInfoList>\n";
     163        print STDERR "</ClassifyList>\n";
    185164    }
    186165    }
     
    189168    }
    190169}
     170
    191171
    192172sub print_single_classifier {
  • trunk/gsdl/bin/script/downloadinfo.pl

    r12625 r12629  
    158158    }
    159159
    160     if ($listall) {
    161     my $download_dir = &util::filename_cat($ENV{'GSDLCOLLECTDIR'},"perllib","downloaders");
     160    if ($listall || $describeall) {
     161    my $download_dir = &util::filename_cat($ENV{'GSDLCOLLECTDIR'}, "perllib", "downloaders");
    162162    if (!opendir (INDIR, $download_dir)) {
    163163        print STDERR "downloadinfo.pl: could not open directory $download_dir\n";
    164164    }
    165165    else {
    166         my @download_list = grep (/Download\.pm$/, readdir (INDIR));
     166        my @downloader_list = grep (/Download\.pm$/, readdir (INDIR));
    167167        closedir (INDIR);
    168        
    169         if ($xml) {
    170         my $intNumDownloads = scalar(@download_list);
    171        
    172         print STDERR "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
    173         print STDERR "<DownloadList length=\"$intNumDownloads\">\n";
    174         map { print STDERR "  <DownloadName>$_</DownloadName>\n"; } @download_list;
    175         print STDERR "</DownloadList>\n";
     168
     169        print STDERR "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
     170        print STDERR "<DownloadList length=\"" . scalar(@downloader_list) . "\">\n";
     171        foreach my $downloader (@downloader_list) {
     172        $downloader =~ s/\.pm$//;
     173        my $downloaderobj = &download::load_download ($downloader);
     174        if ($describeall) {
     175            $downloaderobj->print_xml_usage(0);
     176        }
     177        else {
     178            $downloaderobj->print_xml_usage(0, 1);
     179        }
    176180        }
    177         else {
    178         print STDERR join(" ",@download_list), "\n";
    179         }
    180     }
    181     }
    182     elsif ($describeall) {
    183     my $download_dir = &util::filename_cat($ENV{'GSDLCOLLECTDIR'},"perllib","downloaders");
    184     my @download_list;
    185     if (!opendir (INDIR, $download_dir)) {
    186         print STDERR "downloadinfo.pl: could not open directory $download_dir\n";
    187     }
    188     else {
    189         @download_list = grep (/Download\.pm$/, readdir (INDIR));
    190         closedir (INDIR);
    191     }
    192     #sort (@download_list);
    193     if ($xml) {
    194         my $num_download = scalar(@download_list);
    195         &PrintUsage::print_xml_header("download", 1);
    196         print STDERR "<DownloadInfoList length=\"$num_download\">\n";
    197     }
    198     foreach my $pl (@download_list) {
    199         $pl =~ s/\.pm$//;
    200         &print_single_download($pl, $xml, 0);
    201     }
    202     if ($xml) {
    203         print STDERR "</DownloadInfoList>\n";
    204     }
    205     }
    206 
     181        print STDERR "</DownloadList>\n";
     182    }
     183    }
    207184    else {
    208185    &print_single_download($download_name, $xml, 1);
    209186    }
    210187}
     188
    211189
    212190sub print_single_download {
  • trunk/gsdl/bin/script/pluginfo.pl

    r12625 r12629  
    160160    }
    161161
    162     if ($listall) {
    163     my $plugin_dir = &util::filename_cat($ENV{'GSDLCOLLECTDIR'},"perllib","plugins");
     162    if ($listall || $describeall) {
     163    my $plugin_dir = &util::filename_cat($ENV{'GSDLCOLLECTDIR'}, "perllib", "plugins");
    164164    if (!opendir (INDIR, $plugin_dir)) {
    165165        print STDERR "pluginfo.pl: could not open directory $plugin_dir\n";
     
    169169        closedir (INDIR);
    170170
    171         if ($xml) {
    172         my $num_plugins = scalar(@plugin_list);
    173 
    174         print STDERR "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
    175         print STDERR "<PluginList length=\"$num_plugins\">\n";
    176         map { print STDERR "  <PluginName>$_</PluginName>\n"; } @plugin_list;
    177         print STDERR "</PluginList>\n";
     171        print STDERR "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
     172        print STDERR "<PluginList length=\"" . scalar(@plugin_list) . "\">\n";
     173        foreach my $plugin (@plugin_list) {
     174        $plugin =~ s/\.pm$//;
     175        my $plugobj = &plugin::load_plugin_for_info ($plugin);
     176        if ($describeall) {
     177            $plugobj->print_xml_usage(0);
     178        }
     179        else {
     180            $plugobj->print_xml_usage(0, 1);
     181        }
    178182        }
    179         else {
    180         print STDERR join(" ",@plugin_list), "\n";
    181         }
    182     }
    183     }
    184     elsif ($describeall) {
    185     my $plugin_dir = &util::filename_cat($ENV{'GSDLCOLLECTDIR'},"perllib","plugins");
    186     my @plugin_list;
    187     if (!opendir (INDIR, $plugin_dir)) {
    188         print STDERR "pluginfo.pl: could not open directory $plugin_dir\n";
    189     }
    190     else {
    191         @plugin_list = grep (/Plug\.pm$/, readdir (INDIR));
    192         closedir (INDIR);
    193     }
    194     #sort (@plugin_list);
    195     if ($xml) {
    196         my $num_plugin = scalar(@plugin_list);
    197         &PrintUsage::print_xml_header("plugin", 1);
    198         print STDERR "<PlugInfoList length=\"$num_plugin\">\n";
    199     }
    200     foreach my $pl (@plugin_list) {
    201         $pl =~ s/\.pm$//;
    202         &print_single_plugin($pl, $xml, 0);
    203     }
    204     if ($xml) {
    205         print STDERR "</PlugInfoList>\n";
     183        print STDERR "</PluginList>\n";
    206184    }
    207185    }
     
    210188    }
    211189}
     190
    212191
    213192sub print_single_plugin {
  • trunk/gsdl/bin/script/plugoutinfo.pl

    r12625 r12629  
    162162    }
    163163
    164     if ($listall) {
    165     my $plugout_dir = &util::filename_cat($ENV{'GSDLCOLLECTDIR'},"perllib","plugouts");
     164    if ($listall || $describeall) {
     165    my $plugout_dir = &util::filename_cat($ENV{'GSDLCOLLECTDIR'}, "perllib", "plugouts");
    166166    if (!opendir (INDIR, $plugout_dir)) {
    167167        print STDERR "plugoutinfo.pl: could not open directory $plugout_dir\n";
     
    171171        closedir (INDIR);
    172172
    173         if ($xml) {
    174         my $num_plugouts = scalar(@plugout_list);
    175 
    176         print STDERR "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
    177         print STDERR "<PlugoutList length=\"$num_plugouts\">\n";
    178         map { print STDERR "  <PlugoutName>$_</PlugoutName>\n"; } @plugout_list;
    179         print STDERR "</PlugoutList>\n";
     173        print STDERR "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
     174        print STDERR "<PlugoutList length=\"" . scalar(@plugout_list) . "\">\n";
     175        foreach my $plugout (@plugout_list) {
     176        $plugout =~ s/\.pm$//;
     177        my $plugoutobj = &plugout::load_plugout ($plugout);
     178        if ($describeall) {
     179            $plugoutobj->print_xml_usage(0);
     180        }
     181        else {
     182            $plugoutobj->print_xml_usage(0, 1);
     183        }
    180184        }
    181         else {
    182         print STDERR join(" ",@plugout_list), "\n";
    183         }
    184     }
    185     }
    186     elsif ($describeall) {
    187     my $plugout_dir = &util::filename_cat($ENV{'GSDLCOLLECTDIR'},"perllib","plugouts");
    188     my @plugout_list;
    189     if (!opendir (INDIR, $plugout_dir)) {
    190         print STDERR "plugoutinfo.pl: could not open directory $plugout_dir\n";
    191     }
    192     else {
    193         @plugout_list = grep (/Plugout\.pm$/, readdir (INDIR));
    194         closedir (INDIR);
    195     }
    196     #sort (@plugout_list);
    197     if ($xml) {
    198         my $num_plugout = scalar(@plugout_list);
    199         &PrintUsage::print_xml_header("plugout", 1);
    200         print STDERR "<PlugoutInfoList length=\"$num_plugout\">\n";
    201     }
    202     foreach my $pl (@plugout_list) {
    203         $pl =~ s/\.pm$//;
    204         &print_single_plugout($pl, $xml, 0);
    205     }
    206     if ($xml) {
    207         print STDERR "</PlugoutInfoList>\n";
     185        print STDERR "</PlugoutList>\n";
    208186    }
    209187    }
     
    212190    }
    213191}
     192
    214193
    215194sub print_single_plugout {
Note: See TracChangeset for help on using the changeset viewer.