| 1 | #!/usr/bin/perl | ||||||||||||||||||||||||||||||||||||||||||
| 2 | ###################### | ||||||||||||||||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||||||||||||||||
| 4 | # Copyright (C) 2011 - 2015 TU Clausthal, Institut fuer Maschinenwesen, Joachim Langenbach | ||||||||||||||||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||||||||||||||||
| 6 | # This program is free software: you can redistribute it and/or modify | ||||||||||||||||||||||||||||||||||||||||||
| 7 | # it under the terms of the GNU General Public License as published by | ||||||||||||||||||||||||||||||||||||||||||
| 8 | # the Free Software Foundation, either version 3 of the License, or | ||||||||||||||||||||||||||||||||||||||||||
| 9 | # (at your option) any later version. | ||||||||||||||||||||||||||||||||||||||||||
| 10 | # | ||||||||||||||||||||||||||||||||||||||||||
| 11 | # This program is distributed in the hope that it will be useful, | ||||||||||||||||||||||||||||||||||||||||||
| 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||||||||||||||||||||||||||||||||||
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||||||||||||||||||||||||||||||||||||||||
| 14 | # GNU General Public License for more details. | ||||||||||||||||||||||||||||||||||||||||||
| 15 | # | ||||||||||||||||||||||||||||||||||||||||||
| 16 | # You should have received a copy of the GNU General Public License | ||||||||||||||||||||||||||||||||||||||||||
| 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||||||||||||||||||||||||||||||||||||||||
| 18 | # | ||||||||||||||||||||||||||||||||||||||||||
| 19 | ###################### | ||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | # Pod::Weaver infos | ||||||||||||||||||||||||||||||||||||||||||
| 22 | # PODNAME: fm_create_help | ||||||||||||||||||||||||||||||||||||||||||
| 23 | # ABSTRACT: Walks through an installation and tries to extract all options with informations into a database | ||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | package CAD::Firemen::ParseHelp::Wildfire5; | ||||||||||||||||||||||||||||||||||||||||||
| 29 | { | ||||||||||||||||||||||||||||||||||||||||||
| 30 | 3 | $CAD::Firemen::ParseHelp::Wildfire5::VERSION = '0.7.1'; | |||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||
| 32 | 4 | ▶ | use Exporter 'import'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 3 | our @EXPORT_OK = qw( | |||||||||||||||||||||||||||||||||||||||||
| 34 | extractHelpWildfire5 | ||||||||||||||||||||||||||||||||||||||||||
| 35 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 4 | ▶ | use POSIX; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | 4 | ▶ | use Archive::Zip qw/ :ERROR_CODES :CONSTANTS/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 4 | ▶ | use HTML::TreeBuilder; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 4 | ▶ | use IO::HTML; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | 4 | ▶ | use XML::LibXML; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 4 | ▶ | use Tie::File; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 4 | ▶ | use Term::ProgressBar; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 4 | ▶ | use CAD::Firemen; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | 3 | use CAD::Firemen::Common qw( | |||||||||||||||||||||||||||||||||||||||||
| 46 | strip | ||||||||||||||||||||||||||||||||||||||||||
| 47 | testPassed | ||||||||||||||||||||||||||||||||||||||||||
| 48 | testFailed | ||||||||||||||||||||||||||||||||||||||||||
| 49 | 3 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | sub getChildDivs { | ||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | my $parent = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getChildDivs: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | my @results = (); | |||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | if(!defined($parent) || (ref($parent) ne "HTML::Element")){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $parent or ref $parent ne "HTML::Element"
MC/DC0%0/2
not defined $parent or ref $parent ne "HTML::Element"
not defined $parent
ref $parent ne "HTML::Element"
Truth table0%0/3
not(A) or B
A= not defined $parentB= ref $parent ne "HTML::Element"
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | return @results; | |||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | foreach my $elem ($parent->content_list()){ | |||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | if(ref($elem) ne "HTML::Element"){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | if($elem->tag() eq "div"){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | push(@results, $elem); | |||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | return @results; | |||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | sub extractHelpWildfire5 { | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | my $tocUrl = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
extractHelpWildfire5: not called CC=25 SCAR=64.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | my $language = shift; | |||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | my $cdbOptionsRef = shift; | |||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | my %cdbOptions = %{$cdbOptionsRef}; | |||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | my $verbose = shift; | |||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | my $zipUrl = shift; | |||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | # just to avoid unused warning in release tests | ||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | $language = undef; | |||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | my %optionsInfo = (); | |||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | my %optionsValue = (); | |||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | my %optionsDefault = (); | |||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | my $zip = undef; | |||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | if(-e $zipUrl){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | # catch file not exists error before Zip->new(), because Zip->new() gives ugly error messages | ||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | $zip = Archive::Zip->new($zipUrl); | |||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | if(!defined($zip)){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | testFailed("Load help archive"); | |||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | return ({}, {}, {}, {}); | |||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||
| 93 | else{ | ||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | testPassed("Load help archive"); | |||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | my @toc; | |||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | if(tie(@toc, 'Tie::File', $tocUrl)){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | testPassed("Open TOC"); | |||||||||||||||||||||||||||||||||||||||||
| 102 | # the linebreak is needed to uncolor Term::ProgressBar | ||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | print "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||
| 105 | else{ | ||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | testFailed("Open TOC"); | |||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | if($verbose > 0){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | print "TOC Url: ". $tocUrl ."\n"; | |||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | return ({}, {}, {}, {}); | |||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||
| 112 | # enabling autoflush to print parse status | ||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | my $lines = scalar(@toc); | |||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | my $progress = Term::ProgressBar->new({name => "Collecting infos", count => $lines}); | |||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | $progress->minor(0); | |||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | my %errors = (); | |||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | foreach my $line (@toc){ | |||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | my $line = strip($line);# | |||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | if($line =~ m/label=\"([^\"]+)\" path=\"([^(?:\"|#)]+)/){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | my $opt = uc($1); | |||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | my $file = $2; | |||||||||||||||||||||||||||||||||||||||||
| 123 | # exclude directories, only file paths are used here | ||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | if($file =~ m/\/$/){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||
| 127 | # some options exists several times, therefore only use the first entry found | ||||||||||||||||||||||||||||||||||||||||||
| 128 | # (Last condition) | ||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | if(exists($cdbOptions{$opt}) && ($file ne "") && (!exists($optionsInfo{$opt}))){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
exists $cdbOptions{$opt} and $file ne "" and not exists $optionsInfo{$opt}
exists $cdbOptions{$opt} and $file ne ""
MC/DC0%0/3
exists $cdbOptions{$opt} and $file ne "" and not exists $optionsInfo{$opt}
exists $cdbOptions{$opt}
$file ne ""
not exists $optionsInfo{$opt}
Truth table0%0/4
A and B and not(C)
A= exists $cdbOptions{$opt}B= $file ne ""C= not exists $optionsInfo{$opt}
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | # option found and file path also not empty | ||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | my $htmlTree = HTML::TreeBuilder->new(); | |||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | if(defined($zip)){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | my $content = $zip->contents($file); | |||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | if(!$content){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | $errors{$opt} = "Could not extract file ". $file; | |||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | if(utf8::is_utf8($content)){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | $content = utf8::decode($content); | |||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | $htmlTree->parse($content); | |||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||
| 143 | else{ | ||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | # do some cleanup on the tree | ||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | $htmlTree->eof(); | |||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | # first check whether we've got the correct file with help of title | ||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | my $element = $htmlTree->find('title'); | |||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | if(!$element){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | $errors{$opt} = "Could not find <title>"; | |||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | my @contents = $element->content_refs_list(); | |||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | my $title = uc(${$contents[0]}); | |||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | if($title ne $opt){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | $errors{$opt} = "Title are not matching (Expected: ". $opt .", Got: ". $title .")"; | |||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | $element = $htmlTree->look_down("_tag", "div"); | |||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | my @elements = getChildDivs($element); | |||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | if(scalar(@elements) != 2){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | if(scalar(@elements) == 3){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | # fixing those with empty second div | ||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | if($elements[1]->as_trimmed_text() eq ""){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | $elements[1] = $elements[2]; | |||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | pop(@elements); | |||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||
| 172 | else{ | ||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | $errors{$opt} = "Second div-container of three within the first div container is not empty."; | |||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||
| 177 | else{ | ||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | $errors{$opt} = "Wrong number of div-containers within the first div container (Expected: 2, Got: ". scalar(@elements) .")"; | |||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||
| 182 | # the first div container contains the option name and the second | ||||||||||||||||||||||||||||||||||||||||||
| 183 | # contains the values and the description | ||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | @elements = getChildDivs($elements[1]); | |||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | if(scalar(@elements) < 1){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | $errors{$opt} = "Wrong number of div-containers within the second div container (Expected: >=1, Got: ". scalar(@elements) .")"; | |||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||
| 190 | # get values | ||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | my @values = (); | |||||||||||||||||||||||||||||||||||||||||
| 192 | # the text of the options div (like ansi * , iso) | ||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | my $text = $elements[0]->as_trimmed_text(); | |||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | my @tmp = split(/,/, $text); | |||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | foreach my $value (@tmp){ | |||||||||||||||||||||||||||||||||||||||||
| 196 | # if we have replaced a *, this is the default value, | ||||||||||||||||||||||||||||||||||||||||||
| 197 | # because only the default value contains a star | ||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | if($value =~ s/\*//){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | $optionsDefault{$opt} = uc(strip($value)); | |||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | $value = uc(strip($value)); | |||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | push(@values, $value); | |||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | $optionsValue{$opt} = [ @values ]; | |||||||||||||||||||||||||||||||||||||||||
| 205 | # check extracted values against those from cdb | ||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | if(scalar($optionsValue{$opt}) == scalar(keys(%{$cdbOptions{$opt}}))){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | $errors{$opt} = "Found different values for option ". $opt ."(Expected: ". scalar(keys(%{$cdbOptions{$opt}})) .", Got: ". scalar($optionsValue{$opt}) .")"; | |||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||
| 210 | # get info (all div after the values div, contains description | ||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | $optionsInfo{$opt} = ""; | |||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | for(my $j = 1; $j < scalar(@elements); $j++){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | $optionsInfo{$opt} .= $elements[$j]->as_trimmed_text() ."\n"; | |||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||
| 215 | # remove last linebreak | ||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | $optionsInfo{$opt} = strip($optionsInfo{$opt}); | |||||||||||||||||||||||||||||||||||||||||
| 217 | # remove wide characters | ||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | $optionsInfo{$opt} =~ s/[^[:ascii:]]+//g; | |||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | $htmlTree->delete(); | |||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | $i++; | |||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | $progress->update($i); | |||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | if($i < $lines){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | $progress->update($lines); | |||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | print "\n"; # print line break to keep the progress bar of the last step | |||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | untie @toc; | |||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | return (\%optionsInfo, \%optionsValue, \%optionsDefault, \%errors); | |||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||
| 235 | __END__ | ||||||||||||||||||||||||||||||||||||||||||