Changeset 10218 for trunk/gsdl/perllib/plugins/ConvertToPlug.pm
- Timestamp:
- 2005-07-06T15:27:45+12:00 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/perllib/plugins/ConvertToPlug.pm
r9853 r10218 65 65 'desc' => "{ConvertToPlug.use_strings}", 66 66 'type' => "flag", 67 'reqd' => "no" } ]; 67 'reqd' => "no" }, 68 { 'name' => "extract_keyphrases", 69 'desc' => "{BasPlug.extract_keyphrases}", 70 'type' => "flag", 71 'reqd' => "no", 72 'hiddengli' => "yes" }, 73 { 'name' => "extract_keyphrase_options", 74 'desc' => "{BasPlug.extract_keyphrase_options}", 75 'type' => "string", 76 'reqd' => "no", 77 'hiddengli' => "yes" } ]; 68 78 69 79 my $options = { 'name' => "ConvertToPlug", … … 73 83 'args' => $arguments }; 74 84 75 sub parse_args 85 86 sub findType 76 87 { 77 my $class = shift (@_); 78 my ($args) = @_; 79 80 my $plugin_name = $class; 81 $plugin_name =~ s/\.pm$//; 82 83 my $newargs = {}; 84 85 if (!parsargv::parse($args, 86 q^extract_keyphrases^, \$newargs->{'kea'}, #with extra options (undocumented) 87 q^extract_keyphrase_options/.*/^, \$newargs->{'kea_options'}, #no extra options (undocumented) 88 q^convert_to/(html|text)/html^, \$newargs->{'generate_format'}, 89 q^use_strings^, \$newargs->{'use_strings'}, 90 "allow_extra_options")) { 91 92 print STDERR "\nIncorrect options passed to $plugin_name, "; 93 print STDERR "check your collect.cfg configuration file\n"; 94 $self->print_txt_usage(""); # Use default resource bundle 95 die "\n"; 96 } 97 98 return ($plugin_name, $newargs); 88 my ($inputargs) = @_; 89 90 for(my $intCounter = 0; $intCounter < scalar(@{$inputargs}) ; $intCounter++) 91 { 92 if($inputargs->[$intCounter] eq "-convert_to") 93 { 94 if($inputargs->[$intCounter+1] eq "text" || $inputargs->[$intCounter+1] eq "html") 95 { 96 return $inputargs->[$intCounter+1]; 97 } 98 else {return "html";} 99 } 100 } 101 return "html"; 99 102 } 100 103 101 104 sub new { 102 my $class = shift (@_); 103 if ($class eq "ConvertToPlug" && defined $_[0]) {$class = shift (@_);} 104 my $self; 105 # parsargv::parse might modify the list, so we do this by creating a copy 106 # of the argument list. 107 my @arglist = @_; 108 my ($plugin_name, $args) = $class->parse_args(\@_); 109 110 if ($class eq "PDFPlug" && $args->{'generate_format'} eq "text" && 105 my ($class) = shift (@_); 106 my ($pluginlist,$inputargs,$hashArgOptLists) = @_; 107 push(@$pluginlist, $class); 108 my $classPluginName = (defined $pluginlist->[0]) ? $pluginlist->[0] : $class; 109 my $strConvertTo = findType($inputargs); 110 111 if(defined $arguments){ push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});} 112 if(defined $options) { push(@{$hashArgOptLists->{"OptList"}},$options)}; 113 114 if ($classPluginName eq "PDFPlug" && $strConvertTo eq "text" && 111 115 $ENV{'GSDLOS'} =~ /^windows$/i) { 112 116 print STDERR "Windows does not support pdf to text. PDFs will be converted to HTML instead\n"; 113 $args->{'generate_format'} = "html"; 114 } 115 116 if ($args->{'generate_format'} eq "text") 117 $strConvertTo = "html"; 118 } 119 120 my $self = {}; 121 if ($strConvertTo eq "text") 117 122 { 118 $self = new TEXTPlug ($class, @arglist);123 $self = (defined $hashArgOptLists)? new TEXTPlug($pluginlist,$inputargs,$hashArgOptLists): new TEXTPlug($pluginlist,$inputargs); 119 124 $self->{'convert_to'} = "TEXT"; 120 125 $self->{'convert_to_ext'} = "txt"; … … 122 127 else 123 128 { 124 $self = new HTMLPlug ($class, @arglist);129 $self = (defined $hashArgOptLists)? new HTMLPlug($pluginlist,$inputargs,$hashArgOptLists): new HTMLPlug($pluginlist,$inputargs); 125 130 $self->{'convert_to'} = "HTML"; 126 131 $self->{'convert_to_ext'} = "html"; … … 130 135 } 131 136 132 # 14-05-02 To allow for proper inheritance of arguments - John Thompson133 my $option_list = $self->{'option_list'};134 push( @{$option_list}, $options );135 136 foreach my $key (keys %$args) {137 $self->{$key} = $args->{$key};138 }139 140 137 return bless $self, $class; 141 138 } … … 273 270 274 271 my $outhandle = $self->{'outhandle'}; 275 272 276 273 my $filename = $file; 277 274 $filename = &util::filename_cat ($base_dir, $file) if $base_dir =~ /\w/; … … 296 293 297 294 my $output_ext = $self->{'convert_to_ext'}; 295 298 296 my $conv_filename = $self->tmp_area_convert_file($output_ext, $filename); 299 297
Note:
See TracChangeset
for help on using the changeset viewer.