X-Git-Url: https://www.yuggoth.org/gitweb?p=weather.git;a=blobdiff_plain;f=weather;h=dc0601c5f549a81f432ed4a628b1d19dba8e2e31;hp=1110ea094a7be87ca5968872a4a9459a40954f36;hb=4d25a49d5a5ec5415f8e83ba26fea5adf4e5512a;hpb=b755668b64a70bb7b0efbf1bd0aff8c310471ee1 diff --git a/weather b/weather index 1110ea0..dc0601c 100755 --- a/weather +++ b/weather @@ -1,11 +1,19 @@ #!/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.1, http://fungi.yuggoth.org/weather/ -# Copyright (c) 2006 Jeremy Stanley , all rights reserved. -# Licensed per terms in the LICENSE file distributed with this software. +# Copyright (c) 2006-2010 Jeremy Stanley . 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.""" +# added so distributors can consistently specify a private module location +private_module_path = None +if private_module_path: + import sys + sys.path.insert(1, private_module_path) + import weather # initialize options and configs @@ -18,17 +26,52 @@ if get_bool("list"): print weather.list_aliases(selections.config) # normal operation else: - for argument in selections.arguments: - if get_bool("conditions", argument): - print weather.get_metar( - get("id", argument), - get_bool("verbose", argument) - ) - if not get_bool("conditions", argument) \ - or get_bool("forecast", argument): - print weather.get_forecast( - get("city", argument), - get("st", argument), - get_bool("verbose", argument) - ) - + output = "" + for argument in selections.arguments: + 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), + 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), + 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 )