Skip to content

Commit 15b87b9

Browse files
Add missing flags and document flags (#140)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent 1e67155 commit 15b87b9

4 files changed

Lines changed: 37 additions & 1 deletion

File tree

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ The **Forecast** object, it contains both weather data and the HTTP response fro
112112
- Returns a PirateWeatherDataBlock object
113113
- **daily()**
114114
- Returns a PirateWeatherDataBlock object
115+
- **flags()**
116+
- Returns a PirateWeatherFlagsBlock object
115117
- **update()**
116118
- Refreshes the forecast data by making a new request.
117119

@@ -158,6 +160,36 @@ For a full list of PirateWeatherDataPoint attributes and attribute descriptions,
158160
----------------------------------------------------
159161

160162

163+
*class* pirateweather.models.PirateWeatherFlagsBlock
164+
---------------------------------------------------
165+
166+
Contains data about the flags used to generate the forecast.
167+
168+
**Attributes** *(descriptions taken from the pirateweather.net website)*
169+
- **units**
170+
- Indicates which units were used in the forecasts.
171+
- **version**
172+
- The version of Pirate Weather used to generate the forecast.
173+
- **nearestStation**
174+
- Not implemented, and will always return 0.
175+
- **sources**
176+
- The models used to generate the forecast.
177+
- **sourceTimes**
178+
- The time in UTC when the model was last updated.
179+
- **processTime**
180+
- The time taken to process the request in milliseconds.
181+
- **ingestVersion**
182+
- The ingest version of Pirate Weather used to generate the forecast.
183+
- **nearestCity**
184+
- The name of the closest city to your location.
185+
- **nearestCountry**
186+
- The country name of the closest city to your location.
187+
- **nearestSubNational**
188+
- The sub national name of the closest city to your location.
189+
190+
----------------------------------------------------
191+
192+
161193
How Timezones Work
162194
------------------
163195
Requests with a naive datetime (no time zone specified) will correspond to the supplied time in the requesting location. If a timezone aware datetime object is supplied, the supplied time will be in the associated timezone.

pirateweather/models.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ def __init__(self, d=None):
111111
self.processTime = d.get("processTime")
112112
self.ingestVersion = d.get("ingestVersion")
113113
self.nearestCity = d.get("nearestCity")
114+
self.nearestCountry = d.get("nearestCountry")
115+
self.nearestSubNational = d.get("nearestSubNational")
114116

115117
def __unicode__(self):
116118
"""Return a string representation of the data block."""

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def read(fname):
2020

2121
setup(
2222
name="python-pirateweather",
23-
version="1.2.0",
23+
version="1.2.1",
2424
author="cloneofghosts",
2525
description=("A thin Python Wrapper for the Pirate Weather API"),
2626
license="BSD 2-clause",

tests/test_pirateweather.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ def test_flags(self):
112112
assert flags.processTime
113113
assert flags.ingestVersion
114114
assert flags.nearestCity == "Amsterdam"
115+
assert flags.nearestCountry == "Netherlands"
116+
assert flags.nearestSubNational == "North Holland"
115117

116118
def test_invalid_key(self):
117119
"""Test querying the API endpoint with a invalid API key."""

0 commit comments

Comments
 (0)