
    rbio                         d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	  G d	 d
e          Z
 G d d          ZdS )uC   Rain in the next hour Python model for the Météo-France REST API.    )datetime)Any)Dict)List)Optional)	TypedDict)$timestamp_to_datetime_with_locale_tzc                   h    e Zd ZU dZeeef         ed<   eed<   e	eeef                  ed<   eed<   dS )RainDatazFDescribing the data structure of rain object returned by the REST API.position
updated_onforecastqualityN)
__name__
__module____qualname____doc__r   strr   __annotations__intr        j/var/www/html/mdtn/previsions/meteo_cartes/venv/lib/python3.11/site-packages/meteofrance_api/model/rain.pyr   r      sU         PP38nOOO4S>""""LLLLLr   r   c                       e Zd ZdZdeddfdZedeee	f         fd            Z
edefd            Zedeeee	f                  fd            Zedefd	            Zdee         fd
ZdedefdZdS )Raina  Class to access the results of 'rain' REST 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.
        forecast: A list of dictionaries to describe the following next hour rain
            forecast.
        quality: An integer. Don't know yet the usage.
    raw_datareturnNc                     || _         dS )zInitialize 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.
        Nr   )selfr   s     r   __init__zRain.__init__!   s     !r   c                     | j         d         S )z5Return the position information of the rain forecast.r   r   r    s    r   r   zRain.position*        }Z((r   c                     | j         d         S )z1Return the update timestamp of the rain forecast.r   r   r#   s    r   r   zRain.updated_on/   s     }\**r   c                     | j         d         S )zReturn the rain forecast.r   r   r#   s    r   r   zRain.forecast4   r$   r   c                     | j         d         S )z(Return the quality of the rain forecast.r   r   r#   s    r   r   zRain.quality9   s     }Y''r   c                     t          d | j        D             d          }d}|#|d         }t          || j        d                   }|S )aS  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.
        c              3   2   K   | ]}|d          dk    |V  dS )rain   Nr   ).0cadrans     r   	<genexpr>z-Rain.next_rain_date_locale.<locals>.<genexpr>K   s0      FF6&>A3E3EV3E3E3E3EFFr   Ndttimezone)nextr   r	   r   )r    	next_rainnext_rain_dt_localnext_rain_timestamps       r   next_rain_date_localezRain.next_rain_date_locale?   sd     FF$-FFF
 
	 26 "+D/!E#T]:%>" " "!r   	timestampc                 8    t          || j        d                   S )a9  Convert timestamp in datetime with rain forecast location timezone (Helper).

        Args:
            timestamp: An integer representing the UNIX timestamp.

        Returns:
            A datetime instance corresponding to the timestamp with the timezone of the
                rain forecast location.
        r0   )r	   r   )r    r6   s     r   timestamp_to_locale_timezRain.timestamp_to_locale_timeY   s"     4t}Z0
 
 	
r   )r   r   r   r   r   r!   propertyr   r   r   r   r   r   r   r   r   r   r   r5   r8   r   r   r   r   r      s3        ! !d ! ! ! ! )$sCx. ) ) ) X) +C + + + X+ )$tCH~. ) ) ) X) ( ( ( ( X(
"x'9 " " " "4
# 
( 
 
 
 
 
 
r   r   N)r   r   typingr   r   r   r   r   meteofrance_api.helpersr	   r   r   r   r   r   <module>r<      s    I I                                     H H H H H H    y   O
 O
 O
 O
 O
 O
 O
 O
 O
 O
r   