ó <¿CVc@sdZddlmZmZmZddlmZddlZdefd„ƒYZeƒZ de fd„ƒYZ d e fd „ƒYZ dS( sY This module provides an interface for TweetHandlers, and support for timezone handling. iÿÿÿÿ(ttzinfot timedeltatdatetime(tUTCNtLocalTimezoneOffsetWithUTCcBsOeZdZedej ƒZejr>edej ƒZ neZ d„Z RS(s» 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 tsecondscCs|jS(s2 Access the relevant time offset. (t DSTOFFSET(tselftdt((sb/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/twitter/api.pyt utcoffset's( t__name__t __module__t__doc__Rt_timettimezonet STDOFFSETtdaylighttaltzoneRR (((sb/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/twitter/api.pyRs   tBasicTweetHandlercBs#eZdZdd„Zd„ZRS(s Minimal implementation of `TweetHandler`. Counts the number of Tweets and decides when the client should stop fetching them. icCs(||_d|_t|_d|_dS(Ni(tlimittcountertFalsetdo_stoptNonetmax_id(RR((sb/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/twitter/api.pyt__init__6s   cCs|j|jko|j S(sL Returns `False` if the client should stop fetching Tweets. (RRR(R((sb/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/twitter/api.pyt do_continueEs(R R R RR(((sb/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/twitter/api.pyR/s t TweetHandlerIcBs>eZdZdddd„Zd„Zd„Zed„ZRS(su Interface class whose subclasses should implement a handle method that Twitter clients can delegate to. icCsktj||ƒd|_d|_|r@tdt|Œ|_n|r^tdt|Œ|_nt|_dS(s :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. RN( RRRtupper_date_limittlower_date_limitRtLOCALtTruet startingup(RRRR((sb/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/twitter/api.pyRPs   cCs t‚dS(sJ Deal appropriately with data returned by the Twitter API N(tNotImplementedError(Rtdata((sb/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/twitter/api.pythandlehscCs t‚dS(s? Actions when the tweet limit has been reached N(R!(R((sb/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/twitter/api.pyt on_finishnscCsÄ|js|jrÀd}tj|d|ƒjdtƒ}|jrR||jksj|jrÀ||jkrÀ|jr…d}|j}nd}|j}|r±dj|||ƒGHnt|_qÀndS(s' Validate date limits. s%a %b %d %H:%M:%S +0000 %Yt created_atRtearliertlaters4Date limit {0} is {1} than date of current tweet {2}N( RRRtstrptimetreplaceRtformatRR(RR"tverbosetdate_fmtt tweet_datetmessaget date_limit((sb/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/twitter/api.pytcheck_date_limitts    N( R R R RRR#R$RR0(((sb/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/twitter/api.pyRKs   ( R RRRt nltk.compatRttimeR RRtobjectRR(((sb/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/twitter/api.pyt s