Imported from archive.
[weather.git] / weather
1 #!/usr/bin/env python
2
3 # weather version 1.3, 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 # added so distributors can consistently specify a private module location
10 private_module_path = None
11 if private_module_path:
12         import sys
13         sys.path.insert(1, private_module_path)
14
15 import weather
16
17 # initialize options and configs
18 selections = weather.Selections()
19 get = selections.get
20 get_bool = selections.get_bool
21
22 # this mode just lists the aliases defined in the config
23 if get_bool("list"): print weather.list_aliases(selections.config)
24
25 # normal operation
26 else:
27         for argument in selections.arguments:
28                 if get_bool("conditions", argument):
29                         print weather.get_metar(
30                                 get("id", argument),
31                                 get_bool("verbose", argument)
32                                 )
33                 if not get_bool("conditions", argument) \
34                         or get_bool("forecast", argument):
35                         print weather.get_forecast(
36                                 get("city", argument),
37                                 get("st", argument),
38                                 get_bool("verbose", argument)
39                                 )
40