python-pirateweather 1.1.1__tar.gz → 1.2.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.
- {python_pirateweather-1.1.1/python_pirateweather.egg-info → python_pirateweather-1.2.0}/PKG-INFO +4 -3
- {python_pirateweather-1.1.1 → python_pirateweather-1.2.0}/README.md +2 -1
- {python_pirateweather-1.1.1 → python_pirateweather-1.2.0}/pirateweather/api.py +9 -6
- {python_pirateweather-1.1.1 → python_pirateweather-1.2.0}/pirateweather/models.py +3 -0
- {python_pirateweather-1.1.1 → python_pirateweather-1.2.0/python_pirateweather.egg-info}/PKG-INFO +4 -3
- python_pirateweather-1.2.0/python_pirateweather.egg-info/requires.txt +1 -0
- {python_pirateweather-1.1.1 → python_pirateweather-1.2.0}/setup.py +2 -2
- {python_pirateweather-1.1.1 → python_pirateweather-1.2.0}/tests/test_pirateweather.py +56 -13
- python_pirateweather-1.1.1/python_pirateweather.egg-info/requires.txt +0 -1
- {python_pirateweather-1.1.1 → python_pirateweather-1.2.0}/LICENSE.txt +0 -0
- {python_pirateweather-1.1.1 → python_pirateweather-1.2.0}/MANIFEST.in +0 -0
- {python_pirateweather-1.1.1 → python_pirateweather-1.2.0}/pirateweather/__init__.py +0 -0
- {python_pirateweather-1.1.1 → python_pirateweather-1.2.0}/pirateweather/utils.py +0 -0
- {python_pirateweather-1.1.1 → python_pirateweather-1.2.0}/python_pirateweather.egg-info/SOURCES.txt +0 -0
- {python_pirateweather-1.1.1 → python_pirateweather-1.2.0}/python_pirateweather.egg-info/dependency_links.txt +0 -0
- {python_pirateweather-1.1.1 → python_pirateweather-1.2.0}/python_pirateweather.egg-info/top_level.txt +0 -0
- {python_pirateweather-1.1.1 → python_pirateweather-1.2.0}/setup.cfg +0 -0
{python_pirateweather-1.1.1/python_pirateweather.egg-info → python_pirateweather-1.2.0}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-pirateweather
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.2.0
|
|
4
4
|
Summary: A thin Python Wrapper for the Pirate Weather API
|
|
5
5
|
Home-page: https://github.com/cloneofghosts/python-pirate-weather
|
|
6
6
|
Author: cloneofghosts
|
|
@@ -8,7 +8,7 @@ License: BSD 2-clause
|
|
|
8
8
|
Keywords: weather API wrapper pirateweather location
|
|
9
9
|
Description-Content-Type: text/markdown
|
|
10
10
|
License-File: LICENSE.txt
|
|
11
|
-
Requires-Dist: requests==2.32.
|
|
11
|
+
Requires-Dist: requests==2.32.5
|
|
12
12
|
Dynamic: author
|
|
13
13
|
Dynamic: description
|
|
14
14
|
Dynamic: description-content-type
|
|
@@ -88,12 +88,13 @@ Parameters:
|
|
|
88
88
|
- **latitude** - The latitude of the location for the forecast
|
|
89
89
|
- **longitude** - The longitude of the location for the forecast
|
|
90
90
|
- **time** - (optional) A datetime object for the forecast either in the past or future - see How Timezones Work below for the details on how timezones are handled in this library.
|
|
91
|
-
- **units** - (optional) A string of the preferred units of measurement, "
|
|
91
|
+
- **units** - (optional) A string of the preferred units of measurement, "auto" is the default. "us","ca","uk","si" are also available. See the API Docs (https://pirateweather.net/en/latest/API/#units) for exactly what each unit means.
|
|
92
92
|
- **lang** - (optional) A string of the desired language. See https://pirateweather.net/en/latest/API/#language for supported languages.
|
|
93
93
|
- **lazy** - (optional) Defaults to `false`. If `true` the function will request the json data as it is needed. Results in more requests, but maybe a faster response time.
|
|
94
94
|
- **extend** - (optional) Defaults to `false`. If `"hourly"` the API will hourly data for 168 hours instead of the standard 48 hours.
|
|
95
95
|
- **version** - (optional) Defaults to `1`. If set to `2` the API will return fields that were not part of the Dark Sky API.
|
|
96
96
|
- **icon** - (optional) Defaults to `darksky`. If set to `pirate` the API will return icons which aren't apart of the default Dark Sky icon set.
|
|
97
|
+
- **extraVars** - (optional) Is used to add additional parameters to the API response. The only extra parameter at the moment is `stationPressure` but more may be added in the future.
|
|
97
98
|
- **callback** - (optional) Pass a function to be used as a callback. If used, load_forecast() will use an asynchronous HTTP call and **will not return the forecast object directly**, instead it will be passed to the callback function. Make sure it can accept it.
|
|
98
99
|
|
|
99
100
|
----------------------------------------------------
|
|
@@ -67,12 +67,13 @@ Parameters:
|
|
|
67
67
|
- **latitude** - The latitude of the location for the forecast
|
|
68
68
|
- **longitude** - The longitude of the location for the forecast
|
|
69
69
|
- **time** - (optional) A datetime object for the forecast either in the past or future - see How Timezones Work below for the details on how timezones are handled in this library.
|
|
70
|
-
- **units** - (optional) A string of the preferred units of measurement, "
|
|
70
|
+
- **units** - (optional) A string of the preferred units of measurement, "auto" is the default. "us","ca","uk","si" are also available. See the API Docs (https://pirateweather.net/en/latest/API/#units) for exactly what each unit means.
|
|
71
71
|
- **lang** - (optional) A string of the desired language. See https://pirateweather.net/en/latest/API/#language for supported languages.
|
|
72
72
|
- **lazy** - (optional) Defaults to `false`. If `true` the function will request the json data as it is needed. Results in more requests, but maybe a faster response time.
|
|
73
73
|
- **extend** - (optional) Defaults to `false`. If `"hourly"` the API will hourly data for 168 hours instead of the standard 48 hours.
|
|
74
74
|
- **version** - (optional) Defaults to `1`. If set to `2` the API will return fields that were not part of the Dark Sky API.
|
|
75
75
|
- **icon** - (optional) Defaults to `darksky`. If set to `pirate` the API will return icons which aren't apart of the default Dark Sky icon set.
|
|
76
|
+
- **extraVars** - (optional) Is used to add additional parameters to the API response. The only extra parameter at the moment is `stationPressure` but more may be added in the future.
|
|
76
77
|
- **callback** - (optional) Pass a function to be used as a callback. If used, load_forecast() will use an asynchronous HTTP call and **will not return the forecast object directly**, instead it will be passed to the callback function. Make sure it can accept it.
|
|
77
78
|
|
|
78
79
|
----------------------------------------------------
|
|
@@ -12,13 +12,14 @@ def load_forecast(
|
|
|
12
12
|
lat,
|
|
13
13
|
lng,
|
|
14
14
|
time=None,
|
|
15
|
-
units="
|
|
15
|
+
units="auto",
|
|
16
16
|
lang="en",
|
|
17
17
|
lazy=False,
|
|
18
18
|
callback=None,
|
|
19
19
|
extend=None,
|
|
20
20
|
version=1,
|
|
21
21
|
icon="darksky",
|
|
22
|
+
extraVars=None,
|
|
22
23
|
):
|
|
23
24
|
"""Build the request url and loads some or all of the needed json depending on lazy is True.
|
|
24
25
|
|
|
@@ -27,7 +28,7 @@ def load_forecast(
|
|
|
27
28
|
time: A datetime.datetime object representing the desired time of
|
|
28
29
|
the forecast. If no timezone is present, the API assumes local
|
|
29
30
|
time at the provided latitude and longitude.
|
|
30
|
-
units: A string of the preferred units of measurement, "
|
|
31
|
+
units: A string of the preferred units of measurement, "auto" is
|
|
31
32
|
default. also ca,uk,si is available
|
|
32
33
|
lang: Return summary properties in the desired language
|
|
33
34
|
lazy: Defaults to false. The function will only request the json
|
|
@@ -37,13 +38,15 @@ def load_forecast(
|
|
|
37
38
|
of the standard 48 hours.
|
|
38
39
|
version: If set to 2 the API will return fields that were not part of the Dark Sky API.
|
|
39
40
|
icon: If set to pirate the API will return icons which aren't apart of the default Dark Sky icon set
|
|
41
|
+
extraVars: Is used to add additional parameters to the API response.
|
|
40
42
|
"""
|
|
41
43
|
|
|
42
44
|
if time is None:
|
|
43
|
-
url =
|
|
44
|
-
|
|
45
|
-
f"
|
|
46
|
-
|
|
45
|
+
url = f"https://api.pirateweather.net/forecast/{key}/{lat},{lng}?units={units}&lang={lang}&version={version}&icon={icon}"
|
|
46
|
+
if extend:
|
|
47
|
+
url += f"&extend={extend}"
|
|
48
|
+
if extraVars:
|
|
49
|
+
url += f"&extraVars={extraVars}"
|
|
47
50
|
else:
|
|
48
51
|
url_time = time.replace(
|
|
49
52
|
microsecond=0
|
|
@@ -108,6 +108,9 @@ class PirateWeatherFlagsBlock(UnicodeMixin):
|
|
|
108
108
|
self.nearestStation = d.get("nearest-station")
|
|
109
109
|
self.sources = list(d.get("sources"))
|
|
110
110
|
self.sourceTimes = d.get("sourceTimes")
|
|
111
|
+
self.processTime = d.get("processTime")
|
|
112
|
+
self.ingestVersion = d.get("ingestVersion")
|
|
113
|
+
self.nearestCity = d.get("nearestCity")
|
|
111
114
|
|
|
112
115
|
def __unicode__(self):
|
|
113
116
|
"""Return a string representation of the data block."""
|
{python_pirateweather-1.1.1 → python_pirateweather-1.2.0/python_pirateweather.egg-info}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-pirateweather
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.2.0
|
|
4
4
|
Summary: A thin Python Wrapper for the Pirate Weather API
|
|
5
5
|
Home-page: https://github.com/cloneofghosts/python-pirate-weather
|
|
6
6
|
Author: cloneofghosts
|
|
@@ -8,7 +8,7 @@ License: BSD 2-clause
|
|
|
8
8
|
Keywords: weather API wrapper pirateweather location
|
|
9
9
|
Description-Content-Type: text/markdown
|
|
10
10
|
License-File: LICENSE.txt
|
|
11
|
-
Requires-Dist: requests==2.32.
|
|
11
|
+
Requires-Dist: requests==2.32.5
|
|
12
12
|
Dynamic: author
|
|
13
13
|
Dynamic: description
|
|
14
14
|
Dynamic: description-content-type
|
|
@@ -88,12 +88,13 @@ Parameters:
|
|
|
88
88
|
- **latitude** - The latitude of the location for the forecast
|
|
89
89
|
- **longitude** - The longitude of the location for the forecast
|
|
90
90
|
- **time** - (optional) A datetime object for the forecast either in the past or future - see How Timezones Work below for the details on how timezones are handled in this library.
|
|
91
|
-
- **units** - (optional) A string of the preferred units of measurement, "
|
|
91
|
+
- **units** - (optional) A string of the preferred units of measurement, "auto" is the default. "us","ca","uk","si" are also available. See the API Docs (https://pirateweather.net/en/latest/API/#units) for exactly what each unit means.
|
|
92
92
|
- **lang** - (optional) A string of the desired language. See https://pirateweather.net/en/latest/API/#language for supported languages.
|
|
93
93
|
- **lazy** - (optional) Defaults to `false`. If `true` the function will request the json data as it is needed. Results in more requests, but maybe a faster response time.
|
|
94
94
|
- **extend** - (optional) Defaults to `false`. If `"hourly"` the API will hourly data for 168 hours instead of the standard 48 hours.
|
|
95
95
|
- **version** - (optional) Defaults to `1`. If set to `2` the API will return fields that were not part of the Dark Sky API.
|
|
96
96
|
- **icon** - (optional) Defaults to `darksky`. If set to `pirate` the API will return icons which aren't apart of the default Dark Sky icon set.
|
|
97
|
+
- **extraVars** - (optional) Is used to add additional parameters to the API response. The only extra parameter at the moment is `stationPressure` but more may be added in the future.
|
|
97
98
|
- **callback** - (optional) Pass a function to be used as a callback. If used, load_forecast() will use an asynchronous HTTP call and **will not return the forecast object directly**, instead it will be passed to the callback function. Make sure it can accept it.
|
|
98
99
|
|
|
99
100
|
----------------------------------------------------
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
requests==2.32.5
|
|
@@ -20,7 +20,7 @@ def read(fname):
|
|
|
20
20
|
|
|
21
21
|
setup(
|
|
22
22
|
name="python-pirateweather",
|
|
23
|
-
version="1.
|
|
23
|
+
version="1.2.0",
|
|
24
24
|
author="cloneofghosts",
|
|
25
25
|
description=("A thin Python Wrapper for the Pirate Weather API"),
|
|
26
26
|
license="BSD 2-clause",
|
|
@@ -30,5 +30,5 @@ setup(
|
|
|
30
30
|
package_data={"pirateweather": ["LICENSE.txt", "README.md"]},
|
|
31
31
|
long_description=open("README.md").read(),
|
|
32
32
|
long_description_content_type="text/markdown",
|
|
33
|
-
install_requires=["requests==2.32.
|
|
33
|
+
install_requires=["requests==2.32.5"],
|
|
34
34
|
)
|
|
@@ -18,6 +18,10 @@ class EndToEnd(unittest.TestCase):
|
|
|
18
18
|
"""Set up the API key, location and time for the tests."""
|
|
19
19
|
|
|
20
20
|
self.api_key = os.environ.get("PIRATEWEATHER_API_KEY")
|
|
21
|
+
if not self.api_key:
|
|
22
|
+
# Skip end-to-end tests when the API key isn't available in CI/local dev
|
|
23
|
+
# They require network access and a valid key.
|
|
24
|
+
self.skipTest("PIRATEWEATHER_API_KEY not set")
|
|
21
25
|
self.lat = 52.370235
|
|
22
26
|
self.lng = 4.903549
|
|
23
27
|
self.time = datetime(2015, 2, 27, 6, 0, 0)
|
|
@@ -58,7 +62,7 @@ class EndToEnd(unittest.TestCase):
|
|
|
58
62
|
hourl_data = forecast.hourly()
|
|
59
63
|
|
|
60
64
|
assert forecast.response.status_code == 200
|
|
61
|
-
assert len(hourl_data.data) ==
|
|
65
|
+
assert len(hourl_data.data) == 168
|
|
62
66
|
|
|
63
67
|
def test_version(self):
|
|
64
68
|
"""Test querying the API endpoint."""
|
|
@@ -81,17 +85,33 @@ class EndToEnd(unittest.TestCase):
|
|
|
81
85
|
assert forecast.response.status_code == 200
|
|
82
86
|
assert fc_cur.fireIndex
|
|
83
87
|
|
|
88
|
+
def test_extra_vars(self):
|
|
89
|
+
"""Test querying the API endpoint."""
|
|
90
|
+
|
|
91
|
+
forecast = pirateweather.load_forecast(
|
|
92
|
+
self.api_key, self.lat, self.lng, units="us", extraVars="stationPressure"
|
|
93
|
+
)
|
|
94
|
+
fc_cur = forecast.currently()
|
|
95
|
+
|
|
96
|
+
assert forecast.response.status_code == 200
|
|
97
|
+
assert fc_cur.stationPressure
|
|
98
|
+
|
|
84
99
|
def test_flags(self):
|
|
85
100
|
"""Test the data returned by the flags block."""
|
|
86
101
|
|
|
87
|
-
forecast = pirateweather.load_forecast(
|
|
102
|
+
forecast = pirateweather.load_forecast(
|
|
103
|
+
self.api_key, self.lat, self.lng, version=2
|
|
104
|
+
)
|
|
88
105
|
flags = forecast.flags()
|
|
89
106
|
|
|
90
107
|
assert len(flags.sources) == 3
|
|
91
108
|
assert len(flags.sourceTimes) == 2
|
|
92
109
|
assert flags.nearestStation == 0
|
|
93
|
-
assert flags.units == "
|
|
110
|
+
assert flags.units == "si"
|
|
94
111
|
assert flags.sourceTimes.get("gfs")
|
|
112
|
+
assert flags.processTime
|
|
113
|
+
assert flags.ingestVersion
|
|
114
|
+
assert flags.nearestCity == "Amsterdam"
|
|
95
115
|
|
|
96
116
|
def test_invalid_key(self):
|
|
97
117
|
"""Test querying the API endpoint with a invalid API key."""
|
|
@@ -128,15 +148,25 @@ class BasicFunctionality(unittest.TestCase):
|
|
|
128
148
|
@responses.activate
|
|
129
149
|
def setUp(self):
|
|
130
150
|
"""Set up the data to use in the next tests."""
|
|
131
|
-
|
|
132
|
-
URL = "https://api.pirateweather.net/forecast/foo/50.0,10.0?units=us&lang=en&extend=None&version=1"
|
|
151
|
+
URL = "https://api.pirateweather.net/forecast/foo/50.0,10.0?units=auto&lang=en&version=1&icon=darksky"
|
|
133
152
|
responses.add(
|
|
134
153
|
responses.GET,
|
|
135
154
|
URL,
|
|
136
|
-
body=open(
|
|
155
|
+
body=open(
|
|
156
|
+
os.path.join(os.path.dirname(__file__), "fixtures", "test.json")
|
|
157
|
+
).read(),
|
|
137
158
|
status=200,
|
|
138
159
|
content_type="application/json",
|
|
139
|
-
|
|
160
|
+
match=[
|
|
161
|
+
responses.matchers.query_param_matcher(
|
|
162
|
+
{
|
|
163
|
+
"units": "auto",
|
|
164
|
+
"lang": "en",
|
|
165
|
+
"version": "1",
|
|
166
|
+
"icon": "darksky",
|
|
167
|
+
}
|
|
168
|
+
)
|
|
169
|
+
],
|
|
140
170
|
)
|
|
141
171
|
|
|
142
172
|
api_key = "foo"
|
|
@@ -229,15 +259,27 @@ class ForecastsWithAlerts(unittest.TestCase):
|
|
|
229
259
|
@responses.activate
|
|
230
260
|
def setUp(self):
|
|
231
261
|
"""Set up the test data with alerts to use in the next tests."""
|
|
232
|
-
|
|
233
|
-
URL = "https://api.pirateweather.net/forecast/foo/50.0,10.0?units=us&lang=en&extend=None&version=1"
|
|
262
|
+
URL = "https://api.pirateweather.net/forecast/foo/50.0,10.0?units=auto&lang=en&version=1&icon=darksky"
|
|
234
263
|
responses.add(
|
|
235
264
|
responses.GET,
|
|
236
265
|
URL,
|
|
237
|
-
body=open(
|
|
266
|
+
body=open(
|
|
267
|
+
os.path.join(
|
|
268
|
+
os.path.dirname(__file__), "fixtures", "test_with_alerts.json"
|
|
269
|
+
)
|
|
270
|
+
).read(),
|
|
238
271
|
status=200,
|
|
239
272
|
content_type="application/json",
|
|
240
|
-
|
|
273
|
+
match=[
|
|
274
|
+
responses.matchers.query_param_matcher(
|
|
275
|
+
{
|
|
276
|
+
"units": "auto",
|
|
277
|
+
"lang": "en",
|
|
278
|
+
"version": "1",
|
|
279
|
+
"icon": "darksky",
|
|
280
|
+
}
|
|
281
|
+
)
|
|
282
|
+
],
|
|
241
283
|
)
|
|
242
284
|
|
|
243
285
|
api_key = "foo"
|
|
@@ -306,10 +348,11 @@ class BasicManualURL(unittest.TestCase):
|
|
|
306
348
|
responses.add(
|
|
307
349
|
responses.GET,
|
|
308
350
|
URL,
|
|
309
|
-
body=open(
|
|
351
|
+
body=open(
|
|
352
|
+
os.path.join(os.path.dirname(__file__), "fixtures", "test.json")
|
|
353
|
+
).read(),
|
|
310
354
|
status=200,
|
|
311
355
|
content_type="application/json",
|
|
312
|
-
match_querystring=True,
|
|
313
356
|
)
|
|
314
357
|
|
|
315
358
|
self.forecast = pirateweather.manual("http://test_url.com/")
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
requests==2.32.3
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_pirateweather-1.1.1 → python_pirateweather-1.2.0}/python_pirateweather.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|