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