Mercurial > hg > egg-tcls
changeset 237:56af82fb7a6d
Use lower case.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 19 Jan 2015 11:34:44 +0200 |
parents | f36c26b3c38b |
children | a1d6e2d8789e |
files | fetch_weather.pl |
diffstat | 1 files changed, 22 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/fetch_weather.pl Mon Jan 12 16:17:41 2015 +0200 +++ b/fetch_weather.pl Mon Jan 19 11:34:44 2015 +0200 @@ -252,13 +252,18 @@ return defined($_[0]->[$_[2]]{"nodes"}[0]{$_[1]}) ? $_[0]->[$_[2]]{"nodes"}[0]{$_[1]} : ""; } +sub get_node_lc($$$) +{ + return lc(get_node($_[0], $_[1], $_[2])); +} + my %th_rain_states = ( - "Pouta" => "Poutaa", - "Heikko" => "Heikkoa sadetta", - "Kohtalainen" => "Kohtalaista sadetta", - "Voimakas" => "Voimakasta sadetta", + "Pouta" => "poutaa", + "Heikko" => "heikkoa sadetta", + "Kohtalainen" => "kohtalaista sadetta", + "Voimakas" => "voimakasta sadetta", ); my $th_rain_states_k = join("|", map {quotemeta} sort { length($b)<=>length($a) } keys %th_rain_states); @@ -266,7 +271,7 @@ sub translate_th_rain($) { my $tmp = $_[0]; - $tmp =~ s/($th_rain_states_k)/$th_rain_states{$1}/go; + $tmp =~ s/($th_rain_states_k)/$th_rain_states{$1}/igo; return $tmp; } @@ -277,6 +282,12 @@ } +sub plonk_data_lc($) +{ + return defined($_[0]) ? lc($_[0]) : ""; +} + + ### ### Configuration handling ### @@ -435,11 +446,11 @@ [ 0, parse_timestamp(get_node($fdata, "text", 1), $time_base), - get_node($fdata, "text", 2), - get_node($fdata, "text", 3), + get_node_lc($fdata, "text", 2), + get_node_lc($fdata, "text", 3), translate_th_rain(get_node($fdata, "text", 4)), "", - get_node($fdata, "text", 5), + get_node_lc($fdata, "text", 5), ]; } } @@ -513,10 +524,12 @@ [ 1, plonk_data($flol->{"time"}), - plonk_data($flol->{"temp"}), + plonk_data($flol->{"temperature"}), "", "", plonk_data($flol->{"humidity"}), + plonk_data($flol->{"windspeedms"}), + plonk_data($flol->{"totalcloudcover"}), ]; } }