cloudydays 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
cloudydays/__init__.py ADDED
@@ -0,0 +1 @@
1
+ from cloudydays.cloudydays import Weather
@@ -0,0 +1,53 @@
1
+ import requests
2
+
3
+ #url = "https://api.openweathermap.org/data/2.5/forecast?q=Madrid&appid=0fb99a8f1507b587e934aeb045ff14ba&units=imperial"
4
+ #url = "https://api.openweathermap.org/data/2.5/forecast?lat=40.1&lon=3.4&appid=0fb99a8f1507b587e934aeb045ff14ba&units=imperial"
5
+
6
+ class Weather:
7
+ """Creates a Weather object getting an API key as input and either a city name or long and lat coordinates.
8
+
9
+ Package use example:
10
+
11
+ # Create a weather object using a city name:
12
+ # The api key below is not guaranteed to work.
13
+ # Get your own api key from https://openweathermap.org
14
+ # And wait a couple of hours for the api key to be activated
15
+
16
+ >>> weather1 = Weather(apikey = "0fb99a8f1507b587e934aeb045ff14ba", city = "Madrid")
17
+
18
+ # Using latitude and longitude coordinates
19
+ >>> weather2 = Weather(apikey = "0fb99a8f1507b587e934aeb045ff14ba", lat = 41.1, lon = -4.1)
20
+
21
+ # Get complete weather data for the next 12 hours:
22
+ >>> weather1.next_12h()
23
+
24
+ # Simplified data for the next 12 hours:
25
+ >>> weather1.next_12h_simplified()
26
+ """
27
+
28
+ def __init__(self, apikey, city=None, lat=None, lon=None):
29
+ if city:
30
+ url = f"https://api.openweathermap.org/data/2.5/forecast?q={city}&appid={apikey}&units=imperial"
31
+ r = requests.get(url)
32
+ self.data = r.json()
33
+ elif lat and lon:
34
+ url = f"https://api.openweathermap.org/data/2.5/forecast?lat={lat}&lon={lon}&appid={apikey}&units=imperial"
35
+ r = requests.get(url)
36
+ self.data = r.json()
37
+ else:
38
+ raise TypeError("Provide either a city or lat and long arguments")
39
+
40
+ if self.data["cod"] != "200":
41
+ raise ValueError(self.data["message"])
42
+
43
+ def next_12h(self):
44
+ """Returns 3-hour data for the next 12 hours as a dict."""
45
+ return self.data['list'][:4]
46
+
47
+ def next_12h_simplified(self):
48
+ """Returns date, temperature, and sky condition every 3 hours
49
+ for the next 12 hours as a tuple of tuples"""
50
+ simple_data = []
51
+ for dicty in self.data['list'][:4]:
52
+ simple_data.append((dicty['dt_txt'], dicty['main']['temp'], dicty['weather'][0]['description']))
53
+ return simple_data
@@ -0,0 +1,26 @@
1
+ Metadata-Version: 2.4
2
+ Name: cloudydays
3
+ Version: 1.0.0
4
+ Summary: Weather forecast data
5
+ Home-page: https://example.com
6
+ Author: Yasmeen Shalabi
7
+ Author-email: shalabiyasmeen737@gmail.com
8
+ License: MIT
9
+ Keywords: weather,forecast,openweather
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Topic :: Software Development :: Build Tools
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3.5
15
+ Classifier: Programming Language :: Python :: 3.6
16
+ Classifier: Programming Language :: Python :: 3.7
17
+ Classifier: Programming Language :: Python :: 3.8
18
+ Requires-Dist: requests
19
+ Dynamic: author
20
+ Dynamic: author-email
21
+ Dynamic: classifier
22
+ Dynamic: home-page
23
+ Dynamic: keywords
24
+ Dynamic: license
25
+ Dynamic: requires-dist
26
+ Dynamic: summary
@@ -0,0 +1,6 @@
1
+ cloudydays/__init__.py,sha256=TxK4VCoXfiGaGgdOMr0G9F0mHPBsBl08mO2MiWMMndE,41
2
+ cloudydays/cloudydays.py,sha256=-5EdbdXsIKBHIBao88gTcl6zm0Om8q9lFqS6Wm_Je6g,2257
3
+ cloudydays-1.0.0.dist-info/METADATA,sha256=sj82Igv20xB1U5J9Uup-cX4E8JLzpSUCS1_1LWDqmCE,832
4
+ cloudydays-1.0.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
5
+ cloudydays-1.0.0.dist-info/top_level.txt,sha256=Yskk72c5vtmxohD4Hn_UrlH0C8k8xk53GvGS9ySaoUQ,11
6
+ cloudydays-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ cloudydays