Skip to content

Commit

Permalink
Temp. units formatting altered; [S]unrise/sunset item added
Browse files Browse the repository at this point in the history
  • Loading branch information
nwg-piotr committed Jan 31, 2019
1 parent 25e72c8 commit 37d5500
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions scripts-arch/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def main():
except AttributeError:
pass

unit = "" if settings.units == "imperial" else ""
unit = "°F" if settings.units == "imperial" else "°C"
try:
temp = str(round(float(str(getattr(owm.main, "temp"))), 1)) + unit
except AttributeError:
Expand Down Expand Up @@ -212,7 +212,7 @@ def main():
if settings.items[i] == "w" and wind is not None:
output += " " + wind + " "
if settings.items[i] == "S" and sunrise is not None and sunset is not None:
output += " " + settings.dict["_sunrise"] + " " + sunrise + " " + settings.dict["_sunset"] + " " + sunset + " "
output += " " + settings.dict["_sunrise"] + sunrise + " " + settings.dict["_sunset"] + sunset + " "

print(re.sub(' +', ' ', output).strip())

Expand Down
6 changes: 4 additions & 2 deletions scripts-void/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def main():
except AttributeError:
pass

unit = "" if settings.units == "imperial" else ""
unit = "°F" if settings.units == "imperial" else "°C"
try:
temp = str(round(float(str(getattr(owm.main, "temp"))), 1)) + unit
except AttributeError:
Expand Down Expand Up @@ -211,6 +211,8 @@ def main():
output += " " + humidity + " "
if settings.items[i] == "w" and wind is not None:
output += " " + wind + " "
if settings.items[i] == "S" and sunrise is not None and sunset is not None:
output += " " + settings.dict["_sunrise"] + sunrise + " " + settings.dict["_sunset"] + sunset + " "

print(re.sub(' +', ' ', output).strip())

Expand Down Expand Up @@ -266,7 +268,7 @@ def print_help():

print("\nt2ec --weather [-I<items>] [-A<api_key>] [-C<city_id>] [-U<units>] [-L<lang>]")

print("\n<items>: [s]hort description, [d]escription, [t]emperature, [p]ressure, [h]umidity, [w]ind, [c]ity name")
print("\n<items>: [s]hort description, [d]escription, [t]emperature, [p]ressure, [h]umidity, [w]ind, [c]ity name, [S]unrise/sunset")

print("\nTo show details as a notification:")

Expand Down

0 comments on commit 37d5500

Please sign in to comment.