Ignore:
Timestamp:
2005-07-06T15:27:45+12:00 (19 years ago)
Author:
kjdon
Message:

Jeffrey's new parsing modifications, committed approx 6 July, 15.16

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/classify/BasClas.pm

    r8852 r10218  
    5656use gsprintf;
    5757use printusage;
    58 
     58use parse2;
    5959
    6060my $arguments =
     
    6767    'type' => "string",
    6868    'deft' => "STDERR" },
    69 #      { 'name' => "verbosity",
    70 #   'desc' => "{BasClas.verbosity}",
     69      { 'name' => "verbosity",
     70    'desc' => "{BasClas.verbosity}",
    7171#   'type' => "enum",
    72 #   'deft' => "2",
    73 #   'reqd' => "no" } ];
     72    'type' => "int",
     73    'deft' => "2",
     74    'reqd' => "no" },
    7475#      { 'name' => "ignore_namespace",
    7576#   'desc' => "{BasClas.ignore_namespace}",
     
    214215
    215216sub new {
    216     my $class = shift (@_);
    217     my $name = shift (@_);
    218 
     217    my ($class) = shift (@_);
     218    my ($classifierslist,$args,,$hashArgOptLists) = @_;
     219    push(@$classifierslist, $class);
     220    my $classifier_name = (defined $classifierslist->[0]) ? $classifierslist->[0] : $class;
     221    print STDERR "new $classifier_name\n";
     222    if(defined $arguments){ push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});}
     223    if(defined $options) { push(@{$hashArgOptLists->{"OptList"}},$options)};
     224
     225
     226    # Manually set $self parameters.
    219227    my $self = {};
    220 
    221228    $self->{'outhandle'} = STDERR;
    222229    $self->{'idnum'} = -1;
    223    
    224     $self->{'option_list'} = [ $options ];
    225     my $gsdlinfo;
    226 
    227     # general options available to all classifiers
    228     if (!parsargv::parse(\@_,
    229              q^builddir/.*/^, \$self->{'builddir'},
    230              q^outhandle/.*/STDERR^, \$self->{'outhandle'},
    231              q^verbosity/\d/2^, \$self->{'verbosity'},
    232              q^ignore_namespace^, \$self->{'ignore_namespace'},
    233              q^gsdlinfo^, \$gsdlinfo,
    234              "allow_extra_options")) {
    235 
    236     &gsprintf(STDERR, "\n{BasClas.bad_general_option}\n", $name);
    237     $self->print_txt_usage("");  # Use default resource bundle
    238     die "\n";
    239     }
    240 
    241     if ($gsdlinfo) {
    242     # created from classinfo.pl - set this so subclasses don't need to
    243     # parse the arguments
    244     $self->{'info_only'} = 1;
    245     }
    246     return bless $self, $class;
     230    $self->{'option_list'} = $hashArgOptLists->{"OptList"};
     231    $self->{"info_only"} = 0;
     232
     233    # Check if gsdlinfo is in the argument list or not. 
     234    foreach $strArg (@{$args})
     235    {
     236    if($strArg eq "gsdlinfo")
     237    {
     238        $self->{"info_only"} = 1;
     239        last;
     240    }
     241    }
     242
     243    # If gsdlinfo is not in the argument list, process the argument normally.
     244    if($self->{"info_only"} == 0)
     245    {
     246    my $blnParseFailed = "false";
     247    # general options available to all plugins
     248    if(!parse2::parse($args,$hashArgOptLists->{"ArgList"},$self))
     249    {
     250        $blnParseFailed = "true";
     251    }
     252   
     253    # If the parsing wasn't successful, then print out the text usage of this classifier.
     254    my $classTempClass = bless $self, $class;
     255    if($blnParseFailed eq "true")
     256    {
     257        &gsprintf(STDERR, "\n{BasClas.bad_general_option}\n", $classifier_name);
     258        $classTempClass->print_txt_usage("");  # Use default resource bundle
     259        die "\n";
     260    }
     261    else
     262    {
     263        delete $self->{"info_only"};
     264        return $classTempClass;
     265    }
     266    }
     267
     268    # If gsdlinfo is in the argument list, do not perform any parsing.
     269    else
     270    {   
     271    delete $self->{"info_only"};
     272    return bless $self, $class;
     273    }
    247274}
    248275
Note: See TracChangeset for help on using the changeset viewer.