changeset 43:9ea5d70d501e misc

Added some error checking and reporting, and few missing bits of information into the translation tables.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 20 Apr 2009 15:33:43 +0000
parents 6d43ff1c592a
children 296902ecaefa
files materials/csv2phpsql.pl
diffstat 1 files changed, 21 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/materials/csv2phpsql.pl	Sun Apr 19 11:06:38 2009 +0000
+++ b/materials/csv2phpsql.pl	Mon Apr 20 15:33:43 2009 +0000
@@ -41,6 +41,7 @@
     "comfortable" => 2,
     "chilly" => 3,
     "excellent" => 4,
+    "very warm" => 5,
   },
   7 => {
     "non toxic" => 0,
@@ -160,6 +161,7 @@
     "Abyss" => 22,
     "Pile" => 23,
     "Torrent" => 24,
+    "Chunky" => 25,
   },
   19 => {
     "heap" => 0,
@@ -256,6 +258,7 @@
     "shaped" => 45,
     "puddle" => 46,
     "fibres" => 47,
+    "slab" => 48,
   },
 );
 
@@ -332,10 +335,14 @@
   foreach my $i (sort { $a <=> $b } keys %transtab) {
     print "  array(";
     foreach my $j (keys %{$transtab{$i}}) {
-      print $transtab{$i}{$j};
-      $j =~ s/very /v./;
-      $j =~ s/incredibly /incr./;
-      print " => \"$j\","
+      if (defined($transtab{$i}{$j})) {
+        print $transtab{$i}{$j};
+        $j =~ s/very /v./;
+        $j =~ s/incredibly /incr./;
+        print " => \"$j\","
+      } else {
+        print STDERR "Unknown transTable type $i : $j\n";
+      }
     }
     print "),\n";
   }
@@ -348,7 +355,17 @@
       if (defined($transtab{$j}{$s})) {
         print $transtab{$j}{$s}.", ";
       } elsif (ref($s) eq "ARRAY") {
+        print "array(";
+        foreach my $q (sort { $a cmp $b } @{$s}) {
+          if (defined($transtab{$j}{$q})) {
+            print $transtab{$j}{$q}.",";
+          } else {
+            print STDERR "Unknown matTable type $i : $j :: $q!\n";
+          }
+        }
+        print "),";
       } else {
+        print STDERR "Unknown matTable type $i : $j == $s\n";
         print "-1,";
       }
     }