Giter Club home page Giter Club logo

Comments (3)

wizpig64 avatar wizpig64 commented on May 30, 2024

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.

null8626 avatar null8626 commented on May 30, 2024

I might add a documentation page in the future, development slowed down a lot because i am currently very busy. Sorry!

from python-weather.

thatgaypigeon avatar thatgaypigeon commented on May 30, 2024

👍

from python-weather.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.