From 71291159993b6243ff22b7c49f36eba3a674c44b Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 7 Aug 2014 13:51:02 -0700 Subject: Improve generation of list of supported dive computers Get it straight from the libdivecomputer sources used... Signed-off-by: Dirk Hohndel --- scripts/parse-descriptor.pl | 67 +++++++++++++++++++++++++++++++-------------- 1 file changed, 47 insertions(+), 20 deletions(-) mode change 100644 => 100755 scripts/parse-descriptor.pl (limited to 'scripts') diff --git a/scripts/parse-descriptor.pl b/scripts/parse-descriptor.pl old mode 100644 new mode 100755 index e29658bee..19d4085e8 --- a/scripts/parse-descriptor.pl +++ b/scripts/parse-descriptor.pl @@ -1,37 +1,64 @@ +#!/bin/perl +# +# Extract supported divecomputers from libdivecomputer source +# +# Usage: +# +# parse-descriptor.pl +# +# depending on suffix of the outfile it creates the right content for +# either a text file or and html file use Carp; #set command line arguments my ($infi, $outfi) = @ARGV; my ($type) = $outfi =~ /\.([^.]+)$/; +if ($infi !~ /.*descriptor.c/) { + croak "run as $ARGV[0] \n"; +} + open(my $fh, "<", $infi) || croak "can't open $infi: $!"; open(STDOUT, ">", $outfi) || croak "can't open $outfi: $!"; my $lastVend = ""; +my @descriptors = (); while (<$fh>) { - my ($vend, $mod, $set) = split('\t', $_); - if ($type eq "html") { - if ($vend eq $lastVend) { - printf(", %s", $mod); - } else { - if ($lastVend eq "") { - printf("
%s
\n\t
    \n\t
  • %s", $vend, $mod); - } else { - printf("
  • \n\t
\n
\n
%s
\n\t
    \n\t
  • %s", $vend, $mod); - } + if (/^\s*{\s*"([^\,]*)"\s*,\s*"([^\,]*)"\s*,\s*([^\,]*).*}/) { + push(@descriptors, "$1,$2"); } - } else { - if ($vend eq $lastVend) { - printf(", %s", $mod); +} +my @sortedDescriptors = sort @descriptors; +foreach (@sortedDescriptors) { + ($vend, $mod) = split(',', $_); + if ($type eq "html") { + if ($vend eq $lastVend) { + printf(", %s", $mod); + } else { + if ($lastVend lt "Uemis" && $vend gt "Uemis") { + printf("
  • \n\t
\n
\n
Uemis
\n\t
    \n\t
  • Zürich SDA"); + } + if ($lastVend eq "") { + printf("
    %s
    \n\t
      \n\t
    • %s", $vend, $mod); + } else { + printf("
    • \n\t
    \n
    \n
    %s
    \n\t
      \n\t
    • %s", $vend, $mod); + } + } } else { - if ($lastVend eq "") { - printf("%s: %s", $vend, $mod); - } else { - printf("\n%s: %s", $vend, $mod); - } + if ($vend eq $lastVend) { + printf(", %s", $mod); + } else { + if ($lastVend lt "Uemis" && $vend gt "Uemis") { + printf("\nUemis: Zürich SDA"); + } + if ($lastVend eq "") { + printf("%s: %s", $vend, $mod); + } else { + printf("\n%s: %s", $vend, $mod); + } + } } - } - $lastVend = $vend; + $lastVend = $vend; } if ($type eq "html") { print("
    • \n\t
    \n
    \n
    "); -- cgit v1.2.3-70-g09d2