File: //kunden/lib/python3/dist-packages/fastimport/__pycache__/processor.cpython-39.pyc
a
�+yW� � @ sP d Z ddlZddlZddlmZ ddlmZ G dd� de�ZG dd� de�Z dS ) a$ Processor for fast-import commands.
This module provides the skeleton of a fast-import backend.
To import from a fast-import stream to your version-control system:
- derive a class from the abstract ImportProcessor class and
implement the *_helper methods.
- parse a fast-import stream into a sequence of commands, for example
using the helpers from the parser module.
- pass that command sequence to the process method of your processor.
See git-fast-import.1 for the meaning of each command and the
processors package for examples.
� N)�errors)� newobjectc @ s� e Zd ZdZg Zd(dd�Zdd� Zdd � Zd
d� Zdd
� Z dd� Z
dd� Zdd� Zdd� Z
dd� Zdd� Zdd� Zdd� Zdd� Zd d!� Zd"d#� Zd$d%� Zd&d'� ZdS ))�ImportProcessorz�Base class for fast-import stream processors.
Subclasses should override the pre_*, post_* and *_handler
methods as appropriate.
NFc C sF |d u rt j| _n|| _|| _|d u r.i | _n|| _| �� d| _d S )NF)�sys�stdout�outf�verbose�params�validate_parameters�finished)�selfr r r � r
�6/usr/lib/python3/dist-packages/fastimport/processor.py�__init__0 s
zImportProcessor.__init__c C s( | j D ]}|| jvrt�|| j��qdS )z5Validate that the parameters are correctly specified.N)r �known_paramsr ZUnknownParameter)r �pr
r
r r
@ s
z#ImportProcessor.validate_parametersc C s | � |� dS )z�Import data into Bazaar by processing a stream of commands.
:param command_iter: an iterator providing commands
N)�_process)r �command_iterr
r
r �processF s zImportProcessor.processc C s� | � � |� D ]l}z |jd �d�}t| j|�}W n tyP t�|j��Y n 0 | �|� || |� | � |� | j
r q|q| �� d S )N� _handler�utf8)�pre_process�name�decode�getattr� __class__�KeyErrorr �MissingHandler�pre_handler�post_handlerr �post_process)r r �cmdr �handlerr
r
r r M s
zImportProcessor._processc G s dS )z"Output a warning but timestamp it.Nr
�r �msg�argsr
r
r �warning] s zImportProcessor.warningc G s dS )zOutput a debug message.Nr
)r Zmgsr% r
r
r �debuga s zImportProcessor.debugc C s
t �d�S )zTime of day as a string.z%H:%M:%S)�time�strftime�r r
r
r �_time_of_daye s zImportProcessor._time_of_dayc C s dS )z&Hook for logic at start of processing.Nr
r* r
r
r r j s zImportProcessor.pre_processc C s dS )z$Hook for logic at end of processing.Nr
r* r
r
r r n s zImportProcessor.post_processc C s dS )z*Hook for logic before each handler starts.Nr
�r r! r
r
r r r s zImportProcessor.pre_handlerc C s dS )z+Hook for logic after each handler finishes.Nr
r, r
r
r r v s zImportProcessor.post_handlerc C s t | j��dS )zProcess a ProgressCommand.N)�NotImplementedError�progress_handlerr, r
r
r r. z s z ImportProcessor.progress_handlerc C s t | j��dS )zProcess a BlobCommand.N)r- �blob_handlerr, r
r
r r/ ~ s zImportProcessor.blob_handlerc C s t | j��dS )zProcess a CheckpointCommand.N)r- �checkpoint_handlerr, r
r
r r0 � s z"ImportProcessor.checkpoint_handlerc C s t | j��dS )zProcess a CommitCommand.N)r- �commit_handlerr, r
r
r r1 � s zImportProcessor.commit_handlerc C s t | j��dS )zProcess a ResetCommand.N)r- �
reset_handlerr, r
r
r r2 � s zImportProcessor.reset_handlerc C s t | j��dS )zProcess a TagCommand.N)r- �tag_handlerr, r
r
r r3 � s zImportProcessor.tag_handlerc C s t | j��dS )zProcess a FeatureCommand.N)r- �feature_handlerr, r
r
r r4 � s zImportProcessor.feature_handler)NFN)�__name__�
__module__�__qualname__�__doc__r r r
r r r&