Imported from archive.

* Release 1.5.

* (all): Updated copyright notices for 2010.

* FAQ, INSTALL, LICENSE, README: Reformatted as ReStructuredText.

* FAQ: Updated to mention alternative sources for NOAA's stations
list, in case the recommended one is unavailable (thanks Celejar!).

* NEWS: Renamed to ChangeLog and refactored into GNU format.

* weather: Added some comment padding between the shebang line and
the copyright, so that distributions wishing to carry patches which
modify the interpreter path don't have to refresh them every year
when the copyright line changes in their context.

* weather, weather.1, weatherrc.5, weather.py: Added experimental
alert, atypes, aurl and zones options to support retrieval,
filtering and formatting of unexpired NWS severe weather advisories.

* weather.1, weatherrc.5: Minor cosmetic fixes to option
descriptions.

* weather.1, weatherrc.5, weather.py: Added imperial and metric
options to filter/convert display units (thanks to Andrew Carter for
this suggestion!).

* weather.py: Fixed a METAR parsing error which would trigger an
IndexError exception if the NWS didn't have a station description on
file (thanks to Celejar for reporting the bug!). Fixed METAR title
line parsing to look for human-readable city and state in the first
line--previous code stopped showing the city name after NWS made
slight format mods. Upped the version to 1.5.

* weatherrc: Additional PIE (Saint Petersburg, FL), PNC (Ponca City,
OK), and PNS (Pensacola, FL) aliases.
This commit is contained in:
Jeremy Stanley
2010-03-19 13:30:22 +00:00
parent 8349654b7c
commit 4d25a49d5a
9 changed files with 522 additions and 197 deletions

58
weather
View File

@@ -1,10 +1,10 @@
#!/usr/bin/env python
# distributions may wish to edit the above to refer to a specific interpreter
# path, such as #!/usr/bin/python
# weather version 1.4, http://fungi.yuggoth.org/weather/
# Copyright (c) 2006-2008 Jeremy Stanley <fungi@yuggoth.org>.
# Permission to use, copy, modify, and distribute this software is
# granted under terms provided in the LICENSE file distributed with
# this software.
# Copyright (c) 2006-2010 Jeremy Stanley <fungi@yuggoth.org>. Permission to
# use, copy, modify, and distribute this software is granted under terms
# provided in the LICENSE file distributed with this software.
"""Wrapper utility using the weather.py module."""
@@ -26,22 +26,52 @@ if get_bool("list"): print weather.list_aliases(selections.config)
# normal operation
else:
output = ""
for argument in selections.arguments:
if get_bool("conditions", argument):
print weather.get_metar(
if get_bool("conditions", argument) or not (
get_bool("alert", argument) or get_bool("forecast", argument)
):
partial = weather.get_metar(
id=get("id", argument),
verbose=get_bool("verbose", argument),
quiet=get_bool("quiet", argument),
headers=get("headers", argument),
murl=get("murl", argument)
)
if not get_bool("conditions", argument) \
or get_bool("forecast", argument):
print weather.get_forecast(
murl=get("murl", argument),
imperial=get_bool("imperial", argument),
metric=get_bool("metric", argument)
)
if partial: output += partial + "\n"
if get_bool("forecast", argument) or not (
get_bool("alert", argument) or get_bool("conditions", argument)
):
partial = weather.get_forecast(
city=get("city", argument),
st=get("st", argument),
verbose=get_bool("verbose", argument),
quiet=get_bool("quiet", argument),
flines=get("flines", argument),
furl=get("furl", argument)
)
furl=get("furl", argument),
imperial=get_bool("imperial", argument),
metric=get_bool("metric", argument)
)
if partial: output += partial + "\n"
if get_bool("alert", argument) or not (
get_bool("conditions", argument) or get_bool("forecast", argument)
):
alert_text = ""
for atype in get("atypes", argument).split(","):
for zone in get("zones", argument).split(","):
partial = weather.get_alert(
zone=zone,
verbose=get_bool("verbose", argument),
quiet=get_bool("quiet", argument),
atype=atype,
aurl=get("aurl", argument),
imperial=get_bool("imperial", argument),
metric=get_bool("metric", argument)
)
if partial: alert_text += partial + "\n"
if not alert_text: alert_text = "(no current alerts for your zones)\n"
output += alert_text
output = output.strip()
if output: print( output )