ó <¿CVc@sdZddlmZddlZddlZddlmZdded„Z de fd„ƒYZ dd„Z d „Z dS( s@ Authentication utilities to accompany :module:`twitterclient`. iÿÿÿÿ(tprint_functionN(tTwythoncCstƒjd|d|d|ƒS(s1 Convenience function for authentication t creds_filetsubdirtverbose(t Authenticatet load_creds(RRR((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/twitter/util.pyt credsfromfilesRcBs5eZdZd„Zdded„Zed„ZRS(s2 Methods for authenticating with Twitter. cCsed|_d|_i|_y tjd|_|j|_Wn#tk r`d|_d|_nXdS(Nscredentials.txttTWITTER( RtNonetcreds_fullpathtoauthtostenviront twitter_dirt creds_subdirtKeyError(tself((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/twitter/util.pyt__init__s     c CsQ|dk r||_n|dkrO|jdkrXdd}t|ƒ‚qXn ||_tjjtjj|j|jƒƒ|_tjj |jƒs²t dj |jƒƒ‚nt |jƒw}|rãt dj |jƒƒnxN|D]F}d|krê|jddƒ\}}|jƒ|j|jƒhsc3s|]}|ˆjkVqdS(N(R (R*R+(R(sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/twitter/util.pys jss#Missing or incorrect entries in {} s Credentials file "{}" looks goodN( tFalsetalltTrueRRtpprinttpformatR RR(RRtoauth1t oauth1_keystoauth2t oauth2_keysR ((Rsc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/twitter/util.pyRbs   N(t__name__t __module__t__doc__RR R,RR(((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/twitter/util.pyRs 6c Csµ|d kr6tjjtƒ}tjj|dƒ}ntd|ƒ}|d}|d}t||ddƒ}|jƒ}dj |ƒ}t |dƒ}t |d |ƒWd QXd S( sc For OAuth 2, retrieve an access token for an app and append it to a credentials file. scredentials2.txtRR%R&t oauth_versionisaccess_token={} tatfileN( R R Rtdirnamet__file__RRRtobtain_access_tokenRRR( RRR3R%R&ttwitterR)ttokR!((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/twitter/util.pytadd_access_tokenus    cCs9tjj|ƒr|Stjjtjjd|ƒƒSdS(sà If the path is not absolute, guess that it is a subdirectory of the user's home directory. :param str pth: The pathname of the directory where files of tweets should be written t~N(R Rtisabst expanduserR(tpth((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/twitter/util.pyt guess_pathˆs(R7t __future__RR R/ttwythonRR R,RtobjectRR@RE(((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/twitter/util.pyt s  Z