File: //kunden/lib/python3/dist-packages/dulwich/__pycache__/objectspec.cpython-39.pyc
a
�~�_� � @ sl d Z dd� Zdd� Zdd� Zdd� Zdd
d�Zddd
�Zdd� Zdd� ZG dd� de �Z
dd� Zdd� ZdS )zObject specification.c C s t | dd �d ur| �d�} | S )N�encode�ascii)�getattrr )�text� r �4/usr/lib/python3/dist-packages/dulwich/objectspec.py�to_bytes s
r c C s t |�}| | S )z�Parse a string referring to an object.
Args:
repo: A `Repo` object
objectish: A string referring to an object
Returns: A git object
Raises:
KeyError: If the object can not be found
)r )�repoZ objectishr r r �parse_object s
r c C s( t |�}| | }|jdkr$| |j S |S )z�Parse a string referring to a tree.
Args:
repo: A `Repo` object
treeish: A string referring to a tree
Returns: A git object
Raises:
KeyError: If the object can not be found
s commit)r Z type_nameZtree)r Ztreeish�or r r �
parse_tree, s
r c C sV t |�}|d| d| d| d| d| d g}|D ]}|| v r4| S q4t|��dS )z�Parse a string referring to a reference.
Args:
container: A RefsContainer object
refspec: A string referring to a ref
Returns: A ref
Raises:
KeyError: If the ref can not be found
s refs/s
refs/tags/� refs/heads/s
refs/remotes/s /HEADN)r �KeyError)� container�refspecZ
possible_refs�refr r r � parse_ref= s
�
r Fc C s� t |�}|�d�r"d}|dd� }d|v r:|�d�\}}n| }}|dkrPd}n
t| |�}|dkrhd}n2zt||�}W n" ty� d|vr�d| }Y n0 |||fS ) a Parse a reftuple spec.
Args:
lh_container: A RefsContainer object
hh_container: A RefsContainer object
refspec: A string
Returns: A tuple with left and right ref
Raises:
KeyError: If one of the refs can not be found
� +T� N� :� � /r )r �
startswith�splitr r
)�lh_container�rh_containerr �forceZlhZrhr r r �parse_reftupleV s$
r c C s8 t |t�s|g}g }|D ]}|�t| |||d�� q|S )aX Parse a list of reftuple specs to a list of reftuples.
Args:
lh_container: A RefsContainer object
hh_container: A RefsContainer object
refspecs: A list of refspecs or a string
force: Force overwriting for all reftuples
Returns: A list of refs
Raises:
KeyError: If one of the refs can not be found
)r )�
isinstance�list�appendr )r r �refspecsr �retr r r r �parse_reftuplesy s
�
r"