%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/lazr/restfulclient/authorize/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/lazr/restfulclient/authorize/__pycache__/oauth.cpython-312.pyc

�

!�e�'���dZ	ddlmZddlZddlZddlZddlZddl	m
Z
ddlmZm
Z
ddlmZddlmZeZgd	�Zd
ZGd�d�ZGd
�d�ZGd�de�ZGd�de�ZGd�de�Zy#e$r	ddlmZY�uwxYw)z.OAuth classes for use with lazr.restfulclient.�)�ConfigParser)�SafeConfigParserN)�oauth1)�parse_qs�	urlencode)�HttpAuthorizer)�CredentialsFileError)�AccessToken�Consumer�OAuthAuthorizer�SystemWideConsumer�1c��eZdZdZdd�Zy)rz An OAuth consumer (application).Nc�.�||_||_||_y)anInitialize

        :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)�key�secret�application_name)�selfrrrs    �D/usr/lib/python3/dist-packages/lazr/restfulclient/authorize/oauth.py�__init__zConsumer.__init__8s�������� 0�����N)�__name__�
__module__�__qualname__�__doc__r�rrrr5s
��*�1rrc�2�eZdZdZdd�Zd�ZeZed��Zy)r
zAn OAuth access token.Nc�.�||_||_||_y�N)rr�context)rrrr"s    rrzAccessToken.__init__Js����������rc�L�td|jfd|jfg�S)N�oauth_token_secret�oauth_token)rrr�rs r�	to_stringzAccessToken.to_stringOs,���%�t�{�{�3�����)�
�
�	
rc�N�t|d��}|dd}|dd}|||�S)NF)�keep_blank_valuesr%rr$)r)�cls�s�paramsrrs     r�from_stringzAccessToken.from_stringYs:���!�u�5���]�#�A�&���,�-�a�0���3���rr)	rrrrrr'�__str__�classmethodr-rrrr
r
Gs(�� ��

��G�� �� rr
c��eZdZdZd�ZeZy)�TruthyStringz&A Unicode string which is always true.c��y)NTrr&s r�__bool__zTruthyString.__bool__ds��rN)rrrrr3�__nonzero__rrrr1r1as��0���Krr1c�8��eZdZdZdZd�fd�	Zed��Z�xZS)r
z�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).
    zSystem-wide: %s (%s)c�D��tt|�|j||�y)a	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)�superr
r�consumer_key)rrr�	__class__s   �rrzSystemWideConsumer.__init__ts#���	� �$�0����v�'7�	
rc���	ddl}|j�}|dk(rtj�}|j
|t
j�fzS#t$rd}Y�IwxYw)z�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.
        rNr)�distro�name�	Exception�platform�system�
KEY_FORMAT�socket�gethostname)rr;�distnames   rr8zSystemWideConsumer.consumer_key�s_��	���{�{�}�H�
�r�>����(�H����(�F�,>�,>�,@�!A�A�A��
�	��H�	�s�A�A �A )r)	rrrrr@r�propertyr8�
__classcell__)r9s@rr
r
js*����(�J�

��B��Brr
c�Z�eZdZdZ					d
d�Zed��Zd�Zed��Z	d�Z
d�Zd	�Zy)rzBA client that signs every outgoing request with OAuth credentials.Nc�V�d|_|�t|||�|_||_||_yr!)�consumerr�access_token�oauth_realm)r�
consumer_name�consumer_secretrIrJrs      rrzOAuthAuthorizer.__init__�s7����
��$�$���0@��D�M�)���&��rc��i}|j�|S|jj|d<|jj�|jj|d<|S)zoAny information necessary to identify this user agent.

        In this case, the OAuth consumer name.
        �oauth_consumer�application)rHrr)rr,s  r�user_agent_paramsz!OAuthAuthorizer.user_agent_params�sV�����=�=� ��M�#'�=�=�#4�#4��� ��=�=�)�)�5�$(�M�M�$B�$B�F�=�!��
rc��t�}t|d�r
|j}n|j}||�|j	t
�st
dt
z��|jt
d�}|jt
d�}t||�|_	|jt
d�}|jt
d�}t||�|_y)akLoad 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
        �	read_filezNo configuration for version %sr8rLrI�
access_secretN)r�hasattrrR�readfp�has_section�CREDENTIALS_FILE_VERSIONr	�getrrHr
rI)r�
readable_file�parser�readerr8rLrIrSs        r�loadzOAuthAuthorizer.load�s���"�#���6�;�'��%�%�F��]�]�F��}���!�!�":�;�&�1�4L�L��
��z�z�":�N�K�� �*�*�$�&7�
��!���?��
��z�z�":�N�K���
�
�#;�_�M�
�'��m�D��rc�n�|�}t|d�}|j|�|j�|S)a�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`
        �r)�openr\�close)r*�path�credentials�credentials_files    r�load_from_pathzOAuthAuthorizer.load_from_path�s8���e����c�?�����)�*���� ��rc��|j�td��|j�td��t�}|j	t
�|j
t
d|jj�|j
t
d|jj�|j
t
d|jj�|j
t
d|jj�|j|�y)aHWrite 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
        NzNo consumerzNo access tokenr8rLrIrS)
rHr	rIr�add_sectionrW�setrr�write)r�
writable_filerZs   r�savezOAuthAuthorizer.save�s����=�=� �&�}�5�5����$�&�'8�9�9�!�#�����3�4��
�
�+�^�T�]�]�=N�=N�O��
�
�$�&7����9M�9M�	
�	�
�
�$�n�d�6G�6G�6K�6K�	
�	�
�
�$�o�t�7H�7H�7O�7O�	
�	���]�#rc�:�tjtj|tjtjztj
ztjtjz�d�}|j|�|j�y)aTConvenience 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
        �wN)�os�fdopenr_�O_CREAT�O_TRUNC�O_WRONLY�stat�S_IREAD�S_IWRITErjr`)rrarcs   r�save_to_pathzOAuthAuthorizer.save_to_pathsk���9�9��G�G�����b�j�j�(�2�;�;�6�����
�
�-�
�

�

��	
�	�	�"�#���� rc��tj|jj|jjt|jjxsd�|jjtj|j��}t|j�|_	|j|�\}}}|j�D]
\}}	|	||<�y)z&Sign a request with OAuth credentials.r)�
client_secret�resource_owner_key�resource_owner_secret�signature_method�realmN)r�ClientrHrrr1rI�SIGNATURE_PLAINTEXTrJrx�sign�items)
r�absolute_uri�method�body�headers�client�_�signed_headersr�values
          r�authorizeRequestz OAuthAuthorizer.authorizeRequests�������M�M����-�-�.�.�+�D�,=�,=�,A�,A�,G�R�H�"&�"3�"3�":�":�#�7�7��"�"�

��%1��1J�1J�$K��!�%�{�{�<�8���>�1�(�.�.�0�	!�J�C�� �G�C�L�	!r)NrN�OAuthN)
rrrrrrDrPr\r/rdrjrur�rrrrr�sY��L������
'� ����E�@����$$�8!�*!rr)r�configparserrr�ImportErrorrmr>rArr�oauthlibr�urllib.parserr�lazr.restfulclient.authorizer�lazr.restfulclient.errorsr	�type�
__metaclass__�__all__rWrr
�strr1r
rrrr�<module>r�s���&5�.�=�
��
���,�7�:��
�����
1�1�$ � �4�3��'B��'B�TV!�n�V!��w�.�-�.�s�A2�2B�?B

Zerion Mini Shell 1.0