mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2025-04-21 12:27:27 +03:00
Catalog listing and enhanced versions of various BOOM items from ben-wpan/bom.
- boom/dist/dk/dk-catq.pl: new - query the Digi-Key catalog for a list of items - boom/dist/dk/dk-db.pl: enhanced - never generate more than 1000 queries per wget run (to keep argv from getting too long) - boom/dist/dk/panasonic-erj.catq, boom/dist/dk/stackpole-rmcf.catq: query scripts for dk-catq.pl - boom/lib/e12.inc: enhanced - added Rxx and Rxxx codes - boom/manu/panasonic/panasonic.gen: enhanced - added decoding for all ERJ series resistors listed at Digi-Key - boom/manu/stackpole/: (new) part number decoder for RMCF series resistors
This commit is contained in:
27
boom/dist/dk/Makefile
vendored
Normal file
27
boom/dist/dk/Makefile
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
CACHE = query.data
|
||||
EQUS = panasonic-erj stackpole-rmcf
|
||||
|
||||
.SUFFIXES: .catq .equ
|
||||
|
||||
all: db/digi-key.dsc db/digi-key.inv
|
||||
|
||||
$(CACHE): db/digi-key.equ
|
||||
awk '/^#END/ { exit } /^DIGI-KEY / { print $$2 }' $< | \
|
||||
perl ./dk-db.pl query \
|
||||
`[ -r $(CACHE) ] && echo '' -i $(CACHE)` >_$@ || \
|
||||
{ rm -f $@ _$@; exit 1; }
|
||||
mv _$@ $@
|
||||
|
||||
db/digi-key.equ: $(EQUS:%=db/%.equ)
|
||||
cat $^ >$@ || { rm -rf $@; exit 1; }
|
||||
|
||||
db/digi-key.dsc: $(CACHE)
|
||||
perl ./dk-db.pl dsc $< >$@ || \
|
||||
{ rm -f $@; exit 1; }
|
||||
|
||||
db/digi-key.inv: $(CACHE)
|
||||
perl ./dk-db.pl inv $< >$@ || \
|
||||
{ rm -f $@; exit 1; }
|
||||
|
||||
.catq.equ:
|
||||
perl ./dk-catq.pl $< >$@ || { rm -rf $@; exit 1; }
|
||||
122
boom/dist/dk/dk-catq.pl
vendored
Executable file
122
boom/dist/dk/dk-catq.pl
vendored
Executable file
@@ -0,0 +1,122 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
$BASE = "http://search.digikey.com/scripts/DkSearch/dksus.dll";
|
||||
$QMOD = "stock=1&pbfree=1&rohs=1";
|
||||
$URL = "$BASE?$QMOD&k=";
|
||||
|
||||
$DEBUG = 0;
|
||||
|
||||
|
||||
sub query
|
||||
{
|
||||
local @q = ();
|
||||
|
||||
open(PIPE, "wget -O - '$_[0]' |") || die "wget: $!";
|
||||
while (<PIPE>) {
|
||||
chop;
|
||||
push(@q, $_);
|
||||
}
|
||||
close PIPE;
|
||||
return @q;
|
||||
}
|
||||
|
||||
|
||||
# --- Read query specification ------------------------------------------------
|
||||
|
||||
|
||||
$spec = $ARGV[0];
|
||||
|
||||
while (<>) {
|
||||
s/#.*//;
|
||||
next if /^\s*$/;
|
||||
chop;
|
||||
push(@q, $_);
|
||||
}
|
||||
|
||||
$id = shift @q;
|
||||
$key = shift @q;
|
||||
$cat = shift @q;
|
||||
for (@q) {
|
||||
die "not a field=value pair: \"$_\"" unless /\s*=\s*/;
|
||||
$f{$`} = $';
|
||||
}
|
||||
|
||||
|
||||
# --- Select category ---------------------------------------------------------
|
||||
|
||||
|
||||
$url = $URL.$key;
|
||||
|
||||
@q = &query($url);
|
||||
|
||||
if ($q[1] =~ /<title>Digi-Key</) {
|
||||
undef $found;
|
||||
for (@q) {
|
||||
next unless /Cat=(\d+)[&"].*?>\s*([^,]*?)\s*</;
|
||||
next if $2 ne $cat;
|
||||
$found = $1;
|
||||
last;
|
||||
}
|
||||
|
||||
die "category \"$cat\" not found" unless defined $found;
|
||||
|
||||
|
||||
# --- Get parameter tables ----------------------------------------------------
|
||||
|
||||
|
||||
$url .= "&Cat=$found";
|
||||
|
||||
@q = &query($url);
|
||||
}
|
||||
|
||||
for (@q) {
|
||||
if (/^<th>\s*(.*?)\s*<\/th>/) {
|
||||
print STDERR "col name \"$1\"\n" if $DEBUG;
|
||||
push(@col_name, $1);
|
||||
next;
|
||||
}
|
||||
if (/<select .* name=([^ >]+)/) {
|
||||
$cols++;
|
||||
$col = $col_name[$cols-1];
|
||||
die "cols = $cols" unless defined $col;
|
||||
print STDERR "$col -> \"$1\"\n" if $DEBUG;
|
||||
$col_field{$col} = $1;
|
||||
next;
|
||||
}
|
||||
next unless /<option value=(\d+)>\s*(.*?)\s*(<.*)?$/;
|
||||
print STDERR "val{$col}{$2} = \"$1\"\n" if $DEBUG;
|
||||
$val{$col}{$2} = $1;
|
||||
}
|
||||
|
||||
for (keys %f) {
|
||||
$field = $col_field{$_};
|
||||
die "no such field: $_" unless defined $field;
|
||||
$value = $val{$_}{$f{$_}};
|
||||
die "no such value: \"$_\"=\"$f{$_}\"" unless defined $value;
|
||||
$url .= "&$field=$value";
|
||||
}
|
||||
|
||||
|
||||
# --- Output file header ------------------------------------------------------
|
||||
|
||||
|
||||
print "#EQU\n# Generated from $spec\n# ".`date`."\n";
|
||||
|
||||
|
||||
# --- Get the pages -----------------------------------------------------------
|
||||
|
||||
|
||||
$url =~ s/\?/?Selection\&/; # magic key to the pages
|
||||
$page = 1;
|
||||
|
||||
while (1) {
|
||||
@q = &query("$url&page=$page");
|
||||
$more = 0;
|
||||
for (@q) {
|
||||
$more = 1 if />Next</;
|
||||
next unless /-ND">\s*([^>]*-ND)\s*<\/a><\/td><td>\s*(.*?)\s*</;
|
||||
print "DIGI-KEY $1\t $id $2\n";
|
||||
}
|
||||
last unless $more;
|
||||
$page++;
|
||||
}
|
||||
111
boom/dist/dk/dk-db.pl
vendored
Executable file
111
boom/dist/dk/dk-db.pl
vendored
Executable file
@@ -0,0 +1,111 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
sub rows
|
||||
{
|
||||
local $s = $_[0];
|
||||
my @res = ();
|
||||
|
||||
while ($s =~ m#.*?<tr>(.*?)</tr>#) {
|
||||
push(@res, $1);
|
||||
$s = $';
|
||||
}
|
||||
return @res;
|
||||
}
|
||||
|
||||
|
||||
sub cols
|
||||
{
|
||||
local $s = $_[0];
|
||||
my @res = ();
|
||||
|
||||
while ($s =~ m#.*?<td[^>]*>(.*?)</td>#) {
|
||||
push(@res, $1);
|
||||
$s = $';
|
||||
}
|
||||
return @res;
|
||||
}
|
||||
|
||||
|
||||
sub flush
|
||||
{
|
||||
$cmd = "wget -nv -O - ".join(" ",
|
||||
map
|
||||
"http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail\\&name=$_",
|
||||
@pn);
|
||||
$q .= `$cmd`;
|
||||
@pn = ();
|
||||
}
|
||||
|
||||
|
||||
sub usage
|
||||
{
|
||||
print STDERR "usage: $0 (query [-i cache_file] | dsc | inv) [file ...]\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
$mode = shift @ARGV;
|
||||
&usage unless $mode eq "query" || $mode eq "dsc" || $mode eq "inv";
|
||||
|
||||
if ($mode eq "query") {
|
||||
if ($ARGV[0] eq "-i") {
|
||||
shift @ARGV;
|
||||
$name = shift @ARGV;
|
||||
open(OLD, $name) || die "$name: $!";
|
||||
$q = join("", <OLD>);
|
||||
($old = $q) =~ tr/\r\n//d;
|
||||
close OLD;
|
||||
}
|
||||
|
||||
while (<>) {
|
||||
chop;
|
||||
s/#.*//;
|
||||
next if /^\s*$/;
|
||||
next if /^\s/;
|
||||
s/\s.*//;
|
||||
next if $old =~ m#align=right>Digi-Key Part Number</th><td>$_</td#;
|
||||
push(@pn, $_);
|
||||
&flush if @pn > 1000;
|
||||
}
|
||||
|
||||
&flush if 0+@pn;;
|
||||
|
||||
print $q;
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$q = join("", <>);
|
||||
$q =~ tr/\r\n//d;
|
||||
|
||||
print "#DSC\n" if $mode eq "dsc";
|
||||
print "#INV\n" if $mode eq "inv";
|
||||
print "# MACHINE-GENERATED. DO NOT EDIT !\n";
|
||||
print "# ", `date -u`;
|
||||
|
||||
for (split(/<!DOCTYPE HTML/, $q)) {
|
||||
next unless m#align=right>Digi-Key Part Number</th><td>([^<]+)</td#;
|
||||
$pn = $1;
|
||||
$qty = 0;
|
||||
if (m#align=right>Quantity Available</th><td[^>]*>([0-9,]+)<#) {
|
||||
($qty = $1) =~ tr/,//d;
|
||||
}
|
||||
next unless m#align=right>Description</th><td>(.*?)</td#;
|
||||
$dsc = $1;
|
||||
next unless m#<table.*<th>Price Break<(.*?)</table>#;
|
||||
if ($mode eq "dsc") {
|
||||
print "DIGI-KEY $pn $dsc\n";
|
||||
next;
|
||||
}
|
||||
print "DIGI-KEY $pn $qty USD";
|
||||
for (&rows($1)) {
|
||||
@c = &cols($_);
|
||||
next unless $c[0] =~ /^[0-9,]+$/;
|
||||
next unless $c[1] =~ /^[0-9.]+$/;
|
||||
$c[0] =~ tr/,//d;
|
||||
$c[1] =~ tr/,//d; # let's hope we don't need this one often :)
|
||||
$c[1] =~ s/0+$// if $c[1] =~ /\./;
|
||||
print " $c[0] $c[1]";
|
||||
}
|
||||
print "\n";
|
||||
}
|
||||
14
boom/dist/dk/panasonic-erj.catq
vendored
Normal file
14
boom/dist/dk/panasonic-erj.catq
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
#
|
||||
# File structure:
|
||||
#
|
||||
# - manufacturer name as used in BOOM
|
||||
# - keyword
|
||||
# - product category
|
||||
# - zero or more field=value pairs
|
||||
#
|
||||
# Comment lines and empty lines are ignored.
|
||||
#
|
||||
PANASONIC
|
||||
erj
|
||||
Chip Resistor - Surface Mount
|
||||
Packaging = Cut Tape (CT)
|
||||
14
boom/dist/dk/stackpole-rmcf.catq
vendored
Normal file
14
boom/dist/dk/stackpole-rmcf.catq
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
#
|
||||
# File structure:
|
||||
#
|
||||
# - manufacturer name as used in BOOM
|
||||
# - keyword
|
||||
# - product category
|
||||
# - zero or more field=value pairs
|
||||
#
|
||||
# Comment lines and empty lines are ignored.
|
||||
#
|
||||
STACKPOLE
|
||||
rmcf
|
||||
Chip Resistor - Surface Mount
|
||||
Packaging = Cut Tape (CT)
|
||||
Reference in New Issue
Block a user