Changeset 32305


Ignore:
Timestamp:
2018-07-27T18:31:59+12:00 (6 years ago)
Author:
ak19
Message:
  1. When a plugin's built on multiple inheritance, the first n-1 internal plugins before merging must allow extra args so that parsing does not fail: need to pass 1 (for true) to the constructors of the first n-1 internal plugins to allow extra args. Correcting both the recent PDFv2Plugin, where Renate had found a bug and Kathy had pointed out this fix, and the earlier UnknownConverterPlugin where I didn't know to add this parameter either. 2. Dr Bainbridge explained why UnknownConverterPlugin's convert_to option need not be manually defined when it was unexpectedly undefined: it being undefined only caused warnings when running pluginfo, and the actual solution was to return sooner from the constructor when in info_only (pluginfo) mode.
Location:
main/trunk/greenstone2/perllib/plugins
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/plugins/PDFv2Plugin.pm

    r32303 r32305  
    3131no strict 'subs'; # allow filehandles to be variables and viceversa
    3232
     33use ConvertBinaryFile;
     34use PDFBoxConverter;
    3335use ReadTextFile;
     36
    3437use unicode;
    3538use Mojo::DOM; # for HTML parsing
    3639
    37 use PDFBoxConverter;
    38 use ConvertBinaryFile;
    3940
    4041@PDFv2Plugin::ISA = ('ConvertBinaryFile', 'PDFBoxConverter', 'ReadTextFile');
     
    124125    push(@{$hashArgOptLists->{"OptList"}},$options);
    125126
    126     my $pdfbox_converter_self = new PDFBoxConverter($pluginlist, $inputargs, $hashArgOptLists);
     127    # the 1 at the end of the first constructor call is to allow extra arguments to remain after
     128    # parsing. There should be no extra args after the final constructor call, because all args
     129    # should have been parsed by then, so don't pass 1 to the last constructor.
     130    my $pdfbox_converter_self = new PDFBoxConverter($pluginlist, $inputargs, $hashArgOptLists, 1);
    127131    my $cbf_self = new ConvertBinaryFile($pluginlist, $inputargs, $hashArgOptLists);
    128132    my $self = BaseImporter::merge_inheritance($pdfbox_converter_self, $cbf_self); # this param order seems necessary to preserve the default/user-selected value for the convert_to option
  • main/trunk/greenstone2/perllib/plugins/UnknownConverterPlugin.pm

    r32028 r32305  
    9595    push(@{$hashArgOptLists->{"OptList"}},$options);
    9696
    97     my $unknown_converter_self = new UnknownPlugin($pluginlist, $inputargs, $hashArgOptLists);
     97    my $unknown_converter_self = new UnknownPlugin($pluginlist, $inputargs, $hashArgOptLists, 1);
    9898    my $cbf_self = new ConvertBinaryFile($pluginlist, $inputargs, $hashArgOptLists);
    9999   
     
    104104    $self = bless $self, $class;
    105105
    106 my $outhandle = $self->{'outhandle'};
    107     if(!defined $self->{'convert_to'}) {
    108     $self->{'convert_to'} = "text"; # why do I have to set a value for convert_to here, when a default's already set in $convert_to_list declaration????
    109     }
    110     #print STDERR "\n\n**** convert_to is |" . $self->{'convert_to'} . "|\n\n";
     106    if ($self->{'info_only'}) {
     107
     108    # If running pluginfo, we don't need to go further. Copied from other plugins like PDFPlug
     109    # Returning here when running pluginfo also means that it doesn't matter that convert_to
     110    # is not yet set to its default value at this stage: no warnings at gli start (when pluginfo
     111    # is run) about convert_to being undefined 
     112   
     113    # don't worry about any options etc
     114    return $self;
     115    }
     116   
     117    my $outhandle = $self->{'outhandle'};
    111118
    112119    # Convert_To set up, including secondary_plugins for processing the text or html generated
Note: See TracChangeset for help on using the changeset viewer.