DebConf18/DayTrip/API

From Wiki
Jump to: navigation, search

Here are some API applications for DayTrip

[edit] Tallies

$ make
wc -l *.people
  45 A.people
  10 B.people
   0 C.people
   0 D.people
   5 F.people
   1 G.people
   0 H.people
   0 J.people
   0 K.people
  61 total
$ more * | cat
::::::::::::::
Makefile
::::::::::::::
W=https://wiki.debconf.org
N=action=raw
R=DebConf18/DayTrip/Registration
B=$W/wiki/$R
F=A B C D F G H J K
.PRECIOUS: $(addsuffix .raw, $F) $(addsuffix .people, $F) $(addsuffix .nonpeople, $F)
all:$(addsuffix .people, $F)
	wc -l *.people
%.people:%.raw; ./filter $?
%.raw:; wget -nv -O $@ $B/$*?$N
duplicates:; sort *.people|uniq -c #groups nearby together anyway even if not exact duplicates
nonpeople:; sort -u *.nonpeople #get quick idea if any people were missed
clean:; rm *.people *.nonpeople
cleanraw:; rm *.raw
::::::::::::::
filter
::::::::::::::
#!/usr/bin/perl
use strict;
use warnings FATAL => q/all/;
die unless @ARGV == 1;
my $prefix;
for (@ARGV) {
    /^[A-Z]/ || die;
    $prefix = $&;
}
open( my $fh, "<", $ARGV[0] )
  or die;
open( my $P, ">", "$prefix.people" )
  or die;
open( my $N, ">", "$prefix.nonpeople" )
  or die;

while (<$fh>) {
    my $line = my $oline= $_;
    my $OK   = 0;
    for($line){
	next unless s/^#//;
        chomp;
        s/^\s+//;
        s/^<!--\d+-->//;
        next if /^\.|VIP/;
        next unless length;
        print $P "$line\n";
        $OK = 1;
    }
    print $N $oline unless $OK;
}
Personal tools