Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/lazr/restfulclient/authorize/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/lazr/restfulclient/authorize/oauth.pyc

ó
BÔLc@s"dZddlmZddlZddlZddlZddlZediƒjZej	ej
ejejf\Z	Z
ZZddl
mZddlmZeZddd	d
gZdZdej	fd„ƒYZdejfd
„ƒYZd
efd„ƒYZd	efd„ƒYZdS(s.OAuth classes for use with lazr.restfulclient.iÿÿÿÿ(tSafeConfigParserNsoauth.oauth(tHttpAuthorizer(tCredentialsFileErrortAccessTokentConsumertOAuthAuthorizertSystemWideConsumert1cBseZdZddd„ZRS(s An OAuth consumer (application).tcCs tj|||ƒ||_dS(snInitialize

        :param key: The OAuth consumer key
        :param secret: The OAuth consumer secret. Don't use this. It's
            a misfeature, and lazr.restful doesn't expect it.
        :param application_name: An application name, if different
            from the consumer key. If present, this will be used in
            the User-Agent header.
        N(t
OAuthConsumert__init__tapplication_name(tselftkeytsecretR((sF/usr/lib/python2.7/dist-packages/lazr/restfulclient/authorize/oauth.pyR
9s
N(t__name__t
__module__t__doc__tNoneR
(((sF/usr/lib/python2.7/dist-packages/lazr/restfulclient/authorize/oauth.pyR6scBseZdZddd„ZRS(sAn OAuth access token.RcCs tj|||ƒ||_dS(N(t
OAuthTokenR
tcontext(RR
RR((sF/usr/lib/python2.7/dist-packages/lazr/restfulclient/authorize/oauth.pyR
JsN(RRRRR
(((sF/usr/lib/python2.7/dist-packages/lazr/restfulclient/authorize/oauth.pyRGscBs/eZdZdZdd„Zed„ƒZRS(sÿA consumer associated with the logged-in user rather than an app.

    This can be used to share a single OAuth token among multiple
    desktop applications. The OAuth consumer key will be derived from
    system information (platform and hostname).
    sSystem-wide: %s (%s)RcCs#tt|ƒj|j||ƒdS(s	Constructor.

        :param application_name: An application name. This will be
            used in the User-Agent header.
        :param secret: The OAuth consumer secret. Don't use this. It's
            a misfeature, and lazr.restful doesn't expect it.
        N(tsuperRR
tconsumer_key(RRR((sF/usr/lib/python2.7/dist-packages/lazr/restfulclient/authorize/oauth.pyR
XscCsgytjƒ\}}}Wntk
r4}d}nX|dkrPtjƒ}n|j|tjƒfS(s³The system-wide OAuth consumer key for this computer.

        This key identifies the platform and the computer's
        hostname. It does not identify the active user.
        R(tplatformtlinux_distributiont	Exceptiontsystemt
KEY_FORMATtsockettgethostname(Rtdistnametversiont
release_idte((sF/usr/lib/python2.7/dist-packages/lazr/restfulclient/authorize/oauth.pyRcs
(RRRRR
tpropertyR(((sF/usr/lib/python2.7/dist-packages/lazr/restfulclient/authorize/oauth.pyROscBsheZdZd
dd
dd
d„Zed„ƒZd„Zed„ƒZ	d„Z
d„Zd	„ZRS(sBA client that signs every outgoing request with OAuth credentials.RtOAuthcCsCd|_|dk	r-t|||ƒ|_n||_||_dS(N(RtconsumerRtaccess_tokentoauth_realm(Rt
consumer_nametconsumer_secretR%R&R((sF/usr/lib/python2.7/dist-packages/lazr/restfulclient/authorize/oauth.pyR
zs		cCsRi}|jdkr|S|jj|d<|jjdk	rN|jj|d<n|S(soAny information necessary to identify this user agent.

        In this case, the OAuth consumer name.
        toauth_consumertapplicationN(R$RR
R(Rtparams((sF/usr/lib/python2.7/dist-packages/lazr/restfulclient/authorize/oauth.pytuser_agent_params„scCs¨tƒ}|j|ƒ|jtƒs8tdtƒ‚n|jtdƒ}|jtdƒ}t||ƒ|_|jtdƒ}|jtdƒ}t||ƒ|_	dS(skLoad credentials from a file-like object.

        This overrides the consumer and access token given in the constructor
        and replaces them with the values read from the file.

        :param readable_file: A file-like object to read the credentials from
        :type readable_file: Any object supporting the file-like `read()`
            method
        sNo configuration for version %sRR(R%t
access_secretN(
Rtreadfpthas_sectiontCREDENTIALS_FILE_VERSIONRtgetRR$RR%(Rt
readable_filetparserRR(R%R-((sF/usr/lib/python2.7/dist-packages/lazr/restfulclient/authorize/oauth.pytload’s	

cCs3|ƒ}t|dƒ}|j|ƒ|jƒ|S(s™Convenience method for loading credentials from a file.

        Open the file, create the Credentials and load from the file,
        and finally close the file and return the newly created
        Credentials instance.

        :param path: In which file the credential file should be saved.
        :type path: string
        :return: The loaded Credentials instance.
        :rtype: `Credentials`
        tr(topenR4tclose(tclstpathtcredentialstcredentials_file((sF/usr/lib/python2.7/dist-packages/lazr/restfulclient/authorize/oauth.pytload_from_path¯s

	

cCsÇ|jdkrtdƒ‚n|jdkr<tdƒ‚ntƒ}|jtƒ|jtd|jjƒ|jtd|jj	ƒ|jtd|jjƒ|jtd|jj	ƒ|j
|ƒdS(sHWrite the credentials to the file-like object.

        :param writable_file: A file-like object to write the credentials to
        :type writable_file: Any object supporting the file-like `write()`
            method
        :raise CredentialsFileError: when there is either no consumer or no
            access token
        sNo consumersNo access tokenRR(R%R-N(R$RRR%Rtadd_sectionR0tsetR
Rtwrite(Rt
writable_fileR3((sF/usr/lib/python2.7/dist-packages/lazr/restfulclient/authorize/oauth.pytsaveÂs		
				cCsWtjtj|tjtjBtjBtjtjBƒdƒ}|j	|ƒ|j
ƒdS(sTConvenience method for saving credentials to a file.

        Create the file, call self.save(), and close the
        file. Existing files are overwritten. The resulting file will
        be readable and writable only by the user.

        :param path: In which file the credential file should be saved.
        :type path: string
        twN(tostfdopenR6tO_CREATtO_TRUNCtO_WRONLYtstattS_IREADtS_IWRITERAR7(RR9R;((sF/usr/lib/python2.7/dist-packages/lazr/restfulclient/authorize/oauth.pytsave_to_pathÜs


cCsWtj|j|jd|ƒ}|jtƒ|j|jƒ|j|j|jƒƒdS(s&Sign a request with OAuth credentials.thttp_urlN(	tOAuthRequesttfrom_consumer_and_tokenR$R%tsign_requesttOAuthSignatureMethod_PLAINTEXTtupdatet	to_headerR&(Rtabsolute_uritmethodtbodytheaderst
oauth_request((sF/usr/lib/python2.7/dist-packages/lazr/restfulclient/authorize/oauth.pytauthorizeRequestìsN(
RRRRR
R"R,R4tclassmethodR<RARKRX(((sF/usr/lib/python2.7/dist-packages/lazr/restfulclient/authorize/oauth.pyRws			(RtConfigParserRRCRRHRt
__import__toauthR	RMRPRtlazr.restfulclient.authorizeRtlazr.restfulclient.errorsRttypet
__metaclass__t__all__R0RRRR(((sF/usr/lib/python2.7/dist-packages/lazr/restfulclient/authorize/oauth.pyt<module>s(	(