1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-07-01 02:39:49 +03:00

dk-catq.pl: allow selection of top category as well

- boom/dist/dk/dk-catq.pl: category can now include the top-level category
  (syntax: top/sub)
- boom/dist/dk/dk-catq.pl: corrected value printed in "no such value" error
  message
This commit is contained in:
Werner Almesberger 2010-10-17 00:13:21 -03:00
parent 83d4e709af
commit 046ae8584e

View File

@ -41,6 +41,8 @@ while (<>) {
$id = shift @q;
$key = shift @q;
$cat = shift @q;
($topcat, $cat) = ($`, $') if $cat =~ m|/|;
for (@q) {
die "not a field=value pair: \"$_\"" unless /\s*=\s*/;
push(@{ $f{$`} }, $');
@ -57,6 +59,9 @@ $url = $URL.$key;
if ($q[1] =~ /<title>Digi-Key</) {
undef $found;
for (@q) {
$on = $1 eq $topcat if
defined $topcat && /catfiltertopitem>\s*(.*?)\s*</;
next if defined $topcat && !$on;
next unless /Cat=(\d+)[&"].*?>\s*(.*?)\s*[(<]/;
next if $2 ne $cat;
$found = $1;
@ -98,7 +103,7 @@ for (keys %f) {
die "no such field: $_" unless defined $field;
for $v (@{ $f{$_} }) {
$value = $val{$_}{$v};
die "no such value: \"$_\"=\"$f{$_}\"" unless defined $value;
die "no such value: \"$_\"=\"$v\"" unless defined $value;
$url .= "&$field=$value";
}
}