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.3.tar.gz (3.2 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.3-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: whatnow-0.1.3.tar.gz
  • Upload date:
  • Size: 3.2 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.3.tar.gz
Algorithm Hash digest
SHA256 c9104d6fe6d22eb662feca0c79540088fa87cb748116cf11ee9a7933586b3c98
MD5 5de6ae989991ef3c342262ab14367bef
BLAKE2b-256 bd59b3550c5f6f7f4c77c4e30afb6e3a6580d15feaec856b7a606a56ab3f0fc4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: whatnow-0.1.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4bca47ef1db410a8a48fc9f984e8466d5520caf47e8f6f84a99eb5a8344475d0
MD5 9959ebe5350ca798fb6631e44f34a3dd
BLAKE2b-256 40f00421452be9a8eabfe0190e0a5e61ff2c3e290dbddc4369f720a670f1a926

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