JL idZddlZddlmZmZddlmZmZmZm Z Gdde Z e Z Gdde Z Gd d e Z y) zY This module provides an interface for TweetHandlers, and support for timezone handling. N)ABCMetaabstractmethod)datetime timedeltatimezonetzinfoceZdZdZeej Zejreej Z dZ yeZ dZ 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|jS)z2 Access the relevant time offset. ) DSTOFFSET)selfdts V/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/nltk/twitter/api.py utcoffsetz$LocalTimezoneOffsetWithUTC.utcoffset's~~N) __name__ __module__ __qualname____doc__r_timer STDOFFSETdaylightaltzoner rrrr r sA 5>>/2I ~~u}}n5  rr ceZdZdZddZdZy)BasicTweetHandlerz Minimal implementation of `TweetHandler`. Counts the number of Tweets and decides when the client should stop fetching them. c@||_d|_ d|_ d|_y)NrF)limitcounterdo_stopmax_id)rrs r__init__zBasicTweetHandler.__init__9s,      rcR|j|jkxr |j S)zL Returns `False` if the client should stop fetching Tweets. )r rr!rs r do_continuezBasicTweetHandler.do_continueHs#||djj(=-==rN))rrrrr#r&rrrrr1s >rr) metaclassc@eZdZdZddZedZedZddZy) TweetHandlerIzu Interface class whose subclasses should implement a handle method that Twitter clients can delegate to. Nctj||d|_d|_|rt |dt i|_|rt |dt 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. NrT)rr#upper_date_limitlower_date_limitrLOCAL startingup)rrr,r-s rr#zTweetHandlerI.__init__UsW ""4/ $ $ $,.>$Mu$MD ! $,.>$Mu$MD !rcy)zJ Deal appropriately with data returned by the Twitter API Nr)rdatas rhandlezTweetHandlerI.handlemrcy)z? Actions when the tweet limit has been reached Nrr%s r on_finishzTweetHandlerI.on_finishsr3rc|js |jrd}tj|d|j t j }|jr||jkDs|jr_||jkrO|jrd}|j}nd}|j}|rtdj|||d|_ yyyy) z' Validate date limits. z%a %b %d %H:%M:%S +0000 %Y created_at)rearlierlaterz1Date limit {} is {} than date of current tweet {}TN) r,r-rstrptimereplacerutcprintformatr!)rr1verbosedate_fmt tweet_datemessage date_limits rcheck_date_limitzTweetHandlerI.check_date_limitys  D$9$93H!**4 +=xHPP||QJ%%*t7L7L*L%%*t7L7L*L(('G!%!6!6J%G!%!6!6JKRR& $ +M% %:r)r'NN)F) rrrrr#rr2r5rDrrrr*r*Os9 0    $rr*)rtimerabcrrrrrrr r.rr*rrrrGsI '::6 #$>'>