# HG changeset patch # User Matti Hamalainen # Date 1351008019 -10800 # Node ID 0d574e3248b579d8d643e5c65b389399d1f7e250 # Parent b2f45dd616bcd7be81d05598d19fa41a94e924eb Cleanups. diff -r b2f45dd616bc -r 0d574e3248b5 parsedata.pl --- a/parsedata.pl Tue Oct 23 18:04:15 2012 +0300 +++ b/parsedata.pl Tue Oct 23 19:00:19 2012 +0300 @@ -1,7 +1,7 @@ #!/usr/bin/perl -w # # Fetch and parse HTML format class timetable into more sane formats -# (C) Copyright 2010-2011 Matti Hämäläinen +# (C) Copyright 2010-2012 Matti Hämäläinen # use strict; use Data::Dumper; @@ -219,7 +219,7 @@ die("Usage: $0 [options] -php Output a PHP include file with data in arrays (default) - -xml Output XML. + -xml Output a simple XML file. -o Set output filename. Default is to use stdout. @@ -284,9 +284,10 @@ foreach my $n (@{$d}) { my $l = $$n{"nodes"}[0]{"nodes"}; if (defined($l) && $$n{"args"} =~ /colspan=6\s+rowspan=(\d+)/) { - my $chours = $1 / 2; + my $chours = $1 / 2; # The table is actually in half cells my $cdata = []; my $cgrouped = 0; + foreach my $h (@{$l}) { if (defined($$h{"nodes"})) { foreach my $b (@{$$h{"nodes"}}) { @@ -364,12 +365,12 @@ "\$classInfo = array(\n". " \"general\" => array(".join(", ", map { "\"".escape($_)."\""; } @{$class{"info"}})."),\n". " \"info\" => array(".join(", ", map { "\"".escape(html_collapse($_, 1))."\""; } @{$class{"data"}})."),\n". - " \"info_tags\" => array(".join(", ", map { "\"".escape(html_collapse($_, 0))."\""; } @{$class{"data"}})."),\n". + " \"tags\" => array(".join(", ", map { "\"".escape(html_collapse($_, 0))."\""; } @{$class{"data"}})."),\n". " \"maxdays\" => $maxDays,\n". " \"maxhours\" => $maxHours,\n". ");\n\n"; - print "\$classDefs = array(\n"; + print "\$classHourDefs = array(\n"; foreach my $cid (sort { $a <=> $b } keys %{$hourDefs}) { print " $cid => array("; foreach my $key (keys %{$$hourDefs{$cid}}) {