sunnyday-dd 1.0.0__tar.gz
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.
- sunnyday_dd-1.0.0/PKG-INFO +27 -0
- sunnyday_dd-1.0.0/setup.cfg +4 -0
- sunnyday_dd-1.0.0/setup.py +27 -0
- sunnyday_dd-1.0.0/sunnyday_dd/__init__.py +1 -0
- sunnyday_dd-1.0.0/sunnyday_dd/sunnyday_dd.py +57 -0
- sunnyday_dd-1.0.0/sunnyday_dd.egg-info/PKG-INFO +27 -0
- sunnyday_dd-1.0.0/sunnyday_dd.egg-info/SOURCES.txt +8 -0
- sunnyday_dd-1.0.0/sunnyday_dd.egg-info/dependency_links.txt +1 -0
- sunnyday_dd-1.0.0/sunnyday_dd.egg-info/requires.txt +1 -0
- sunnyday_dd-1.0.0/sunnyday_dd.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sunnyday_dd
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Weather forecast data.
|
|
5
|
+
Home-page: https://example.com
|
|
6
|
+
Author: Devendra Desaine
|
|
7
|
+
Author-email: devendra.desaine@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Keywords: weather,forecast,openweather,devendra,desaine
|
|
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
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
+
Requires-Dist: requests
|
|
20
|
+
Dynamic: author
|
|
21
|
+
Dynamic: author-email
|
|
22
|
+
Dynamic: classifier
|
|
23
|
+
Dynamic: home-page
|
|
24
|
+
Dynamic: keywords
|
|
25
|
+
Dynamic: license
|
|
26
|
+
Dynamic: requires-dist
|
|
27
|
+
Dynamic: summary
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
from setuptools import setup
|
|
2
|
+
|
|
3
|
+
setup(
|
|
4
|
+
name='sunnyday_dd', # Your package will have this name
|
|
5
|
+
packages=['sunnyday_dd'], # Name the package again
|
|
6
|
+
version='1.0.0', # To be increased every time you change your library
|
|
7
|
+
license='MIT', # Type of license. More here: https://help.github.com/articles/licensing-a-repository
|
|
8
|
+
description='Weather forecast data.', # Short description of your library
|
|
9
|
+
author='Devendra Desaine', # Your name
|
|
10
|
+
author_email='devendra.desaine@gmail.com', # Your email
|
|
11
|
+
url='https://example.com', # Homepage of your library (e.g. github or your website)
|
|
12
|
+
keywords=['weather', 'forecast', 'openweather', 'devendra', 'desaine'], # Keywords users can search on pypi.org
|
|
13
|
+
install_requires=[
|
|
14
|
+
'requests',
|
|
15
|
+
],
|
|
16
|
+
classifiers=[
|
|
17
|
+
'Development Status :: 3 - Alpha', # Choose either "3 - Alpha", "4 - Beta" or "5 - Production/Stable" as the current state of your package
|
|
18
|
+
'Intended Audience :: Developers', # Who is the audience for your library?
|
|
19
|
+
'Topic :: Software Development :: Build Tools',
|
|
20
|
+
'License :: OSI Approved :: MIT License', # Type a license again
|
|
21
|
+
'Programming Language :: Python :: 3.5', # Python versions that your library supports
|
|
22
|
+
'Programming Language :: Python :: 3.6',
|
|
23
|
+
'Programming Language :: Python :: 3.7',
|
|
24
|
+
'Programming Language :: Python :: 3.8',
|
|
25
|
+
'Programming Language :: Python :: 3.14',
|
|
26
|
+
],
|
|
27
|
+
)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from sunnyday_dd.sunnyday_dd import Weather
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
|
|
3
|
+
class Weather:
|
|
4
|
+
"""
|
|
5
|
+
Creates a weather object for a given city or lat and lon coordinates
|
|
6
|
+
|
|
7
|
+
Package use example:
|
|
8
|
+
# Create a weather object using city name:
|
|
9
|
+
# The api key below is not guaranteed to work
|
|
10
|
+
# Get your own api key from https://openweathermap.org
|
|
11
|
+
|
|
12
|
+
>>> weather1 = Weather(apikey="ac58da78cb3a7407e17c99422b614c41", city = "New York")
|
|
13
|
+
|
|
14
|
+
# Using latitude and longitude coordinates
|
|
15
|
+
|
|
16
|
+
>>> weather2 = Weather(apikey="ac58da78cb3a7407e17c99422b614c41", lat = 41.1, lon = -4.1)
|
|
17
|
+
|
|
18
|
+
# Get complete weather data for the nxet 12 hours
|
|
19
|
+
>>> weather1.next_12h()
|
|
20
|
+
|
|
21
|
+
# Simplified data for the next 12 hours
|
|
22
|
+
>>> weather1.next_12h_simplified()
|
|
23
|
+
|
|
24
|
+
"""
|
|
25
|
+
def __init__(self, apikey, city=None, lat=None, lon=None):
|
|
26
|
+
self.apikey = apikey
|
|
27
|
+
self.city = city
|
|
28
|
+
self.lat = lat
|
|
29
|
+
self.lon = lon
|
|
30
|
+
|
|
31
|
+
if city:
|
|
32
|
+
url = f"http://api.openweathermap.org/data/2.5/forecast?q={self.city}&appid={self.apikey}&units=metric"
|
|
33
|
+
r = requests.get(url)
|
|
34
|
+
self.data = r.json()
|
|
35
|
+
elif lat and lon:
|
|
36
|
+
url = f"http://api.openweathermap.org/data/2.5/forecast?lat={self.lat}&lon={self.lon}&appid={self.apikey}&units=metric"
|
|
37
|
+
r = requests.get(url)
|
|
38
|
+
self.data = r.json()
|
|
39
|
+
else:
|
|
40
|
+
raise TypeError("Provide either city or lat and lon arguments")
|
|
41
|
+
|
|
42
|
+
if self.data["cod"] != "200":
|
|
43
|
+
raise ValueError(self.data["message"])
|
|
44
|
+
|
|
45
|
+
def next_12h(self):
|
|
46
|
+
"""Returns 3-hour data for the next 12 hours as a dictionary
|
|
47
|
+
"""
|
|
48
|
+
return self.data['list'][:4] # Slice the first 4 elements of the list
|
|
49
|
+
|
|
50
|
+
def next_12h_simplified(self):
|
|
51
|
+
"""Returns date. temperature and sky conditions every 3hours
|
|
52
|
+
for the next 12 hours as a tuple of tuples.
|
|
53
|
+
"""
|
|
54
|
+
simple_data = []
|
|
55
|
+
for dicty in self.data['list'][:4]:
|
|
56
|
+
simple_data.append((dicty['dt_txt'], dicty['main']['temp'], dicty['weather'][0]['description']))
|
|
57
|
+
return simple_data
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sunnyday_dd
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Weather forecast data.
|
|
5
|
+
Home-page: https://example.com
|
|
6
|
+
Author: Devendra Desaine
|
|
7
|
+
Author-email: devendra.desaine@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Keywords: weather,forecast,openweather,devendra,desaine
|
|
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
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
+
Requires-Dist: requests
|
|
20
|
+
Dynamic: author
|
|
21
|
+
Dynamic: author-email
|
|
22
|
+
Dynamic: classifier
|
|
23
|
+
Dynamic: home-page
|
|
24
|
+
Dynamic: keywords
|
|
25
|
+
Dynamic: license
|
|
26
|
+
Dynamic: requires-dist
|
|
27
|
+
Dynamic: summary
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
requests
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
sunnyday_dd
|