Ë
    çÍ:jÃ  ã                   óŠ   — d Z ddlZddlmZmZ ddlmZmZmZm	Z	  G d„ de	«      Z
 e
«       Z G d„ de¬	«      Z G d
„ de«      Zy)zY
This module provides an interface for TweetHandlers, and support for timezone
handling.
é    N)ÚABCMetaÚabstractmethod)ÚdatetimeÚ	timedeltaÚtimezoneÚtzinfoc                   óŠ   — e Zd ZdZ eej                   ¬«      Zej                  r eej                   ¬«      Z
d„ ZyeZ
d„ Zy)ÚLocalTimezoneOffsetWithUTCa»  
    This is not intended to be a general purpose class for dealing with the
    local timezone. In particular:

    * it assumes that the date passed has been created using
      `datetime(..., tzinfo=Local)`, where `Local` is an instance of
      the object `LocalTimezoneOffsetWithUTC`;
    * for such an object, it returns the offset with UTC, used for date comparisons.

    Reference: https://docs.python.org/3/library/datetime.html
    )Úsecondsc                 ó   — | j                   S )z2
        Access the relevant time offset.
        )Ú	DSTOFFSET)ÚselfÚdts     úe/home/mcse/projects/srt_converter/srt-converter-venv/lib/python3.12/site-packages/nltk/twitter/api.pyÚ	utcoffsetz$LocalTimezoneOffsetWithUTC.utcoffset'   s   € ð �~‰~Ðó    N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ú_timer   Ú	STDOFFSETÚdaylightÚaltzoner   r   © r   r   r
   r
      sA   „ ñ
ñ  5§>¡> /Ô2€Ià‡~‚~Ù u§}¡} nÔ5ˆ	óð ˆ	ór   r
   c                   ó   — e Zd ZdZdd„Zd„ Zy)ÚBasicTweetHandlerz�
    Minimal implementation of `TweetHandler`.

    Counts the number of Tweets and decides when the client should stop
    fetching them.
    c                 ó@   — || _         d| _        	 d| _        	 d | _        y )Nr   F)ÚlimitÚcounterÚdo_stopÚmax_id)r   r   s     r   Ú__init__zBasicTweetHandler.__init__9   s,   € ØˆŒ
ØˆŒð	ð ˆŒð	ð ˆ�r   c                 óR   — | j                   | j                  k  xr | j                   S )zL
        Returns `False` if the client should stop fetching Tweets.
        )r    r   r!   ©r   s    r   Údo_continuezBasicTweetHandler.do_continueH   s#   € ð �|‰|˜dŸj™jÑ(Ò=°·±Ð-=Ð=r   N)é   )r   r   r   r   r#   r&   r   r   r   r   r   1   s   „ ñóó>r   r   )Ú	metaclassc                   ó@   — e Zd ZdZdd„Zed„ «       Zed„ «       Zdd„Zy)	ÚTweetHandlerIzu
    Interface class whose subclasses should implement a handle method that
    Twitter clients can delegate to.
    Nc                 ó²   — t         j                  | |«       d| _        d| _        |rt	        |dt
        iŽ| _        |rt	        |dt
        iŽ| _        d| _        y)a  
        :param int limit: The number of data items to process in the current        round of processing.

        :param tuple upper_date_limit: The date at which to stop collecting        new data. This should be entered as a tuple which can serve as the        argument to `datetime.datetime`.        E.g. `date_limit=(2015, 4, 1, 12, 40)` for 12:30 pm on April 1 2015.

        :param tuple lower_date_limit: The date at which to stop collecting        new data. See `upper_data_limit` for formatting.
        Nr   T)r   r#   Úupper_date_limitÚlower_date_limitr   ÚLOCALÚ
startingup)r   r   r,   r-   s       r   r#   zTweetHandlerI.__init__U   sW   € ô 	×"Ñ" 4¨Ô/à $ˆÔØ $ˆÔÙÜ$,Ð.>Ð$MÄuÑ$MˆDÔ!ÙÜ$,Ð.>Ð$MÄuÑ$MˆDÔ!àˆ�r   c                  ó   — y)zJ
        Deal appropriately with data returned by the Twitter API
        Nr   )r   Údatas     r   ÚhandlezTweetHandlerI.handlem   ó   � r   c                  ó   — y)z?
        Actions when the tweet limit has been reached
        Nr   r%   s    r   Ú	on_finishzTweetHandlerI.on_finishs   r3   r   c                 ó´  — | j                   s| j                  rÀd}t        j                  |d   |«      j	                  t
        j                  ¬«      }| j                   r|| j                   kD  s| j                  r_|| j                  k  rO| j                   rd}| j                   }nd}| j                  }|rt        dj                  |||«      «       d| _	        yyyy)	z'
        Validate date limits.
        z%a %b %d %H:%M:%S +0000 %YÚ
created_at)r   ÚearlierÚlaterz1Date limit {} is {} than date of current tweet {}TN)
r,   r-   r   ÚstrptimeÚreplacer   ÚutcÚprintÚformatr!   )r   r1   ÚverboseÚdate_fmtÚ
tweet_dateÚmessageÚ
date_limits          r   Úcheck_date_limitzTweetHandlerI.check_date_limity   s×   € ð × Ò  D×$9Ò$9Ø3ˆHÜ!×*Ñ*¨4°Ñ+=¸xÓH×PÑPÜ—|‘|ð Qó ˆJð ×%Ò%¨*°t×7LÑ7LÒ*LØ×%Ò%¨*°t×7LÑ7LÒ*Là×(Ò(Ø'�GØ!%×!6Ñ!6‘Jà%�GØ!%×!6Ñ!6�JÙÜØK×RÑRØ&¨°óôð
  $�•ð +MÐ%ð %:r   )r'   NN)F)	r   r   r   r   r#   r   r2   r5   rD   r   r   r   r*   r*   O   s9   „ ñó
ð0 ñó ðð
 ñó ðô
$r   r*   )r   Útimer   Úabcr   r   r   r   r   r   r
   r.   r   r*   r   r   r   ú<module>rG      sI   ðñó
 ß 'ß :Ó :ô ô ñ6 	#Ó$€ô> 'õ >ô<B$Ð%õ B$r   