From d33f6dcbb12202cfa61b9716fec02c0dd53788b5 Mon Sep 17 00:00:00 2001 From: oncleben31 Date: Mon, 10 Aug 2020 09:38:07 +0200 Subject: [PATCH 01/33] Add darglint in dev dependencies --- poetry.lock | 14 +++++++++++++- pyproject.toml | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/poetry.lock b/poetry.lock index d29b37f8..092be923 100644 --- a/poetry.lock +++ b/poetry.lock @@ -158,6 +158,14 @@ version = "*" [package.extras] toml = ["toml"] +[[package]] +category = "dev" +description = "A utility for ensuring Google-style docstrings stay up to date with the source code." +name = "darglint" +optional = false +python-versions = ">=3.5,<4.0" +version = "1.5.5" + [[package]] category = "dev" description = "A backport of the dataclasses module for Python 3.6" @@ -800,7 +808,7 @@ docs = ["sphinx", "jaraco.packaging (>=3.2)", "rst.linker (>=1.9)"] testing = ["jaraco.itertools", "func-timeout"] [metadata] -content-hash = "b34a6f2595df5e396a1772c97c787a71f30964513d9d299ec342d43654561505" +content-hash = "a63527bd3fd906726cce5402646dd897eafed4ba9f5c5761c1ac753d1c1f1623" lock-version = "1.0" python-versions = "^3.6.1" @@ -893,6 +901,10 @@ coverage = [ {file = "coverage-5.3-cp39-cp39-win_amd64.whl", hash = "sha256:47a11bdbd8ada9b7ee628596f9d97fbd3851bd9999d398e9436bd67376dbece7"}, {file = "coverage-5.3.tar.gz", hash = "sha256:280baa8ec489c4f542f8940f9c4c2181f0306a8ee1a54eceba071a449fb870a0"}, ] +darglint = [ + {file = "darglint-1.5.5-py3-none-any.whl", hash = "sha256:cd882c812f28ee3b5577259bfd8d6d25962386dd87fc1f3756eac24370aaa060"}, + {file = "darglint-1.5.5.tar.gz", hash = "sha256:2f12ce2ef3d8189279a8f2eb4c53fd215dbacae50e37765542a91310400a9cd6"}, +] dataclasses = [ {file = "dataclasses-0.6-py3-none-any.whl", hash = "sha256:454a69d788c7fda44efd71e259be79577822f5e3f53f029a22d08004e951dc9f"}, {file = "dataclasses-0.6.tar.gz", hash = "sha256:6988bd2b895eef432d562370bb707d540f32f7360ab13da45340101bc2307d84"}, diff --git a/pyproject.toml b/pyproject.toml index 043731e8..161abc56 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,6 +46,7 @@ safety = "^1.9.0" pep8-naming = "^0.11.1" mypy = "^0.782" typeguard = "^2.9.1" +darglint = "^1.5.2" [tool.coverage.paths] source = ["src", "*/site-packages"] From 991cea0749b214b0f31e858b01f9f91f64d93d5a Mon Sep 17 00:00:00 2001 From: oncleben31 Date: Mon, 10 Aug 2020 09:43:14 +0200 Subject: [PATCH 02/33] Add darglint check in nox pre-commit session --- .flake8 | 2 +- noxfile.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.flake8 b/.flake8 index 60b05147..dc94f57a 100644 --- a/.flake8 +++ b/.flake8 @@ -1,5 +1,5 @@ [flake8] -select = B,B9,C,D,E,F,N,S,W +select = B,B9,C,D,DAR,E,F,N,S,W max-complexity = 10 docstring-convention = google exclude = .venv,.git,.tox,docs,venv,bin,lib,deps,build,.eggs diff --git a/noxfile.py b/noxfile.py index 7f216d34..06b459b1 100644 --- a/noxfile.py +++ b/noxfile.py @@ -159,6 +159,7 @@ def precommit(session: Session) -> None: install( session, "black", + "darglint", "flake8", "flake8-bandit", "flake8-bugbear", From 1d6ba0952bf2c341a5c57e2ad366db20d4415fe0 Mon Sep 17 00:00:00 2001 From: oncleben31 Date: Mon, 10 Aug 2020 09:43:49 +0200 Subject: [PATCH 03/33] Add darglint configuration file --- .darglint | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .darglint diff --git a/.darglint b/.darglint new file mode 100644 index 00000000..2b03755a --- /dev/null +++ b/.darglint @@ -0,0 +1,2 @@ +[darglint] +strictness = short From 96704b0127ad635bfd7d5d5309b697e7a4c1fc81 Mon Sep 17 00:00:00 2001 From: oncleben31 Date: Mon, 10 Aug 2020 18:33:24 +0200 Subject: [PATCH 04/33] Update python module top docstrings --- src/meteofrance/client.py | 2 +- src/meteofrance/exceptions.py | 2 +- src/meteofrance/helpers.py | 2 +- src/meteofrance/model/__init__.py | 2 +- src/meteofrance/model/forecast.py | 2 +- src/meteofrance/model/picture_of_the_day.py | 2 +- src/meteofrance/model/place.py | 15 +-------------- src/meteofrance/model/rain.py | 2 +- src/meteofrance/model/warning.py | 5 +++-- src/meteofrance/session.py | 2 +- 10 files changed, 12 insertions(+), 24 deletions(-) diff --git a/src/meteofrance/client.py b/src/meteofrance/client.py index 42d33839..37d3e411 100644 --- a/src/meteofrance/client.py +++ b/src/meteofrance/client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -"""Météo-France weather forecast python API.""" +"""Client for the Météo-France REST API.""" from typing import List from typing import Optional diff --git a/src/meteofrance/exceptions.py b/src/meteofrance/exceptions.py index e9f736b9..5a631be8 100644 --- a/src/meteofrance/exceptions.py +++ b/src/meteofrance/exceptions.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -"""Météo-France exceptions.""" +"""Météo-France API module exceptions.""" class MeteoFranceException(Exception): diff --git a/src/meteofrance/helpers.py b/src/meteofrance/helpers.py index 8084297d..6967e445 100644 --- a/src/meteofrance/helpers.py +++ b/src/meteofrance/helpers.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -"""Météo-France helpers.""" +"""Helpers to be used with the Météo-France REST API .""" import math from datetime import datetime from typing import Dict diff --git a/src/meteofrance/model/__init__.py b/src/meteofrance/model/__init__.py index 6dbc643b..be7a0e26 100644 --- a/src/meteofrance/model/__init__.py +++ b/src/meteofrance/model/__init__.py @@ -1,4 +1,4 @@ -"""Météo-France models.""" +"""Météo-France models for the REST API.""" from .forecast import Forecast from .picture_of_the_day import PictureOfTheDay from .place import Place diff --git a/src/meteofrance/model/forecast.py b/src/meteofrance/model/forecast.py index b56e6222..7e945c09 100644 --- a/src/meteofrance/model/forecast.py +++ b/src/meteofrance/model/forecast.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -"""Météo-France weather forecast python API. Forecast class.""" +"""Weather forecast Python model for the Météo-France REST API.""" import sys from datetime import datetime from typing import Any diff --git a/src/meteofrance/model/picture_of_the_day.py b/src/meteofrance/model/picture_of_the_day.py index 22914c24..18fd3d09 100644 --- a/src/meteofrance/model/picture_of_the_day.py +++ b/src/meteofrance/model/picture_of_the_day.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -"""Météo-France weather forecast python API. PictureOfTheDay class.""" +"""Picture of the Day@ Python model for the Météo-France REST API.""" import sys from typing import Mapping diff --git a/src/meteofrance/model/place.py b/src/meteofrance/model/place.py index 3fe4d03c..864187e2 100644 --- a/src/meteofrance/model/place.py +++ b/src/meteofrance/model/place.py @@ -1,18 +1,5 @@ # -*- coding: utf-8 -*- -"""Météo-France weather forecast python API. Place class. - -Example of a place in JSON format: -{ - "insee":"11254", - "name":"Montréal", - "lat":43.2, - "lon":2.14083, - "country":"FR", - "admin":"Languedoc-Roussillon", - "admin2":"11", - "postCode":"11290" -} -""" +"""Place Python model for the Météo-France REST API.""" import sys from typing import Optional diff --git a/src/meteofrance/model/rain.py b/src/meteofrance/model/rain.py index 63bea46b..5c091d8b 100644 --- a/src/meteofrance/model/rain.py +++ b/src/meteofrance/model/rain.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -"""Météo-France weather forecast python API. Rain class.""" +"""Rain in the next hour Python model for the Météo-France REST API.""" import sys from datetime import datetime from typing import Any diff --git a/src/meteofrance/model/warning.py b/src/meteofrance/model/warning.py index 04f2f090..ebda8956 100644 --- a/src/meteofrance/model/warning.py +++ b/src/meteofrance/model/warning.py @@ -1,7 +1,8 @@ # -*- coding: utf-8 -*- -"""Météo-France weather forecast python API. Classes for weather alert. +"""Weather alert buletin Python model for the Météo-France REST API. -For getting weather alerts in France and Andorre. + +For getting weather alerts in France Metropole and Andorre. """ import sys from typing import Any diff --git a/src/meteofrance/session.py b/src/meteofrance/session.py index 8095f9a3..169fb10e 100644 --- a/src/meteofrance/session.py +++ b/src/meteofrance/session.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -"""Météo-France weather forecast python API.""" +"""Session managers for the Météo-France REST API.""" from typing import Any from typing import Optional From 5678a8dc793946a547d4236ee934b7401fd710c8 Mon Sep 17 00:00:00 2001 From: oncleben31 Date: Wed, 12 Aug 2020 08:26:23 +0200 Subject: [PATCH 05/33] Rewrite client docstrings with the Google style --- src/meteofrance/client.py | 128 +++++++++++++++++++++++++++----------- 1 file changed, 92 insertions(+), 36 deletions(-) diff --git a/src/meteofrance/client.py b/src/meteofrance/client.py index 37d3e411..663c7135 100644 --- a/src/meteofrance/client.py +++ b/src/meteofrance/client.py @@ -26,7 +26,7 @@ class MeteoFranceClient: - """Proxy to the Météo-France API. + """Proxy to the Météo-France REST API. You will find methods and helpers to request weather forecast, rain forecast and weather alert bulletin. @@ -47,10 +47,21 @@ def search_places( latitude: Optional[str] = None, longitude: Optional[str] = None, ) -> List[Place]: - """Return the places link to a search. + """Search the places (cities) linked to a query by name. You can add GPS coordinates in parameter to search places arround a given location. + + Args: + search_query: A complete name, only a part of a name or a postal code (for + France only) corresponding to a city in the world. + latitude: Optional; Latitude in degree of a reference point to order + results. The nearest places first. + longitude: Optional; Longitude in degree of a reference point to order + results. The nearest places first. + + Returns: + A list of places (Place instance) corresponding to the query. """ # Construct the list of the GET parameters params = {"q": search_query} @@ -67,14 +78,22 @@ def search_places( # Forecast # def get_forecast( - self, - latitude: float, - longitude: float, - language: str = "fr", + self, latitude: float, longitude: float, language: str = "fr", ) -> Forecast: - """Return the weather forecast for a GPS location. + """Retrieve the weather forecast for a given GPS location. Results can be fetched in french or english according to the language parameter. + + Args: + latitude: Latitude in degree of the GPS point corresponding to the weather + forecast. + longitude: Longitude in degree of the GPS point corresponding to the weather + forecast. + language: Optional; If language is equal "fr" (default value) results will + be in French. All other value will give results in English. + + Returns: + A Forecast intance representing the hourly and daily weather forecast. """ # TODO: add possibility to request forecast from id @@ -86,14 +105,18 @@ def get_forecast( ) return Forecast(resp.json()) - def get_forecast_for_place( - self, - place: Place, - language: str = "fr", - ) -> Forecast: - """Return the weather forecast for a Place. + def get_forecast_for_place(self, place: Place, language: str = "fr",) -> Forecast: + """Retrieve the weather forecast for a given Place instance. Results can be fetched in french or english according to the language parameter. + + Args: + place: Place class instance corresponding to a location. + language: Optional; If language is equal "fr" (default value) results will + be in French. All other value will give results in English. + + Returns: + A Forecast intance representing the hourly and daily weather forecast. """ return self.get_forecast(place.latitude, place.longitude, language) @@ -101,9 +124,20 @@ def get_forecast_for_place( # Rain # def get_rain(self, latitude: float, longitude: float, language: str = "fr") -> Rain: - """Return the next 1 hour rain forecast for a GPS the location. + """Retrieve the next 1 hour rain forecast for a given GPS the location. Results can be fetched in french or english according to the language parameter. + + Args: + latitude: Latitude in degree of the GPS point corresponding to the rain + forecast. + longitude: Longitude in degree of the GPS point corresponding to the rain + forecast. + language: Optional; If language is equal "fr" (default value) results will + be in French. All other value will give results in English. + + Returns: + A Rain instance representing the next hour rain forecast. """ # TODO: add protection if no rain forecast for this position @@ -121,15 +155,21 @@ def get_warning_current_phenomenoms( ) -> CurrentPhenomenons: """Return the current weather phenomenoms (or alerts) for a given domain. - domain: could be `france` or any department numbers on two digits. - For some departments you ca access an additional bulletin for coastal - phenomenoms. - To access it add `10` after the domain id (example: `1310`). - - with_costal_bulletin: If set to True, you can get the basic bulletin and - coastal bulletin merged. - - depth: use 1 with `france` domain to have all sub location phenomenoms. + Args: + domain: could be `france` or any France métropole department numbers on two + digits. For some departments you can access an additional bulletin for + coastal phenomenoms. To access it add `10` after the domain id (example: + `1310`). + depth: Optional; To be used with domain = 'france'. With depth = 0 the + results will show only natinal sum up of the weather alerts. If + depth = 1, you wil have in addtion the buletin for all France métropole + department and Andorre + with_costal_bulletin: Optional; If set to True (default is False), you can + get the basic bulletin and coastal bulletin merged. + + Returns: + A warning.CurrentPhenomenons instance representing the weather alert + bulletin. """ # Send the API request resp = self.session.request( @@ -156,19 +196,24 @@ def get_warning_current_phenomenoms( return phenomenoms def get_warning_full(self, domain: str, with_costal_bulletin: bool = False) -> Full: - """Return a complete bulletin of the weather phenomenons for a given domain. + """Retrieve a complete bulletin of the weather phenomenons for a given domain. For a given domain we can access the maximum alert, a timelaps of the alert - evolution for - the next 24 hours, a list of alerts and other metadatas. - - domain: could be `france` or any department numbers on two digits. - For some department you can access an additional bulletin for coastal - phenomenoms. - To access it add `10` after the domain id (example: `1310`). + evolution for the next 24 hours, a list of alerts and other metadatas. with_costal_bulletin: If set to True, you can get the basic bulletin and coastal bulletin merged. + + Args: + domain: could be `france` or any France métropole department numbers on two + digits. For some departments you can access an additional bulletin for + coastal phenomenoms. To access it add `10` after the domain id (example: + `1310`). + with_costal_bulletin: Optional; If set to True (default is False), you can + get the basic bulletin and coastal bulletin merged. + + Returns: + A warning.Full instance representing the complete weather alert bulletin. """ # TODO: add formatDate parameter @@ -182,16 +227,22 @@ def get_warning_full(self, domain: str, with_costal_bulletin: bool = False) -> F if with_costal_bulletin: if domain in COASTAL_DEPARTMENT_LIST: resp = self.session.request( - "get", - "warning/full", - params={"domain": domain + "10"}, + "get", "warning/full", params={"domain": domain + "10"}, ) full_phenomenoms.merge_with_coastal_phenomenons(Full(resp.json())) return full_phenomenoms def get_warning_thumbnail(self, domain: str = "france") -> str: - """Return the thumbnail of the weather phenomenoms or alerts map.""" + """Retrieve the thumbnail URL of the weather phenomenoms or alerts map. + + Args: + domain: could be `france` or any France métropole department numbers on two + digits. + + Returns: + The URL of the thumbnail representing the weather alert status. + """ # Return directly the URL of the gif image return ( f"{METEOFRANCE_API_URL}/warning/thumbnail?&token={METEOFRANCE_API_TOKEN}" @@ -202,6 +253,11 @@ def get_warning_thumbnail(self, domain: str = "france") -> str: # Picture of the day # def get_picture_of_the_day(self) -> PictureOfTheDay: - """Return the picture of the day image URL & description.""" + """Retrieve the picture of the day image URL & description. + + Returns: + PictureOfTheDay instance with the URL and the description of the picture of + the day. + """ resp = self.session_net.request("get", "ImageJour/last.txt") return PictureOfTheDay(resp.json()) From c68566e43439f4417baa2332150f50996ad8d043 Mon Sep 17 00:00:00 2001 From: oncleben31 Date: Fri, 14 Aug 2020 09:02:42 +0200 Subject: [PATCH 06/33] Rewrite helpers docstrings with Google style --- src/meteofrance/helpers.py | 69 +++++++++++++++++++++++++++++++++----- 1 file changed, 61 insertions(+), 8 deletions(-) diff --git a/src/meteofrance/helpers.py b/src/meteofrance/helpers.py index 6967e445..341d7d72 100644 --- a/src/meteofrance/helpers.py +++ b/src/meteofrance/helpers.py @@ -24,7 +24,13 @@ def get_warning_text_status_from_indice_color( ) -> Optional[str]: """Convert the color code (in int) in readable text (Helper). - Returned text is in French or English according to the lang parameter. + Args: + int_color: Color status in int. Value expected between 1 and 4. + lang: Optional; If language is equal 'fr' (default value) results will + be in French. All other value will give results in English. + + Returns: + Color status in text. French or English according to the lang parameter. """ if lang == "fr": return ALERT_COLOR_LIST_FR[int_color] @@ -37,7 +43,13 @@ def get_phenomenon_name_from_indice( ) -> Optional[str]: """Convert the phenomenom code in readable text (Hepler). - Returned text is in French or English according to the lang parameter. + Args: + int_phenomenon: ID of the phenomenom in int. Value expected between 1 and 9. + lang: Optional; If language is equal "fr" (default value) results will + be in French. All other value will give results in English. + + Returns: + Phenomenom in text. French or English according to the lang parameter. """ if lang == "fr": return ALERT_TYPE_LIST_FR[int_phenomenon] @@ -46,7 +58,14 @@ def get_phenomenon_name_from_indice( def is_coastal_department(department_number: str) -> bool: - """Identify when a second bulletin is availabe for coastal risks (Helper).""" + """Identify when a second bulletin is availabe for coastal risks (Helper). + + Args: + department_number: Department number on 2 characters + + Returns: + True if the department have an additional coastal bulletin. False otherwise. + """ return department_number in COASTAL_DEPARTMENT_LIST @@ -54,6 +73,12 @@ def is_valid_warning_department(department_number: str) -> bool: """Identify if there is a weather alert bulletin for this department (Helper). Weather alert buletins are available only for France métropole and Andorre. + + Args: + department_number: Department number on 2 characters. + + Returns: + True if a department is France Métropole or Andorre. """ return department_number in VALID_DEPARTMENT_LIST @@ -61,7 +86,16 @@ def is_valid_warning_department(department_number: str) -> bool: def readeable_phenomenoms_dict( list_phenomenoms: List[Dict[str, int]], language: str = "fr" ) -> Dict[Optional[str], Optional[str]]: - """Create a dictionary with human readable keys and values (Helper).""" + """Create a dictionary with human readable keys and values (Helper). + + Args: + list_phenomenoms: Dictionnary with phenomnom ID and color code of status. + language: Optional; If language is equal "fr" (default value) results will + be in French. All other value will give results in English. + + Returns: + Dictionnary with keys and value human readable. + """ # Init empty dictionnary readable_dict = {} @@ -78,8 +112,14 @@ def readeable_phenomenoms_dict( def haversine(coord1: Tuple[float, float], coord2: Tuple[float, float]) -> float: """Compute distance in meters between to GPS coordinates using Harvesine formula. - coord1 and coord2 are tuple with latitude and longitude in degrees. source: https://janakiev.com/blog/gps-points-distance-python/ + + Args: + coord1: Tuple with latitude and longitude in degrees for first point + coord2: Tuple with latitude and longitude in degrees for second point + + Returns: + Distance in meters between the two points """ radius = 6372800 # Earth radius in meters lat1, lon1 = coord1 @@ -101,9 +141,17 @@ def sort_places_versus_distance_from_coordinates( ) -> List[Place]: """Oder list of places according to the distance to a reference coordinates. - gps_coordinates are in degrees. Note: this helper is compensating the bad results of the API. Results in the API - are sorted but lot of case identified where it doesn't work (example: Montréal) + are generaly sorted, but lot of cases identified where the order is inconsistent + (example: Montréal) + + Args: + list_places: List of Place instances to be ordered + gps_coord: Tuple with latitude and longitude in degrees for the reference point + + Returns: + List of Place instances ordered by distance to the reference point (nearest + first) """ sorted_places = sorted( list_places, @@ -115,7 +163,12 @@ def sort_places_versus_distance_from_coordinates( def timestamp_to_dateime_with_locale_tz(timestamp: int, local_tz: str) -> datetime: """Convert timestamp in datetime (Helper). - The local timezone corresponding to the forecast location is used. + Args: + timestamp: Timestamp. + local_tz: Name of the timezone to be used to convert the timestamp. + + Returns: + Datetime instance corresponding to the timestamp with a timezone. """ # convert timestamp in datetime with UTC timezone dt_utc = utc.localize(datetime.utcfromtimestamp(timestamp)) From d1c424302766e46d7c7bbe6a9b1c55c6b7260d27 Mon Sep 17 00:00:00 2001 From: oncleben31 Date: Sat, 3 Oct 2020 07:52:20 +0200 Subject: [PATCH 07/33] use the term metropolitan France --- src/meteofrance/client.py | 24 ++++++++++++------------ src/meteofrance/helpers.py | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/meteofrance/client.py b/src/meteofrance/client.py index 663c7135..2d28f2ec 100644 --- a/src/meteofrance/client.py +++ b/src/meteofrance/client.py @@ -156,14 +156,14 @@ def get_warning_current_phenomenoms( """Return the current weather phenomenoms (or alerts) for a given domain. Args: - domain: could be `france` or any France métropole department numbers on two - digits. For some departments you can access an additional bulletin for - coastal phenomenoms. To access it add `10` after the domain id (example: - `1310`). + domain: could be `france` or any metropolitan France department numbers on + two digits. For some departments you can access an additional bulletin + for coastal phenomenoms. To access it add `10` after the domain id + (example: `1310`). depth: Optional; To be used with domain = 'france'. With depth = 0 the results will show only natinal sum up of the weather alerts. If - depth = 1, you wil have in addtion the buletin for all France métropole - department and Andorre + depth = 1, you wil have in addtion the buletin for all metropolitan + France department and Andorre with_costal_bulletin: Optional; If set to True (default is False), you can get the basic bulletin and coastal bulletin merged. @@ -205,10 +205,10 @@ def get_warning_full(self, domain: str, with_costal_bulletin: bool = False) -> F coastal bulletin merged. Args: - domain: could be `france` or any France métropole department numbers on two - digits. For some departments you can access an additional bulletin for - coastal phenomenoms. To access it add `10` after the domain id (example: - `1310`). + domain: could be `france` or any metropolitan France department numbers on + two digits. For some departments you can access an additional bulletin + for coastal phenomenoms. To access it add `10` after the domain id + (example: `1310`). with_costal_bulletin: Optional; If set to True (default is False), you can get the basic bulletin and coastal bulletin merged. @@ -237,8 +237,8 @@ def get_warning_thumbnail(self, domain: str = "france") -> str: """Retrieve the thumbnail URL of the weather phenomenoms or alerts map. Args: - domain: could be `france` or any France métropole department numbers on two - digits. + domain: could be `france` or any metropolitan France department numbers on + two digits. Returns: The URL of the thumbnail representing the weather alert status. diff --git a/src/meteofrance/helpers.py b/src/meteofrance/helpers.py index 341d7d72..7d25c1be 100644 --- a/src/meteofrance/helpers.py +++ b/src/meteofrance/helpers.py @@ -72,13 +72,13 @@ def is_coastal_department(department_number: str) -> bool: def is_valid_warning_department(department_number: str) -> bool: """Identify if there is a weather alert bulletin for this department (Helper). - Weather alert buletins are available only for France métropole and Andorre. + Weather alert buletins are available only for metropolitan France and Andorre. Args: department_number: Department number on 2 characters. Returns: - True if a department is France Métropole or Andorre. + True if a department is metropolitan France or Andorre. """ return department_number in VALID_DEPARTMENT_LIST From fe4175a430cc4519ff2940c5bca6403e4a25d98b Mon Sep 17 00:00:00 2001 From: oncleben31 Date: Sat, 3 Oct 2020 08:38:33 +0200 Subject: [PATCH 08/33] Rewrite session docstrings with the Google doc style --- src/meteofrance/session.py | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/src/meteofrance/session.py b/src/meteofrance/session.py index 169fb10e..7fa5f6d7 100644 --- a/src/meteofrance/session.py +++ b/src/meteofrance/session.py @@ -13,19 +13,32 @@ class MeteoFranceSession(Session): - """Session for Météo-France.""" + """HTTP session manager for Météo-France. + + This session object allows to manage the authentication in the API using a token. + """ host: str = METEOFRANCE_API_URL def __init__(self, access_token: Optional[str] = None): - """Initialize the auth.""" + """Initialize the authentication.""" self.access_token = access_token or METEOFRANCE_API_TOKEN Session.__init__(self) def request( # type: ignore self, method: str, path: str, *args: Any, **kwargs: Any ) -> Response: - """Make a request.""" + """Make a request using token authentication. + + Args: + method: Method for the HTTP request (example "get"). + path: path of the REST API endpoint. + args: all other non-keyword arguments. + kwargs: all other keyword arguments. + + Returns: + the Response object corresponding to the result of the API request. + """ params_inputs = kwargs.pop("params", None) params = {"token": self.access_token} @@ -40,7 +53,11 @@ def request( # type: ignore class MeteoFranceWSSession(MeteoFranceSession): - """Session for Météo-France WS.""" + """HTTP session manager for Météo-France WS. + + Child class dedicated to additional REST API URI for specific command like getDetail + , getAllVigilances, getVigilance. + """ host: str = METEOFRANCE_WS_API_URL @@ -50,7 +67,11 @@ def __init__(self, access_token: Optional[str] = None): class MeteoNetSession(MeteoFranceSession): - """Session for MétéoNet.""" + """HTTP session manager for MétéoNet. + + Child class dedicated to additional REST API URI for specific command like ImageJour + , radarEU. + """ host: str = METEONET_API_URL From 757d6d3468d4c48cf369b5831a01eb094811e755 Mon Sep 17 00:00:00 2001 From: oncleben31 Date: Sat, 3 Oct 2020 12:14:11 +0200 Subject: [PATCH 09/33] Rewrite forecast model docstrings --- src/meteofrance/model/forecast.py | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/src/meteofrance/model/forecast.py b/src/meteofrance/model/forecast.py index 7e945c09..105411fa 100644 --- a/src/meteofrance/model/forecast.py +++ b/src/meteofrance/model/forecast.py @@ -17,7 +17,7 @@ class ForecastData(TypedDict): - """Describing the structure of the API returned forecast object.""" + """Describing the data structure of the forecast object returned by the REST API.""" position: Dict[str, Any] updated_on: int @@ -27,7 +27,23 @@ class ForecastData(TypedDict): class Forecast: - """Class to access the results of a `forecast` API command.""" + """Class to access the results of a `forecast` API request. + + Attributes: + position: A dictionary with metadata about the position of the forecast place. + updated_on: A timestamp as int corresponding to the latest update date. + daily_forecast: A list of dictionaries to describe the daily forecast for the + next 15 days. + forecast: A list of dictionaries to describe the hourly forecast for the next + days. + probability_forecast: A list of dictionaries to describe the event probability + forecast (rain, snwow, freezing) for next 10 days. + today_forecast: A dictionary corresponding to the daily forecast for the current + day. + nearest_forecast: A dictionary corresponding to the nearest hourly forecast. + current_forecast: A dictionary corresponding to the hourly forecast for the + current hour. + """ def __init__(self, raw_data: ForecastData): """Initialize a Forecast object.""" @@ -68,7 +84,7 @@ def nearest_forecast(self) -> Dict[str, Any]: """Return the nearest hourly forecast.""" # get timestamp for current time now_timestamp = int(utc.localize(datetime.utcnow()).timestamp()) - # sort list of foerecast by distance between current timestamp and + # sort list of forecast by distance between current timestamp and # forecast timestamp sorted_forecast = sorted( self.forecast, key=lambda x: abs(x["dt"] - now_timestamp) @@ -91,8 +107,13 @@ def current_forecast(self) -> Dict[str, Any]: return forecast_by_datetime.get(current_hour_timestamp, self.nearest_forecast) def timestamp_to_locale_time(self, timestamp: int) -> datetime: - """Convert timestamp in datetime (Helper). + """Convert timestamp in datetime in the forecast location timezone (Helper). - The timezone corresponding to the forecast location is used. + Args: + timestamp: An integer to describe the UNIX timestamp. + + Returns: + Datetime instance corresponding to the timestamp with the timezone of the + forecast location. """ return timestamp_to_dateime_with_locale_tz(timestamp, self.position["timezone"]) From 0b4b369db693eeacbb37a5e45207cc3cf89f4a57 Mon Sep 17 00:00:00 2001 From: oncleben31 Date: Sat, 3 Oct 2020 13:42:55 +0200 Subject: [PATCH 10/33] Rewrite picture of day model docstrings --- src/meteofrance/model/picture_of_the_day.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/meteofrance/model/picture_of_the_day.py b/src/meteofrance/model/picture_of_the_day.py index 18fd3d09..855f2ad1 100644 --- a/src/meteofrance/model/picture_of_the_day.py +++ b/src/meteofrance/model/picture_of_the_day.py @@ -10,7 +10,7 @@ class PictureOfTheDayData(TypedDict): - """Describe the structure of the API returned ImageJour object.""" + """Describing the data structure of ImageJour object returned by the REST API.""" vignette: str imageHD: str # noqa: N815 @@ -18,7 +18,14 @@ class PictureOfTheDayData(TypedDict): class PictureOfTheDay: - """Class to access the results of a `ImageJour/last` API command.""" + """Class to access the results of a `ImageJour/last` REST API request. + + Attributes: + image_url: A string corresponding to the picture of the day URL. + image_hd_url: A string corresponding to the URL for the HD version of the + picture of the day. + descritpion: A string with the description of the picture of the day. + """ def __init__(self, raw_data: Mapping[str, PictureOfTheDayData]): """Initialize a PictureOfTheDay object.""" From 011faedb97b2c080b80b22c38aecc440343f356b Mon Sep 17 00:00:00 2001 From: oncleben31 Date: Sat, 3 Oct 2020 20:27:49 +0200 Subject: [PATCH 11/33] Rewrite place model doctstrings --- src/meteofrance/model/place.py | 44 ++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/src/meteofrance/model/place.py b/src/meteofrance/model/place.py index 864187e2..61a478b6 100644 --- a/src/meteofrance/model/place.py +++ b/src/meteofrance/model/place.py @@ -10,7 +10,7 @@ class PlaceData(TypedDict): - """Describe the structure of the API returned place object.""" + """Describing the data structure of place object returned by the REST API.""" insee: str name: str @@ -23,14 +23,34 @@ class PlaceData(TypedDict): class Place: - """Class to access the results of 'places' API command.""" + """Class to access the results of 'places' REST API request. + + Attributes: + insee: A string corresponding to the INSEE ID of the place. + name: Name of the place. + lat: A float with the latitude in degree of the place. + lon: A float with the longitude in degree of the place + country: A string corresponding to the country code of the place. + admin: A string with the name of the administrative area ('Département' for + France and Region for other countries). + admin2: A string correponding to an administrative code ( 'Département' number + for France) + postCode: A string corresponding to the ZIP code of location. + """ def __init__(self, raw_data: PlaceData): """Initialize a Place object.""" self.raw_data = raw_data def __repr__(self) -> str: - """Return string representation of this class.""" + """Return string representation of this class. + + Returns: + A string to represent the instance of the Place class using the name, + country and amdin area of the location. + + Example: + """ return "<{}(name={}, country={}, admin={})>".format( self.__class__.__name__, self.name, self.country, self.admin ) @@ -38,7 +58,13 @@ def __repr__(self) -> str: def __str__(self) -> str: """Provide an easy way to identify the Place. - examples: `Toulouse - (31)` or `Montréal - (Quebec)` + Returns: + A string to represent a Place instance with city name, Region name, + department ID and the country name. + + For Examples: + `Marseille - Provence-Alpes-Côte d'Azur (13) - FR` + or `Montréal - Quebec - CA` """ if self.country == "FR": return f"{self.name} - {self.admin} ({self.admin2}) - {self.country}" @@ -72,18 +98,12 @@ def country(self) -> str: @property def admin(self) -> Optional[str]: - """Return the admin of the place. - - Seems to be the department in text ex: "Gers". - """ + """Return the admin of the place.""" return self.raw_data.get("admin") @property def admin2(self) -> Optional[str]: - """Return the admin2 of the place. - - Seems to be the department in numbers "32". - """ + """Return the admin2 of the place.""" return self.raw_data.get("admin2") @property From 14774987384aae52fc7e3473df9a7a55072be9bc Mon Sep 17 00:00:00 2001 From: oncleben31 Date: Sat, 3 Oct 2020 21:04:04 +0200 Subject: [PATCH 12/33] Add missing type information for __init__ methods --- src/meteofrance/client.py | 2 +- src/meteofrance/model/forecast.py | 2 +- src/meteofrance/model/picture_of_the_day.py | 4 ++-- src/meteofrance/model/place.py | 2 +- src/meteofrance/session.py | 6 +++--- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/meteofrance/client.py b/src/meteofrance/client.py index 2d28f2ec..1c6eee2a 100644 --- a/src/meteofrance/client.py +++ b/src/meteofrance/client.py @@ -32,7 +32,7 @@ class MeteoFranceClient: weather alert bulletin. """ - def __init__(self, access_token: Optional[str] = None): + def __init__(self, access_token: Optional[str] = None) -> None: """Initialize the API and store the auth so we can make requests.""" self.session = MeteoFranceSession(access_token) self.session_ws = MeteoFranceWSSession() diff --git a/src/meteofrance/model/forecast.py b/src/meteofrance/model/forecast.py index 105411fa..cc4d8088 100644 --- a/src/meteofrance/model/forecast.py +++ b/src/meteofrance/model/forecast.py @@ -45,7 +45,7 @@ class Forecast: current hour. """ - def __init__(self, raw_data: ForecastData): + def __init__(self, raw_data: ForecastData) -> None: """Initialize a Forecast object.""" self.raw_data = raw_data diff --git a/src/meteofrance/model/picture_of_the_day.py b/src/meteofrance/model/picture_of_the_day.py index 855f2ad1..06105216 100644 --- a/src/meteofrance/model/picture_of_the_day.py +++ b/src/meteofrance/model/picture_of_the_day.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -"""Picture of the Day@ Python model for the Météo-France REST API.""" +"""Picture of the Day Python model for the Météo-France REST API.""" import sys from typing import Mapping @@ -27,7 +27,7 @@ class PictureOfTheDay: descritpion: A string with the description of the picture of the day. """ - def __init__(self, raw_data: Mapping[str, PictureOfTheDayData]): + def __init__(self, raw_data: Mapping[str, PictureOfTheDayData]) -> None: """Initialize a PictureOfTheDay object.""" self.raw_data = raw_data["result"] diff --git a/src/meteofrance/model/place.py b/src/meteofrance/model/place.py index 61a478b6..110e2ffb 100644 --- a/src/meteofrance/model/place.py +++ b/src/meteofrance/model/place.py @@ -38,7 +38,7 @@ class Place: postCode: A string corresponding to the ZIP code of location. """ - def __init__(self, raw_data: PlaceData): + def __init__(self, raw_data: PlaceData) -> None: """Initialize a Place object.""" self.raw_data = raw_data diff --git a/src/meteofrance/session.py b/src/meteofrance/session.py index 7fa5f6d7..83365fb9 100644 --- a/src/meteofrance/session.py +++ b/src/meteofrance/session.py @@ -20,7 +20,7 @@ class MeteoFranceSession(Session): host: str = METEOFRANCE_API_URL - def __init__(self, access_token: Optional[str] = None): + def __init__(self, access_token: Optional[str] = None) -> None: """Initialize the authentication.""" self.access_token = access_token or METEOFRANCE_API_TOKEN Session.__init__(self) @@ -61,7 +61,7 @@ class MeteoFranceWSSession(MeteoFranceSession): host: str = METEOFRANCE_WS_API_URL - def __init__(self, access_token: Optional[str] = None): + def __init__(self, access_token: Optional[str] = None) -> None: """Initialize the Météo-France WS.""" super().__init__(access_token) @@ -75,6 +75,6 @@ class MeteoNetSession(MeteoFranceSession): host: str = METEONET_API_URL - def __init__(self, access_token: Optional[str] = None): + def __init__(self, access_token: Optional[str] = None) -> None: """Initialize the MétéoNet.""" super().__init__(access_token) From f25f71d987d67d2c896949731c85ecb3d147b1f7 Mon Sep 17 00:00:00 2001 From: oncleben31 Date: Sat, 3 Oct 2020 21:24:39 +0200 Subject: [PATCH 13/33] Rewrite rain model doctstrings --- src/meteofrance/model/rain.py | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/src/meteofrance/model/rain.py b/src/meteofrance/model/rain.py index 5c091d8b..81cbf468 100644 --- a/src/meteofrance/model/rain.py +++ b/src/meteofrance/model/rain.py @@ -16,7 +16,7 @@ class RainData(TypedDict): - """Describing the structure of the API returned rain object.""" + """Describing the data structure of rain object returned by the REST API.""" position: Dict[str, Any] updated_on: int @@ -25,9 +25,17 @@ class RainData(TypedDict): class Rain: - """Class to access the results of 'rain' API command.""" + """Class to access the results of 'rain' REST API request. - def __init__(self, raw_data: RainData): + Attributes: + position: A dictionary with metadata about the position of the forecast place. + position: A dictionary with metadata about the position of the forecast place. + forecast: A list of dictionaries to describe the following next hour rain + forecast. + quality: An integer. Don't know yet the usage. + """ + + def __init__(self, raw_data: RainData) -> None: """Initialize a Rain object.""" self.raw_data = raw_data @@ -53,7 +61,15 @@ def quality(self) -> int: return self.raw_data["quality"] def next_rain_date_locale(self) -> Optional[datetime]: - """Return the date of the next rain in the Place timezone (Helper).""" + """Estimate the date of the next rain in the Place timezone (Helper). + + Returns: + A datetime instance representing the date estimation of the next rain within + the next hour. + If no rain is expected in the following hour 'None' is returned. + + The datetime use the location timezone. + """ # search first cadran with rain next_rain = next( (cadran for cadran in self.forecast if cadran["rain"] > 1), None @@ -71,8 +87,13 @@ def next_rain_date_locale(self) -> Optional[datetime]: return next_rain_dt_local def timestamp_to_locale_time(self, timestamp: int) -> datetime: - """Convert timestamp in datetime (Helper). + """Convert timestamp in datetime with rain forecast location timezone (Helper). + + Args: + timestamp: An integer representing the UNIX timestamp. - The timezone corresponding to the forecast location is used. + Returns: + A datetime instance corresponding to the timestamp with the timezone of the + rain forecast location. """ return timestamp_to_dateime_with_locale_tz(timestamp, self.position["timezone"]) From 8f150e670c5702d4ad2619f11f1d271299313a95 Mon Sep 17 00:00:00 2001 From: oncleben31 Date: Sat, 3 Oct 2020 21:48:02 +0200 Subject: [PATCH 14/33] Rewrite warning model docstrings --- src/meteofrance/model/warning.py | 60 +++++++++++++++++++++++++++----- 1 file changed, 51 insertions(+), 9 deletions(-) diff --git a/src/meteofrance/model/warning.py b/src/meteofrance/model/warning.py index ebda8956..dd94e83d 100644 --- a/src/meteofrance/model/warning.py +++ b/src/meteofrance/model/warning.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- """Weather alert buletin Python model for the Météo-France REST API. - For getting weather alerts in France Metropole and Andorre. """ import sys @@ -16,7 +15,7 @@ class WarnningCurrentPhenomenonsData(TypedDict): - """Describing the structure of the API returned CurrentPhenomenons object.""" + """Describing the data structure of CurrentPhenomenons object from the REST API.""" update_time: int end_validity_time: int @@ -25,7 +24,7 @@ class WarnningCurrentPhenomenonsData(TypedDict): class WarnningFullData(TypedDict): - """Describing the structure of the API returned full object.""" + """Describing the data structure of full object from the REST API.""" update_time: int end_validity_time: int @@ -42,13 +41,23 @@ class WarnningFullData(TypedDict): class CurrentPhenomenons: - """Class to access the results of a `warning/currentPhenomenons` API command. + """Class to access the results of a `warning/currentPhenomenons` REST API request. For coastal department two bulletins are avalaible corresponding to two different domains. + + Attributes: + update_time: A timestamp (as integer) corresponding to the latest update of the + pheomenoms. + end_validity_time: A timestamp (as integer) corresponding to expiration date of + the phenomenoms. + domain_id: A string corresponding do the domain ID of the bulletin. Value is + 'France' or a department number. + phenomenons_max_colors: A list of dictionnaries with type of phenomenoms and the + current alert level. """ - def __init__(self, raw_data: WarnningCurrentPhenomenonsData): + def __init__(self, raw_data: WarnningCurrentPhenomenonsData) -> None: """Initialize a CurrentPhenomenons object.""" self.raw_data = raw_data @@ -75,14 +84,26 @@ def phenomenons_max_colors(self) -> List[Dict[str, int]]: def merge_with_coastal_phenomenons( self, coastal_phenomenoms: "CurrentPhenomenons" ) -> None: - """Merge the classical phenomenoms bulleting with the coastal one.""" + """Merge the classical phenomenoms bulleting with the coastal one. + + Extend the phenomenomes_max_colors property with the content of the coastal + weather alert bulletin. + + Args: + coastal_phenomenoms: CurrentPhenomenons instance corresponding to the + coastal weather alert bulletin. + """ # TODO: Add consitency check self.raw_data["phenomenons_max_colors"].extend( coastal_phenomenoms.phenomenons_max_colors ) def get_domain_max_color(self) -> int: - """Get the maximum level of alert of a given domain (class helper).""" + """Get the maximum level of alert of a given domain (class helper). + + Returns: + An integer correspondingt to the status code representing the maximul alert. + """ max_int_color = max( x["phenomenon_max_color_id"] for x in self.phenomenons_max_colors ) @@ -97,9 +118,22 @@ class Full: For coastal department two bulletins are avalaible corresponding to two different domains. + + Attributes: + update_time: A timestamp (as integer) corresponding to the latest update of the + pheomenoms. + end_validity_time: A timestamp (as integer) corresponding to expiration date of + the phenomenoms. + domain_id: A string corresponding do the domain ID of the bulletin. Value is + 'France' or a department number. + color_max: An integer reprenting the maximum alert level in the domain. + timelaps: A list of dictionnaries corresponding to the schedule of each + phenomenoms in the next 24 hours. + phenomenons_items: list of dictionnaries corresponding the alert level for each + phenomenoms type. """ - def __init__(self, raw_data: WarnningFullData): + def __init__(self, raw_data: WarnningFullData) -> None: """Initialize a Full object.""" self.raw_data = raw_data @@ -134,7 +168,15 @@ def phenomenons_items(self) -> List[Dict[str, int]]: return self.raw_data["phenomenons_items"] def merge_with_coastal_phenomenons(self, coastal_phenomenoms: "Full") -> None: - """Merge the classical phenomenoms bulleting with the coastal one.""" + """Merge the classical phenomenoms bulleting with the coastal one. + + Extend the color_max, timelaps and phenomenons_items properties with the content + of the coastal weather alert bulletin. + + Args: + coastal_phenomenoms: Full instance corresponding to the coastal weather + alert bulletin. + """ # TODO: Add consitency check # TODO: Check if other data need to be merged From 979442743177a12efcfedb8c551290458259deec Mon Sep 17 00:00:00 2001 From: oncleben31 Date: Sat, 3 Oct 2020 22:47:45 +0200 Subject: [PATCH 15/33] Add docstrings for __init__ methods --- src/meteofrance/client.py | 6 +++++- src/meteofrance/model/forecast.py | 7 ++++++- src/meteofrance/model/picture_of_the_day.py | 8 +++++++- src/meteofrance/model/place.py | 7 ++++++- src/meteofrance/model/rain.py | 7 ++++++- src/meteofrance/model/warning.py | 16 ++++++++++++++-- src/meteofrance/session.py | 18 +++++++++++++++--- 7 files changed, 59 insertions(+), 10 deletions(-) diff --git a/src/meteofrance/client.py b/src/meteofrance/client.py index 1c6eee2a..146a244b 100644 --- a/src/meteofrance/client.py +++ b/src/meteofrance/client.py @@ -33,7 +33,11 @@ class MeteoFranceClient: """ def __init__(self, access_token: Optional[str] = None) -> None: - """Initialize the API and store the auth so we can make requests.""" + """Initialize the API and store the auth so we can make requests. + + Args: + access_token: a string containing the authentication token for the REST API. + """ self.session = MeteoFranceSession(access_token) self.session_ws = MeteoFranceWSSession() self.session_net = MeteoNetSession() diff --git a/src/meteofrance/model/forecast.py b/src/meteofrance/model/forecast.py index cc4d8088..1babbcb9 100644 --- a/src/meteofrance/model/forecast.py +++ b/src/meteofrance/model/forecast.py @@ -46,7 +46,12 @@ class Forecast: """ def __init__(self, raw_data: ForecastData) -> None: - """Initialize a Forecast object.""" + """Initialize a Forecast object. + + Args: + raw_data: A dictionary representing the JSON response from 'forecast' REST + API request. The structure is described by the ForecastData class. + """ self.raw_data = raw_data @property diff --git a/src/meteofrance/model/picture_of_the_day.py b/src/meteofrance/model/picture_of_the_day.py index 06105216..af03ff30 100644 --- a/src/meteofrance/model/picture_of_the_day.py +++ b/src/meteofrance/model/picture_of_the_day.py @@ -28,7 +28,13 @@ class PictureOfTheDay: """ def __init__(self, raw_data: Mapping[str, PictureOfTheDayData]) -> None: - """Initialize a PictureOfTheDay object.""" + """Initialize a PictureOfTheDay object. + + Args: + raw_data: A dictionary representing the JSON response from 'ImageJour/last' + REST API request. The structure is described by the PictureOfTheDayData + class. + """ self.raw_data = raw_data["result"] @property diff --git a/src/meteofrance/model/place.py b/src/meteofrance/model/place.py index 110e2ffb..b3a260e4 100644 --- a/src/meteofrance/model/place.py +++ b/src/meteofrance/model/place.py @@ -39,7 +39,12 @@ class Place: """ def __init__(self, raw_data: PlaceData) -> None: - """Initialize a Place object.""" + """Initialize a Place object. + + Args: + raw_data: A dictionary representing the JSON response from 'places' REST API + request. The structure is described by the PlaceData class. + """ self.raw_data = raw_data def __repr__(self) -> str: diff --git a/src/meteofrance/model/rain.py b/src/meteofrance/model/rain.py index 81cbf468..6fe2c52d 100644 --- a/src/meteofrance/model/rain.py +++ b/src/meteofrance/model/rain.py @@ -36,7 +36,12 @@ class Rain: """ def __init__(self, raw_data: RainData) -> None: - """Initialize a Rain object.""" + """Initialize a Rain object. + + Args: + raw_data: A dictionary representing the JSON response from 'rain' REST API + request. The structure is described by the RainData class. + """ self.raw_data = raw_data @property diff --git a/src/meteofrance/model/warning.py b/src/meteofrance/model/warning.py index dd94e83d..0e8411fd 100644 --- a/src/meteofrance/model/warning.py +++ b/src/meteofrance/model/warning.py @@ -58,7 +58,13 @@ class CurrentPhenomenons: """ def __init__(self, raw_data: WarnningCurrentPhenomenonsData) -> None: - """Initialize a CurrentPhenomenons object.""" + """Initialize a CurrentPhenomenons object. + + Args: + raw_data: A dictionary representing the JSON response from + 'warning/currentPhenomenons' REST API request. The structure is + described by the WarnningCurrentPhenomenonsData class. + """ self.raw_data = raw_data @property @@ -134,7 +140,13 @@ class Full: """ def __init__(self, raw_data: WarnningFullData) -> None: - """Initialize a Full object.""" + """Initialize a Full object. + + Args: + raw_data: A dictionary representing the JSON response from'warning/full' + REST API request. The structure is described by the WarnningFullData + class. + """ self.raw_data = raw_data @property diff --git a/src/meteofrance/session.py b/src/meteofrance/session.py index 83365fb9..a0b17919 100644 --- a/src/meteofrance/session.py +++ b/src/meteofrance/session.py @@ -21,7 +21,11 @@ class MeteoFranceSession(Session): host: str = METEOFRANCE_API_URL def __init__(self, access_token: Optional[str] = None) -> None: - """Initialize the authentication.""" + """Initialize the authentication. + + Args: + access_token: a string containing the authentication token for the REST API. + """ self.access_token = access_token or METEOFRANCE_API_TOKEN Session.__init__(self) @@ -62,7 +66,11 @@ class MeteoFranceWSSession(MeteoFranceSession): host: str = METEOFRANCE_WS_API_URL def __init__(self, access_token: Optional[str] = None) -> None: - """Initialize the Météo-France WS.""" + """Initialize the Météo-France WS. + + Args: + access_token: a string containing the authentication token for the REST API. + """ super().__init__(access_token) @@ -76,5 +84,9 @@ class MeteoNetSession(MeteoFranceSession): host: str = METEONET_API_URL def __init__(self, access_token: Optional[str] = None) -> None: - """Initialize the MétéoNet.""" + """Initialize the MétéoNet. + + Args: + access_token: a string containing the authentication token for the REST API. + """ super().__init__(access_token) From 60ece916b092b9dc3a250b7761de0f53cb5431e2 Mon Sep 17 00:00:00 2001 From: oncleben31 Date: Sat, 3 Oct 2020 23:00:18 +0200 Subject: [PATCH 16/33] Add sphinx to dev dependencies --- poetry.lock | 257 ++++++++++++++++++++++++++++++++++++++++++++++++- pyproject.toml | 1 + 2 files changed, 257 insertions(+), 1 deletion(-) diff --git a/poetry.lock b/poetry.lock index 092be923..74ca94bf 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,3 +1,11 @@ +[[package]] +category = "dev" +description = "A configurable sidebar-enabled Sphinx theme" +name = "alabaster" +optional = false +python-versions = "*" +version = "0.7.12" + [[package]] category = "dev" description = "A small Python module for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." @@ -40,6 +48,17 @@ dev = ["coverage", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "zope.int docs = ["sphinx", "zope.interface"] tests = ["coverage", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "zope.interface"] +[[package]] +category = "dev" +description = "Internationalization utilities" +name = "babel" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" +version = "2.8.0" + +[package.dependencies] +pytz = ">=2015.7" + [[package]] category = "dev" description = "Security oriented static analyser for python code." @@ -183,6 +202,14 @@ optional = false python-versions = "*" version = "0.3.1" +[[package]] +category = "dev" +description = "Docutils -- Python Documentation Utilities" +name = "docutils" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" +version = "0.16" + [[package]] category = "dev" description = "A parser for Python dependency files" @@ -314,6 +341,14 @@ optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" version = "2.10" +[[package]] +category = "dev" +description = "Getting image size from png/jpeg/jpeg2000/gif file" +name = "imagesize" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" +version = "1.2.0" + [[package]] category = "dev" description = "Read metadata from Python packages" @@ -355,6 +390,28 @@ optional = false python-versions = "*" version = "1.0.1" +[[package]] +category = "dev" +description = "A very fast and expressive template engine." +name = "jinja2" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" +version = "2.11.2" + +[package.dependencies] +MarkupSafe = ">=0.23" + +[package.extras] +i18n = ["Babel (>=0.8)"] + +[[package]] +category = "dev" +description = "Safely add untrusted strings to HTML/XML markup." +name = "markupsafe" +optional = false +python-versions = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*" +version = "1.1.1" + [[package]] category = "dev" description = "McCabe checker, plugin for flake8" @@ -521,6 +578,14 @@ optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" version = "2.2.0" +[[package]] +category = "dev" +description = "Pygments is a syntax highlighting package written in Python." +name = "pygments" +optional = false +python-versions = ">=3.5" +version = "2.7.1" + [[package]] category = "dev" description = "Python parsing module" @@ -704,6 +769,109 @@ optional = false python-versions = "*" version = "2.0.0" +[[package]] +category = "dev" +description = "Python documentation generator" +name = "sphinx" +optional = false +python-versions = ">=3.5" +version = "3.2.1" + +[package.dependencies] +Jinja2 = ">=2.3" +Pygments = ">=2.0" +alabaster = ">=0.7,<0.8" +babel = ">=1.3" +colorama = ">=0.3.5" +docutils = ">=0.12" +imagesize = "*" +packaging = "*" +requests = ">=2.5.0" +setuptools = "*" +snowballstemmer = ">=1.1" +sphinxcontrib-applehelp = "*" +sphinxcontrib-devhelp = "*" +sphinxcontrib-htmlhelp = "*" +sphinxcontrib-jsmath = "*" +sphinxcontrib-qthelp = "*" +sphinxcontrib-serializinghtml = "*" + +[package.extras] +docs = ["sphinxcontrib-websupport"] +lint = ["flake8 (>=3.5.0)", "flake8-import-order", "mypy (>=0.780)", "docutils-stubs"] +test = ["pytest", "pytest-cov", "html5lib", "typed-ast", "cython"] + +[[package]] +category = "dev" +description = "sphinxcontrib-applehelp is a sphinx extension which outputs Apple help books" +name = "sphinxcontrib-applehelp" +optional = false +python-versions = ">=3.5" +version = "1.0.2" + +[package.extras] +lint = ["flake8", "mypy", "docutils-stubs"] +test = ["pytest"] + +[[package]] +category = "dev" +description = "sphinxcontrib-devhelp is a sphinx extension which outputs Devhelp document." +name = "sphinxcontrib-devhelp" +optional = false +python-versions = ">=3.5" +version = "1.0.2" + +[package.extras] +lint = ["flake8", "mypy", "docutils-stubs"] +test = ["pytest"] + +[[package]] +category = "dev" +description = "sphinxcontrib-htmlhelp is a sphinx extension which renders HTML help files" +name = "sphinxcontrib-htmlhelp" +optional = false +python-versions = ">=3.5" +version = "1.0.3" + +[package.extras] +lint = ["flake8", "mypy", "docutils-stubs"] +test = ["pytest", "html5lib"] + +[[package]] +category = "dev" +description = "A sphinx extension which renders display math in HTML via JavaScript" +name = "sphinxcontrib-jsmath" +optional = false +python-versions = ">=3.5" +version = "1.0.1" + +[package.extras] +test = ["pytest", "flake8", "mypy"] + +[[package]] +category = "dev" +description = "sphinxcontrib-qthelp is a sphinx extension which outputs QtHelp document." +name = "sphinxcontrib-qthelp" +optional = false +python-versions = ">=3.5" +version = "1.0.3" + +[package.extras] +lint = ["flake8", "mypy", "docutils-stubs"] +test = ["pytest"] + +[[package]] +category = "dev" +description = "sphinxcontrib-serializinghtml is a sphinx extension which outputs \"serialized\" HTML files (json and pickle)." +name = "sphinxcontrib-serializinghtml" +optional = false +python-versions = ">=3.5" +version = "1.1.4" + +[package.extras] +lint = ["flake8", "mypy", "docutils-stubs"] +test = ["pytest"] + [[package]] category = "dev" description = "Manage dynamic plugins for Python applications" @@ -808,11 +976,15 @@ docs = ["sphinx", "jaraco.packaging (>=3.2)", "rst.linker (>=1.9)"] testing = ["jaraco.itertools", "func-timeout"] [metadata] -content-hash = "a63527bd3fd906726cce5402646dd897eafed4ba9f5c5761c1ac753d1c1f1623" +content-hash = "5c201dc70cfae188955146de6cb259327b2dcee4b1330d578a2a89625d0e98f2" lock-version = "1.0" python-versions = "^3.6.1" [metadata.files] +alabaster = [ + {file = "alabaster-0.7.12-py2.py3-none-any.whl", hash = "sha256:446438bdcca0e05bd45ea2de1668c1d9b032e1a9154c2c259092d77031ddd359"}, + {file = "alabaster-0.7.12.tar.gz", hash = "sha256:a661d72d58e6ea8a57f7a86e37d86716863ee5e92788398526d58b26a4e4dc02"}, +] appdirs = [ {file = "appdirs-1.4.4-py2.py3-none-any.whl", hash = "sha256:a841dacd6b99318a741b166adb07e19ee71a274450e68237b4650ca1055ab128"}, {file = "appdirs-1.4.4.tar.gz", hash = "sha256:7d5d0167b2b1ba821647616af46a749d1c653740dd0d2415100fe26e27afdf41"}, @@ -829,6 +1001,10 @@ attrs = [ {file = "attrs-19.3.0-py2.py3-none-any.whl", hash = "sha256:08a96c641c3a74e44eb59afb61a24f2cb9f4d7188748e76ba4bb5edfa3cb7d1c"}, {file = "attrs-19.3.0.tar.gz", hash = "sha256:f7b7ce16570fe9965acd6d30101a28f62fb4a7f9e926b3bbc9b61f8b04247e72"}, ] +babel = [ + {file = "Babel-2.8.0-py2.py3-none-any.whl", hash = "sha256:d670ea0b10f8b723672d3a6abeb87b565b244da220d76b4dba1b66269ec152d4"}, + {file = "Babel-2.8.0.tar.gz", hash = "sha256:1aac2ae2d0d8ea368fa90906567f5c08463d98ade155c0c4bfedd6a0f7160e38"}, +] bandit = [ {file = "bandit-1.6.2-py2.py3-none-any.whl", hash = "sha256:336620e220cf2d3115877685e264477ff9d9abaeb0afe3dc7264f55fa17a3952"}, {file = "bandit-1.6.2.tar.gz", hash = "sha256:41e75315853507aa145d62a78a2a6c5e3240fe14ee7c601459d0df9418196065"}, @@ -913,6 +1089,10 @@ distlib = [ {file = "distlib-0.3.1-py2.py3-none-any.whl", hash = "sha256:8c09de2c67b3e7deef7184574fc060ab8a793e7adbb183d942c389c8b13c52fb"}, {file = "distlib-0.3.1.zip", hash = "sha256:edf6116872c863e1aa9d5bb7cb5e05a022c519a4594dc703843343a9ddd9bff1"}, ] +docutils = [ + {file = "docutils-0.16-py2.py3-none-any.whl", hash = "sha256:0c5b78adfbf7762415433f5515cd5c9e762339e23369dbe8000d84a4bf4ab3af"}, + {file = "docutils-0.16.tar.gz", hash = "sha256:c2de3a60e9e7d07be26b7f2b00ca0309c207e06c100f9cc2a94931fc75a478fc"}, +] dparse = [ {file = "dparse-0.5.1-py3-none-any.whl", hash = "sha256:e953a25e44ebb60a5c6efc2add4420c177f1d8404509da88da9729202f306994"}, {file = "dparse-0.5.1.tar.gz", hash = "sha256:a1b5f169102e1c894f9a7d5ccf6f9402a836a5d24be80a986c7ce9eaed78f367"}, @@ -956,6 +1136,10 @@ idna = [ {file = "idna-2.10-py2.py3-none-any.whl", hash = "sha256:b97d804b1e9b523befed77c48dacec60e6dcb0b5391d57af6a65a312a90648c0"}, {file = "idna-2.10.tar.gz", hash = "sha256:b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6"}, ] +imagesize = [ + {file = "imagesize-1.2.0-py2.py3-none-any.whl", hash = "sha256:6965f19a6a2039c7d48bca7dba2473069ff854c36ae6f19d2cde309d998228a1"}, + {file = "imagesize-1.2.0.tar.gz", hash = "sha256:b1f6b5a4eab1f73479a50fb79fcf729514a900c341d8503d62a62dbc4127a2b1"}, +] importlib-metadata = [ {file = "importlib_metadata-1.7.0-py2.py3-none-any.whl", hash = "sha256:dc15b2969b4ce36305c51eebe62d418ac7791e9a157911d58bfb1f9ccd8e2070"}, {file = "importlib_metadata-1.7.0.tar.gz", hash = "sha256:90bb658cdbbf6d1735b6341ce708fc7024a3e14e99ffdc5783edea9f9b077f83"}, @@ -968,6 +1152,45 @@ iniconfig = [ {file = "iniconfig-1.0.1-py3-none-any.whl", hash = "sha256:80cf40c597eb564e86346103f609d74efce0f6b4d4f30ec8ce9e2c26411ba437"}, {file = "iniconfig-1.0.1.tar.gz", hash = "sha256:e5f92f89355a67de0595932a6c6c02ab4afddc6fcdc0bfc5becd0d60884d3f69"}, ] +jinja2 = [ + {file = "Jinja2-2.11.2-py2.py3-none-any.whl", hash = "sha256:f0a4641d3cf955324a89c04f3d94663aa4d638abe8f733ecd3582848e1c37035"}, + {file = "Jinja2-2.11.2.tar.gz", hash = "sha256:89aab215427ef59c34ad58735269eb58b1a5808103067f7bb9d5836c651b3bb0"}, +] +markupsafe = [ + {file = "MarkupSafe-1.1.1-cp27-cp27m-macosx_10_6_intel.whl", hash = "sha256:09027a7803a62ca78792ad89403b1b7a73a01c8cb65909cd876f7fcebd79b161"}, + {file = "MarkupSafe-1.1.1-cp27-cp27m-manylinux1_i686.whl", hash = "sha256:e249096428b3ae81b08327a63a485ad0878de3fb939049038579ac0ef61e17e7"}, + {file = "MarkupSafe-1.1.1-cp27-cp27m-manylinux1_x86_64.whl", hash = "sha256:500d4957e52ddc3351cabf489e79c91c17f6e0899158447047588650b5e69183"}, + {file = "MarkupSafe-1.1.1-cp27-cp27m-win32.whl", hash = "sha256:b2051432115498d3562c084a49bba65d97cf251f5a331c64a12ee7e04dacc51b"}, + {file = "MarkupSafe-1.1.1-cp27-cp27m-win_amd64.whl", hash = "sha256:98c7086708b163d425c67c7a91bad6e466bb99d797aa64f965e9d25c12111a5e"}, + {file = "MarkupSafe-1.1.1-cp27-cp27mu-manylinux1_i686.whl", hash = "sha256:cd5df75523866410809ca100dc9681e301e3c27567cf498077e8551b6d20e42f"}, + {file = "MarkupSafe-1.1.1-cp27-cp27mu-manylinux1_x86_64.whl", hash = "sha256:43a55c2930bbc139570ac2452adf3d70cdbb3cfe5912c71cdce1c2c6bbd9c5d1"}, + {file = "MarkupSafe-1.1.1-cp34-cp34m-macosx_10_6_intel.whl", hash = "sha256:1027c282dad077d0bae18be6794e6b6b8c91d58ed8a8d89a89d59693b9131db5"}, + {file = "MarkupSafe-1.1.1-cp34-cp34m-manylinux1_i686.whl", hash = "sha256:62fe6c95e3ec8a7fad637b7f3d372c15ec1caa01ab47926cfdf7a75b40e0eac1"}, + {file = "MarkupSafe-1.1.1-cp34-cp34m-manylinux1_x86_64.whl", hash = "sha256:88e5fcfb52ee7b911e8bb6d6aa2fd21fbecc674eadd44118a9cc3863f938e735"}, + {file = "MarkupSafe-1.1.1-cp34-cp34m-win32.whl", hash = "sha256:ade5e387d2ad0d7ebf59146cc00c8044acbd863725f887353a10df825fc8ae21"}, + {file = "MarkupSafe-1.1.1-cp34-cp34m-win_amd64.whl", hash = "sha256:09c4b7f37d6c648cb13f9230d847adf22f8171b1ccc4d5682398e77f40309235"}, + {file = "MarkupSafe-1.1.1-cp35-cp35m-macosx_10_6_intel.whl", hash = "sha256:79855e1c5b8da654cf486b830bd42c06e8780cea587384cf6545b7d9ac013a0b"}, + {file = "MarkupSafe-1.1.1-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:c8716a48d94b06bb3b2524c2b77e055fb313aeb4ea620c8dd03a105574ba704f"}, + {file = "MarkupSafe-1.1.1-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:7c1699dfe0cf8ff607dbdcc1e9b9af1755371f92a68f706051cc8c37d447c905"}, + {file = "MarkupSafe-1.1.1-cp35-cp35m-win32.whl", hash = "sha256:6dd73240d2af64df90aa7c4e7481e23825ea70af4b4922f8ede5b9e35f78a3b1"}, + {file = "MarkupSafe-1.1.1-cp35-cp35m-win_amd64.whl", hash = "sha256:9add70b36c5666a2ed02b43b335fe19002ee5235efd4b8a89bfcf9005bebac0d"}, + {file = "MarkupSafe-1.1.1-cp36-cp36m-macosx_10_6_intel.whl", hash = "sha256:24982cc2533820871eba85ba648cd53d8623687ff11cbb805be4ff7b4c971aff"}, + {file = "MarkupSafe-1.1.1-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:00bc623926325b26bb9605ae9eae8a215691f33cae5df11ca5424f06f2d1f473"}, + {file = "MarkupSafe-1.1.1-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:717ba8fe3ae9cc0006d7c451f0bb265ee07739daf76355d06366154ee68d221e"}, + {file = "MarkupSafe-1.1.1-cp36-cp36m-win32.whl", hash = "sha256:535f6fc4d397c1563d08b88e485c3496cf5784e927af890fb3c3aac7f933ec66"}, + {file = "MarkupSafe-1.1.1-cp36-cp36m-win_amd64.whl", hash = "sha256:b1282f8c00509d99fef04d8ba936b156d419be841854fe901d8ae224c59f0be5"}, + {file = "MarkupSafe-1.1.1-cp37-cp37m-macosx_10_6_intel.whl", hash = "sha256:8defac2f2ccd6805ebf65f5eeb132adcf2ab57aa11fdf4c0dd5169a004710e7d"}, + {file = "MarkupSafe-1.1.1-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:46c99d2de99945ec5cb54f23c8cd5689f6d7177305ebff350a58ce5f8de1669e"}, + {file = "MarkupSafe-1.1.1-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:ba59edeaa2fc6114428f1637ffff42da1e311e29382d81b339c1817d37ec93c6"}, + {file = "MarkupSafe-1.1.1-cp37-cp37m-win32.whl", hash = "sha256:b00c1de48212e4cc9603895652c5c410df699856a2853135b3967591e4beebc2"}, + {file = "MarkupSafe-1.1.1-cp37-cp37m-win_amd64.whl", hash = "sha256:9bf40443012702a1d2070043cb6291650a0841ece432556f784f004937f0f32c"}, + {file = "MarkupSafe-1.1.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:6788b695d50a51edb699cb55e35487e430fa21f1ed838122d722e0ff0ac5ba15"}, + {file = "MarkupSafe-1.1.1-cp38-cp38-manylinux1_i686.whl", hash = "sha256:cdb132fc825c38e1aeec2c8aa9338310d29d337bebbd7baa06889d09a60a1fa2"}, + {file = "MarkupSafe-1.1.1-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:13d3144e1e340870b25e7b10b98d779608c02016d5184cfb9927a9f10c689f42"}, + {file = "MarkupSafe-1.1.1-cp38-cp38-win32.whl", hash = "sha256:596510de112c685489095da617b5bcbbac7dd6384aeebeda4df6025d0256a81b"}, + {file = "MarkupSafe-1.1.1-cp38-cp38-win_amd64.whl", hash = "sha256:e8313f01ba26fbbe36c7be1966a7b7424942f670f38e666995b88d012765b9be"}, + {file = "MarkupSafe-1.1.1.tar.gz", hash = "sha256:29872e92839765e546828bb7754a68c418d927cd064fd4708fab9fe9c8bb116b"}, +] mccabe = [ {file = "mccabe-0.6.1-py2.py3-none-any.whl", hash = "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42"}, {file = "mccabe-0.6.1.tar.gz", hash = "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"}, @@ -1039,6 +1262,10 @@ pyflakes = [ {file = "pyflakes-2.2.0-py2.py3-none-any.whl", hash = "sha256:0d94e0e05a19e57a99444b6ddcf9a6eb2e5c68d3ca1e98e90707af8152c90a92"}, {file = "pyflakes-2.2.0.tar.gz", hash = "sha256:35b2d75ee967ea93b55750aa9edbbf72813e06a66ba54438df2cfac9e3c27fc8"}, ] +pygments = [ + {file = "Pygments-2.7.1-py3-none-any.whl", hash = "sha256:307543fe65c0947b126e83dd5a61bd8acbd84abec11f43caebaf5534cbc17998"}, + {file = "Pygments-2.7.1.tar.gz", hash = "sha256:926c3f319eda178d1bd90851e4317e6d8cdb5e292a3386aac9bd75eca29cf9c7"}, +] pyparsing = [ {file = "pyparsing-2.4.7-py2.py3-none-any.whl", hash = "sha256:ef9d7589ef3c200abe66653d3f1ab1033c3c419ae9b9bdb1240a85b024efc88b"}, {file = "pyparsing-2.4.7.tar.gz", hash = "sha256:c203ec8783bf771a155b207279b9bccb8dea02d8f0c9e5f8ead507bc3246ecc1"}, @@ -1144,6 +1371,34 @@ snowballstemmer = [ {file = "snowballstemmer-2.0.0-py2.py3-none-any.whl", hash = "sha256:209f257d7533fdb3cb73bdbd24f436239ca3b2fa67d56f6ff88e86be08cc5ef0"}, {file = "snowballstemmer-2.0.0.tar.gz", hash = "sha256:df3bac3df4c2c01363f3dd2cfa78cce2840a79b9f1c2d2de9ce8d31683992f52"}, ] +sphinx = [ + {file = "Sphinx-3.2.1-py3-none-any.whl", hash = "sha256:ce6fd7ff5b215af39e2fcd44d4a321f6694b4530b6f2b2109b64d120773faea0"}, + {file = "Sphinx-3.2.1.tar.gz", hash = "sha256:321d6d9b16fa381a5306e5a0b76cd48ffbc588e6340059a729c6fdd66087e0e8"}, +] +sphinxcontrib-applehelp = [ + {file = "sphinxcontrib-applehelp-1.0.2.tar.gz", hash = "sha256:a072735ec80e7675e3f432fcae8610ecf509c5f1869d17e2eecff44389cdbc58"}, + {file = "sphinxcontrib_applehelp-1.0.2-py2.py3-none-any.whl", hash = "sha256:806111e5e962be97c29ec4c1e7fe277bfd19e9652fb1a4392105b43e01af885a"}, +] +sphinxcontrib-devhelp = [ + {file = "sphinxcontrib-devhelp-1.0.2.tar.gz", hash = "sha256:ff7f1afa7b9642e7060379360a67e9c41e8f3121f2ce9164266f61b9f4b338e4"}, + {file = "sphinxcontrib_devhelp-1.0.2-py2.py3-none-any.whl", hash = "sha256:8165223f9a335cc1af7ffe1ed31d2871f325254c0423bc0c4c7cd1c1e4734a2e"}, +] +sphinxcontrib-htmlhelp = [ + {file = "sphinxcontrib-htmlhelp-1.0.3.tar.gz", hash = "sha256:e8f5bb7e31b2dbb25b9cc435c8ab7a79787ebf7f906155729338f3156d93659b"}, + {file = "sphinxcontrib_htmlhelp-1.0.3-py2.py3-none-any.whl", hash = "sha256:3c0bc24a2c41e340ac37c85ced6dafc879ab485c095b1d65d2461ac2f7cca86f"}, +] +sphinxcontrib-jsmath = [ + {file = "sphinxcontrib-jsmath-1.0.1.tar.gz", hash = "sha256:a9925e4a4587247ed2191a22df5f6970656cb8ca2bd6284309578f2153e0c4b8"}, + {file = "sphinxcontrib_jsmath-1.0.1-py2.py3-none-any.whl", hash = "sha256:2ec2eaebfb78f3f2078e73666b1415417a116cc848b72e5172e596c871103178"}, +] +sphinxcontrib-qthelp = [ + {file = "sphinxcontrib-qthelp-1.0.3.tar.gz", hash = "sha256:4c33767ee058b70dba89a6fc5c1892c0d57a54be67ddd3e7875a18d14cba5a72"}, + {file = "sphinxcontrib_qthelp-1.0.3-py2.py3-none-any.whl", hash = "sha256:bd9fc24bcb748a8d51fd4ecaade681350aa63009a347a8c14e637895444dfab6"}, +] +sphinxcontrib-serializinghtml = [ + {file = "sphinxcontrib-serializinghtml-1.1.4.tar.gz", hash = "sha256:eaa0eccc86e982a9b939b2b82d12cc5d013385ba5eadcc7e4fed23f4405f77bc"}, + {file = "sphinxcontrib_serializinghtml-1.1.4-py2.py3-none-any.whl", hash = "sha256:f242a81d423f59617a8e5cf16f5d4d74e28ee9a66f9e5b637a18082991db5a9a"}, +] stevedore = [ {file = "stevedore-3.2.0-py3-none-any.whl", hash = "sha256:c8f4f0ebbc394e52ddf49de8bcc3cf8ad2b4425ebac494106bbc5e3661ac7633"}, {file = "stevedore-3.2.0.tar.gz", hash = "sha256:38791aa5bed922b0a844513c5f9ed37774b68edc609e5ab8ab8d8fe0ce4315e5"}, diff --git a/pyproject.toml b/pyproject.toml index 161abc56..173cea4e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -47,6 +47,7 @@ pep8-naming = "^0.11.1" mypy = "^0.782" typeguard = "^2.9.1" darglint = "^1.5.2" +sphinx = "^3.2.1" [tool.coverage.paths] source = ["src", "*/site-packages"] From 143d00e816b50f14e99b4c3d2e2e6637f5b8e239 Mon Sep 17 00:00:00 2001 From: oncleben31 Date: Sat, 3 Oct 2020 23:28:35 +0200 Subject: [PATCH 17/33] Init sphinx configuration --- docs/conf.py | 4 ++++ docs/index.rst | 2 ++ 2 files changed, 6 insertions(+) create mode 100644 docs/conf.py create mode 100644 docs/index.rst diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 00000000..72db9137 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,4 @@ +"""Sphinx configuration.""" +project = "meteofrance-api" +author = "Oncleben31" +copyright = f"2020, {author}" diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 00000000..058c3837 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,2 @@ +This is docs/index.rst, +documenting the Météo-France API Python project. From d12530e3222eed14f3704972faf1b226c1745d24 Mon Sep 17 00:00:00 2001 From: oncleben31 Date: Sat, 3 Oct 2020 23:32:46 +0200 Subject: [PATCH 18/33] Add nox session to generate docs --- noxfile.py | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index 06b459b1..12f14735 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1,5 +1,6 @@ """Nox sessions.""" import contextlib +import shutil import sys import tempfile from pathlib import Path @@ -12,7 +13,7 @@ python_versions = ["3.8", "3.7", "3.6"] package = "meteofrance_api" nox.options.sessions = "pre-commit", "safety", "mypy", "tests", "typeguard" -locations = "src", "tests", "noxfile.py" +locations = "src", "tests", "noxfile.py", "docs/conf.py" class Poetry: @@ -227,3 +228,31 @@ def coverage(session: Session) -> None: session.run("coverage", "combine") session.run("coverage", *args) + + +@nox.session(name="docs-build", python="3.8") +def docs_build(session: Session) -> None: + """Build the documentation.""" + args = session.posargs or ["docs", "docs/_build"] + session.install(".") + session.install("sphinx") + + build_dir = Path("docs", "_build") + if build_dir.exists(): + shutil.rmtree(build_dir) + + session.run("sphinx-build", *args) + + +@nox.session(python="3.8") +def docs(session: Session) -> None: + """Build and serve the documentation with live reloading on file changes.""" + args = session.posargs or ["--open-browser", "docs", "docs/_build"] + session.install(".") + session.install("sphinx", "sphinx-autobuild") + + build_dir = Path("docs", "_build") + if build_dir.exists(): + shutil.rmtree(build_dir) + + session.run("sphinx-autobuild", *args) From b64d27e44f366a484a22acf3984161d4167f6e2b Mon Sep 17 00:00:00 2001 From: oncleben31 Date: Sun, 4 Oct 2020 00:42:25 +0200 Subject: [PATCH 19/33] Add sphinx-autobuild to dev dependencies --- poetry.lock | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ pyproject.toml | 1 + 2 files changed, 58 insertions(+) diff --git a/poetry.lock b/poetry.lock index 74ca94bf..a0e30636 100644 --- a/poetry.lock +++ b/poetry.lock @@ -404,6 +404,21 @@ MarkupSafe = ">=0.23" [package.extras] i18n = ["Babel (>=0.8)"] +[[package]] +category = "dev" +description = "Python LiveReload is an awesome tool for web developers" +name = "livereload" +optional = false +python-versions = "*" +version = "2.6.3" + +[package.dependencies] +six = "*" + +[package.dependencies.tornado] +python = ">=2.8" +version = "*" + [[package]] category = "dev" description = "Safely add untrusted strings to HTML/XML markup." @@ -801,6 +816,21 @@ docs = ["sphinxcontrib-websupport"] lint = ["flake8 (>=3.5.0)", "flake8-import-order", "mypy (>=0.780)", "docutils-stubs"] test = ["pytest", "pytest-cov", "html5lib", "typed-ast", "cython"] +[[package]] +category = "dev" +description = "Rebuild Sphinx documentation on changes, with live-reload in the browser." +name = "sphinx-autobuild" +optional = false +python-versions = ">=3.6" +version = "2020.9.1" + +[package.dependencies] +livereload = "*" +sphinx = "*" + +[package.extras] +test = ["pytest", "pytest-cov"] + [[package]] category = "dev" description = "sphinxcontrib-applehelp is a sphinx extension which outputs Apple help books" @@ -895,6 +925,15 @@ optional = false python-versions = "*" version = "0.10.1" +[[package]] +category = "dev" +description = "Tornado is a Python web framework and asynchronous networking library, originally developed at FriendFeed." +marker = "python_version > \"2.7\"" +name = "tornado" +optional = false +python-versions = ">= 3.5" +version = "6.0.4" + [[package]] category = "dev" description = "a fork of Python 2 and 3 ast modules with type comment support" @@ -1156,6 +1195,9 @@ jinja2 = [ {file = "Jinja2-2.11.2-py2.py3-none-any.whl", hash = "sha256:f0a4641d3cf955324a89c04f3d94663aa4d638abe8f733ecd3582848e1c37035"}, {file = "Jinja2-2.11.2.tar.gz", hash = "sha256:89aab215427ef59c34ad58735269eb58b1a5808103067f7bb9d5836c651b3bb0"}, ] +livereload = [ + {file = "livereload-2.6.3.tar.gz", hash = "sha256:776f2f865e59fde56490a56bcc6773b6917366bce0c267c60ee8aaf1a0959869"}, +] markupsafe = [ {file = "MarkupSafe-1.1.1-cp27-cp27m-macosx_10_6_intel.whl", hash = "sha256:09027a7803a62ca78792ad89403b1b7a73a01c8cb65909cd876f7fcebd79b161"}, {file = "MarkupSafe-1.1.1-cp27-cp27m-manylinux1_i686.whl", hash = "sha256:e249096428b3ae81b08327a63a485ad0878de3fb939049038579ac0ef61e17e7"}, @@ -1375,6 +1417,10 @@ sphinx = [ {file = "Sphinx-3.2.1-py3-none-any.whl", hash = "sha256:ce6fd7ff5b215af39e2fcd44d4a321f6694b4530b6f2b2109b64d120773faea0"}, {file = "Sphinx-3.2.1.tar.gz", hash = "sha256:321d6d9b16fa381a5306e5a0b76cd48ffbc588e6340059a729c6fdd66087e0e8"}, ] +sphinx-autobuild = [ + {file = "sphinx-autobuild-2020.9.1.tar.gz", hash = "sha256:4b184a7db893f2100bbd831991ae54ca89167a2b9ce68faea71eaa9e37716aed"}, + {file = "sphinx_autobuild-2020.9.1-py3-none-any.whl", hash = "sha256:df5c72cb8b8fc9b31279c4619780c4e95029be6de569ff60a8bb2e99d20f63dd"}, +] sphinxcontrib-applehelp = [ {file = "sphinxcontrib-applehelp-1.0.2.tar.gz", hash = "sha256:a072735ec80e7675e3f432fcae8610ecf509c5f1869d17e2eecff44389cdbc58"}, {file = "sphinxcontrib_applehelp-1.0.2-py2.py3-none-any.whl", hash = "sha256:806111e5e962be97c29ec4c1e7fe277bfd19e9652fb1a4392105b43e01af885a"}, @@ -1407,6 +1453,17 @@ toml = [ {file = "toml-0.10.1-py2.py3-none-any.whl", hash = "sha256:bda89d5935c2eac546d648028b9901107a595863cb36bae0c73ac804a9b4ce88"}, {file = "toml-0.10.1.tar.gz", hash = "sha256:926b612be1e5ce0634a2ca03470f95169cf16f939018233a670519cb4ac58b0f"}, ] +tornado = [ + {file = "tornado-6.0.4-cp35-cp35m-win32.whl", hash = "sha256:5217e601700f24e966ddab689f90b7ea4bd91ff3357c3600fa1045e26d68e55d"}, + {file = "tornado-6.0.4-cp35-cp35m-win_amd64.whl", hash = "sha256:c98232a3ac391f5faea6821b53db8db461157baa788f5d6222a193e9456e1740"}, + {file = "tornado-6.0.4-cp36-cp36m-win32.whl", hash = "sha256:5f6a07e62e799be5d2330e68d808c8ac41d4a259b9cea61da4101b83cb5dc673"}, + {file = "tornado-6.0.4-cp36-cp36m-win_amd64.whl", hash = "sha256:c952975c8ba74f546ae6de2e226ab3cc3cc11ae47baf607459a6728585bb542a"}, + {file = "tornado-6.0.4-cp37-cp37m-win32.whl", hash = "sha256:2c027eb2a393d964b22b5c154d1a23a5f8727db6fda837118a776b29e2b8ebc6"}, + {file = "tornado-6.0.4-cp37-cp37m-win_amd64.whl", hash = "sha256:5618f72e947533832cbc3dec54e1dffc1747a5cb17d1fd91577ed14fa0dc081b"}, + {file = "tornado-6.0.4-cp38-cp38-win32.whl", hash = "sha256:22aed82c2ea340c3771e3babc5ef220272f6fd06b5108a53b4976d0d722bcd52"}, + {file = "tornado-6.0.4-cp38-cp38-win_amd64.whl", hash = "sha256:c58d56003daf1b616336781b26d184023ea4af13ae143d9dda65e31e534940b9"}, + {file = "tornado-6.0.4.tar.gz", hash = "sha256:0fe2d45ba43b00a41cd73f8be321a44936dc1aba233dee979f17a042b83eb6dc"}, +] typed-ast = [ {file = "typed_ast-1.4.1-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:73d785a950fc82dd2a25897d525d003f6378d1cb23ab305578394694202a58c3"}, {file = "typed_ast-1.4.1-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:aaee9905aee35ba5905cfb3c62f3e83b3bec7b39413f0a7f19be4e547ea01ebb"}, diff --git a/pyproject.toml b/pyproject.toml index 173cea4e..1d57ff6f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,6 +48,7 @@ mypy = "^0.782" typeguard = "^2.9.1" darglint = "^1.5.2" sphinx = "^3.2.1" +sphinx-autobuild = "^2020.9.1" [tool.coverage.paths] source = ["src", "*/site-packages"] From f3a1144bb53fb2a4552229308168418b3ca26bef Mon Sep 17 00:00:00 2001 From: oncleben31 Date: Sun, 4 Oct 2020 00:43:22 +0200 Subject: [PATCH 20/33] Update sphinx configuration --- docs/conf.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 72db9137..36bee68d 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,4 +1,8 @@ """Sphinx configuration.""" +from datetime import datetime + project = "meteofrance-api" -author = "Oncleben31" -copyright = f"2020, {author}" +author = "HACF-fr" +copyright = f"{datetime.now().year}, {author}" +extensions = ["sphinx.ext.autodoc", "sphinx.ext.napoleon"] +autodoc_typehints = "description" From 9607bdeeda20dcbab4c4996427c815c75d47a47f Mon Sep 17 00:00:00 2001 From: oncleben31 Date: Sun, 4 Oct 2020 19:06:21 +0200 Subject: [PATCH 21/33] Convert LICENSE in reST --- LICENSE => LICENSE.rst | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) rename LICENSE => LICENSE.rst (57%) diff --git a/LICENSE b/LICENSE.rst similarity index 57% rename from LICENSE rename to LICENSE.rst index 4c88a57d..f87a1c78 100644 --- a/LICENSE +++ b/LICENSE.rst @@ -1,4 +1,5 @@ MIT License +=========== Copyright (c) 2020 HACF Home Assistant Communauté Francophone @@ -12,10 +13,10 @@ furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +**The software is provided "as is", without warranty of any kind, express or +implied, including but not limited to the warranties of merchantability, +fitness for a particular purpose and noninfringement. In no event shall the +authors or copyright holders be liable for any claim, damages or other +liability, whether in an action of contract, tort or otherwise, arising from, +out of or in connection with the software or the use or other dealings in the +software.** From 3572a601f6f167fc8047c85e2811dd92560e1c07 Mon Sep 17 00:00:00 2001 From: oncleben31 Date: Sun, 4 Oct 2020 22:39:54 +0200 Subject: [PATCH 22/33] Convert README to reST --- README.md | 88 ------------------------------------ README.rst | 130 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 130 insertions(+), 88 deletions(-) delete mode 100644 README.md create mode 100644 README.rst diff --git a/README.md b/README.md deleted file mode 100644 index 0fac942f..00000000 --- a/README.md +++ /dev/null @@ -1,88 +0,0 @@ -# meteofrance-api - -Client Python pour l'API Météo-France. | Python client for Météo-France API. - -[![Build Status][build-shield]][build] -[![codecov][codecov-shield]][codecov] -[![License][license-shield]](LICENSE) - -[![GitHub Release][releases-shield]][releases] -[![PyPI version][pypi-shield]][pypi] -[![GitHub Activity][commits-shield]][commits] - -You will find English README content [here](#for-english-speaking-users). - -Vous trouverez le contenu francophone du README [ici](#pour-les-francophones). - -## Pour les francophones - -### Description - -Ce package Python permet de gérer la communication avec l'API non publique de -Météo-France utilisée par les applications moblies officielles. - -Le client permet: - -- Rechercher des lieux de prévisions. -- Accéder aux prévisions météorologiques horraires ou quotidiennes. -- Accéder aux prévisions de pluie dans l'heure quand disponibles. -- Accéder aux alertes météo pour chaque département français et l'Andorre. Deux - bulletins sont disponibles : un synthétique et un second avec l'évolution des alertes - pour les prochaines 24 heures (exemple [ici](http://vigilance.meteofrance.com/Bulletin_sans.html?a=dept32&b=2&c=)). - -Ce package a été développé avec l'intention d'être utilisé par [Home-Assistant](https://home-assistant.io/) mais il peut être utilsé dans d'autres contextes. - -### Installation - -Pour utiliser le module Python `meteofrance` vous devez en premier installer -le package: - -`pip install meteofrance-api` - -Vous pouvez trouver un exemple d'usage dans un module Python en regardant [le test d'intégration](tests/test_integrations.py). - -### Contribuer - -Les contributions sont les bienvenues. Veuillez consulter les bonnes pratiques -détaillées dans [`CONTRIBUTING.md`](CONTRIBUTING.md). - -## For English speaking users - -### Descritption - -This Python package manages the communication with the private Météo-France API -used by the official moblie applications. - -The client allows: - -- Search a forecast location. -- Fetch daily or hourly weather forecast. -- Fetch rain forecast within the next hour if available. -- Fetch the weather alerts or phenomenoms for each French department or Andorre. - Two bulletin are availabe: one basic and an other advanced with the timelaps evolution for the next 24 hours (example [here](http://vigilance.meteofrance.com/Bulletin_sans.html?a=dept32&b=2&c=)). - -This package have been developed to be used with [Home-Assistant](https://home-assistant.io/) but it can be used in other contexts. - -### Installation - -To use the `meteofrance` Python module, you have to install this package first: - -`pip install meteofrance-api` - -You will find an example ot usage in a Python program in the [integration test](tests/test_integrations.py). - -### Contributing - -Contributions are welcomed. Please check the guidelines in [`CONTRIBUTING.md`](CONTRIBUTING.md). - -[commits-shield]: https://img.shields.io/github/commit-activity/y/hacf-fr/meteofrance-api.svg?style=for-the-badge -[commits]: https://github.com/hacf-fr/meteofrance-api/commits/master -[license-shield]: https://img.shields.io/github/license/hacf-fr/meteofrance-api.svg?style=for-the-badge -[releases-shield]: https://img.shields.io/github/release/hacf-fr/meteofrance-api.svg?style=for-the-badge -[releases]: https://github.com/hacf-fr/meteofrance-api/releases -[build-shield]: https://img.shields.io/github/workflow/status/hacf-fr/meteofrance-api/Python%20package?style=for-the-badge -[build]: https://github.com/hacf-fr/meteofrance-api/actions?query=workflow%3A%22Python+package%22 -[codecov-shield]: https://img.shields.io/codecov/c/github/hacf-fr/meteofrance-api?style=for-the-badge -[codecov]: https://codecov.io/gh/hacf-fr/meteofrance-api -[pypi-shield]: https://img.shields.io/pypi/v/meteofrance-api?style=for-the-badge -[pypi]: https://pypi.org/project/meteofrance-api/ diff --git a/README.rst b/README.rst new file mode 100644 index 00000000..637b8b1c --- /dev/null +++ b/README.rst @@ -0,0 +1,130 @@ +Météo-France API +================ + +Client Python pour l'API Météo-France. | Python client for Météo-France API. + +|PyPI| |GitHub Release| |Python Version| |License| + +|Read the Docs| |Tests| |Codecov| |GitHub Activity| + +|pre-commit| |Black| + + +.. |PyPI| image:: https://img.shields.io/pypi/v/meteofrance-api + :target: https://pypi.org/project/meteofrance-api/ + :alt: PyPI +.. |GitHub Release| image:: https://img.shields.io/github/release/hacf-fr/meteofrance-api.svg + :target: https://github.com/hacf-fr/meteofrance-api/releases + :alt: GitHub Release +.. |Python Version| image:: https://img.shields.io/pypi/pyversions/meteofrance-api + :target: https://pypi.org/project/meteofrance-api/ + :alt: Python Version +.. |License| image:: https://img.shields.io/pypi/l/meteofrance-api + :target: https://opensource.org/licenses/MIT + :alt: License +.. |Read the Docs| image:: https://img.shields.io/readthedocs/meteofrance-api/latest.svg?label=Read%20the%20Docs + :target: https://meteofrance-api.readthedocs.io/ + :alt: Read the documentation at https://meteofrance-api.readthedocs.io/ +.. |Tests| image:: https://github.com/hacf-fr/meteofrance-api/workflows/Tests/badge.svg + :target: https://github.com/hacf-fr/meteofrance-api/actions?workflow=Tests + :alt: Tests +.. |Codecov| image:: https://codecov.io/gh/hacf-fr/meteofrance-api/branch/master/graph/badge.svg + :target: https://codecov.io/gh/hacf-fr/meteofrance-api + :alt: Codecov +.. |GitHub Activity| image:: https://img.shields.io/github/commit-activity/y/hacf-fr/meteofrance-api.svg + :target: https://github.com/hacf-fr/meteofrance-api/commits/master + :alt: GitHub Activity +.. |pre-commit| image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white + :target: https://github.com/pre-commit/pre-commit + :alt: pre-commit +.. |Black| image:: https://img.shields.io/badge/code%20style-black-000000.svg + :target: https://github.com/psf/black + :alt: Black + +You will find English README content in the section :ref:`english`. + +Vous trouverez le contenu francophone du README dans la section :ref:`french`. + +.. _french: + +Pour les francophones +--------------------- + +Déscription +^^^^^^^^^^^ + +Ce package Python permet de gérer la communication avec l'API non publique de +Météo-France utilisée par les applications moblies officielles. + +Le client permet: + +* Rechercher des lieux de prévisions. +* Accéder aux prévisions météorologiques horraires ou quotidiennes. +* Accéder aux prévisions de pluie dans l'heure quand disponibles. +* Accéder aux alertes météo pour chaque département français et l'Andorre. Deux + bulletins sont disponibles : un synthétique et un second avec l'évolution des alertes + pour les prochaines 24 heures (exemple `ici `_). + +Ce package a été développé avec l'intention d'être utilisé par `Home-Assistant `_ +mais il peut être utilsé dans d'autres contextes. + +Installation +^^^^^^^^^^^^ + +Pour utiliser le module Python ``meteofrance`` vous devez en premier installer +le package: + +.. code:: console + + $ pip install meteofrance-api + + +Vous pouvez trouver un exemple d'usage dans un module Python en regardant +`le test d'intégration `_. + +Contribuer +^^^^^^^^^^ + +Les contributions sont les bienvenues. Veuillez consulter les bonnes pratiques +détaillées dans `CONTRIBUTING.md `_. + + +.. _english: + + +For English speaking users +-------------------------- + +Descritption +^^^^^^^^^^^^ + +This Python package manages the communication with the private Météo-France API +used by the official moblie applications. + +The client allows: + +* Search a forecast location. +* Fetch daily or hourly weather forecast. +* Fetch rain forecast within the next hour if available. +* Fetch the weather alerts or phenomenoms for each French department or Andorre. + Two bulletin are availabe: one basic and an other advanced with the timelaps evolution + for the next 24 hours (example `here `_). + +This package have been developed to be used with `Home-Assistant `_ +but it can be used in other contexts. + +Installation +^^^^^^^^^^^^ + +To use the ``meteofrance`` Python module, you have to install this package first: + +.. code:: console + + $ pip install meteofrance-api + +You will find an example ot usage in a Python program in the `integration test `_. + +Contributing +^^^^^^^^^^^^ + +Contributions are welcomed. Please check the guidelines in `CONTRIBUTING.md `_. From 6431648f82c4e88f3383eac47c0135736a21724c Mon Sep 17 00:00:00 2001 From: oncleben31 Date: Sun, 4 Oct 2020 23:32:45 +0200 Subject: [PATCH 23/33] update README reference in Poetry project --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 1d57ff6f..f398b2a6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ authors = ["oncleben31 "] homepage = "https://github.com/hacf-fr/meteofrance-api" repository = "https://github.com/hacf-fr/meteofrance-api" keywords = ["weather", "weather-api", "meteo"] -readme = "README.md" +readme = "README.rst" packages = [ { include = "meteofrance", from = "src" }, ] From 40d782e35b92f372b46ef22eb4c99fde04179a5d Mon Sep 17 00:00:00 2001 From: oncleben31 Date: Sun, 4 Oct 2020 23:34:07 +0200 Subject: [PATCH 24/33] Convert CONTRIBUTING to reST --- CONTRIBUTING.md | 117 ---------------------------------- CONTRIBUTING.rst | 162 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 162 insertions(+), 117 deletions(-) delete mode 100644 CONTRIBUTING.md create mode 100644 CONTRIBUTING.rst diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 56251df5..00000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,117 +0,0 @@ -# Contribuer | Contributing - -You will find instructions in English [here](#contributing). - -Vous trouverez les instructions en français [ici](#contribuer). - -## Contribuer - -Vous êtes tous invités à contribuer à ce projet pour le maintenir ou l'améliorer. -Même si vous n'êtes pas un développeur, vous pouvez suremnent donner un coup de -main en remontant les bugs constatés, en partageant vos idées d'amélioration ou -en participant à la documentation. - -## Préparer votre environement de développement - -Vous aurez besoin de Python 3.6+ et des outils suivants: - -- [Poetry](https://python-poetry.org) -- [Nox](https://nox.thea.codes/en/stable) - -Installez le package avec les dépendances de développement: - -`$ poetry install` - -Vous pouvez maintenant utiliser une session interactive Python: - -`$ poetry run python` - -Je vous recommande d'installer un pre-commit-hook pour lancer automatiquement quelques vérfication avant de commit vos modifications. - -`$ nox -s pre-commit -- install` - -## Tester le projet - -Dérouler la suite de tests complète: - -`$ nox` - -Lister toutes les sessions disponibles dans Nox: - -`$ nox --list-sessions` - -Vous pouvez lancer une session Nox spécifique. Par exemple, lancez la suite de -tests unitaires avec: - -`$ nox --session=tests` - -Les tests unitaires sont dans le répertoire `tests` et utilisent le framework pytest. - -### Soumettre votre Pull Request (PR) - -Ouvrez une [pull request](https://github.com/hacf-fr/meteofrance-api/pulls) pour proposer des changements à ce projet. - -Votre pull request doit vérifier les conditions suivantes pour être acceptée: - -- La suite de tests Nox doit réussir sans erreurs ni warning. -- Doit inclure des tests unitaires. Ce projet maintien une couverture de code à 100%. - -### Proposer une nouvelle fonctionnalité - -Pour proposer vos idées d'amélioration, ouvrez une [issue](https://github.com/hacf-fr/meteofrance-api/issues) en utilisant le -modèle `feature request`. - -## Contributing - -You are all invited to contribute to this project for maintenance or improvement. -Even if you are not a developer, you can probably help to report some bugs, share -improvements ideas, or contribute to the documentation. - -### How to set up your development environment - -You need Python 3.6+ and the following tools: - -- [Poetry](https://python-poetry.org) -- [Nox](https://nox.thea.codes/en/stable) - -Install the package with development requirements: - -`$ poetry install` - -You can now run an interactive Python session, or the command-line interface: - -`$ poetry run python` - -I recommand to install a pre-commit-hook to have some checks done automatically before you commit your changes. - -`$ nox -s pre-commit -- install` - -### How to test the project - -Run the full test suite: - -`$ nox` - -List the available Nox sessions: - -`$ nox --list-sessions` - -You can also run a specific Nox session. For example, invoke the unit test suite like this: - -`$ nox --session=tests` - -Unit tests are located in the tests directory, and are written using the pytest testing framework. - -### How to submit changes - -Open a [pull request](https://github.com/hacf-fr/meteofrance-api/pulls) to submit changes to this project. - -Your pull request needs to meet the following guidelines for acceptance: - -- The Nox test suite must pass without errors and warnings. -- Include unit tests. This project maintains 100% code coverage. - -### Feature suggestion - -If you want to suggest a new feature for this project, please open an [`issue`](https://github.com/hacf-fr/meteofrance-api/issues) by -using the `feature request` template. diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst new file mode 100644 index 00000000..03cc6f36 --- /dev/null +++ b/CONTRIBUTING.rst @@ -0,0 +1,162 @@ +Contribuer | Contributing +========================= + +You will find instructions in English in the section :ref:`english-contribution`. + +Vous trouverez les instructions en français dans la section :ref:`french-contribution`. + +.. _french-contribution: + +Contribuer +---------- + +Vous êtes tous invités à contribuer à ce projet pour le maintenir ou l'améliorer. +Même si vous n'êtes pas un développeur, vous pouvez suremnent donner un coup de +main en remontant les bugs constatés, en partageant vos idées d'amélioration ou +en participant à la documentation. + +Préparer votre environement de développement +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Vous aurez besoin de Python 3.6+ et des outils suivants: + +- Poetry_ +- Nox_ + +Installez le package avec les dépendances de développement: + +.. code:: console + + $ poetry install + +Vous pouvez maintenant utiliser une session interactive Python: + +.. code:: console + + $ poetry run python + +Je vous recommande d'installer un pre-commit-hook pour lancer automatiquement quelques +vérfication avant de commit vos modifications. + +.. code:: console + + $ nox -s pre-commit -- install + +Tester le projet +^^^^^^^^^^^^^^^^ + +Dérouler la suite de tests complète: + +.. code:: console + + $ nox + +Lister toutes les sessions disponibles dans Nox: + +.. code:: console + + $ nox --list-sessions + +Vous pouvez lancer une session Nox spécifique. Par exemple, lancez la suite de +tests unitaires avec: + +.. code:: console + + $ nox --session=tests + +Les tests unitaires sont dans le répertoire `tests` et utilisent le framework pytest. + +Soumettre votre Pull Request (PR) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Ouvrez une `pull request`_ pour proposer des changements à ce projet. + +Votre pull request doit vérifier les conditions suivantes pour être acceptée: + +* La suite de tests Nox doit réussir sans erreurs ni warning. +* Doit inclure des tests unitaires. Ce projet maintien une couverture de code à 100%. + +Proposer une nouvelle fonctionnalité +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Pour proposer vos idées d'amélioration, ouvrez une `issue `_ +en utilisant le modèle ``feature request``. + +.. _english-contribution: + +Contributing +------------ + +You are all invited to contribute to this project for maintenance or improvement. +Even if you are not a developer, you can probably help to report some bugs, share +improvements ideas, or contribute to the documentation. + +How to set up your development environment +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +You need Python 3.6+ and the following tools: + +- Poetry_ +- Nox_ + +Install the package with development requirements: + +.. code:: console + + $ poetry install + +You can now run an interactive Python session, or the command-line interface: + +.. code:: console + + $ poetry run python + +I recommand to install a pre-commit-hook to have some checks done automatically before you commit your changes. + +.. code:: console + + $ nox -s pre-commit -- install + +How to test the project +^^^^^^^^^^^^^^^^^^^^^^^ + +Run the full test suite: + +.. code:: console + + $ nox + +List the available Nox sessions: + +.. code:: console + + $ nox --list-sessions + +You can also run a specific Nox session. For example, invoke the unit test suite like this: + +.. code:: console + + $ nox --session=tests + +Unit tests are located in the tests directory, and are written using the pytest testing framework. + +How to submit changes +^^^^^^^^^^^^^^^^^^^^^ + +Open a `pull request`_ to submit +changes to this project. + +Your pull request needs to meet the following guidelines for acceptance: + +- The Nox test suite must pass without errors and warnings. +- Include unit tests. This project maintains 100% code coverage. + +Feature suggestion +^^^^^^^^^^^^^^^^^^ + +If you want to suggest a new feature for this project, please open an `issue `_ +by using the `feature request` template. + +.. _Poetry: https://python-poetry.org/ +.. _Nox: https://nox.thea.codes/ +.. _pull request: https://github.com/hacf-fr/meteofrance-api/pulls From e7dc7610ad70ed76aec4fb314a26798c0d6e3e22 Mon Sep 17 00:00:00 2001 From: oncleben31 Date: Sun, 4 Oct 2020 23:37:07 +0200 Subject: [PATCH 25/33] Add sphinx documentation --- README.rst | 12 ++++++++---- docs/conf.py | 2 +- docs/contributing.rst | 1 + docs/index.rst | 15 +++++++++++++-- docs/license.rst | 1 + docs/reference.rst | 20 ++++++++++++++++++++ 6 files changed, 44 insertions(+), 7 deletions(-) create mode 100644 docs/contributing.rst create mode 100644 docs/license.rst create mode 100644 docs/reference.rst diff --git a/README.rst b/README.rst index 637b8b1c..e39b394e 100644 --- a/README.rst +++ b/README.rst @@ -1,5 +1,5 @@ -Météo-France API -================ +Météo-France Python API +======================= Client Python pour l'API Météo-France. | Python client for Météo-France API. @@ -86,7 +86,7 @@ Contribuer ^^^^^^^^^^ Les contributions sont les bienvenues. Veuillez consulter les bonnes pratiques -détaillées dans `CONTRIBUTING.md `_. +détaillées dans `CONTRIBUTING.rst`_. .. _english: @@ -127,4 +127,8 @@ You will find an example ot usage in a Python program in the `integration test < Contributing ^^^^^^^^^^^^ -Contributions are welcomed. Please check the guidelines in `CONTRIBUTING.md `_. +Contributions are welcomed. Please check the guidelines in `CONTRIBUTING.rst`_. + +.. github-only + +.. _CONTRIBUTING.rst: CONTRIBUTING.rst diff --git a/docs/conf.py b/docs/conf.py index 36bee68d..31cbfbee 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -2,7 +2,7 @@ from datetime import datetime project = "meteofrance-api" -author = "HACF-fr" +author = "HACF" copyright = f"{datetime.now().year}, {author}" extensions = ["sphinx.ext.autodoc", "sphinx.ext.napoleon"] autodoc_typehints = "description" diff --git a/docs/contributing.rst b/docs/contributing.rst new file mode 100644 index 00000000..e582053e --- /dev/null +++ b/docs/contributing.rst @@ -0,0 +1 @@ +.. include:: ../CONTRIBUTING.rst diff --git a/docs/index.rst b/docs/index.rst index 058c3837..8d8e34ce 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,2 +1,13 @@ -This is docs/index.rst, -documenting the Météo-France API Python project. +.. include:: ../README.rst + :end-before: github-only + +.. _CONTRIBUTING.rst: contributing.html + +.. toctree:: + :hidden: + :maxdepth: 1 + + reference + contributing + License + Changelog diff --git a/docs/license.rst b/docs/license.rst new file mode 100644 index 00000000..68c5792f --- /dev/null +++ b/docs/license.rst @@ -0,0 +1 @@ +.. include:: ../LICENSE.rst diff --git a/docs/reference.rst b/docs/reference.rst new file mode 100644 index 00000000..62941793 --- /dev/null +++ b/docs/reference.rst @@ -0,0 +1,20 @@ +Reference +========= + +.. contents:: + :local: + :backlinks: none + + +meteofrance +----------- + +.. automodule:: meteofrance + :members: + + +meteofrance.model +----------------- + +.. automodule:: meteofrance.model + :members: From 94810cca90f0b0b215da6ff6884b243729e65a14 Mon Sep 17 00:00:00 2001 From: oncleben31 Date: Mon, 5 Oct 2020 00:17:23 +0200 Subject: [PATCH 26/33] Add docs-build in Nox defaults sessions --- noxfile.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index 12f14735..1ae42143 100644 --- a/noxfile.py +++ b/noxfile.py @@ -12,7 +12,14 @@ python_versions = ["3.8", "3.7", "3.6"] package = "meteofrance_api" -nox.options.sessions = "pre-commit", "safety", "mypy", "tests", "typeguard" +nox.options.sessions = ( + "pre-commit", + "safety", + "mypy", + "tests", + "typeguard", + "docs-build", +) locations = "src", "tests", "noxfile.py", "docs/conf.py" From 800483ae70c75465cbda48aa1f5aa0317fe37ed2 Mon Sep 17 00:00:00 2001 From: oncleben31 Date: Mon, 5 Oct 2020 23:43:20 +0200 Subject: [PATCH 27/33] Update README anchors and links --- README.rst | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/README.rst b/README.rst index e39b394e..a47efb6d 100644 --- a/README.rst +++ b/README.rst @@ -41,11 +41,9 @@ Client Python pour l'API Météo-France. | Python client for Météo-France API. :target: https://github.com/psf/black :alt: Black -You will find English README content in the section :ref:`english`. +You will find English README content in the section `For English speaking users`_. -Vous trouverez le contenu francophone du README dans la section :ref:`french`. - -.. _french: +Vous trouverez le contenu francophone du README dans la section `Pour les francophones`_. Pour les francophones --------------------- @@ -89,9 +87,6 @@ Les contributions sont les bienvenues. Veuillez consulter les bonnes pratiques détaillées dans `CONTRIBUTING.rst`_. -.. _english: - - For English speaking users -------------------------- From 5bc90ace54196f1ddaf2076061866b74e0889f5a Mon Sep 17 00:00:00 2001 From: oncleben31 Date: Mon, 5 Oct 2020 23:48:20 +0200 Subject: [PATCH 28/33] Update CONTRIBUTING anchors and links --- CONTRIBUTING.rst | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 03cc6f36..04e43d38 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -1,11 +1,9 @@ Contribuer | Contributing ========================= -You will find instructions in English in the section :ref:`english-contribution`. +You will find instructions in English in the section `Contributing`_. -Vous trouverez les instructions en français dans la section :ref:`french-contribution`. - -.. _french-contribution: +Vous trouverez les instructions en français dans la section `Contribuer`_. Contribuer ---------- @@ -82,8 +80,6 @@ Proposer une nouvelle fonctionnalité Pour proposer vos idées d'amélioration, ouvrez une `issue `_ en utilisant le modèle ``feature request``. -.. _english-contribution: - Contributing ------------ From f771ae1542cb01934f12ff276084f0828e78f941 Mon Sep 17 00:00:00 2001 From: Oncleben31 Date: Sun, 11 Oct 2020 20:12:16 +0200 Subject: [PATCH 29/33] Apply suggestions from code review Co-authored-by: Quentame --- CONTRIBUTING.rst | 4 ++-- README.rst | 8 ++++---- src/meteofrance/client.py | 2 +- src/meteofrance/helpers.py | 8 ++++---- src/meteofrance/model/forecast.py | 2 +- src/meteofrance/model/place.py | 2 +- src/meteofrance/model/rain.py | 2 +- src/meteofrance/model/warning.py | 6 +++--- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 04e43d38..de1b80a9 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -9,7 +9,7 @@ Contribuer ---------- Vous êtes tous invités à contribuer à ce projet pour le maintenir ou l'améliorer. -Même si vous n'êtes pas un développeur, vous pouvez suremnent donner un coup de +Même si vous n'êtes pas un développeur, vous pouvez sûrement donner un coup de main en remontant les bugs constatés, en partageant vos idées d'amélioration ou en participant à la documentation. @@ -84,7 +84,7 @@ Contributing ------------ You are all invited to contribute to this project for maintenance or improvement. -Even if you are not a developer, you can probably help to report some bugs, share +Even if you are not a developer, you can help to report some bugs, share improvements ideas, or contribute to the documentation. How to set up your development environment diff --git a/README.rst b/README.rst index a47efb6d..4edd7de6 100644 --- a/README.rst +++ b/README.rst @@ -52,14 +52,14 @@ Déscription ^^^^^^^^^^^ Ce package Python permet de gérer la communication avec l'API non publique de -Météo-France utilisée par les applications moblies officielles. +Météo-France utilisée par les applications mobiles officielles. Le client permet: * Rechercher des lieux de prévisions. -* Accéder aux prévisions météorologiques horraires ou quotidiennes. +* Accéder aux prévisions météorologiques horaires ou quotidiennes. * Accéder aux prévisions de pluie dans l'heure quand disponibles. -* Accéder aux alertes météo pour chaque département français et l'Andorre. Deux +* Accéder aux alertes météo pour chaque département français et d'Andorre. Deux bulletins sont disponibles : un synthétique et un second avec l'évolution des alertes pour les prochaines 24 heures (exemple `ici `_). @@ -94,7 +94,7 @@ Descritption ^^^^^^^^^^^^ This Python package manages the communication with the private Météo-France API -used by the official moblie applications. +used by the official mobile applications. The client allows: diff --git a/src/meteofrance/client.py b/src/meteofrance/client.py index 146a244b..11d89d0d 100644 --- a/src/meteofrance/client.py +++ b/src/meteofrance/client.py @@ -166,7 +166,7 @@ def get_warning_current_phenomenoms( (example: `1310`). depth: Optional; To be used with domain = 'france'. With depth = 0 the results will show only natinal sum up of the weather alerts. If - depth = 1, you wil have in addtion the buletin for all metropolitan + depth = 1, you will have in addition, the bulletin for all metropolitan France department and Andorre with_costal_bulletin: Optional; If set to True (default is False), you can get the basic bulletin and coastal bulletin merged. diff --git a/src/meteofrance/helpers.py b/src/meteofrance/helpers.py index 7d25c1be..3110417d 100644 --- a/src/meteofrance/helpers.py +++ b/src/meteofrance/helpers.py @@ -89,14 +89,14 @@ def readeable_phenomenoms_dict( """Create a dictionary with human readable keys and values (Helper). Args: - list_phenomenoms: Dictionnary with phenomnom ID and color code of status. + list_phenomenoms: Dictionary with phenomenon ID and color code of status. language: Optional; If language is equal "fr" (default value) results will be in French. All other value will give results in English. Returns: - Dictionnary with keys and value human readable. + Dictionary with keys and value human readable. """ - # Init empty dictionnary + # Init empty dictionary readable_dict = {} # Translate phenomenom name and alert level @@ -142,7 +142,7 @@ def sort_places_versus_distance_from_coordinates( """Oder list of places according to the distance to a reference coordinates. Note: this helper is compensating the bad results of the API. Results in the API - are generaly sorted, but lot of cases identified where the order is inconsistent + are generally sorted, but lot of cases identified where the order is inconsistent (example: Montréal) Args: diff --git a/src/meteofrance/model/forecast.py b/src/meteofrance/model/forecast.py index 1babbcb9..e12e6218 100644 --- a/src/meteofrance/model/forecast.py +++ b/src/meteofrance/model/forecast.py @@ -37,7 +37,7 @@ class Forecast: forecast: A list of dictionaries to describe the hourly forecast for the next days. probability_forecast: A list of dictionaries to describe the event probability - forecast (rain, snwow, freezing) for next 10 days. + forecast (rain, snow, freezing) for next 10 days. today_forecast: A dictionary corresponding to the daily forecast for the current day. nearest_forecast: A dictionary corresponding to the nearest hourly forecast. diff --git a/src/meteofrance/model/place.py b/src/meteofrance/model/place.py index b3a260e4..3b98b29d 100644 --- a/src/meteofrance/model/place.py +++ b/src/meteofrance/model/place.py @@ -52,7 +52,7 @@ def __repr__(self) -> str: Returns: A string to represent the instance of the Place class using the name, - country and amdin area of the location. + country and admin area of the location. Example: """ diff --git a/src/meteofrance/model/rain.py b/src/meteofrance/model/rain.py index 6fe2c52d..eff6feb6 100644 --- a/src/meteofrance/model/rain.py +++ b/src/meteofrance/model/rain.py @@ -29,7 +29,7 @@ class Rain: Attributes: position: A dictionary with metadata about the position of the forecast place. - position: A dictionary with metadata about the position of the forecast place. + updated_on: A timestamp as int corresponding to the latest update date. forecast: A list of dictionaries to describe the following next hour rain forecast. quality: An integer. Don't know yet the usage. diff --git a/src/meteofrance/model/warning.py b/src/meteofrance/model/warning.py index 0e8411fd..4a1941d7 100644 --- a/src/meteofrance/model/warning.py +++ b/src/meteofrance/model/warning.py @@ -108,7 +108,7 @@ def get_domain_max_color(self) -> int: """Get the maximum level of alert of a given domain (class helper). Returns: - An integer correspondingt to the status code representing the maximul alert. + An integer corresponding to the status code representing the maximum alert. """ max_int_color = max( x["phenomenon_max_color_id"] for x in self.phenomenons_max_colors @@ -132,7 +132,7 @@ class Full: the phenomenoms. domain_id: A string corresponding do the domain ID of the bulletin. Value is 'France' or a department number. - color_max: An integer reprenting the maximum alert level in the domain. + color_max: An integer representing the maximum alert level in the domain. timelaps: A list of dictionnaries corresponding to the schedule of each phenomenoms in the next 24 hours. phenomenons_items: list of dictionnaries corresponding the alert level for each @@ -180,7 +180,7 @@ def phenomenons_items(self) -> List[Dict[str, int]]: return self.raw_data["phenomenons_items"] def merge_with_coastal_phenomenons(self, coastal_phenomenoms: "Full") -> None: - """Merge the classical phenomenoms bulleting with the coastal one. + """Merge the classical phenomenon bulletin with the coastal one. Extend the color_max, timelaps and phenomenons_items properties with the content of the coastal weather alert bulletin. From 1bdd4d69b6a44084d9613271d440a118def236b9 Mon Sep 17 00:00:00 2001 From: oncleben31 Date: Sun, 11 Oct 2020 20:24:16 +0200 Subject: [PATCH 30/33] Implement fix from code review --- README.rst | 4 ++-- src/meteofrance/client.py | 18 ++++++++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/README.rst b/README.rst index 4edd7de6..28b7a626 100644 --- a/README.rst +++ b/README.rst @@ -48,7 +48,7 @@ Vous trouverez le contenu francophone du README dans la section `Pour les franco Pour les francophones --------------------- -Déscription +Description ^^^^^^^^^^^ Ce package Python permet de gérer la communication avec l'API non publique de @@ -90,7 +90,7 @@ détaillées dans `CONTRIBUTING.rst`_. For English speaking users -------------------------- -Descritption +Descrtption ^^^^^^^^^^^^ This Python package manages the communication with the private Météo-France API diff --git a/src/meteofrance/client.py b/src/meteofrance/client.py index 11d89d0d..de97fd34 100644 --- a/src/meteofrance/client.py +++ b/src/meteofrance/client.py @@ -82,7 +82,10 @@ def search_places( # Forecast # def get_forecast( - self, latitude: float, longitude: float, language: str = "fr", + self, + latitude: float, + longitude: float, + language: str = "fr", ) -> Forecast: """Retrieve the weather forecast for a given GPS location. @@ -109,7 +112,11 @@ def get_forecast( ) return Forecast(resp.json()) - def get_forecast_for_place(self, place: Place, language: str = "fr",) -> Forecast: + def get_forecast_for_place( + self, + place: Place, + language: str = "fr", + ) -> Forecast: """Retrieve the weather forecast for a given Place instance. Results can be fetched in french or english according to the language parameter. @@ -205,9 +212,6 @@ def get_warning_full(self, domain: str, with_costal_bulletin: bool = False) -> F For a given domain we can access the maximum alert, a timelaps of the alert evolution for the next 24 hours, a list of alerts and other metadatas. - with_costal_bulletin: If set to True, you can get the basic bulletin and - coastal bulletin merged. - Args: domain: could be `france` or any metropolitan France department numbers on two digits. For some departments you can access an additional bulletin @@ -231,7 +235,9 @@ def get_warning_full(self, domain: str, with_costal_bulletin: bool = False) -> F if with_costal_bulletin: if domain in COASTAL_DEPARTMENT_LIST: resp = self.session.request( - "get", "warning/full", params={"domain": domain + "10"}, + "get", + "warning/full", + params={"domain": domain + "10"}, ) full_phenomenoms.merge_with_coastal_phenomenons(Full(resp.json())) From 34e593c9be7c865be4bd80ce28208624db5ddd77 Mon Sep 17 00:00:00 2001 From: oncleben31 Date: Sun, 11 Oct 2020 20:31:28 +0200 Subject: [PATCH 31/33] Fix code style by Black --- src/meteofrance/client.py | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/meteofrance/client.py b/src/meteofrance/client.py index de97fd34..02f63f3c 100644 --- a/src/meteofrance/client.py +++ b/src/meteofrance/client.py @@ -82,10 +82,7 @@ def search_places( # Forecast # def get_forecast( - self, - latitude: float, - longitude: float, - language: str = "fr", + self, latitude: float, longitude: float, language: str = "fr", ) -> Forecast: """Retrieve the weather forecast for a given GPS location. @@ -112,11 +109,7 @@ def get_forecast( ) return Forecast(resp.json()) - def get_forecast_for_place( - self, - place: Place, - language: str = "fr", - ) -> Forecast: + def get_forecast_for_place(self, place: Place, language: str = "fr",) -> Forecast: """Retrieve the weather forecast for a given Place instance. Results can be fetched in french or english according to the language parameter. @@ -235,9 +228,7 @@ def get_warning_full(self, domain: str, with_costal_bulletin: bool = False) -> F if with_costal_bulletin: if domain in COASTAL_DEPARTMENT_LIST: resp = self.session.request( - "get", - "warning/full", - params={"domain": domain + "10"}, + "get", "warning/full", params={"domain": domain + "10"}, ) full_phenomenoms.merge_with_coastal_phenomenons(Full(resp.json())) From 4817c55d93f07b29d54acd35f7bf705a3fdd70f9 Mon Sep 17 00:00:00 2001 From: oncleben31 Date: Sun, 11 Oct 2020 22:02:30 +0200 Subject: [PATCH 32/33] Refresh poetry.lock --- poetry.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/poetry.lock b/poetry.lock index a0e30636..fda8feec 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1015,7 +1015,7 @@ docs = ["sphinx", "jaraco.packaging (>=3.2)", "rst.linker (>=1.9)"] testing = ["jaraco.itertools", "func-timeout"] [metadata] -content-hash = "5c201dc70cfae188955146de6cb259327b2dcee4b1330d578a2a89625d0e98f2" +content-hash = "bb103923ff3d70d5a66136ec620eefcd0b5506e7c3d0fb4731c6806d45ab8f15" lock-version = "1.0" python-versions = "^3.6.1" From a72f6b31885b253c4d5d87be64cb2d96334760b1 Mon Sep 17 00:00:00 2001 From: oncleben31 Date: Sun, 11 Oct 2020 22:05:22 +0200 Subject: [PATCH 33/33] Code style modification by Black --- src/meteofrance/client.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/meteofrance/client.py b/src/meteofrance/client.py index 02f63f3c..de97fd34 100644 --- a/src/meteofrance/client.py +++ b/src/meteofrance/client.py @@ -82,7 +82,10 @@ def search_places( # Forecast # def get_forecast( - self, latitude: float, longitude: float, language: str = "fr", + self, + latitude: float, + longitude: float, + language: str = "fr", ) -> Forecast: """Retrieve the weather forecast for a given GPS location. @@ -109,7 +112,11 @@ def get_forecast( ) return Forecast(resp.json()) - def get_forecast_for_place(self, place: Place, language: str = "fr",) -> Forecast: + def get_forecast_for_place( + self, + place: Place, + language: str = "fr", + ) -> Forecast: """Retrieve the weather forecast for a given Place instance. Results can be fetched in french or english according to the language parameter. @@ -228,7 +235,9 @@ def get_warning_full(self, domain: str, with_costal_bulletin: bool = False) -> F if with_costal_bulletin: if domain in COASTAL_DEPARTMENT_LIST: resp = self.session.request( - "get", "warning/full", params={"domain": domain + "10"}, + "get", + "warning/full", + params={"domain": domain + "10"}, ) full_phenomenoms.merge_with_coastal_phenomenons(Full(resp.json()))