HEX
Server: Apache
System: Linux infong-uk86 4.4.400-icpu-106 #2 SMP Mon Sep 15 08:23:40 UTC 2025 x86_64
User: u44115835 (4976590)
PHP: 8.4.17
Disabled: NONE
Upload Files
File: //kunden/lib/python3/dist-packages/dulwich/__pycache__/config.cpython-39.pyc
a

�~�_�C�@s|dZddlZddlZddlmZmZmZddlmZzddl	m
Z
mZWn"eyjddlm
Z
mZYn0ddl
mZe�Zdd�ZGd	d
�d
e�ZGdd�de�ZGd
d�dee�Zdd�Zed�ed�ed�ed�ed�ed�ed�ed�ed�ed�iZed�ed�gZed�ed�gZdd�Zdd�Zd d!�Zd"d#�Zd$d%�ZGd&d'�d'e�Zd(d)�Z Gd*d+�d+e�Z!d,d-�Z"dS).z�Reading and writing Git configuration files.

TODO:
 * preserve formatting when updating configuration files
 * treat subsection names as case-insensitive for [branch.foo] style
   subsections
�N)�BinaryIO�Tuple�Optional)�OrderedDict)�Iterable�MutableMapping)�GitFilecCs6t|ttf�r|��St|t�r2t|�tt|��S|S�N)�
isinstance�bytes�str�lowerr�type�map�	lower_key)�key�r�0/usr/lib/python3/dist-packages/dulwich/config.pyr6s
�rcsNeZdZeddd��Z�fdd�Z�fdd�Zefdd	�Zefd
d�Z	�Z
S)
�CaseInsensitiveDictNcCsLt||�r|S|�}|dur |St|t�s.t�|��D]\}}|||<q6|Sr	)r
r�	TypeError�items)�clsZdict_in�outr�valuerrr�makeDs


zCaseInsensitiveDict.makecs&t|�}tt|�j||fi|��dSr	)r�superr�__setitem__)�selfrr�kwargs��	__class__rrrWszCaseInsensitiveDict.__setitem__cst|�}tt|��|�Sr	)rrr�__getitem__)r�itemrrrrr!\szCaseInsensitiveDict.__getitem__cCs4z
||WStyYn0|tur0t|��S|Sr	)�KeyError�SENTINALr�rr�defaultrrr�getas

zCaseInsensitiveDict.getcCs6z
||WSty,|�||�||<Yn0||Sr	)r#r'r%rrr�
setdefaultls

zCaseInsensitiveDict.setdefault)N)�__name__�
__module__�__qualname__�classmethodrrr!r$r'r(�
__classcell__rrrrrBsrc@sBeZdZdZdd�Zddd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�ConfigzA Git configuration.cCst|j��dS)a'Retrieve the contents of a configuration setting.

        Args:
          section: Tuple with section name and optional subsection namee
          subsection: Subsection name
        Returns:
          Contents of the setting
        Raises:
          KeyError: if the value is not set
        N)�NotImplementedErrorr'�r�section�namerrrr'xsz
Config.getNcCsXz|�||�}Wnty&|YS0|��dkr8dS|��dkrHdStd|��dS)aWRetrieve a configuration setting as boolean.

        Args:
          section: Tuple with section name and optional subsection name
          name: Name of the setting, including section and possible
            subsection.
        Returns:
          Contents of the setting
        Raises:
          KeyError: if the value is not set
        �trueT�falseFznot a valid boolean string: %rN)r'r#r
�
ValueError)rr1r2r&rrrr�get_boolean�s
zConfig.get_booleancCst|j��dS)a	Set a configuration value.

        Args:
          section: Tuple with section name and optional subsection namee
          name: Name of the configuration value, including section
            and optional subsection
           value: value of the setting
        N)r/�set�rr1r2rrrrr7�s	z
Config.setcCst|j��dS)z�Iterate over the configuration pairs for a specific section.

        Args:
          section: Tuple with section name and optional subsection namee
        Returns:
          Iterator over (name, value) pairs
        N)r/�	iteritems�rr1rrrr9�szConfig.iteritemscCst|j��dS)zRIterate over the sections.

        Returns: Iterator over section tuples
        N)r/�itersections�rrrrr;�szConfig.itersectionscCs||��vS)z�Check if a specified section exists.

        Args:
          name: Name of section to check for
        Returns:
          boolean indicating whether the section exists
        )r;)rr2rrr�has_section�szConfig.has_section)N)
r)r*r+�__doc__r'r6r7r9r;r=rrrrr.us

r.c@s�eZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zedd��Z
dd�Zdd�Zdd�Zdd�Zdd�ZdS) �
ConfigDictz)Git configuration stored in a dictionary.NcCs&|durt��}||_t�|�|_dS)zCreate a new ConfigDict.N)�sys�getdefaultencoding�encodingrr�_values�r�valuesrBrrr�__init__�szConfigDict.__init__cCsd|jj|jfS)Nz%s(%r))r r)rCr<rrr�__repr__�szConfigDict.__repr__cCst||j�o|j|jkSr	)r
r rC)r�otherrrr�__eq__�s
�zConfigDict.__eq__cCs|j�|�Sr	)rCr!�rrrrrr!�szConfigDict.__getitem__cCs|j�||�Sr	)rCr)rrrrrrr�szConfigDict.__setitem__cCs|j�|�Sr	)rC�__delitem__rJrrrrK�szConfigDict.__delitem__cCs
|j��Sr	)rC�__iter__r<rrrrL�szConfigDict.__iter__cCs
|j��Sr	)rC�__len__r<rrrrM�szConfigDict.__len__cCsB|�d�}t|�dkr,|d|d|dfS|dd|dfSdS)N�.�r��)�split�len)rr2�partsrrr�_parse_setting�s
zConfigDict._parse_settingcsDt|t�s|f}t�fdd�|D��}t|t�s<|��j�}||fS)Ncs&g|]}t|t�s|��j�n|�qSr)r
r�encoderB)�.0Z
subsectionr<rr�
<listcomp>�s��z6ConfigDict._check_section_and_name.<locals>.<listcomp>)r
�tuplerrVrBr0rr<r�_check_section_and_name�s
�
z"ConfigDict._check_section_and_namecCsT|�||�\}}t|�dkr@z|j||WSty>Yn0|j|df|S)NrPr)rZrSrCr#r0rrrr'�szConfigDict.getcCs@|�||�\}}t|�ttfvr,|�|j�}||j�|�|<dSr	)rZr�boolrrVrBrCr(r8rrrr7szConfigDict.setcCs|j�|���Sr	)rCr'rr:rrrr9
szConfigDict.iteritemscCs
|j��Sr	)rC�keysr<rrrr;szConfigDict.itersections)NN)r)r*r+r>rFrGrIr!rrKrLrMr,rUrZr'r7r9r;rrrrr?�s 

r?cCsL|�d�s0|�d�s0|�d�s0d|vs0|�d�r@dt|�dSt|�SdS)N� �	�#�")�
startswith�endswith�
_escape_value�rrrr�_format_strings
����re�\r`�n�
�tr^�b�r_�;r]cCs>t|���}t�}t�}d}d}|t|�k�r(||}|td�kr�|d7}zt||}WnHty|td||f��Yn(ty�td||||f��Yn0|r�|�|�t�}|�	|�nZ|td�kr�|}nF|t
vr�|s�q(n4|tvr�|�	|�n |�r|�|�t�}|�	|�|d7}q |�r6td��t|�S)	NFrrfrPz1escape character in %r at %d before end of stringz=escape character followed by unknown character %s at %d in %rr`zmissing end quote)
�	bytearray�striprS�ord�
_ESCAPE_TABLE�
IndexErrorr5r#�extend�append�_COMMENT_CHARS�_WHITESPACE_CHARSr)r�retZ
whitespaceZ	in_quotes�i�c�vrrr�
_parse_string*sR����




rzcCs4|�dd�}|�dd�}|�dd�}|�dd�}|S)	zEscape a value.rfs\\rhs\nr^s\tr`s\")�replacerdrrrrcVs
rccCs<tt|��D]*}|||d�}|��s|dkrdSqdS)NrP�-FT��rangerS�isalnum�r2rwrxrrr�_check_variable_name_s
r�cCs<tt|��D]*}|||d�}|��s|dvrdSqdS)NrP)r|�.FTr}r�rrr�_check_section_namegs
r�cCsbtd�td�h}td�}d}tt|��D]4\}}||kr@|}q(|s(||vr(|d|�Sq(|S)Nr_rlr`F)ro�	enumeraterm)�lineZ
comment_bytesZquoteZstring_openrw�	characterrrr�_strip_commentsosr�csheZdZdZd�fdd�	Zeedd�dd��Zedd�d	d
��Zddd�dd�Z	edd�d
d�Z
�ZS)�
ConfigFilez@A Git configuration file, like .git/config or ~/.gitconfig.
    Ncstt|�j||d�d|_dS)N)rErB)rr�rF�pathrDrrrrF�szConfigFile.__init__)�f�returnc	Cs�|�}d}d}d}t|���D�]|\}}|��}|du�rXt|�dk�r�|dd�dk�r�t|���}z|�d�}Wnty�td��Yn0|d|��dd�}	||dd�}t|	�dk�r@|	ddd�d	ks�|	dd
d�d	kr�td|	d��n|	ddd
�|	d<t	|	d��s.td|	d��|	d|	df}nXt	|	d��s^td|	d��|	d�d
d�}	t|	�dk�r�|	d|	df}n
|	df}|j
�|�t|���dk�r�q|du�r�td|��z|�dd�\}}
Wnt�y�|}d}
Yn0|��}t
|��std|��|
�d��r8|
dd�}nd}t|
�}
|
|j
||<d}q|�d��rv||dd�7}q||7}t|�}
|
|j
||<d}d}q|S)z+Read configuration from a file-like object.NrrP�[�]zexpected trailing ]r]rQr`���zInvalid subsection %rzinvalid section name %rr��zsetting %r without section�=r3zinvalid variable name %rs\
���)r��	readlines�lstriprSr��rstrip�indexr5rRr�rCr(rnr�rbrz)rr�rvr1ZsettingZcontinuation�linenor�ZlastZptsrrrr�	from_file�sz
 (
��
�



zConfigFile.from_file)r�cCsBt|d��$}|�|�}||_|Wd�S1s40YdS)z'Read configuration from a file on disk.�rbN)rr�r�)rr�r�rvrrr�	from_path�s
zConfigFile.from_pathcCsF|dur|j}t|d��}|�|�Wd�n1s80YdS)z&Write configuration to a file on disk.N�wb)r�r�
write_to_file)rr�r�rrr�
write_to_path�szConfigFile.write_to_pathc	Cs�|j��D]�\}}z|\}}Wnty:|\}d}Yn0|durX|�d|d�n|�d|d|d�|��D]F\}}|dur�d}n|dur�d	}nt|�}|�d
|d|d�qzq
dS)
z*Write configuration to a file-like object.Nr�s]
s "s"]
Tr3Fr4r^s = rh)rCrr5�writere)rr�r1rE�section_nameZsubsection_namerrrrrr��s,

���zConfigFile.write_to_file)NN)N)r)r*r+r>rFr,rr�r�r�r�r-rrrrr�}sDr�cGs*tj�dtj�d��}tjj|g|�R�S)NZXDG_CONFIG_HOMEz
~/.config/)�os�environr'r��
expanduser�join)Z
path_segmentsZxdg_config_homerrr�get_xdg_config_home_path�s�r�c@sJeZdZdZddd�Zdd�Zedd��Zed	d
��Zdd�Z	d
d�Z
dS)�
StackedConfigz6Configuration which reads from multiple config files..NcCs||_||_dSr	)�backends�writable)rr�r�rrrrF�szStackedConfig.__init__cCsd|jj|jfS)Nz<%s for %r>)r r)r�r<rrrrG�szStackedConfig.__repr__cCs||���Sr	)�default_backends)rrrrr&szStackedConfig.defaultc	Cs|g}|�tj�d��|�tdd��dtjvr:|�d�g}|D]4}zt�|�}WntyjYqBYn0|�|�qB|S)zjRetrieve the default configuration.

        See git-config(1) for details on the files searched.
        z~/.gitconfigZgit�configZGIT_CONFIG_NOSYSTEMz/etc/gitconfig)	rsr�r�r�r�r�r�r��FileNotFoundError)r�pathsr�r�Zcfrrrr�s


zStackedConfig.default_backendsc	CsNt|t�s|f}|jD]*}z|�||�WSty>Yq0qt|��dSr	)r
rYr�r'r#)rr1r2Zbackendrrrr's

zStackedConfig.getcCs$|jdurt|j��|j�|||�Sr	)r�r/r7r8rrrr7%s

zStackedConfig.set)N)r)r*r+r>rFrGr,r&r�r'r7rrrrr��s



r�ccsF|��D]8}|\}}|dkr|�|d�}|�|d�}|||fVqdS)z�Parse a gitmodules GitConfig file, returning submodules.

   Args:
     config: A `ConfigFile`
   Returns:
     list of tuples (submodule path, url, name),
       where name is quoted part of the section's name.
    s	submodulespathsurlN)r\r')r�r1Zsection_kindr�Zsm_pathZsm_urlrrr�parse_submodules+s	r�)#r>r�r@�typingrrr�collectionsr�collections.abcrr�ImportErrorZdulwich.filer�objectr$rrr.r?rerorprtrurzrcr�r�r�r�r�r�r�rrrr�<module>s@3MR�,	s4