File: //kunden/lib/python3/dist-packages/breezy/__pycache__/treebuilder.cpython-39.pyc
a
�*�^X � @ sT d Z ddlmZ ddlmZ G dd� dej�ZG dd� dej�ZG d d
� d
e�Z dS )z�TreeBuilder helper class.
TreeBuilders are used to build trees of various shapes or properties. This
can be extremely useful in testing for instance.
� )�absolute_import� )�errorsc @ s e Zd ZdZdS )�AlreadyBuildingz,The tree builder is already building a tree.N��__name__�
__module__�__qualname__Z_fmt� r
r
�4/usr/lib/python3/dist-packages/breezy/treebuilder.pyr s r c @ s e Zd ZdZdS )�NotBuildingzNot currently building a tree.Nr r
r
r
r r ! s r c @ s8 e Zd ZdZdd� Zdd� Zdd� Zdd � Zd
d� ZdS )
�TreeBuilderzUA TreeBuilder allows the creation of specific content in one tree at a
time.
c C s d| _ d| _dS )zConstruct a TreeBuilder.NF)�_tree�
_root_done��selfr
r
r �__init__+ s zTreeBuilder.__init__c C s� | � � | js$| j�ddd� d| _|D ]X}|�d�rL| j�|dd� � q(d}d |�d
�|f }| j�|dd� | j�||� q(dS )a Build recipe into the current tree.
:param recipe: A sequence of paths. For each path, the corresponding
path in the current tree is created and added. If the path ends in
'/' then a directory is added, otherwise a regular file is added.
� s root-idZ directoryT�/N����
s contents of %s%szutf-8�file)�_ensure_buildingr r �add�endswith�mkdir�encodeZput_file_bytes_non_atomic)r Zrecipe�name�endZcontentr
r
r �build0 s
zTreeBuilder.buildc C s | j du rt�dS )z:Raise NotBuilding if there is no current tree being built.N)r r r r
r
r r D s
zTreeBuilder._ensure_buildingc C s | � � | j}d| _|�� dS )z!Finish building the current tree.N)r r Zunlock�r Ztreer
r
r �finish_treeI s zTreeBuilder.finish_treec C s"