Comments (3)
DailyForecast doesn't seem to have any text descriptions available for an entire daily forecast. I tackled this problem by taking all of the unique descriptions from the hourly forecasts within the daily, and joining them together:
import asyncio
import python_weather
from python_weather.forecast import CurrentForecast, DailyForecast
F = python_weather.IMPERIAL
def render_current(x: CurrentForecast) -> str:
return f"{x.temperature}°{F}, {x.description}."
def render_daily(x: DailyForecast) -> str:
t = f"{x.lowest_temperature}-{x.average_temperature}-{x.highest_temperature}"
descriptions = ", ".join(set(h.description for h in x.hourly))
emoji = "".join(map(repr, set(h.type for h in x.hourly)))
return f"{x.date:%a}: {t}°{F}, {descriptions}. {emoji}"
async def print_weather():
async with python_weather.Client(format=F) as client:
weather = await client.get("Seattle")
print(render_current(weather.current))
for forecast in weather.forecasts:
print(render_daily(forecast))
if __name__ == '__main__':
asyncio.run(print_weather())
71°F, Clear.
Mon: 58-72-91°F, Sunny, Partly cloudy, Clear. ⛅️☀️
Tue: 56-70-88°F, Sunny, Clear. ☀️
Wed: 59-74-93°F, Sunny, Clear. ☀️
I don't see a docs page, but you can just browse the source directly: https://github.com/null8626/python-weather/blob/main/python_weather/forecast.py
from python-weather.
I might add a documentation page in the future, development slowed down a lot because i am currently very busy. Sorry!
from python-weather.
👍
from python-weather.
Related Issues (20)
- TypeError: function() argument 'code' must be code, not str HOT 1
- weather forecast is not updating HOT 2
- when passing in to the function different locations nothing returns. HOT 5
- Cant use if you ever forgot to close client HOT 1
- Debian specific requirements for your docs HOT 10
- The MSN API is retired HOT 5
- print(forecast) returns AttributeError HOT 2
- Temperature is incorrect and with/without state produces different results HOT 7
- Change language HOT 1
- How to convert time to normal view ? HOT 2
- City list HOT 4
- Problem with forecasts HOT 6
- Sky_text aint working HOT 2
- How can i show where the weather is shown? HOT 3
- Set days in forecast HOT 1
- How do I access the UV Index number like I could in older versions? E.g. 3 instead of "Low" HOT 4
- ValueError: 308 is not a valid WeatherType HOT 5
- Getting history of weather HOT 1
- Trouble installing HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-weather.