Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/pygit2/__pycache__/callbacks.cpython-39.pyc
Ðазад
a n�h�= � @ s d Z ddlmZ ddlmZ ddlmZ ddlmZm Z ddl m Z mZ ddlm Z mZ G d d � d �ZG dd� de�Zed*dd��Zed+dd��Zed,dd��Zedd� �Zdd� Zedd� �Zedd� �Zedd� �Zedd� �Zed d!� �Zed"d#� �Zed$d%� �Zed&d'� �Zd(d)� Zd S )-a� In this module we keep everything concerning callback. This is how it works, with an example: 1. The pygit2 API calls libgit2, it passes a payload object e.g. Remote.fetch calls git_remote_fetch 2. libgit2 calls Python callbacks e.g. git_remote_fetch calls _transfer_progress_cb 3. Optionally, the Python callback may proxy to a user defined function e.g. _transfer_progress_cb calls RemoteCallbacks.transfer_progress 4. The user defined function may return something on success, or raise an exception on error, or raise the special Passthrough exception. 5. The callback may return in 3 different ways to libgit2: - Returns GIT_OK on success. - Returns GIT_PASSTHROUGH if the user defined function raised Passthrough, this tells libgit2 to act as if this callback didn't exist in the first place. - Returns GIT_EUSER if another exception was raised, and keeps the exception in the payload to be re-raised later. 6. libgit2 returns to the pygit2 API, with an error code e.g. git_remote_fetch returns to Remote.fetch 7. The pygit2 API will: - Return something on success. - Raise the original exception if libgit2 returns GIT_EUSER - Raise another exception if libgit2 returns another error code The payload object is passed all the way, so pygit2 API can send information to the inner user defined function, and this can send back results to the pygit2 API. � )�contextmanager)�wraps� )�Oid)�check_error�Passthrough)�ffi�C)�maybe_string�to_bytesc @ s e Zd Zdd� Zdd� ZdS )�Payloadc K s( |� � D ]\}}t| ||� qd | _d S �N)�items�setattr�_stored_exception)�self�kw�key�value� r ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/pygit2/callbacks.py�__init__S s zPayload.__init__c C s* |t jkr| jd usJ �| j�t|� d S r )r � GIT_EUSERr r )r Z error_coder r r r X s zPayload.check_errorN)�__name__� __module__�__qualname__r r r r r r r Q s r c sR e Zd ZdZd� fdd� Zdd� Zdd� Zd d � Zdd� Zd d� Z dd� Z � ZS )�RemoteCallbacksa Base class for pygit2 remote callbacks. Inherit from this class and override the callbacks which you want to use in your class, which you can then pass to the network operations. For the credentials, you can either subclass and override the 'credentials' method, or if it's a constant value, pass the value to the constructor, e.g. RemoteCallbacks(credentials=credentials). You can as well pass the certificate the same way, for example: RemoteCallbacks(certificate=certificate). Nc s* t � �� |d ur|| _|d ur&|| _d S r )�superr �credentials�certificate)r r r �� __class__r r r n s zRemoteCallbacks.__init__c C s dS )z� Progress output callback. Override this function with your own progress reporting function Parameters: string : str Progress output from the remote. Nr )r �stringr r r �sideband_progressu s z!RemoteCallbacks.sideband_progressc C s t �dS )a Credentials callback. If the remote server requires authentication, this function will be called and its return value used for authentication. Override it if you want to be able to perform authentication. Returns: credential Parameters: url : str The url of the remote. username_from_url : str or None Username extracted from the url, if any. allowed_types : int Credential types supported by the remote. N�r )r �urlZusername_from_urlZ allowed_typesr r r r � s zRemoteCallbacks.credentialsc C s t �dS )a Certificate callback. Override with your own function to determine whether to accept the server's certificate. Returns: True to connect, False to abort. Parameters: certificate : None The certificate. It is currently always None while we figure out how to represent it cross-platform. valid : bool Whether the TLS/SSH library thinks the certificate is valid. host : str The hostname we want to connect to. Nr$ )r r �valid�hostr r r �certificate_check� s z!RemoteCallbacks.certificate_checkc C s dS )z� Transfer progress callback. Override with your own function to report transfer progress. Parameters: stats : TransferProgress The progress up to now. Nr )r �statsr r r �transfer_progress� s z!RemoteCallbacks.transfer_progressc C s dS )aH Update tips callback. Override with your own function to report reference updates. Parameters: refname : str The name of the reference that's being updated. old : Oid The reference's old value. new : Oid The reference's new value. Nr )r �refname�old�newr r r �update_tips� s zRemoteCallbacks.update_tipsc C s dS )aT Push update reference callback. Override with your own function to report the remote's acceptance or rejection of reference updates. refname : str The name of the reference (on the remote). message : str Rejection message from the remote. If None, the update was accepted. Nr )r r+ �messager r r �push_update_reference� s z%RemoteCallbacks.push_update_reference)NN)r r r �__doc__r r# r r( r* r. r0 � __classcell__r r r r r ` s r Nc c sh |d u r t �d�}t�|tj� t �| �}| jr>tj|_||_ | j rRtj|_||_ d | _|| _| V d S )Nzgit_clone_options *)r r- r Zgit_clone_options_initZGIT_CLONE_OPTIONS_VERSION� new_handle� repository�_repository_create_cbZ repository_cbZrepository_cb_payload�remote�_remote_create_cbZ remote_cbZremote_cb_payloadr Z clone_options��payload�opts�handler r r �git_clone_options� s r<