Date:2012-03-06 21:47:50 (7 years 8 months ago)
Author:Werner Almesberger
Commit:dd3c0c205b58484983a8402b127a8c8035f00638
Message:m1r4/dsv/bomshelf: support adding components to the BOM

Also removed a comment that is now in Makefile.
Files: m1r4/dsv/bomshelf (3 diffs)

Change Details

m1r4/dsv/bomshelf
11#!/usr/bin/perl
2#
3# Source:
4# http://downloads.qi-hardware.com/hardware/milkymist_one/bom/rc3/milkymist_one_bom_rc3.ods
5# - save as CVS
6# - edit to remove embedded newlines
7#
82
93sub csv
104{
...... 
5044    next if /^\s*#/;
5145    next if /^\s*$/;
5246    if (/^[Cc]:\s*/) {
47        undef $p if $clear;
48        $clear = 0;
49        if (defined $p) {
50            $cr{$p} = $';
51            for $c (&csv($')) {
52                warn "\"$c\" (supplement) used for $r{$c} ".
53                    "and $p" if defined $r{$c};
54                $r{$c} = $p;
55            }
56            next;
57        }
5358        die "unknown component reference $'" unless defined $r{$'};
5459        $p = $r{$'};
5560        next;
5661    }
5762    if (/^[Pp]:\s*/) {
5863        $p = $';
64        $clear = 0;
5965        next if defined $cr{$p};
6066        @a = grep { $_ =~ /^$p/ } keys %cr;
6167        die "key $p* is ambiguous" if scalar @a > 1;
6268        if (!@a) {
6369            @a = grep { $_ =~ /$p/ } keys %cr;
6470            die "key *$p* is ambiguous" if scalar @a > 1;
65            die "key $p matches nothing" unless @a;
71            if (!@a) {
72                warn "adding $p as supplement";
73                next;
74            }
6675        }
6776        $p = $a[0];
6877        next;
...... 
7079    if (/^[Aa]:\s*/) {
7180        $a{$p} .= "," if defined $a{$p};
7281        $a{$p} .= $';
82        $clear = 1;
7383        next;
7484    }
7585    if (/^[Dd]:\s*/) {
7686        $url{$p} = $';
87        $clear = 1;
7788        next;
7889    }
7990    die "don't recognize \"$_\"";

Archive Download the corresponding diff file

Branches:
master



interactive