| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package ZConf::Weather; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
20722
|
use Weather::Underground; |
|
|
1
|
|
|
|
|
116492
|
|
|
|
1
|
|
|
|
|
37
|
|
|
4
|
1
|
|
|
1
|
|
870
|
use Text::NeatTemplate; |
|
|
1
|
|
|
|
|
4378
|
|
|
|
1
|
|
|
|
|
49
|
|
|
5
|
1
|
|
|
1
|
|
1234
|
use ZConf; |
|
|
1
|
|
|
|
|
128527
|
|
|
|
1
|
|
|
|
|
34
|
|
|
6
|
1
|
|
|
1
|
|
11
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
30
|
|
|
7
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
3916
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
ZConf::Weather - A ZConf module for fetching weather information. |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 VERSION |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Version 1.0.0 |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $VERSION = '1.0.0'; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
use ZConf::Weather; |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my $zcw = ZConf::Weather->new(); |
|
26
|
|
|
|
|
|
|
... |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 FUNCTIONS |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head2 new |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
This initializes it. |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
One arguement is taken and that is a hash value. |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
If this function errors, it will will be set permanently. |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head3 hash values |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head4 zconf |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
This is the a ZConf object. |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
my $zcw=ZConf::Weather->new(); |
|
45
|
|
|
|
|
|
|
if($zcw->{error}){ |
|
46
|
|
|
|
|
|
|
print "Error!\n"; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub new{ |
|
52
|
0
|
|
|
0
|
1
|
|
my %args; |
|
53
|
0
|
0
|
|
|
|
|
if(defined($_[1])){ |
|
54
|
0
|
|
|
|
|
|
%args= %{$_[1]}; |
|
|
0
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
} |
|
56
|
0
|
|
|
|
|
|
my $function='new'; |
|
57
|
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
my $self={error=>undef, |
|
59
|
|
|
|
|
|
|
perror=>undef, |
|
60
|
|
|
|
|
|
|
errorString=>undef, |
|
61
|
|
|
|
|
|
|
module=>'ZConf-Weather', |
|
62
|
|
|
|
|
|
|
zconfconfig=>'weather', |
|
63
|
|
|
|
|
|
|
}; |
|
64
|
0
|
|
|
|
|
|
bless $self; |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
#get the ZConf object |
|
67
|
0
|
0
|
|
|
|
|
if (!defined($args{zconf})) { |
|
68
|
|
|
|
|
|
|
#creates the ZConf object |
|
69
|
0
|
|
|
|
|
|
$self->{zconf}=ZConf->new(); |
|
70
|
0
|
0
|
|
|
|
|
if(defined($self->{zconf}->{error})){ |
|
71
|
0
|
|
|
|
|
|
$self->{error}=1; |
|
72
|
0
|
|
|
|
|
|
$self->{perror}=1; |
|
73
|
0
|
|
|
|
|
|
$self->{errorString}="Could not initiate ZConf. It failed with '" |
|
74
|
|
|
|
|
|
|
.$self->{zconf}->{error}."', '". |
|
75
|
|
|
|
|
|
|
$self->{zconf}->{errorString}."'"; |
|
76
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
77
|
0
|
|
|
|
|
|
return $self; |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
}else { |
|
80
|
0
|
|
|
|
|
|
$self->{zconf}=$args{zconf}; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
#create the config if it does not exist |
|
86
|
|
|
|
|
|
|
#if it does exist, make sure the set we are using exists |
|
87
|
0
|
|
|
|
|
|
my $returned = $self->{zconf}->configExists("weather"); |
|
88
|
0
|
0
|
|
|
|
|
if($self->{zconf}->{error}){ |
|
89
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
90
|
0
|
|
|
|
|
|
$self->{perror}=1; |
|
91
|
0
|
|
|
|
|
|
$self->{errorString}="Checking if '".$self->{zconfconfig}."' exists failed. error='". |
|
92
|
|
|
|
|
|
|
$self->{zconf}->{error}."', errorString='". |
|
93
|
|
|
|
|
|
|
$self->{zconf}->{errorString}."'"; |
|
94
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.':'.$self->{errorString}); |
|
95
|
0
|
|
|
|
|
|
return $self; |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
#initiate the config if it does not exist |
|
99
|
0
|
0
|
|
|
|
|
if (!$returned) { |
|
100
|
|
|
|
|
|
|
#init it |
|
101
|
0
|
|
|
|
|
|
$self->init; |
|
102
|
0
|
0
|
|
|
|
|
if ($self->{zconf}->{error}) { |
|
103
|
0
|
|
|
|
|
|
$self->{perror}=1; |
|
104
|
0
|
|
|
|
|
|
$self->{errorString}='Init failed.'; |
|
105
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
106
|
0
|
|
|
|
|
|
return $self; |
|
107
|
|
|
|
|
|
|
} |
|
108
|
|
|
|
|
|
|
}else { |
|
109
|
|
|
|
|
|
|
#if we have a set, make sure we also have a set that will be loaded |
|
110
|
0
|
|
|
|
|
|
$returned=$self->{zconf}->defaultSetExists($self->{zconfconfig}); |
|
111
|
0
|
0
|
|
|
|
|
if ($self->{zconf}->{error}) { |
|
112
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
113
|
0
|
|
|
|
|
|
$self->{perror}=1; |
|
114
|
0
|
|
|
|
|
|
$self->{errorString}="Checking if '".$self->{zconfconfig}."' exists failed. error='". |
|
115
|
|
|
|
|
|
|
$self->{zconf}->{error}."', errorString='". |
|
116
|
|
|
|
|
|
|
$self->{zconf}->{errorString}."'"; |
|
117
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
118
|
0
|
|
|
|
|
|
return $self; |
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
#if we don't have a default set, initialize it |
|
122
|
0
|
0
|
|
|
|
|
if (!$returned) { |
|
123
|
|
|
|
|
|
|
#init it |
|
124
|
0
|
|
|
|
|
|
$self->init; |
|
125
|
0
|
0
|
|
|
|
|
if ($self->{zconf}->{error}) { |
|
126
|
0
|
|
|
|
|
|
$self->{perror}=1; |
|
127
|
0
|
|
|
|
|
|
$self->{errorString}='Init failed.'; |
|
128
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
129
|
0
|
|
|
|
|
|
return $self; |
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
} |
|
132
|
|
|
|
|
|
|
} |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
#read the config |
|
135
|
0
|
|
|
|
|
|
$self->{zconf}->read({config=>$self->{zconfconfig}}); |
|
136
|
0
|
0
|
|
|
|
|
if ($self->{zconf}->{error}) { |
|
137
|
0
|
|
|
|
|
|
$self->{error}=1; |
|
138
|
0
|
|
|
|
|
|
$self->{perror}=1; |
|
139
|
0
|
|
|
|
|
|
$self->{errorString}="Reading the ZConf config '".$self->{zconfconfig}."' failed. error='". |
|
140
|
|
|
|
|
|
|
$self->{zconf}->{error}."', errorString='". |
|
141
|
|
|
|
|
|
|
$self->{zconf}->{errorString}."'"; |
|
142
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
143
|
0
|
|
|
|
|
|
return $self; |
|
144
|
|
|
|
|
|
|
} |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
|
|
147
|
0
|
|
|
|
|
|
return $self; |
|
148
|
|
|
|
|
|
|
} |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head2 getDefaultLocal |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
This gets what the default local is set to. |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
my $local=$zcw->getDefaultLocal; |
|
155
|
|
|
|
|
|
|
if($zcw->{error}){ |
|
156
|
|
|
|
|
|
|
print "Error!\n"; |
|
157
|
|
|
|
|
|
|
} |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=cut |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub getDefaultLocal{ |
|
162
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
163
|
0
|
|
|
|
|
|
my $function='getDefaultLocal'; |
|
164
|
|
|
|
|
|
|
|
|
165
|
0
|
|
|
|
|
|
$self->errorblank; |
|
166
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
167
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set'); |
|
168
|
|
|
|
|
|
|
} |
|
169
|
|
|
|
|
|
|
|
|
170
|
0
|
0
|
|
|
|
|
if (!defined($self->{zconf}->{conf}{weather}{defaultLocal})) { |
|
171
|
0
|
|
|
|
|
|
$self->{error}=15; |
|
172
|
0
|
|
|
|
|
|
$self->{errorString}='No default local specified.'; |
|
173
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
174
|
0
|
|
|
|
|
|
return undef; |
|
175
|
|
|
|
|
|
|
} |
|
176
|
|
|
|
|
|
|
|
|
177
|
0
|
|
|
|
|
|
return $self->{zconf}->{conf}{weather}{defaultLocal}; |
|
178
|
|
|
|
|
|
|
} |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head2 getDefaultType |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
This gets what the default type is set to. |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
my $local=$zcw->getDefaultType; |
|
185
|
|
|
|
|
|
|
if($zcw->{error}){ |
|
186
|
|
|
|
|
|
|
print "Error!\n"; |
|
187
|
|
|
|
|
|
|
} |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=cut |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
sub getDefaultType{ |
|
192
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
193
|
0
|
|
|
|
|
|
my $function='getDefaultType'; |
|
194
|
|
|
|
|
|
|
|
|
195
|
0
|
|
|
|
|
|
$self->errorblank; |
|
196
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
197
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set'); |
|
198
|
|
|
|
|
|
|
} |
|
199
|
|
|
|
|
|
|
|
|
200
|
0
|
0
|
|
|
|
|
if (!defined($self->{zconf}->{conf}{weather}{defaultType})) { |
|
201
|
0
|
|
|
|
|
|
$self->{error}=15; |
|
202
|
0
|
|
|
|
|
|
$self->{errorString}='No default type specified.'; |
|
203
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
204
|
0
|
|
|
|
|
|
return undef; |
|
205
|
|
|
|
|
|
|
} |
|
206
|
|
|
|
|
|
|
|
|
207
|
0
|
|
|
|
|
|
return $self->{zconf}->{conf}{weather}{defaultLocal}; |
|
208
|
|
|
|
|
|
|
} |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=head2 getSet |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
This gets what the current set is. |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
my $set=$zcw->getSet; |
|
215
|
|
|
|
|
|
|
if($zbm->{error}){ |
|
216
|
|
|
|
|
|
|
print "Error!\n"; |
|
217
|
|
|
|
|
|
|
} |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=cut |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
sub getSet{ |
|
222
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
223
|
0
|
|
|
|
|
|
my $function='getSet'; |
|
224
|
|
|
|
|
|
|
|
|
225
|
0
|
|
|
|
|
|
$self->errorblank; |
|
226
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
227
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set'); |
|
228
|
|
|
|
|
|
|
} |
|
229
|
|
|
|
|
|
|
|
|
230
|
0
|
|
|
|
|
|
my $set=$self->{zconf}->getSet('weather'); |
|
231
|
0
|
0
|
|
|
|
|
if($self->{zconf}->{error}){ |
|
232
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
233
|
0
|
|
|
|
|
|
$self->{errorString}='ZConf error getting the loaded set the config "weather".'. |
|
234
|
|
|
|
|
|
|
' ZConf error="'.$self->{zconf}->{error}.'" '. |
|
235
|
|
|
|
|
|
|
'ZConf error string="'.$self->{zconf}->{errorString}.'"'; |
|
236
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
237
|
0
|
|
|
|
|
|
return undef; |
|
238
|
|
|
|
|
|
|
} |
|
239
|
|
|
|
|
|
|
|
|
240
|
0
|
|
|
|
|
|
return $set; |
|
241
|
|
|
|
|
|
|
} |
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=head2 getTemplate |
|
244
|
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
This returns a template as a string. |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
my $template=$zcw->getTemplate('some/template'); |
|
248
|
|
|
|
|
|
|
if ($zcw->{error}) { |
|
249
|
|
|
|
|
|
|
print "Error!\n"; |
|
250
|
|
|
|
|
|
|
} |
|
251
|
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
=cut |
|
253
|
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
sub getTemplate{ |
|
255
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
256
|
0
|
|
|
|
|
|
my $template=$_[1]; |
|
257
|
0
|
|
|
|
|
|
my $function='getTemplate'; |
|
258
|
|
|
|
|
|
|
|
|
259
|
0
|
|
|
|
|
|
$self->errorblank; |
|
260
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
261
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set'); |
|
262
|
|
|
|
|
|
|
} |
|
263
|
|
|
|
|
|
|
|
|
264
|
0
|
0
|
|
|
|
|
if (!defined($template)) { |
|
265
|
0
|
|
|
|
|
|
$self->{error}=6; |
|
266
|
0
|
|
|
|
|
|
$self->{errorstring}='No template specified.'; |
|
267
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
268
|
0
|
|
|
|
|
|
return undef; |
|
269
|
|
|
|
|
|
|
} |
|
270
|
|
|
|
|
|
|
|
|
271
|
0
|
|
|
|
|
|
my $returned=$self->templateExists($template); |
|
272
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
273
|
0
|
|
|
|
|
|
warn('ZConf-Weather getTemplate: templateExists errored'); |
|
274
|
0
|
|
|
|
|
|
return undef; |
|
275
|
|
|
|
|
|
|
} |
|
276
|
|
|
|
|
|
|
|
|
277
|
0
|
0
|
|
|
|
|
if (!$returned) { |
|
278
|
0
|
|
|
|
|
|
warn('ZConf-Weather getTemplate:7: The template, "'.$template.'", does not exist'); |
|
279
|
0
|
|
|
|
|
|
$self->{errror}=7; |
|
280
|
0
|
|
|
|
|
|
$self->{errorstring}='The template, "'.$template.'", does not exist'; |
|
281
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
282
|
0
|
|
|
|
|
|
return undef; |
|
283
|
|
|
|
|
|
|
} |
|
284
|
|
|
|
|
|
|
|
|
285
|
0
|
|
|
|
|
|
return $self->{zconf}{conf}{weather}{'templates/'.$template}; |
|
286
|
|
|
|
|
|
|
} |
|
287
|
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
=head2 getWeather |
|
289
|
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
Returns the arrayref from Weather::Underground->get_weather. |
|
291
|
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
The only arguement required is the name of the local. |
|
293
|
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
$aref=$zcw->getWeather('someLocal'); |
|
295
|
|
|
|
|
|
|
if($zcw->{error}){ |
|
296
|
|
|
|
|
|
|
print "Error!\n"; |
|
297
|
|
|
|
|
|
|
} |
|
298
|
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
=cut |
|
300
|
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
sub getWeather{ |
|
302
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
303
|
0
|
|
|
|
|
|
my $name=$_[1]; |
|
304
|
0
|
|
|
|
|
|
my $function='getWeather'; |
|
305
|
|
|
|
|
|
|
|
|
306
|
0
|
|
|
|
|
|
$self->errorblank; |
|
307
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
308
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set'); |
|
309
|
|
|
|
|
|
|
} |
|
310
|
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
#inits the weather object... |
|
312
|
0
|
|
|
|
|
|
my $weather=$self->getWeatherObj($name); |
|
313
|
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
#gets the weather |
|
315
|
0
|
|
|
|
|
|
my $arrayref = $weather->get_weather(); |
|
316
|
0
|
0
|
|
|
|
|
if (!$arrayref) { |
|
317
|
0
|
|
|
|
|
|
$self->{error}=12; |
|
318
|
0
|
|
|
|
|
|
$self->{errorString}='Failed to fetch the weather'; |
|
319
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
320
|
0
|
|
|
|
|
|
return undef; |
|
321
|
|
|
|
|
|
|
} |
|
322
|
|
|
|
|
|
|
|
|
323
|
0
|
|
|
|
|
|
return $arrayref; |
|
324
|
|
|
|
|
|
|
} |
|
325
|
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
=head2 getWeatherObj |
|
327
|
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
This fetches the Weather::Underground object. |
|
329
|
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
The only arguement accepted is the name of the local. |
|
331
|
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
my $wu=$zcw->getWeatherObj('someLocal'); |
|
333
|
|
|
|
|
|
|
if($zcw->{error}){ |
|
334
|
|
|
|
|
|
|
print "Error!"; |
|
335
|
|
|
|
|
|
|
} |
|
336
|
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
=cut |
|
338
|
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
sub getWeatherObj{ |
|
340
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
341
|
0
|
|
|
|
|
|
my $name=$_[1]; |
|
342
|
0
|
|
|
|
|
|
my $function='getWeatherObj'; |
|
343
|
|
|
|
|
|
|
|
|
344
|
0
|
|
|
|
|
|
$self->errorblank; |
|
345
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
346
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set'); |
|
347
|
|
|
|
|
|
|
} |
|
348
|
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
#error if no local is defined |
|
350
|
0
|
0
|
|
|
|
|
if (!defined($name)) { |
|
351
|
0
|
|
|
|
|
|
$name=$self->getDefaultLocal; |
|
352
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
353
|
0
|
|
|
|
|
|
$self->{error}=16; |
|
354
|
0
|
|
|
|
|
|
$self->{errorString}='getDefaultLocal errors and no local is specified.'; |
|
355
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
356
|
0
|
|
|
|
|
|
return undef; |
|
357
|
|
|
|
|
|
|
} |
|
358
|
|
|
|
|
|
|
} |
|
359
|
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
#local exists errored |
|
361
|
0
|
|
|
|
|
|
my $returned=$self->localExists($name); |
|
362
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
363
|
0
|
|
|
|
|
|
warn('ZConf-Weather getWeatherObj: localExists errored'); |
|
364
|
0
|
|
|
|
|
|
return undef; |
|
365
|
|
|
|
|
|
|
} |
|
366
|
|
|
|
|
|
|
|
|
367
|
0
|
0
|
|
|
|
|
if (!$returned) { |
|
368
|
0
|
|
|
|
|
|
$self->{error}=10; |
|
369
|
0
|
|
|
|
|
|
$self->{errorString}='The local "'.$name.'" does not exist.'; |
|
370
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
371
|
0
|
|
|
|
|
|
return undef; |
|
372
|
|
|
|
|
|
|
} |
|
373
|
|
|
|
|
|
|
|
|
374
|
|
|
|
|
|
|
#gets the keys for that will be used |
|
375
|
0
|
|
|
|
|
|
my $local=$self->{zconf}->{conf}{weather}{'locals/'.$name.'/local'}; |
|
376
|
0
|
|
|
|
|
|
my $type=$self->{zconf}->{conf}{weather}{'locals/'.$name.'/type'}; |
|
377
|
0
|
|
|
|
|
|
my $template; |
|
378
|
0
|
0
|
|
|
|
|
if ($type eq 'template') { |
|
379
|
0
|
|
|
|
|
|
$template=$self->{zconf}->{conf}{weather}{'locals/'.$name.'/template'}; |
|
380
|
|
|
|
|
|
|
} |
|
381
|
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
#inits the weather object... |
|
383
|
0
|
|
|
|
|
|
my $weather=Weather::Underground->new(place=>$local); |
|
384
|
0
|
0
|
|
|
|
|
if (!$weather) { |
|
385
|
0
|
|
|
|
|
|
$self->{error}=11; |
|
386
|
0
|
|
|
|
|
|
$self->{errorString}='Failed to init the module Weather::Underground.'; |
|
387
|
0
|
|
|
|
|
|
return undef; |
|
388
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
389
|
|
|
|
|
|
|
} |
|
390
|
|
|
|
|
|
|
|
|
391
|
0
|
|
|
|
|
|
return $weather; |
|
392
|
|
|
|
|
|
|
} |
|
393
|
|
|
|
|
|
|
|
|
394
|
|
|
|
|
|
|
=head2 init |
|
395
|
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
This initializes it or a new set. |
|
397
|
|
|
|
|
|
|
|
|
398
|
|
|
|
|
|
|
If the specified set already exists, it will be reset. |
|
399
|
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
One arguement is required and it is the name of the set. If |
|
401
|
|
|
|
|
|
|
it is not defined, ZConf will use the default one. |
|
402
|
|
|
|
|
|
|
|
|
403
|
|
|
|
|
|
|
#creates a new set named foo |
|
404
|
|
|
|
|
|
|
$zcw->init('foo'); |
|
405
|
|
|
|
|
|
|
if($zcw->{error}){ |
|
406
|
|
|
|
|
|
|
print "Error!\n"; |
|
407
|
|
|
|
|
|
|
} |
|
408
|
|
|
|
|
|
|
|
|
409
|
|
|
|
|
|
|
#creates a new set with ZConf choosing it's name |
|
410
|
|
|
|
|
|
|
$zcw->init(); |
|
411
|
|
|
|
|
|
|
if($zcw->{error}){ |
|
412
|
|
|
|
|
|
|
print "Error!\n"; |
|
413
|
|
|
|
|
|
|
} |
|
414
|
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
=cut |
|
416
|
|
|
|
|
|
|
|
|
417
|
|
|
|
|
|
|
sub init{ |
|
418
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
419
|
0
|
|
|
|
|
|
my $set=$_[1]; |
|
420
|
0
|
|
|
|
|
|
my $function='init'; |
|
421
|
|
|
|
|
|
|
|
|
422
|
|
|
|
|
|
|
#blanks any previous errors |
|
423
|
0
|
|
|
|
|
|
$self->errorblank; |
|
424
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
425
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set'); |
|
426
|
|
|
|
|
|
|
} |
|
427
|
|
|
|
|
|
|
|
|
428
|
0
|
|
|
|
|
|
my $returned = $self->{zconf}->configExists("weather"); |
|
429
|
0
|
0
|
|
|
|
|
if(defined($self->{zconf}->{error})){ |
|
430
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
431
|
0
|
|
|
|
|
|
$self->{errorString}="Could not check if the config 'weather' exists.". |
|
432
|
|
|
|
|
|
|
" It failed with '".$self->{zconf}->{error}."', '" |
|
433
|
|
|
|
|
|
|
.$self->{zconf}->{errorString}."'"; |
|
434
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
435
|
0
|
|
|
|
|
|
return undef; |
|
436
|
|
|
|
|
|
|
} |
|
437
|
|
|
|
|
|
|
|
|
438
|
|
|
|
|
|
|
#create the config if it does not exist |
|
439
|
0
|
0
|
|
|
|
|
if (!$returned) { |
|
440
|
0
|
|
|
|
|
|
$self->{zconf}->createConfig("weather"); |
|
441
|
0
|
0
|
|
|
|
|
if ($self->{zconf}->{error}) { |
|
442
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
443
|
0
|
|
|
|
|
|
$self->{errorString}="Could not create the ZConf config 'weather'.". |
|
444
|
|
|
|
|
|
|
" It failed with '".$self->{zconf}->{error}."', '" |
|
445
|
|
|
|
|
|
|
.$self->{zconf}->{errorString}."'"; |
|
446
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
447
|
0
|
|
|
|
|
|
return undef; |
|
448
|
|
|
|
|
|
|
} |
|
449
|
|
|
|
|
|
|
} |
|
450
|
|
|
|
|
|
|
|
|
451
|
|
|
|
|
|
|
#create the new set |
|
452
|
0
|
|
|
|
|
|
$self->{zconf}->writeSetFromHash({config=>"weather", set=>$set},{}); |
|
453
|
|
|
|
|
|
|
#error if the write failed |
|
454
|
0
|
0
|
|
|
|
|
if ($self->{zconf}->{error}) { |
|
455
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
456
|
0
|
|
|
|
|
|
$self->{errorString}="writeSetFromHash failed.". |
|
457
|
|
|
|
|
|
|
" It failed with '".$self->{zconf}->{error}."', '" |
|
458
|
|
|
|
|
|
|
.$self->{zconf}->{errorString}."'"; |
|
459
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
460
|
0
|
|
|
|
|
|
return undef; |
|
461
|
|
|
|
|
|
|
} |
|
462
|
|
|
|
|
|
|
|
|
463
|
0
|
|
|
|
|
|
return 1; |
|
464
|
|
|
|
|
|
|
} |
|
465
|
|
|
|
|
|
|
|
|
466
|
|
|
|
|
|
|
=head2 listLocals |
|
467
|
|
|
|
|
|
|
|
|
468
|
|
|
|
|
|
|
This gets a list of available locals. |
|
469
|
|
|
|
|
|
|
|
|
470
|
|
|
|
|
|
|
my @locals=$zcw->listLocals; |
|
471
|
|
|
|
|
|
|
if($zcw->{error}){ |
|
472
|
|
|
|
|
|
|
print "Error!\n"; |
|
473
|
|
|
|
|
|
|
} |
|
474
|
|
|
|
|
|
|
|
|
475
|
|
|
|
|
|
|
=cut |
|
476
|
|
|
|
|
|
|
|
|
477
|
|
|
|
|
|
|
sub listLocals{ |
|
478
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
479
|
0
|
|
|
|
|
|
my $function='listLocals'; |
|
480
|
|
|
|
|
|
|
|
|
481
|
0
|
|
|
|
|
|
$self->errorblank; |
|
482
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
483
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set'); |
|
484
|
|
|
|
|
|
|
} |
|
485
|
|
|
|
|
|
|
|
|
486
|
0
|
|
|
|
|
|
my @localsA=$self->{zconf}->regexVarSearch('weather', '^locals/'); |
|
487
|
0
|
0
|
|
|
|
|
if ($self->{zconf}->{error}) { |
|
488
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
489
|
0
|
|
|
|
|
|
$self->{errorString}='ZConf error listing locals for the config "weather".'. |
|
490
|
|
|
|
|
|
|
' ZConf error="'.$self->{zconf}->{error}.'" '. |
|
491
|
|
|
|
|
|
|
'ZConf error string="'.$self->{zconf}->{errorString}.'"'; |
|
492
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
493
|
0
|
|
|
|
|
|
return undef; |
|
494
|
|
|
|
|
|
|
} |
|
495
|
|
|
|
|
|
|
|
|
496
|
|
|
|
|
|
|
#removes templates/ from the beginning of the variable name |
|
497
|
0
|
|
|
|
|
|
my $int=0; |
|
498
|
0
|
|
|
|
|
|
my %locals; |
|
499
|
0
|
|
|
|
|
|
while (defined($localsA[$int])) { |
|
500
|
0
|
|
|
|
|
|
my @split=split(/\//, $localsA[$int]); |
|
501
|
0
|
|
|
|
|
|
$locals{$split[1]}=''; |
|
502
|
|
|
|
|
|
|
|
|
503
|
0
|
|
|
|
|
|
$int++; |
|
504
|
|
|
|
|
|
|
} |
|
505
|
|
|
|
|
|
|
|
|
506
|
0
|
|
|
|
|
|
return keys(%locals); |
|
507
|
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
} |
|
509
|
|
|
|
|
|
|
|
|
510
|
|
|
|
|
|
|
=head2 listSets |
|
511
|
|
|
|
|
|
|
|
|
512
|
|
|
|
|
|
|
This lists the available sets. |
|
513
|
|
|
|
|
|
|
|
|
514
|
|
|
|
|
|
|
my @sets=$zcw->listSets; |
|
515
|
|
|
|
|
|
|
if($zcw->{error}){ |
|
516
|
|
|
|
|
|
|
print "Error!"; |
|
517
|
|
|
|
|
|
|
} |
|
518
|
|
|
|
|
|
|
|
|
519
|
|
|
|
|
|
|
=cut |
|
520
|
|
|
|
|
|
|
|
|
521
|
|
|
|
|
|
|
sub listSets{ |
|
522
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
523
|
0
|
|
|
|
|
|
my $function='listSets'; |
|
524
|
|
|
|
|
|
|
|
|
525
|
|
|
|
|
|
|
#blanks any previous errors |
|
526
|
0
|
|
|
|
|
|
$self->errorblank; |
|
527
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
528
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set'); |
|
529
|
|
|
|
|
|
|
} |
|
530
|
|
|
|
|
|
|
|
|
531
|
0
|
|
|
|
|
|
my @sets=$self->{zconf}->getAvailableSets('weather'); |
|
532
|
0
|
0
|
|
|
|
|
if($self->{zconf}->{error}){ |
|
533
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
534
|
0
|
|
|
|
|
|
$self->{errorString}='ZConf error listing sets for the config "weather".'. |
|
535
|
|
|
|
|
|
|
' ZConf error="'.$self->{zconf}->{error}.'" '. |
|
536
|
|
|
|
|
|
|
'ZConf error string="'.$self->{zconf}->{errorString}.'"'; |
|
537
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
538
|
0
|
|
|
|
|
|
return undef; |
|
539
|
|
|
|
|
|
|
} |
|
540
|
|
|
|
|
|
|
|
|
541
|
0
|
|
|
|
|
|
return @sets; |
|
542
|
|
|
|
|
|
|
} |
|
543
|
|
|
|
|
|
|
|
|
544
|
|
|
|
|
|
|
=head2 listTemplates |
|
545
|
|
|
|
|
|
|
|
|
546
|
|
|
|
|
|
|
This gets a list of available templates. |
|
547
|
|
|
|
|
|
|
|
|
548
|
|
|
|
|
|
|
my @templates=$zcw->listTemplates; |
|
549
|
|
|
|
|
|
|
if($zcw->{error}){ |
|
550
|
|
|
|
|
|
|
print "Error!\n"; |
|
551
|
|
|
|
|
|
|
} |
|
552
|
|
|
|
|
|
|
|
|
553
|
|
|
|
|
|
|
=cut |
|
554
|
|
|
|
|
|
|
|
|
555
|
|
|
|
|
|
|
sub listTemplates{ |
|
556
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
557
|
0
|
|
|
|
|
|
my $function='listTemplates'; |
|
558
|
|
|
|
|
|
|
|
|
559
|
0
|
|
|
|
|
|
$self->errorblank; |
|
560
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
561
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set'); |
|
562
|
|
|
|
|
|
|
} |
|
563
|
|
|
|
|
|
|
|
|
564
|
0
|
|
|
|
|
|
my @templates=$self->{zconf}->regexVarSearch('weather', '^templates/'); |
|
565
|
0
|
0
|
|
|
|
|
if ($self->{zconf}->{error}) { |
|
566
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
567
|
0
|
|
|
|
|
|
$self->{errorString}='ZConf error listing templates for the config "weather".'. |
|
568
|
|
|
|
|
|
|
' ZConf error="'.$self->{zconf}->{error}.'" '. |
|
569
|
|
|
|
|
|
|
'ZConf error string="'.$self->{zconf}->{errorString}.'"'; |
|
570
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
571
|
0
|
|
|
|
|
|
return undef; |
|
572
|
|
|
|
|
|
|
} |
|
573
|
|
|
|
|
|
|
|
|
574
|
|
|
|
|
|
|
#removes templates/ from the beginning of the variable name |
|
575
|
0
|
|
|
|
|
|
my $int=0; |
|
576
|
0
|
|
|
|
|
|
while (defined($templates[$int])) { |
|
577
|
0
|
|
|
|
|
|
$templates[$int]=~s/^templates\///; |
|
578
|
|
|
|
|
|
|
|
|
579
|
0
|
|
|
|
|
|
$int++; |
|
580
|
|
|
|
|
|
|
} |
|
581
|
|
|
|
|
|
|
|
|
582
|
0
|
|
|
|
|
|
return @templates; |
|
583
|
|
|
|
|
|
|
} |
|
584
|
|
|
|
|
|
|
|
|
585
|
|
|
|
|
|
|
=head2 localExists |
|
586
|
|
|
|
|
|
|
|
|
587
|
|
|
|
|
|
|
This makes sure a specified local exists. |
|
588
|
|
|
|
|
|
|
|
|
589
|
|
|
|
|
|
|
my $returned=$zcw->localExists('somelocal'); |
|
590
|
|
|
|
|
|
|
if($zcw->{error}){ |
|
591
|
|
|
|
|
|
|
print "Error!\n"; |
|
592
|
|
|
|
|
|
|
}else{ |
|
593
|
|
|
|
|
|
|
if($returned){ |
|
594
|
|
|
|
|
|
|
print "It exists.\n"; |
|
595
|
|
|
|
|
|
|
} |
|
596
|
|
|
|
|
|
|
} |
|
597
|
|
|
|
|
|
|
|
|
598
|
|
|
|
|
|
|
=cut |
|
599
|
|
|
|
|
|
|
|
|
600
|
|
|
|
|
|
|
sub localExists{ |
|
601
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
602
|
0
|
|
|
|
|
|
my $local=$_[1]; |
|
603
|
0
|
|
|
|
|
|
my $function='localExists'; |
|
604
|
|
|
|
|
|
|
|
|
605
|
0
|
|
|
|
|
|
$self->errorblank; |
|
606
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
607
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set'); |
|
608
|
|
|
|
|
|
|
} |
|
609
|
|
|
|
|
|
|
|
|
610
|
0
|
|
|
|
|
|
my @locals=$self->listLocals; |
|
611
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
612
|
0
|
|
|
|
|
|
warn('ZConf-Weather localExists:2: listLocals errored'); |
|
613
|
0
|
|
|
|
|
|
return undef; |
|
614
|
|
|
|
|
|
|
} |
|
615
|
|
|
|
|
|
|
|
|
616
|
0
|
|
|
|
|
|
my $int=0; |
|
617
|
0
|
|
|
|
|
|
while (defined($locals[$int])) { |
|
618
|
0
|
0
|
|
|
|
|
if ($locals[$int] eq $local) { |
|
619
|
0
|
|
|
|
|
|
return 1; |
|
620
|
|
|
|
|
|
|
} |
|
621
|
|
|
|
|
|
|
|
|
622
|
0
|
|
|
|
|
|
$int++; |
|
623
|
|
|
|
|
|
|
} |
|
624
|
|
|
|
|
|
|
|
|
625
|
0
|
|
|
|
|
|
return undef; |
|
626
|
|
|
|
|
|
|
} |
|
627
|
|
|
|
|
|
|
|
|
628
|
|
|
|
|
|
|
=head2 readSet |
|
629
|
|
|
|
|
|
|
|
|
630
|
|
|
|
|
|
|
This reads a specific set. If the set specified |
|
631
|
|
|
|
|
|
|
is undef, the default set is read. |
|
632
|
|
|
|
|
|
|
|
|
633
|
|
|
|
|
|
|
#read the default set |
|
634
|
|
|
|
|
|
|
$zcw->readSet(); |
|
635
|
|
|
|
|
|
|
if($zcr->{error}){ |
|
636
|
|
|
|
|
|
|
print "Error!\n"; |
|
637
|
|
|
|
|
|
|
} |
|
638
|
|
|
|
|
|
|
|
|
639
|
|
|
|
|
|
|
#read the set 'someSet' |
|
640
|
|
|
|
|
|
|
$zcw->readSet('someSet'); |
|
641
|
|
|
|
|
|
|
if($zcr->{error}){ |
|
642
|
|
|
|
|
|
|
print "Error!\n"; |
|
643
|
|
|
|
|
|
|
} |
|
644
|
|
|
|
|
|
|
|
|
645
|
|
|
|
|
|
|
=cut |
|
646
|
|
|
|
|
|
|
|
|
647
|
|
|
|
|
|
|
sub readSet{ |
|
648
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
649
|
0
|
|
|
|
|
|
my $set=$_[1]; |
|
650
|
0
|
|
|
|
|
|
my $function='readSet'; |
|
651
|
|
|
|
|
|
|
|
|
652
|
|
|
|
|
|
|
#blanks any previous errors |
|
653
|
0
|
|
|
|
|
|
$self->errorblank; |
|
654
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
655
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set'); |
|
656
|
|
|
|
|
|
|
} |
|
657
|
|
|
|
|
|
|
|
|
658
|
0
|
|
|
|
|
|
$self->{zconf}->read({config=>'weather', set=>$set}); |
|
659
|
0
|
0
|
|
|
|
|
if ($self->{zconf}->{error}) { |
|
660
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
661
|
0
|
|
|
|
|
|
$self->{errorString}='ZConf error reading the config "weather".'. |
|
662
|
|
|
|
|
|
|
' ZConf error="'.$self->{zconf}->{error}.'" '. |
|
663
|
|
|
|
|
|
|
'ZConf error string="'.$self->{zconf}->{errorString}.'"'; |
|
664
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
665
|
0
|
|
|
|
|
|
return undef; |
|
666
|
|
|
|
|
|
|
} |
|
667
|
|
|
|
|
|
|
|
|
668
|
0
|
|
|
|
|
|
return 1; |
|
669
|
|
|
|
|
|
|
} |
|
670
|
|
|
|
|
|
|
|
|
671
|
|
|
|
|
|
|
=head2 run |
|
672
|
|
|
|
|
|
|
|
|
673
|
|
|
|
|
|
|
This acts on a local using it's defined type. |
|
674
|
|
|
|
|
|
|
|
|
675
|
|
|
|
|
|
|
$zcw->run('someLocal'); |
|
676
|
|
|
|
|
|
|
if($zcw->{error}){ |
|
677
|
|
|
|
|
|
|
print "Error!\n"; |
|
678
|
|
|
|
|
|
|
} |
|
679
|
|
|
|
|
|
|
|
|
680
|
|
|
|
|
|
|
=cut |
|
681
|
|
|
|
|
|
|
|
|
682
|
|
|
|
|
|
|
sub run{ |
|
683
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
684
|
0
|
|
|
|
|
|
my $name=$_[1]; |
|
685
|
0
|
|
|
|
|
|
my $function='run'; |
|
686
|
|
|
|
|
|
|
|
|
687
|
|
|
|
|
|
|
#blank any previous errors |
|
688
|
0
|
|
|
|
|
|
$self->errorblank; |
|
689
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
690
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set'); |
|
691
|
|
|
|
|
|
|
} |
|
692
|
|
|
|
|
|
|
|
|
693
|
|
|
|
|
|
|
#try to get it if no local is given |
|
694
|
0
|
0
|
|
|
|
|
if (!defined($name)) { |
|
695
|
0
|
|
|
|
|
|
$name=$self->getDefaultLocal; |
|
696
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
697
|
0
|
|
|
|
|
|
warn('ZConf-Weather run: No local was given and getDefaultLocal failed.'); |
|
698
|
0
|
|
|
|
|
|
return undef; |
|
699
|
|
|
|
|
|
|
} |
|
700
|
|
|
|
|
|
|
} |
|
701
|
|
|
|
|
|
|
|
|
702
|
|
|
|
|
|
|
#gets the weather |
|
703
|
0
|
|
|
|
|
|
my $arrayref = $self->getWeather($name); |
|
704
|
0
|
0
|
|
|
|
|
if (!$arrayref) { |
|
705
|
0
|
|
|
|
|
|
warn('ZConf-Weather run:12: Failed to fetch the weather'); |
|
706
|
0
|
|
|
|
|
|
$self->{error}=12; |
|
707
|
0
|
|
|
|
|
|
$self->{errorString}='Failed to fetch the weather'; |
|
708
|
0
|
|
|
|
|
|
return undef; |
|
709
|
|
|
|
|
|
|
} |
|
710
|
|
|
|
|
|
|
|
|
711
|
|
|
|
|
|
|
#gets the keys for that will be used |
|
712
|
0
|
|
|
|
|
|
my $local=$self->{zconf}->{conf}{weather}{'locals/'.$name.'/local'}; |
|
713
|
0
|
|
|
|
|
|
my $type=$self->{zconf}->{conf}{weather}{'locals/'.$name.'/type'}; |
|
714
|
0
|
|
|
|
|
|
my $template; |
|
715
|
0
|
0
|
|
|
|
|
if ($type eq 'template') { |
|
716
|
0
|
|
|
|
|
|
$template=$self->{zconf}->{conf}{weather}{'locals/'.$name.'/template'}; |
|
717
|
|
|
|
|
|
|
} |
|
718
|
|
|
|
|
|
|
|
|
719
|
|
|
|
|
|
|
#handles if if the type is set to dump |
|
720
|
0
|
0
|
|
|
|
|
if ($type eq 'dump') { |
|
721
|
0
|
|
|
|
|
|
foreach (@$arrayref) { |
|
722
|
0
|
|
|
|
|
|
while (my ($key, $value) = each %{$_}) { |
|
|
0
|
|
|
|
|
|
|
|
723
|
0
|
|
|
|
|
|
print $key."=".$value."\n"; |
|
724
|
|
|
|
|
|
|
} |
|
725
|
|
|
|
|
|
|
} |
|
726
|
0
|
|
|
|
|
|
return 1; |
|
727
|
|
|
|
|
|
|
} |
|
728
|
|
|
|
|
|
|
|
|
729
|
|
|
|
|
|
|
#processes it if the type is set to template |
|
730
|
0
|
0
|
|
|
|
|
if ($type eq 'template') { |
|
731
|
|
|
|
|
|
|
#fetches the template |
|
732
|
0
|
|
|
|
|
|
my $t=$self->getTemplate($template); |
|
733
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
734
|
0
|
|
|
|
|
|
warn('ZConf-Weather run: getTemplate errored'); |
|
735
|
0
|
|
|
|
|
|
return undef; |
|
736
|
|
|
|
|
|
|
} |
|
737
|
|
|
|
|
|
|
|
|
738
|
|
|
|
|
|
|
#inits the template object |
|
739
|
0
|
|
|
|
|
|
my $tobj=Text::NeatTemplate->new(); |
|
740
|
|
|
|
|
|
|
|
|
741
|
|
|
|
|
|
|
#processes each one |
|
742
|
0
|
|
|
|
|
|
foreach (@$arrayref) { |
|
743
|
0
|
|
|
|
|
|
print $tobj->fill_in(data_hash=>%{$_},template=>$t); |
|
|
0
|
|
|
|
|
|
|
|
744
|
|
|
|
|
|
|
} |
|
745
|
0
|
|
|
|
|
|
return 1; |
|
746
|
|
|
|
|
|
|
} |
|
747
|
|
|
|
|
|
|
|
|
748
|
0
|
|
|
|
|
|
warn('ZConf-Weather run:14: The type, "'.$type.'", is not a valid type.'); |
|
749
|
0
|
|
|
|
|
|
$self->{error}=14; |
|
750
|
0
|
|
|
|
|
|
$self->{errorString}='The type, "'.$type.'", is not a valid type.'; |
|
751
|
|
|
|
|
|
|
|
|
752
|
0
|
|
|
|
|
|
return undef; |
|
753
|
|
|
|
|
|
|
} |
|
754
|
|
|
|
|
|
|
|
|
755
|
|
|
|
|
|
|
=head2 setLocal |
|
756
|
|
|
|
|
|
|
|
|
757
|
|
|
|
|
|
|
This sets a local. If it does not exist, it will be created. |
|
758
|
|
|
|
|
|
|
An already existing one will be overwriten. |
|
759
|
|
|
|
|
|
|
|
|
760
|
|
|
|
|
|
|
=head3 argsHash |
|
761
|
|
|
|
|
|
|
|
|
762
|
|
|
|
|
|
|
=head4 local |
|
763
|
|
|
|
|
|
|
|
|
764
|
|
|
|
|
|
|
This is the local it is for. |
|
765
|
|
|
|
|
|
|
|
|
766
|
|
|
|
|
|
|
=head4 name |
|
767
|
|
|
|
|
|
|
|
|
768
|
|
|
|
|
|
|
This is name that will be used differentiating between the |
|
769
|
|
|
|
|
|
|
various locals setup. It needs to be a valid ZConf set name. |
|
770
|
|
|
|
|
|
|
|
|
771
|
|
|
|
|
|
|
=head4 type |
|
772
|
|
|
|
|
|
|
|
|
773
|
|
|
|
|
|
|
This is what to do with it after downloading it. |
|
774
|
|
|
|
|
|
|
|
|
775
|
|
|
|
|
|
|
=head4 template |
|
776
|
|
|
|
|
|
|
|
|
777
|
|
|
|
|
|
|
The template to use if 'type' is set to 'template'. |
|
778
|
|
|
|
|
|
|
|
|
779
|
|
|
|
|
|
|
=cut |
|
780
|
|
|
|
|
|
|
|
|
781
|
|
|
|
|
|
|
sub setLocal{ |
|
782
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
783
|
0
|
|
|
|
|
|
my %args; |
|
784
|
0
|
0
|
|
|
|
|
if(defined($_[1])){ |
|
785
|
0
|
|
|
|
|
|
%args= %{$_[1]}; |
|
|
0
|
|
|
|
|
|
|
|
786
|
|
|
|
|
|
|
} |
|
787
|
0
|
|
|
|
|
|
my $function='setLocal'; |
|
788
|
|
|
|
|
|
|
|
|
789
|
|
|
|
|
|
|
#blanks any previous errors |
|
790
|
0
|
|
|
|
|
|
$self->errorblank; |
|
791
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
792
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set'); |
|
793
|
|
|
|
|
|
|
} |
|
794
|
|
|
|
|
|
|
|
|
795
|
|
|
|
|
|
|
#makes sure a locality is defined... this is the only one really needed... |
|
796
|
0
|
0
|
|
|
|
|
if (!defined($args{local})) { |
|
797
|
0
|
|
|
|
|
|
$self->{error}=3; |
|
798
|
0
|
|
|
|
|
|
$self->{errorString}='No local defined in %args'; |
|
799
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
800
|
0
|
|
|
|
|
|
return undef; |
|
801
|
|
|
|
|
|
|
} |
|
802
|
|
|
|
|
|
|
|
|
803
|
|
|
|
|
|
|
#error if the type is not defined |
|
804
|
0
|
0
|
|
|
|
|
if (!defined($args{type})) { |
|
805
|
0
|
|
|
|
|
|
$self->{error}=5; |
|
806
|
0
|
|
|
|
|
|
$self->{errorString}='No type defined in %args'; |
|
807
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
808
|
0
|
|
|
|
|
|
return undef; |
|
809
|
|
|
|
|
|
|
} |
|
810
|
|
|
|
|
|
|
|
|
811
|
|
|
|
|
|
|
#error if the type is not print or template |
|
812
|
0
|
0
|
0
|
|
|
|
if (($args{type} ne 'print') || ($args{type} ne 'template')) { |
|
813
|
0
|
|
|
|
|
|
$self->{error}=8; |
|
814
|
0
|
|
|
|
|
|
$self->{errorString}='"'.$args{type}.' is not a valid type'; |
|
815
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
816
|
0
|
|
|
|
|
|
return undef; |
|
817
|
|
|
|
|
|
|
} |
|
818
|
|
|
|
|
|
|
|
|
819
|
|
|
|
|
|
|
#make sure it is a legit name |
|
820
|
0
|
0
|
|
|
|
|
if (!defined($self->{zconf}->setNameLegit($args{name}))) { |
|
821
|
0
|
|
|
|
|
|
$self->{error}=4; |
|
822
|
0
|
|
|
|
|
|
$self->{errorString}='Name is not a valid name.'; |
|
823
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
824
|
0
|
|
|
|
|
|
return undef; |
|
825
|
|
|
|
|
|
|
} |
|
826
|
|
|
|
|
|
|
|
|
827
|
0
|
0
|
|
|
|
|
if ($args{type} eq 'template') { |
|
828
|
|
|
|
|
|
|
#error if no template is specified |
|
829
|
0
|
0
|
|
|
|
|
if (!defined($args{template})) { |
|
830
|
0
|
|
|
|
|
|
$self->{error}=6; |
|
831
|
0
|
|
|
|
|
|
$self->{errorString}='No template defined in %args'; |
|
832
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
833
|
0
|
|
|
|
|
|
return undef; |
|
834
|
|
|
|
|
|
|
} |
|
835
|
|
|
|
|
|
|
|
|
836
|
|
|
|
|
|
|
#return if templateExists errored |
|
837
|
0
|
|
|
|
|
|
my $returned=$self->templateExists($args{template}); |
|
838
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
839
|
0
|
|
|
|
|
|
warn('ZConf-Weather addLocal: templateExists errored'); |
|
840
|
0
|
|
|
|
|
|
return undef; |
|
841
|
|
|
|
|
|
|
} |
|
842
|
|
|
|
|
|
|
} |
|
843
|
|
|
|
|
|
|
|
|
844
|
|
|
|
|
|
|
#set the ZConf var for local |
|
845
|
0
|
|
|
|
|
|
$self->{zconf}->setVar('weather', 'locals/'.$args{name}.'/local', $args{local}); |
|
846
|
|
|
|
|
|
|
#we only need to check this once as if it works once |
|
847
|
|
|
|
|
|
|
#it will work for the others |
|
848
|
0
|
0
|
|
|
|
|
if ($self->{zconf}->{error}) { |
|
849
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
850
|
0
|
|
|
|
|
|
$self->{errorString}=' Error set the variable "locals/'.$args{name}.'/local"'. |
|
851
|
|
|
|
|
|
|
'for "weather" ZConf error="'.$self->{zconf}->{error}.'" '. |
|
852
|
|
|
|
|
|
|
'ZConf error string="'.$self->{zconf}->{errorString}.'"'; |
|
853
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
854
|
0
|
|
|
|
|
|
return undef; |
|
855
|
|
|
|
|
|
|
} |
|
856
|
|
|
|
|
|
|
|
|
857
|
|
|
|
|
|
|
#sets the template |
|
858
|
0
|
|
|
|
|
|
$self->{zconf}->setVar('weather', 'locals/'.$args{name}.'/type', $args{type}); |
|
859
|
|
|
|
|
|
|
|
|
860
|
|
|
|
|
|
|
#only set the template if it is set to it |
|
861
|
0
|
0
|
|
|
|
|
if ($args{type} eq 'template') { |
|
862
|
|
|
|
|
|
|
#set the template if the type is set to #template |
|
863
|
0
|
|
|
|
|
|
$self->{zconf}->setVar('weather', 'locals/'.$args{name}.'/type', $args{type}); |
|
864
|
|
|
|
|
|
|
} |
|
865
|
|
|
|
|
|
|
|
|
866
|
0
|
|
|
|
|
|
return 1; |
|
867
|
|
|
|
|
|
|
} |
|
868
|
|
|
|
|
|
|
|
|
869
|
|
|
|
|
|
|
=head2 setTemplate |
|
870
|
|
|
|
|
|
|
|
|
871
|
|
|
|
|
|
|
This sets a specified template to the given value. |
|
872
|
|
|
|
|
|
|
|
|
873
|
|
|
|
|
|
|
$zcw->setTemplate($templateName, $template); |
|
874
|
|
|
|
|
|
|
if ($zcw->{error}) { |
|
875
|
|
|
|
|
|
|
print "Error!\n"; |
|
876
|
|
|
|
|
|
|
} |
|
877
|
|
|
|
|
|
|
|
|
878
|
|
|
|
|
|
|
=cut |
|
879
|
|
|
|
|
|
|
|
|
880
|
|
|
|
|
|
|
sub setTemplate{ |
|
881
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
882
|
0
|
|
|
|
|
|
my $name=$_[1]; |
|
883
|
0
|
|
|
|
|
|
my $template=$_[2]; |
|
884
|
0
|
|
|
|
|
|
my $function='setTemplate'; |
|
885
|
|
|
|
|
|
|
|
|
886
|
|
|
|
|
|
|
#blanks any previous errors |
|
887
|
0
|
|
|
|
|
|
$self->errorblank; |
|
888
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
889
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set'); |
|
890
|
|
|
|
|
|
|
} |
|
891
|
|
|
|
|
|
|
|
|
892
|
|
|
|
|
|
|
#make sure a name for the template is specified |
|
893
|
0
|
0
|
|
|
|
|
if (!defined($name)) { |
|
894
|
0
|
|
|
|
|
|
$self->{error}=6; |
|
895
|
0
|
|
|
|
|
|
$self->{errorstring}='No template specified.'; |
|
896
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
897
|
0
|
|
|
|
|
|
return undef; |
|
898
|
|
|
|
|
|
|
} |
|
899
|
|
|
|
|
|
|
|
|
900
|
|
|
|
|
|
|
#make sure a template is specified |
|
901
|
0
|
0
|
|
|
|
|
if (!defined($template)) { |
|
902
|
0
|
|
|
|
|
|
$self->{error}=9; |
|
903
|
0
|
|
|
|
|
|
$self->{errorstring}='No template specified.'; |
|
904
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
905
|
0
|
|
|
|
|
|
return undef; |
|
906
|
|
|
|
|
|
|
} |
|
907
|
|
|
|
|
|
|
|
|
908
|
0
|
|
|
|
|
|
$self->{zconf}->setVar('weather', 'templates/'.$name, $template); |
|
909
|
0
|
0
|
|
|
|
|
if ($self->{zconf}->{error}) { |
|
910
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
911
|
0
|
|
|
|
|
|
$self->{errorString}=' Error set the variable "templates/'.$name.'"'. |
|
912
|
|
|
|
|
|
|
'for "weather" ZConf error="'.$self->{zconf}->{error}.'" '. |
|
913
|
|
|
|
|
|
|
'ZConf error string="'.$self->{zconf}->{errorString}.'"'; |
|
914
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
915
|
0
|
|
|
|
|
|
return undef; |
|
916
|
|
|
|
|
|
|
} |
|
917
|
|
|
|
|
|
|
|
|
918
|
0
|
|
|
|
|
|
return 1; |
|
919
|
|
|
|
|
|
|
} |
|
920
|
|
|
|
|
|
|
|
|
921
|
|
|
|
|
|
|
=head2 templateExists |
|
922
|
|
|
|
|
|
|
|
|
923
|
|
|
|
|
|
|
This makes sure a specified template exists. |
|
924
|
|
|
|
|
|
|
|
|
925
|
|
|
|
|
|
|
my $returned=$zcw->templateExists('someTemplate'); |
|
926
|
|
|
|
|
|
|
if($zcw->{error}){ |
|
927
|
|
|
|
|
|
|
print "Error!\n"; |
|
928
|
|
|
|
|
|
|
}else{ |
|
929
|
|
|
|
|
|
|
if($returned){ |
|
930
|
|
|
|
|
|
|
print "It exists.\n"; |
|
931
|
|
|
|
|
|
|
} |
|
932
|
|
|
|
|
|
|
} |
|
933
|
|
|
|
|
|
|
|
|
934
|
|
|
|
|
|
|
=cut |
|
935
|
|
|
|
|
|
|
|
|
936
|
|
|
|
|
|
|
sub templateExists{ |
|
937
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
938
|
0
|
|
|
|
|
|
my $template=$_[1]; |
|
939
|
0
|
|
|
|
|
|
my $function='templateExists'; |
|
940
|
|
|
|
|
|
|
|
|
941
|
0
|
|
|
|
|
|
$self->errorblank; |
|
942
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
943
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set'); |
|
944
|
|
|
|
|
|
|
} |
|
945
|
|
|
|
|
|
|
|
|
946
|
0
|
|
|
|
|
|
my @templates=$self->listTemplates; |
|
947
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
948
|
0
|
|
|
|
|
|
warn('ZConf-Weather templateExists: listTemplates errored'); |
|
949
|
0
|
|
|
|
|
|
return undef; |
|
950
|
|
|
|
|
|
|
} |
|
951
|
|
|
|
|
|
|
|
|
952
|
0
|
|
|
|
|
|
my $int=0; |
|
953
|
0
|
|
|
|
|
|
while (defined($templates[$int])) { |
|
954
|
0
|
0
|
|
|
|
|
if ($templates[$int] eq $template) { |
|
955
|
0
|
|
|
|
|
|
return 1; |
|
956
|
|
|
|
|
|
|
} |
|
957
|
|
|
|
|
|
|
|
|
958
|
0
|
|
|
|
|
|
$int++; |
|
959
|
|
|
|
|
|
|
} |
|
960
|
|
|
|
|
|
|
|
|
961
|
0
|
|
|
|
|
|
return undef; |
|
962
|
|
|
|
|
|
|
} |
|
963
|
|
|
|
|
|
|
|
|
964
|
|
|
|
|
|
|
=head2 errorblank |
|
965
|
|
|
|
|
|
|
|
|
966
|
|
|
|
|
|
|
This blanks the error storage and is only meant for internal usage. |
|
967
|
|
|
|
|
|
|
|
|
968
|
|
|
|
|
|
|
It does the following. |
|
969
|
|
|
|
|
|
|
|
|
970
|
|
|
|
|
|
|
$self->{error}=undef; |
|
971
|
|
|
|
|
|
|
$self->{errorString}=""; |
|
972
|
|
|
|
|
|
|
|
|
973
|
|
|
|
|
|
|
=cut |
|
974
|
|
|
|
|
|
|
|
|
975
|
|
|
|
|
|
|
#blanks the error flags |
|
976
|
|
|
|
|
|
|
sub errorblank{ |
|
977
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
978
|
|
|
|
|
|
|
|
|
979
|
0
|
0
|
|
|
|
|
if ($self->{perror}) { |
|
980
|
0
|
|
|
|
|
|
return undef; |
|
981
|
|
|
|
|
|
|
} |
|
982
|
|
|
|
|
|
|
|
|
983
|
0
|
|
|
|
|
|
$self->{error}=undef; |
|
984
|
0
|
|
|
|
|
|
$self->{errorString}=""; |
|
985
|
|
|
|
|
|
|
|
|
986
|
0
|
|
|
|
|
|
return 1; |
|
987
|
|
|
|
|
|
|
} |
|
988
|
|
|
|
|
|
|
|
|
989
|
|
|
|
|
|
|
=head1 ERROR CODES |
|
990
|
|
|
|
|
|
|
|
|
991
|
|
|
|
|
|
|
=head2 1 |
|
992
|
|
|
|
|
|
|
|
|
993
|
|
|
|
|
|
|
Could not initialize ZConf. |
|
994
|
|
|
|
|
|
|
|
|
995
|
|
|
|
|
|
|
=head2 2 |
|
996
|
|
|
|
|
|
|
|
|
997
|
|
|
|
|
|
|
ZConf error. |
|
998
|
|
|
|
|
|
|
|
|
999
|
|
|
|
|
|
|
=head2 3 |
|
1000
|
|
|
|
|
|
|
|
|
1001
|
|
|
|
|
|
|
No local defined. |
|
1002
|
|
|
|
|
|
|
|
|
1003
|
|
|
|
|
|
|
=head2 4 |
|
1004
|
|
|
|
|
|
|
|
|
1005
|
|
|
|
|
|
|
Invalid set name. |
|
1006
|
|
|
|
|
|
|
|
|
1007
|
|
|
|
|
|
|
=head2 5 |
|
1008
|
|
|
|
|
|
|
|
|
1009
|
|
|
|
|
|
|
No type specified. |
|
1010
|
|
|
|
|
|
|
|
|
1011
|
|
|
|
|
|
|
=head2 6 |
|
1012
|
|
|
|
|
|
|
|
|
1013
|
|
|
|
|
|
|
No template name specified. |
|
1014
|
|
|
|
|
|
|
|
|
1015
|
|
|
|
|
|
|
=head2 7 |
|
1016
|
|
|
|
|
|
|
|
|
1017
|
|
|
|
|
|
|
Non-existant template. |
|
1018
|
|
|
|
|
|
|
|
|
1019
|
|
|
|
|
|
|
=head2 8 |
|
1020
|
|
|
|
|
|
|
|
|
1021
|
|
|
|
|
|
|
Invalid type specified. |
|
1022
|
|
|
|
|
|
|
|
|
1023
|
|
|
|
|
|
|
=head2 9 |
|
1024
|
|
|
|
|
|
|
|
|
1025
|
|
|
|
|
|
|
No template specified. |
|
1026
|
|
|
|
|
|
|
|
|
1027
|
|
|
|
|
|
|
=head2 10 |
|
1028
|
|
|
|
|
|
|
|
|
1029
|
|
|
|
|
|
|
Local does not exist. |
|
1030
|
|
|
|
|
|
|
|
|
1031
|
|
|
|
|
|
|
=head2 11 |
|
1032
|
|
|
|
|
|
|
|
|
1033
|
|
|
|
|
|
|
Failed to init the module Weather::Underground. |
|
1034
|
|
|
|
|
|
|
|
|
1035
|
|
|
|
|
|
|
=head2 12 |
|
1036
|
|
|
|
|
|
|
|
|
1037
|
|
|
|
|
|
|
Failed to fetch the weather. |
|
1038
|
|
|
|
|
|
|
|
|
1039
|
|
|
|
|
|
|
=head2 13 |
|
1040
|
|
|
|
|
|
|
|
|
1041
|
|
|
|
|
|
|
Template does not exist. |
|
1042
|
|
|
|
|
|
|
|
|
1043
|
|
|
|
|
|
|
=head2 14 |
|
1044
|
|
|
|
|
|
|
|
|
1045
|
|
|
|
|
|
|
The type is not valid. |
|
1046
|
|
|
|
|
|
|
|
|
1047
|
|
|
|
|
|
|
=head2 15 |
|
1048
|
|
|
|
|
|
|
|
|
1049
|
|
|
|
|
|
|
No default local specified. |
|
1050
|
|
|
|
|
|
|
|
|
1051
|
|
|
|
|
|
|
=head2 16 |
|
1052
|
|
|
|
|
|
|
|
|
1053
|
|
|
|
|
|
|
getDefaultLocal errors and no local is specified. |
|
1054
|
|
|
|
|
|
|
|
|
1055
|
|
|
|
|
|
|
=head2 17 |
|
1056
|
|
|
|
|
|
|
|
|
1057
|
|
|
|
|
|
|
No default type specified. |
|
1058
|
|
|
|
|
|
|
|
|
1059
|
|
|
|
|
|
|
=head1 ZConf Keys |
|
1060
|
|
|
|
|
|
|
|
|
1061
|
|
|
|
|
|
|
=head2 Misc Keys |
|
1062
|
|
|
|
|
|
|
|
|
1063
|
|
|
|
|
|
|
=head3 defaultLocal |
|
1064
|
|
|
|
|
|
|
|
|
1065
|
|
|
|
|
|
|
This is the default local to act upon if not specified. |
|
1066
|
|
|
|
|
|
|
|
|
1067
|
|
|
|
|
|
|
=head3 defaultType |
|
1068
|
|
|
|
|
|
|
|
|
1069
|
|
|
|
|
|
|
This is the default thing to do. |
|
1070
|
|
|
|
|
|
|
|
|
1071
|
|
|
|
|
|
|
=head3 defaultTemplate |
|
1072
|
|
|
|
|
|
|
|
|
1073
|
|
|
|
|
|
|
This is the default template name to use. |
|
1074
|
|
|
|
|
|
|
|
|
1075
|
|
|
|
|
|
|
=head2 Local Keys |
|
1076
|
|
|
|
|
|
|
|
|
1077
|
|
|
|
|
|
|
=head3 locals/*/local |
|
1078
|
|
|
|
|
|
|
|
|
1079
|
|
|
|
|
|
|
This is the location it is for. It can be specified as 'City', |
|
1080
|
|
|
|
|
|
|
'City, State', 'State', 'State, Country', or 'Country'. |
|
1081
|
|
|
|
|
|
|
|
|
1082
|
|
|
|
|
|
|
=head3 locals/*/type |
|
1083
|
|
|
|
|
|
|
|
|
1084
|
|
|
|
|
|
|
This specifies what should be done when fetching it. |
|
1085
|
|
|
|
|
|
|
|
|
1086
|
|
|
|
|
|
|
=head4 dump |
|
1087
|
|
|
|
|
|
|
|
|
1088
|
|
|
|
|
|
|
Prints it in 'variable=value' format. |
|
1089
|
|
|
|
|
|
|
|
|
1090
|
|
|
|
|
|
|
=head4 template |
|
1091
|
|
|
|
|
|
|
|
|
1092
|
|
|
|
|
|
|
This prints it using the specied template name. The template name being |
|
1093
|
|
|
|
|
|
|
'templates/'. |
|
1094
|
|
|
|
|
|
|
|
|
1095
|
|
|
|
|
|
|
=head2 Template Keys |
|
1096
|
|
|
|
|
|
|
|
|
1097
|
|
|
|
|
|
|
=head3 templates/* |
|
1098
|
|
|
|
|
|
|
|
|
1099
|
|
|
|
|
|
|
This is a template. For please see the section TEMPLATE for more information on |
|
1100
|
|
|
|
|
|
|
the keys and etc. |
|
1101
|
|
|
|
|
|
|
|
|
1102
|
|
|
|
|
|
|
'*' can be any zconf compatible var name. |
|
1103
|
|
|
|
|
|
|
|
|
1104
|
|
|
|
|
|
|
=head1 AUTHOR |
|
1105
|
|
|
|
|
|
|
|
|
1106
|
|
|
|
|
|
|
Zane C. Bowers, C<< >> |
|
1107
|
|
|
|
|
|
|
|
|
1108
|
|
|
|
|
|
|
=head1 BUGS |
|
1109
|
|
|
|
|
|
|
|
|
1110
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
|
1111
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
|
1112
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
|
1113
|
|
|
|
|
|
|
|
|
1114
|
|
|
|
|
|
|
|
|
1115
|
|
|
|
|
|
|
|
|
1116
|
|
|
|
|
|
|
|
|
1117
|
|
|
|
|
|
|
=head1 SUPPORT |
|
1118
|
|
|
|
|
|
|
|
|
1119
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
1120
|
|
|
|
|
|
|
|
|
1121
|
|
|
|
|
|
|
perldoc ZConf::Weather |
|
1122
|
|
|
|
|
|
|
|
|
1123
|
|
|
|
|
|
|
|
|
1124
|
|
|
|
|
|
|
You can also look for information at: |
|
1125
|
|
|
|
|
|
|
|
|
1126
|
|
|
|
|
|
|
=over 4 |
|
1127
|
|
|
|
|
|
|
|
|
1128
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
|
1129
|
|
|
|
|
|
|
|
|
1130
|
|
|
|
|
|
|
L |
|
1131
|
|
|
|
|
|
|
|
|
1132
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
1133
|
|
|
|
|
|
|
|
|
1134
|
|
|
|
|
|
|
L |
|
1135
|
|
|
|
|
|
|
|
|
1136
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
1137
|
|
|
|
|
|
|
|
|
1138
|
|
|
|
|
|
|
L |
|
1139
|
|
|
|
|
|
|
|
|
1140
|
|
|
|
|
|
|
=item * Search CPAN |
|
1141
|
|
|
|
|
|
|
|
|
1142
|
|
|
|
|
|
|
L |
|
1143
|
|
|
|
|
|
|
|
|
1144
|
|
|
|
|
|
|
=back |
|
1145
|
|
|
|
|
|
|
|
|
1146
|
|
|
|
|
|
|
|
|
1147
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
|
1148
|
|
|
|
|
|
|
|
|
1149
|
|
|
|
|
|
|
|
|
1150
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
1151
|
|
|
|
|
|
|
|
|
1152
|
|
|
|
|
|
|
Copyright 2009 Zane C. Bowers, all rights reserved. |
|
1153
|
|
|
|
|
|
|
|
|
1154
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
1155
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
1156
|
|
|
|
|
|
|
|
|
1157
|
|
|
|
|
|
|
|
|
1158
|
|
|
|
|
|
|
=cut |
|
1159
|
|
|
|
|
|
|
|
|
1160
|
|
|
|
|
|
|
1; # End of ZConf::Weather |