Imported from archive.
[weather.git] / weather
1 #!/usr/bin/python
2
3 # Copyright (c) 2006 Jeremy Stanley <fungi@yuggoth.org>, all rights reserved.
4 # Licensed per terms in the LICENSE file distributed with this software.
5
6 import weather
7
8 # initialize options and configs
9 selections = weather.Selections()
10 get = selections.get
11 get_boolean = selections.get_boolean
12
13 # this mode just lists the aliases defined in the config
14 if get_boolean("list"): print weather.list_aliases(selections.config)
15
16 # normal operation
17 else:
18         for argument in selections.arguments:
19                 if get_boolean("conditions", argument):
20                         print weather.get_metar(
21                                 get("id", argument),
22                                 get_boolean("verbose", argument)
23                                 )
24                 if not get_boolean("conditions", argument) \
25                         or get_boolean("forecast", argument):
26                         print weather.get_forecast(
27                                 get("city", argument),
28                                 get("st", argument),
29                                 get_boolean("verbose", argument)
30                                 )
31