
    /h                         S r SSKrSSKJrJr  SSKJrJrJrJ	r	   " S S\	5      r
\
" 5       r " S S\S	9r " S
 S\5      rg)zY
This module provides an interface for TweetHandlers, and support for timezone
handling.
    N)ABCMetaabstractmethod)datetime	timedeltatimezonetzinfoc                       \ rS rSrSr\" \R                  * S9r\R                  (       a  \" \R                  * S9rO\rS rSrg)LocalTimezoneOffsetWithUTC   a  
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                     U R                   $ )z"
Access the relevant time offset.
)	DSTOFFSET)selfdts     H/var/www/auris/envauris/lib/python3.13/site-packages/nltk/twitter/api.py	utcoffset$LocalTimezoneOffsetWithUTC.utcoffset'   s     ~~     N)__name__
__module____qualname____firstlineno____doc__r   _timer   	STDOFFSETdaylightaltzoner   r   __static_attributes__r   r   r   r
   r
      s:    
 5>>/2I~~u}}n5		r   r
   c                   (    \ rS rSrSrSS jrS rSrg)BasicTweetHandler1   z
Minimal implementation of `TweetHandler`.

Counts the number of Tweets and decides when the client should stop
fetching them.
c                 >    Xl         SU l         SU l         S U l        g )Nr   F)limitcounterdo_stopmax_id)r   r$   s     r   __init__BasicTweetHandler.__init__9   s*    
	 	 r   c                 d    U R                   U R                  :  =(       a    U R                  (       + $ )z<
Returns `False` if the client should stop fetching Tweets.
)r%   r$   r&   r   s    r   do_continueBasicTweetHandler.do_continueH   s#     ||djj(=-==r   )r%   r&   r$   r'   N)   )r   r   r   r   r   r(   r,   r   r   r   r   r!   r!   1   s    >r   r!   )	metaclassc                   L    \ rS rSrSrS	S jr\S 5       r\S 5       rS
S jr	Sr
g)TweetHandlerIO   zi
Interface class whose subclasses should implement a handle method that
Twitter clients can delegate to.
Nc                     [         R                  X5        SU l        SU l        U(       a  [	        US[
        06U l        U(       a  [	        US[
        06U l        SU l        g)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$   r4   r5   s       r   r(   TweetHandlerI.__init__U   sU     	""4/ $ $$,.>$Mu$MD!$,.>$Mu$MD!r   c                     g)z:
Deal appropriately with data returned by the Twitter API
Nr   )r   datas     r   handleTweetHandlerI.handlem       r   c                     g)z/
Actions when the tweet limit has been reached
Nr   r+   s    r   	on_finishTweetHandlerI.on_finishs   r=   r   c                    U R                   (       d  U R                  (       a  Sn[        R                  " US   U5      R	                  [
        R                  S9nU R                   (       a  X@R                   :  d   U R                  (       ah  X@R                  :  aX  U R                   (       a  SnU R                   nOSnU R                  nU(       a  [        SR                  XeU5      5        SU l	        gggg)	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)
r4   r5   r   strptimereplacer   utcprintformatr&   )r   r:   verbosedate_fmt
tweet_datemessage
date_limits          r   check_date_limitTweetHandlerI.check_date_limity   s       D$9$93H!**4+=xHPP|| Q J %%*7L7L*L%%*7L7L*L(('G!%!6!6J%G!%!6!6JKRR&
  $ +M% %:r   )r&   r5   r7   r4   )r.   NN)F)r   r   r   r   r   r(   r   r;   r?   rO   r   r   r   r   r1   r1   O   s9    
0  
  
$r   r1   )r   timer   abcr   r   r   r   r   r   r
   r6   r!   r1   r   r   r   <module>rS      sI   
  ' : : 6 	#$>' ><B$% B$r   