Skip to main content

A module to get the the current Day, Date, Time and Temperature

Project description

Whatnow

Whatnow is a Python module that retrieves the current weather details for your location. It uses the OpenWeatherMap API to fetch weather data and geocoder to determine your current location based on your IP address.

Features

  • Get current temperature, humidity, wind speed, and cloudiness
  • Check if it is raining or snowing
  • Display the current date, time, and day of the week

Installation

To use this module, you need to install the required dependencies:

pip install requests geocoder

Usage

Get an API Key from OpenWeatherMap

Sign up at OpenWeatherMap to get your free API key.

Update the API Key in the Script

Replace the placeholder API key in the script with your actual API key:
python

api_key = "your_actual_api_key_here"

Run the Script

Execute the script to get the current weather details:

bash

python whatnow.py

Example Output

markdown


City: Your City Date: 2023-05-26 Time: 14:23:45 Day: Friday Temperature: 25.0°C Humidity: 60% Wind Speed: 5.0 m/s It's Clear

Functions

get_weather_details(city_name, api_key)

Fetches weather details for the specified city using the OpenWeatherMap API.

Parameters:
    city_name (str): The name of the city to fetch weather details for.
    api_key (str): Your OpenWeatherMap API key.

Returns:
    A dictionary with weather details such as temperature, humidity, wind speed, cloudiness, and whether it is raining or snowing.

get_location()

Determines the current location based on the IP address.

Returns:
    A geocoder location object.

extract_city(location)

Extracts the city name from a geocoder location object.

Parameters:
    location (geocoder object): The location object to extract the city from.

Returns:
    The name of the city (str).

get_current_datetime()

Gets the current date, time, and day of the week.

Returns:
    A tuple containing the current date (str), time (str), and day (str).

main()

Main function that orchestrates the retrieval and display of weather details. License

This project is licensed under the MIT License. See the LICENSE file for details. Contributing

Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes. Author

Deepak Kumar Upadhayay - dku3132@gmail.com Acknowledgments

OpenWeatherMap for providing the weather API.
Geocoder for providing the location API.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

whatnow-0.1.2.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

whatnow-0.1.2-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file whatnow-0.1.2.tar.gz.

File metadata

  • Download URL: whatnow-0.1.2.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/7.1.0 keyring/24.3.1 pkginfo/1.10.0 readme-renderer/34.0 requests-toolbelt/1.0.0 requests/2.31.0 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12

File hashes

Hashes for whatnow-0.1.2.tar.gz
Algorithm Hash digest
SHA256 025bf4f76472a86278f185967e02c93d422f27eaa4daf0b768fbf85be0e4b052
MD5 3b89d08a0babe5e861190735e3285dbf
BLAKE2b-256 1659367212c33c47c784903b5d50eb8aa7ad237f771ede910f216e01b33aca11

See more details on using hashes here.

File details

Details for the file whatnow-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: whatnow-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 3.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/7.1.0 keyring/24.3.1 pkginfo/1.10.0 readme-renderer/34.0 requests-toolbelt/1.0.0 requests/2.31.0 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12

File hashes

Hashes for whatnow-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8fdd7eaf36afabb51e40b986511f8db69ce38c1cdb5d0300af0e0d3e778e403f
MD5 74effd03ac08ebfdb5fb6903eb8dadd1
BLAKE2b-256 163fd12e502e3949ebc104487fb5e8b49871a402b0203213f28fbdc05f607fa7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page