%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python3/dist-packages/launchpadlib/__pycache__/
Upload File :
Create Path :
Current File : //usr/lib/python3/dist-packages/launchpadlib/__pycache__/launchpad.cpython-312.pyc

�

;��au����dZeZdgZddlZddlZ	ddlmZddl
Z
	ddlmZddlmZmZmZmZddlmZdd	lmZdd
lmZmZmZmZmZmZmZm Z m!Z!ddl"m#Z#ddl$m%Z%m&Z&d
Z'Gd�de�Z(Gd�de�Z)Gd�de�Z*Gd�de*�Z+Gd�de*�Z,Gd�de*�Z-Gd�de�Z.Gd�de�Z/y#e$r	ddl	mZY��wxYw#e$rddlm
Z
e
jZY��wxYw)zRoot Launchpad API class.�	Launchpad�N)�urlsplit)�proxy_info_from_environment)�	ProxyInfo)�CollectionWithKeyBasedLookup�
HostedFile�ScalarValue�ServiceRoot)�SystemWideConsumer)�RestfulHttp)	�AccessToken�AnonymousAccessToken� AuthorizeRequestTokenWithBrowser�AuthorizeRequestTokenWithURL�Consumer�Credentials�MemoryCredentialStore�KeyringCredentialStore�UnencryptedFileCredentialStore)�uris)�STAGING_SERVICE_ROOT�EDGE_SERVICE_ROOTzhttps://api.launchpad.netc��eZdZdZd�ZdZy)�	PersonSetz7A custom subclass capable of person lookup by username.c�z�t|jjj��dzt|�zS)z7Transform a username into the URL to a person resource.�~��str�_root�	_root_uri�ensureSlash��self�keys  �8/usr/lib/python3/dist-packages/launchpadlib/launchpad.py�_get_url_from_idzPersonSet._get_url_from_idJs.���4�:�:�'�'�3�3�5�6��<�s�3�x�G�G��teamN��__name__�
__module__�__qualname__�__doc__r&�
collection_of�r'r%rrGs��A�H��Mr'rc��eZdZdZd�ZdZy)�BugSetz2A custom subclass capable of bug lookup by bug ID.c�z�t|jjj��dzt|�zS)z2Transform a bug ID into the URL to a bug resource.zbugs/rr"s  r%r&zBugSet._get_url_from_idWs.���4�:�:�'�'�3�3�5�6��@�3�s�8�K�Kr'�bugNr)r/r'r%r1r1Ts��<�L��Mr'r1c��eZdZdZd�ZdZy)�	PillarSetzzA custom subclass capable of lookup by pillar name.

    Projects, project groups, and distributions are all pillars.
    c�t�t|jjj��t|�zS)z<Transform a project name into the URL to a project resource.rr"s  r%r&zPillarSet._get_url_from_idds)���4�:�:�'�'�3�3�5�6��S��A�Ar'Nr)r/r'r%r5r5^s���
B��Mr'r5c��eZdZdZdZy)�
ProjectSetz;A custom subclass for accessing the collection of projects.�projectN�r*r+r,r-r.r/r'r%r8r8ms
��E��Mr'r8c��eZdZdZdZy)�ProjectGroupSet�AA custom subclass for accessing the collection of project groups.�
project_groupNr:r/r'r%r<r<ss
��K�#�Mr'r<c��eZdZdZdZy)�DistributionSetr=�distributionNr:r/r'r%r@r@ys
��K�"�Mr'r@c�8��eZdZdZ�fd�Zd�Z�fd�Zd�Z�xZS)�LaunchpadOAuthAwareHttpzBDetects expired/invalid OAuth tokens and tries to get a new token.c�B��||_||_tt|�|�y�N)�	launchpad�authorization_engine�superrC�__init__)r#rFrG�args�	__class__s    �r%rIz LaunchpadOAuthAwareHttp.__init__�s"���"���$8��!�
�%�t�5�t�<r'c��|jdk(xr7|jd�xs$|jd�xs|jd�S)z=Helper method to detect an error caused by a bad OAuth token.i�s
Expired tokens
Invalid tokensUnknown access token)�status�
startswith)r#�response�contents   r%�_bad_oauth_tokenz(LaunchpadOAuthAwareHttp._bad_oauth_token�sO�����#�%�
����/�0�
;��!�!�"2�3�
;��!�!�"9�:�	
r'c�R��tt|�
|�\}}|j||g|���SrE)rHrC�_request�retry_on_bad_token)r#rJrOrPrKs    �r%rSz LaunchpadOAuthAwareHttp._request�s9���!�"9�4�I�
�
���'�'�t�&�&�x��@�4�@�@r'c��|j||�rp|j�dd|jj_|j|jj|jj
�|j|�S||fS)zxIf the response indicates a bad token, get a new token and retry.

        Otherwise, just return the response.
        N)rQrGrF�credentials�access_token�credential_storerS)r#rOrPrJs    r%rTz*LaunchpadOAuthAwareHttp.retry_on_bad_token�sy��
�!�!�(�G�4��)�)�5�7;�D�N�N�&�&�3��%�%����*�*�D�N�N�,K�,K�
�!�4�=�=�$�'�'��� � r')	r*r+r,r-rIrQrSrT�
__classcell__�rKs@r%rCrCs���L�=�

�A�!r'rCc����eZdZdZdZeeeee	d�Z
e
jej�e
jddeef�fd�	Zd�Zed��Zed��Zed	��Zee
jddedddddef
d
��Zee
jddedgdddef
d��Zed��Zee
jddeefd
��Zede
jddeddddedddf
d��Zed��Ze	dd��Zedd��Z�xZS)rz�Root Launchpad API class.

    :ivar credentials: The credentials instance used to access Launchpad.
    :type credentials: `Credentials`
    z1.0)�bugs�
distributions�people�project_groups�projectsNc	����tj|�}|j|�s|j|dz�rd|z}	t|	��||_||_tt|�#||||||�y)arRoot access to the Launchpad API.

        :param credentials: The credentials used to access Launchpad.
        :type credentials: `Credentials`
        :param authorization_engine: The object used to get end-user input
            for authorizing OAuth request tokens. Used when an OAuth
            access token expires or becomes invalid during a
            session, or is discovered to be invalid once launchpadlib
            starts up.
        :type authorization_engine: `RequestTokenAuthorizationEngine`
        :param service_root: The URL to the root of the web service.
        :type service_root: string
        �/z�It looks like you're using a service root that incorporates the name of the web service version ("%s"). Please use one of the constants from launchpadlib.uris instead, or at least remove the version name from the root URI.N)	r�lookup_service_root�endswith�
ValueErrorrXrGrHrrI)r#rVrGrX�service_root�cache�timeout�
proxy_info�version�errorrKs          �r%rIzLaunchpad.__init__�s����0�/�/��=��� � ��)�\�-B�-B��c�M�.
�6�9@�	@�
��U�#�#� 0���
%9��!�
�i��'���u�g�z�7�	
r'c�6�t||j||||�SrE)rCrG)r#rVrgrhris     r%�httpFactoryzLaunchpad.httpFactory�s'��&���%�%�����

�	
r'c�Z�hd�ttjj��zS)N>�SUDO_GID�SUDO_UID�	SUDO_USER)�set�os�environ�keys)�clss r%�_is_sudozLaunchpad._is_sudo�s��4�s�2�:�:�?�?�;L�7M�M�Mr'c�B�|j�rt|�St|�SrE)rwrr)rvrJs  r%�authorization_engine_factoryz&Launchpad.authorization_engine_factory�s#���<�<�>�
0��6�6�/��6�6r'c�R�|j�rt|�St|d��S)NT)�fallback)rwrr)rv�credential_save_faileds  r%�credential_store_factoryz"Launchpad.credential_store_factorys'���<�<�>�
)�)?�@�@�%�&<�t�L�Lr'c
���|jd�t||�}t||��}|�|j|||	�}|�|j	|�}|||||||||
�S)aConvenience method for setting up access credentials.

        When all three pieces of credential information (the consumer
        name, the access token and the access secret) are available, this
        method can be used to quickly log into the service root.

        This method is deprecated as of launchpadlib version
        1.9.0. You should use Launchpad.login_anonymously() for
        anonymous access, and Launchpad.login_with() for all other
        purposes.

        :param consumer_name: the application name.
        :type consumer_name: string
        :param token_string: the access token, as appropriate for the
            `AccessToken` constructor
        :type token_string: string
        :param access_secret: the access token's secret, as appropriate for
            the `AccessToken` constructor
        :type access_secret: string
        :param service_root: The URL to the root of the web service.
        :type service_root: string
        :param authorization_engine: See `Launchpad.__init__`. If you don't
            provide an authorization engine, a default engine will be
            constructed using your values for `service_root` and
            `credential_save_failed`.
        :param allow_access_levels: This argument is ignored, and only
            present to preserve backwards compatibility.
        :param max_failed_attempts: This argument is ignored, and only
            present to preserve backwards compatibility.
        :return: The web service root
        :rtype: `Launchpad`
        �login)�
consumer_namerW)� _warn_of_deprecated_login_methodr
rryr})rvr��token_string�
access_secretrfrgrhrirG�allow_access_levels�max_failed_attemptsrXr|rjrWrVs                r%rzLaunchpad.logins���b	�,�,�W�5�"�<��?��!�'�l�
�� �'�#&�#C�#C��m�-@�$� ��#�"�;�;�&� ���� �������	
�		
r'c�X�|jd�|j||||||||	|
|�
S)a�Get credentials from Launchpad and log into the service root.

        This method is deprecated as of launchpadlib version
        1.9.0. You should use Launchpad.login_anonymously() for
        anonymous access and Launchpad.login_with() for all other
        purposes.

        :param consumer_name: Either a consumer name, as appropriate for
            the `Consumer` constructor, or a premade Consumer object.
        :type consumer_name: string
        :param service_root: The URL to the root of the web service.
        :type service_root: string
        :param authorization_engine: See `Launchpad.__init__`. If you don't
            provide an authorization engine, a default engine will be
            constructed using your values for `service_root` and
            `credential_save_failed`.
        :param allow_access_levels: This argument is ignored, and only
            present to preserve backwards compatibility.
        :return: The web service root
        :rtype: `Launchpad`
        �get_token_and_login)r��_authorize_token_and_login)rvr�rfrgrhrirGr�r�rXr|rjs            r%r�zLaunchpad.get_token_and_loginUsE��H	�,�,�-B�C��-�-������ ���"��
�	
r'c
��t|t�r|}nt|�}td�}||_|�|j||d|�}|�|j
|	�}n|jd|	|jd�|j|j�}
|
�
|||�}n|
}|j|j_|||||||||
�S)aEAuthorize a request token. Log in with the resulting access token.

        This is the private, non-deprecated implementation of the
        deprecated method get_token_and_login(). Once
        get_token_and_login() is removed, this code can be streamlined
        and moved into its other call site, login_with().
        Nr|rX)�
isinstancerrr�consumerryr}�"_assert_login_argument_consistencyr|�load�unique_consumer_id�application_name)rvr�rfrgrhrirGr�rXr|rjr�rV�cached_credentialss              r%r�z$Launchpad._authorize_token_and_login�s
��*�m�X�.�$�H�
*�-�8�H�"�$�'��'����'�#&�#C�#C��m�T�3F�$� ��#�"�;�;�&� ��
�2�2�(�&� �7�7�"�	
�.�2�2� �3�3�
���%�/�{�<L�M�K�-�K�$�5�5�
� � �1��� �������	
�		
r'c
�~�|j||�\}}}}t�}	t||	��}
||
dd|||||��S)z:Get access to Launchpad without providing any credentials.)rWN)rfrgrhrirj)�
_get_pathsrr)rvr�rf�launchpadlib_dirrhrirj�
cache_path�service_root_dir�tokenrVs           r%�login_anonymouslyzLaunchpad.login_anonymously�s]�� 
�N�N�<�)9�:�	
�����$�&��!�-�e�D������%���!��	
�		
r'c�p�|j||�\}}}}|�|�
|�td��|	�tjj	d�}	|	�
|
�td��|
�!|	�
t|	|�}
n2|j
|�}
n |jd||
jd�|
}
|�|j||||�}na|jd||j�|jd||jj�|jd||j�|j|j|||||||
||
�
S)	a�Log in to Launchpad, possibly acquiring and storing credentials.

        Use this method to get a `Launchpad` object. If the end-user
        has no cached Launchpad credential, their browser will open
        and they'll be asked to log in and authorize a desktop
        integration. The authorized Launchpad credential will be
        stored securely: in the GNOME keyring, the KDE Wallet, or in
        an encrypted file on disk.

        The next time your program (or any other program run by that
        user on the same computer) invokes this method, the end-user
        will be prompted to unlock their keyring (or equivalent), and
        the credential will be retrieved from local storage and
        reused.

        You can customize this behavior in three ways:

        1. Pass in a filename to `credentials_file`. The end-user's
           credential will be written to that file, and on subsequent
           runs read from that file. Alternatively the filename can be
           given in the LP_CREDENTIALS_FILE environment variable.

        2. Subclass `CredentialStore` and pass in an instance of the
           subclass as `credential_store`. This lets you change how
           the end-user's credential is stored and retrieved locally.

        3. Subclass `RequestTokenAuthorizationEngine` and pass in an
           instance of the subclass as `authorization_engine`. This
           lets you change change what happens when the end-user needs
           to authorize the Launchpad credential.

        :param application_name: The application name. This is *not*
            the OAuth consumer name. Unless a consumer_name is also
            provided, the OAuth consumer will be a system-wide
            consumer representing the end-user's computer as a whole.
        :type application_name: string

        :param service_root: The URL to the root of the web service.
        :type service_root: string.  Can either be the full URL to a service
            or one of the short service names.

        :param launchpadlib_dir: The directory used to store cached
           data obtained from Launchpad. The cache is shared by all
           consumers, and each Launchpad service root has its own
           cache.
        :type launchpadlib_dir: string

        :param authorization_engine: A strategy for getting the
            end-user to authorize an OAuth request token, for
            exchanging the request token for an access token, and for
            storing the access token locally so that it can be
            reused. By default, launchpadlib will open the end-user's
            web browser to have them authorize the request token.
        :type authorization_engine: `RequestTokenAuthorizationEngine`

        :param allow_access_levels: The acceptable access levels for
            this application.

            This argument is used to construct the default
            `authorization_engine`, so if you pass in your own
            `authorization_engine` any value for this argument will be
            ignored. This argument will also be ignored unless you
            also specify `consumer_name`.

        :type allow_access_levels: list of strings

        :param max_failed_attempts: Ignored; only present for
            backwards compatibility.

        :param credentials_file: The path to a file in which to store
            this user's OAuth access token.

        :param version: The version of the Launchpad web service to use.

        :param consumer_name: The consumer name, as appropriate for
            the `Consumer` constructor. You probably don't want to
            provide this, since providing it will prevent you from
            taking advantage of desktop-wide integration.
        :type consumer_name: string

        :param credential_save_failed: a callback that is called upon
           a failure to save the credentials locally. This argument is
           used to construct the default `credential_store`, so if
           you pass in your own `credential_store` any value for
           this argument will be ignored.
        :type credential_save_failed: A callable

        :param credential_store: A strategy for storing an OAuth
            access token locally. By default, tokens are stored in the
            GNOME keyring (or equivalent). If `credentials_file` is
            provided, then tokens are stored unencrypted in that file.
        :type credential_store: `CredentialStore`

        :return: A web service root authorized as the end-user.
        :rtype: `Launchpad`

        zZAt least one of application_name, consumer_name, or authorization_engine must be provided.�LP_CREDENTIALS_FILEzFAt most one of credentials_file and credential_store must be provided.r|rXr�r�r�)r�rersrt�getrr}r�r|ryr�r�r$r�r�)rvr�rfr�rhrirGr�r��credentials_filerjr�r|rXr�r�s                r%�
login_withzLaunchpad.login_with�s���n
�N�N�<�)9�:�	
�����
�$��%�$�,��9��
�
�#�!�z�z�~�~�.C�D���'�,<�,H��$��
�
�#��+�$B�$�&<�$� �$'�#?�#?�*�$� �
�2�2�(�&� �7�7�"�	
� 0���'�#&�#C�#C�� ��#�	$� �
�2�2�"� �$�5�5�
�
�2�2���$�-�-�1�1�
�
�2�2�%�#�$�8�8�
��-�-� �)�)����� ���"��
�	
r'c�>�tjd|zt�y)Nz�The Launchpad.%s() method is deprecated. You should use Launchpad.login_anonymous() for anonymous access and Launchpad.login_with() for all other purposes.)�warnings�warn�DeprecationWarning)rv�names  r%r�z*Launchpad._warn_of_deprecated_login_method�s#���
�
�A��
�
�	
r'c	�@�d}|�||k7rt|||||||fz��yy)a�Helper to find conflicting values passed into the login methods.

        Many of the arguments to login_with are used to build other
        objects--the authorization engine or the credential store. If
        these objects are provided directly, many of the arguments
        become redundant. We'll allow redundant arguments through, but
        if a argument *conflicts* with the corresponding value in the
        provided object, we raise an error.
        z�Inconsistent values given for %s: (%r passed in, versus %r in %s). You don't need to pass in %s if you pass in %s, so just omit that argument.N)re)rv�
argument_name�argument_value�object_value�object_name�inconsistent_value_messages      r%r�z,Launchpad._assert_login_argument_consistency�sP��$
*�	#��%�.�L�*H��*�!�"� ��!��
��
�

�+I�%r'c���|� tjjdd�}tjj|�}|dddk(rt	d��	tj
|d�tj|d�tj|�}t|�\}}}}}tjj||�}	tjj|	d�}
	tj
|
d�|||
|	fS#t$r(}|jtjk7r�Yd}~��d}~wwxYw#t$r(}|jtjk7r�Yd}~�fd}~wwxYw)a�Locate launchpadlib-related user paths and ensure they exist.

        This is a helper function used by login_with() and
        login_anonymously().

        :param service_root: The service root the user wants to
            connect to. This may be an alias (which will be
            dereferenced to a URL and returned) or a URL (which will
            be returned as is).
        :param launchpadlib_dir: The user's base launchpadlib
            directory, if known. This may be modified, expanded, or
            determined from the environment if missing. A definitive
            value will be returned.

        :return: A 4-tuple:
            (service_root_uri, launchpadlib_dir, cache_dir, service_root_dir)
        Nrz
.launchpadlib�zSMust set $HOME or pass 'launchpadlib_dir' to indicate location to store cached datai�rg)
rs�path�join�
expanduserre�makedirs�OSError�errno�EEXIST�chmodrrcr)rvrfr��err�scheme�	host_namer��query�fragmentr�r�s           r%r�zLaunchpad._get_paths�sD��&�#�!�w�w�|�|�C��A���7�7�-�-�.>�?���B�Q��3�&��9��
�	��K�K�(�%�0�	���!�5�)��/�/��=��3;�L�3I�0��	�4����7�7�<�<�(8�)�D���W�W�\�\�"2�G�<�
�	��K�K�
�E�*��.�
�<L�M�M���	��y�y�E�L�L�(��)��	���	��y�y�E�L�L�(��)��	�s0�D�)D9�	D6�D1�1D6�9	E*�E%�%E*)zauthorization enginerE)r*r+r,r-�DEFAULT_VERSIONr1r@rr<r8�RESOURCE_TYPE_CLASSES�updater
rrrrIrm�classmethodrwryr}rr�r�r�r�r�r�r�rYrZs@r%rr�s������O��(��)����� � ��!B�!B�C��.�.���.��.
�`
��N��N��7��7��M��M���.�.���.�!� � ��#��F
��F
�P��.�.���.�!�� ��#��/
��/
�b�Q
��Q
�f��.�.���.��
��
�:���.�.���.�!� � ����#��M
��M
�^�	
��	
��+�!��!�F�+N��+Nr')0r-�type�
__metaclass__�__all__r�rs�urllib.parser�ImportError�urlparser��httplib2rr�from_environment�lazr.restfulclient.resourcerrr	r
�"lazr.restfulclient.authorize.oauthr�lazr.restfulclient._browserr�launchpadlib.credentialsr
rrrrrrrr�launchpadlibr�launchpadlib.urisrr�OAUTH_REALMrr1r5r8r<r@rCrr/r'r%�<module>r�s��" ��
����
�	�"�%��=�4���B�3�
�
�
���
*��
�,�
��
)���,�����$�i�$�#�i�#�&!�k�&!�R}	N��}	N��W�"�!�"���=�"�"+�"<�"<��=�s"�B9�C
�9C�C�
C$�#C$

Zerion Mini Shell 1.0