#!/usr/bin/perl # # Scan the directory, find the boards, and make an HTML # table describing what we found. #$WEBURL = "https://svn.so-much-stuff.com/svn/trunk/Eagle/projects/DEC"; $WEBURL = "/pdp8/trunk/Eagle/projects/DEC"; # # # # # # # # # #
row 1, cell 1row 1, cell 2
row 2, cell 1row 2, cell 2
# # Keep these tables ordered as you want them presented # (and the indices must line up). @suffix = ( ".html", ".pdf", ".brd", ".sch", "front.jpg", "back.jpg", ".wtb", ".wts", ".xpl", ".cp.pdf", "ds.pdf", "ds2.pdf", # "brd.pdf", # "sch.pdf", # "hb.pdf", ); @desc = ( "Javascript view", "PDF schematic", "Eagle board", "Eagle schematic", "Front side photo", "Back side photo", "Want to buy", "Want to sell", "Have example", "Component Placement", "Data Sheet", "Another Data Sheet", "Eagle board PDF", "Eagle schematic PDF", "Logic Handbook PDF", ); # # Look at the situation with respect to a board and decide what # next further action should be taken. # $d is the name of the directory. # $b is the name of the board (M111A). # $d2 is the basename of the module (M111). sub NextAction { # # Warn if there's a photo, but no schematic or exemplar. ($pdf) = <$d/${d2}[A-z]*.pdf>; warn "$d/$b: photos without .pdf!\n" if (! -f "$d/${d2}.xpl") && (! -f $pdf) && (-f "$d/${b}front.jpg" && -f "$d/${b}back.jpg"); # # A .pdf should imply a photograph, .wtb or .xpl. # return print STDERR "$d/$b: Missing .wtb and .xpl!\n" # if ! (-f "$d/$b.wtb" || -f "$d/$b.xpl"); # # A .wts should imply a .xpl. return print STDERR "$d/$b: Missing $d/$b.xpl!\n" if -f "$d/$b.wts" && ! -f "$d/$b.xpl"; # # A .xpl should imply no .wtb. return print STDERR "$d/$b: .wtb with $d/$b.xpl!\n" if -f "$d/$b.xpl" && -f "$d/$b.wtb"; # A .wtb should imply no .wts or .xpl. # (A .wtb with .xpl already checked for.) return print STDERR "$d/$b: .wtb with .wts!\n" if -f "$d/$b.wtb" && -f "$d/$b.wts"; # # A .xpl of the board should imply photographs of the board. return print STDERR "$d/$b: .xpl without photos!\n" if -f "$d/$b.xpl" && ! (-f "$d/${b}front.jpg" && -f "$d/${b}back.jpg"); # # Photographs of the board should imply the existence of .sch and .brd. return print STDERR "$d/$b: needs Eagle drawings!\n" if (-f "$d/${b}front.jpg" && -f "$d/${b}back.jpg") && ! (-f "$d/$b.sch" && -f "$d/$b.brd"); # # Existence of schematic and board should imply a .pdf return print STDERR "$d/$b: needs .pdf!\n" if -f "$d/$b.sch" && ! -f "$d/$b.pdf"; # # A .pdf should imply the existence of .sch and .brd for an "X" # version of the board, as well. # BUGBUG: for now, check for the .brd instead. return print STDERR "$d/$b: needs Eagle 'X' version!\n" # if -f "$d/$b.pdf" if -f "$d/$b.brd" && ! (-f "$d/${d2}X.sch" && -f "$d/${d2}X.brd") && ! (-f "$d/${d2}.nox"); # # I can't believe something got finished! return 0; } $modules = "modules"; open(MTXT, ">$modules.txt") || die "$modules.txt: $!"; print MTXT "Module\tVersions Description\r\n"; open(MHTM, ">$modules.htm") || die "$modules.htm: $!"; print MHTM "\r\n"; print MHTM "\r\n"; for $d1 ('Axxx', 'Bxxx', 'Gxxx', 'Hxxx', 'Kxxx', 'Mxxx', 'Rxxx', 'Sxxx', 'Wxxx') { opendir(DIR1, $d1) || die "$d1: $!"; open(STDOUT, ">$d1.htm") || die "$d1.htm: $!"; print "
\n"; print "

$d1

\n"; print "
Module"; print MHTM "VersionsDescription
\n"; $column = 99; sub byname { $a cmp $b } foreach $d2 (sort byname readdir(DIR1)) { next if $d2 eq '.'; next if $d2 eq '..'; next unless -d "$d1/$d2"; # Have located a likely directory -- is it a project? next unless -f "$d1/$d2/eagle.epf"; # It is a project, get the description. open(INPUT, "$d1/$d2/DESCRIPTION") || die "$d1/$d2/DESCRIPTION: $!"; $desc = ; $desc =~ s/[\r\n]//g; close(INPUT); $versions = ""; # Next, scan it for boards. # print "\n"; # Start a new line for each directory. # $column = 0; %boards = (); opendir(DIR2, "$d1/$d2") || die "$d1/$d2: $!"; foreach $f (readdir(DIR2)) { foreach $suf (@suffix) { $b = $f; # Beware: .pdf picks up "ds.pdf", "sch.pdf", and "brd.pdf". $boards{$b} = 1 if $b =~ s/$suf$//; ; } } @boards = sort byname keys %boards; @boards = grep(!/brd$/ && !/sch$/, @boards); $d = "$d1/$d2"; warn "$d2: no extant revisions??\n" unless @boards; foreach $b (sort byname @boards) { next unless $b =~ /^$d2([A-Z])$/ || $b =~ /^$d2([S]..)$/ || $b =~ /^$d2([A-Z]Y.)$/; if ($b =~ /^$d2([A-Z]\w*)$/) { $versions .= $1; # $versions .= "*" unless -f "$d/$b.brd"; $versions .= "+" if !-f "$d/$b.brd" && -f "$d/${b}back.jpg"; $versions .= "*" if !-f "$d/$b.brd" && !-f "$d/${b}back.jpg"; $versions .= "-" if -f "$d/$b.brd-"; $versions .= " "; } if (++$column > 7) { print "" unless $column == 99; print "\n"; $column = 0; } die "$d/$b: Inventory info conflict\n" if -f "$d/$b.wtb" && -f "$d/$b.wts"; &NextAction; # print STDERR "$d/$b: no Inventory info\n" # unless -f "$d/$b.wtb" || -f "$d/$b.wts" || -f "$d/$b.xpl"; print "\r\n"; } else { print MHTM "\r\n"; } } print "\n
$b:\n"; $i = 0; foreach $suf (@suffix) { if (-f "$d/$d2-$suf") { print "
$desc[$i]\n"; } if (-f "$d/$b$suf") { print "
$desc[$i]\n"; # } else { # print STDERR "$d/$b: no $desc[$i]\n" # unless $suf =~ /^.wt/ || $suf =~ /^.xpl/; } $i++; } } print MTXT "$d2\t$versions\t $desc\r\n"; print MHTM "
$d2"; print MHTM "$versions"; if (-f "$d1/$d2/$d2-ds.pdf") { print MHTM "$desc"; } else { print MHTM "$desc"; } if (-f "$d1/$d2/$d2-ds2.pdf") { print MHTM " (another)
"; print ""; } close(MTXT); close(MHTM);