Mercurial > hg > lukkari
changeset 174:eaac0a84a7d2
Cosmetics.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 24 Aug 2015 16:05:10 +0300 |
parents | d98aaa540459 |
children | 6dea01a68019 |
files | parsedata.pl |
diffstat | 1 files changed, 19 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/parsedata.pl Mon Aug 24 12:19:59 2015 +0300 +++ b/parsedata.pl Mon Aug 24 16:05:10 2015 +0300 @@ -328,9 +328,9 @@ } -sub getDataStruct($$); +sub get_hour_data_struct($$); -sub getDataStruct($$) +sub get_hour_data_struct($$) { my @out = (); my ($tmp, $first) = @_; @@ -340,7 +340,7 @@ my @str = (); foreach my $item (@{$tmp}) { - push(@str, getDataStruct($item, 0)); + push(@str, get_hour_data_struct($item, 0)); } if (scalar(@str) > 0) { @@ -353,8 +353,8 @@ my @str = (); foreach my $key (keys %{$tmp}) { - push(@out, "\"".$key."\" => ".getDataStruct($$tmp{$key}, 1)) if ($opt_mode eq "php"); - push(@out, "<".$key.">".getDataStruct($$tmp{$key}, 1)."</".$key.">") if ($opt_mode eq "xml"); + push(@out, "\"".$key."\" => ".get_hour_data_struct($$tmp{$key}, 1)) if ($opt_mode eq "php"); + push(@out, "<".$key.">".get_hour_data_struct($$tmp{$key}, 1)."</".$key.">") if ($opt_mode eq "xml"); } if (scalar(@str) > 0) { @@ -527,7 +527,8 @@ binmode STDOUT, ':encoding(utf-8)'; ### Output data in desired format -if ($opt_mode eq "php") { +if ($opt_mode eq "php") +{ print "<?\n". "\$classInfo = array(\n". " \"general\" => array(".join(", ", map { "\"".escape($_)."\""; } @{$class{"info"}})."),\n". @@ -540,14 +541,16 @@ ");\n\n"; print "\$classHourTimes = array(\n"; - foreach my $chour (@$hourTimes) { + foreach my $chour (@$hourTimes) + { print " array(\"start\" => ".$$chour{"start"}.", \"end\" => ".$$chour{"end"}."),\n"; } print ");\n\n"; print "\$classHourDefs = array(\n"; - foreach my $cid (sort { $a <=> $b } keys %{$hourDefs}) { - print " $cid => array(".getDataStruct($$hourDefs{$cid}, 0)."),\n"; + foreach my $cid (sort { $a <=> $b } keys %{$hourDefs}) + { + print " $cid => array(".get_hour_data_struct($$hourDefs{$cid}, 0)."),\n"; } print ");\n\n"; @@ -563,7 +566,8 @@ print ");\n?>\n"; } -elsif ($opt_mode eq "xml") { +elsif ($opt_mode eq "xml") +{ print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n". "<timetable>\n". " <class>\n". @@ -577,15 +581,17 @@ print " <hours>\n"; my $cid = 0; - foreach my $chour (@$hourTimes) { + foreach my $chour (@$hourTimes) + { print " <hour id=\"".$cid."\"><start>".$$chour{"start"}."</start><end>".$$chour{"end"}."</end></hour>\n"; $cid++; } print " </hours>\n\n"; print " <classes>\n"; - foreach $cid (sort { $a <=> $b } keys %{$hourDefs}) { - print " <class id=\"$cid\">".getDataStruct($$hourDefs{$cid}, 0)."</class>\n"; + foreach $cid (sort { $a <=> $b } keys %{$hourDefs}) + { + print " <class id=\"$cid\">".get_hour_data_struct($$hourDefs{$cid}, 0)."</class>\n"; } print " </classes>\n\n";