HEX
Server: Apache/2.4.65 (Debian)
System: Linux kubikelcreative 5.10.0-35-amd64 #1 SMP Debian 5.10.237-1 (2025-05-19) x86_64
User: www-data (33)
PHP: 8.4.13
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/aptsources/__pycache__/distinfo.cpython-39.pyc
a

?��`/8�@s�ddlmZddlZddlZddlZddlZddlmZmZddl	Z	ddl
Z
ddl
mZdd�Z
Gdd�de�ZGd	d
�d
e�ZGdd�de�ZGd
d�de�Zdd�ZGdd�de�Zedk�r�edd�Ze�ej�ejD]�Ze�dej�e�dej�e�dej�e�dej�ejik�rFe�de ej�!���ej"D] Z#e�de#je#je#j$f��qLej%D]Z&e�de&j��qtq�dS)�)�print_functionN)�Popen�PIPE)�gettextc		#s�t�}t�|���}|D]X}d|vr6|�|d�d��d|vr\d|dvrNq�|�|d�t|���EdHqWd�dS|D]}d|vr�|�|d�q�Wd�n1s�0Yt|��"}t	t
t�|���}Wd�n1s�0Y|D]�}|d|v�rq�dV|d�
d	d�|d<t�|���}|D]�}d|v�s:d|dv�rZ�q:d
|v�r�|d�t�fdd�|d
�d�D���r��q:t|�jfi|����D]}|�d
��r��q�|V�q��q:Wd�q�1�s�0Yq�t�|��t}|D]$}d|v�r�d|dv�r��q$�q�|D]4}d|v�rHd|dv�rH�q(t|���EdH�q(Wd�n1�st0YdS)
a~Expand the given template.

    A template file consists of a header, followed by paragraphs
    of templated suites, followed by a footer. A templated suite
    is any paragraph where the Suite field contains {.

    This function expands all templated suites using the information
    found in the CSV file supplied by distro-info-data.

    It yields lines of template info.
    zX-Exclude-Suitesz, �Suite�{NZseries��versionz LTSz	X-Versionc3sR|]J}|�d�r(t�|dd���dkpH|�d�oHt�|dd���dkVqdS)�le�Nr�ge)�
startswith�apt_pkgZversion_compare)�.0�field�Zver��5/usr/lib/python3/dist-packages/aptsources/distinfo.py�	<genexpr>Zs�
�
z#_expand_template.<locals>.<genexpr>)�setrZTagFile�update�split�add�str�
splitlines�open�reversed�list�csvZ
DictReader�replace�any�formatr
)	�templateZcsv_pathZknown_suitesZtmplZsectionZ
csv_objectZreleasesZrel�linerrr�_expand_template&sV
.
0
�
0
r$c@s$eZdZdd�Zdd�Zdd�ZdS)�TemplatecCsXd|_d|_g|_d|_d|_d|_d|_g|_g|_d|_	i|_
d|_d|_d|_
dS�NFT)�name�child�parents�
match_name�description�base_uri�type�
components�children�	match_uri�
mirror_set�distribution�	available�official��selfrrr�__init__yszTemplate.__init__cCs|dd�|jD�vS)z8 Check if the distribution provides the given component css|]}|jVqdS�N)r')r�crrrr��z)Template.has_component.<locals>.<genexpr>)r.)r6�comprrr�
has_component�szTemplate.has_componentcCs2t|�\}}}||jvr*|j|�||�SdSdS)z8 Check if a given url of a repository is a valid mirror FN)�	split_urlr1�has_repository)r6�url�proto�hostname�dirrrr�	is_mirror�s
zTemplate.is_mirrorN)�__name__�
__module__�__qualname__r7r<rCrrrrr%wsr%c@sFeZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dS)�	ComponentNcCs||_||_||_||_dSr8)r'r+�description_long�parent_component)r6r'�descZ	long_descrIrrrr7�szComponent.__init__cCs|jSr8�rIr5rrr�get_parent_component�szComponent.get_parent_componentcCs
||_dSr8rK)r6�parentrrr�set_parent_component�szComponent.set_parent_componentcCs(|jdur|jS|jdur |jSdSdSr8)rHr+r5rrr�get_description�s


zComponent.get_descriptioncCs
||_dSr8)r+�r6rJrrr�set_description�szComponent.set_descriptioncCs
||_dSr8�rHrPrrr�set_description_long�szComponent.set_description_longcCs|jSr8rRr5rrr�get_description_long�szComponent.get_description_long)NNN)
rDrErFr7rLrNrOrQrSrTrrrrrG�s
rGc@sJeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�Mirrorz( Storage for mirror related information NcCs"||_g|_|�||�||_dSr8)rA�repositories�add_repository�location)r6r@rArBrXrrrr7�szMirror.__init__cCs|j�t||��dSr8)rV�append�
Repository�r6r@rBrrrrW�szMirror.add_repositorycs�fdd�|jD�S)Ncsg|]}|j�kr|�qSr�r@�r�rr\rr�
<listcomp>�r:z5Mirror.get_repositories_for_proto.<locals>.<listcomp>�rV)r6r@rr\r�get_repositories_for_proto�sz!Mirror.get_repositories_for_protocCs6|durdS|jD]}|j|kr||jvrdSqdSr&)rVr@rB)r6r@rBr^rrrr>�s
zMirror.has_repositorycs�fdd��jD�S)Ncsg|]}|��j��qSr)�get_urlrAr]r5rrr_�r:z(Mirror.get_repo_urls.<locals>.<listcomp>r`r5rr5r�
get_repo_urls�szMirror.get_repo_urlscCs|jSr8�rXr5rrr�get_location�szMirror.get_locationcCs
||_dSr8rd)r6rXrrr�set_location�szMirror.set_location)N)rDrErF�__doc__r7rWrar>rcrerfrrrrrU�s
rUc@s$eZdZdd�Zdd�Zdd�ZdS)rZcCs||_||_dSr8�r@rBr[rrrr7�szRepository.__init__cCs|j|jfSr8rhr5rrr�get_info�szRepository.get_infocCsd|j||jfS)Nz
%s://%s/%srh)r6rArrrrb�szRepository.get_urlN)rDrErFr7rirbrrrrrZ�srZcCs,tjd|dd�}t|�dkr(|�d�q|S)zE split a given URL into the protocoll, the hostname and the dir part z:*\/+�)�maxsplitrN)�rer�lenrY)r?rrrrr=�sr=c@seZdZddd�Zdd�ZdS)�DistInfoN�/usr/share/python-apt/templatesc
CsHd|_g|_tj�d�|_d}t�d�}t�d�}|s�z"tgd�dt	d��
�d��}WnFtt
fy�}z*|jtjkr�t�d	|�d
}WYd}~n
d}~00||_i}d||f}d�|���}	d}
d}t||	�D�]V}|�d
d�}
t|
�dkr�q�|
d��}|
d��}|dk�r$t|�|_q�|dk�r6||_q�|dk�rn|�|
|�d}t�}
||
_||
_d||
_q�|dk�r�||
_q�|dk�r�d|
_|jD]*}|j|k�r�|
j �!|�|j"�!|
��q�q�|dk�r�t�#|�|
_$q�|dk�r�t�#|�|
_%q�|dk�r||
_&q�|dk�r |
j'�s ||
_'q�|d|jk�r8||
_'q�|dk�rR|
j(�sR||
_(q�|d|jk�rj||
_(q�|dk�s�|d|jk�r�t)j*�+|��r�|�p�t)j*�,t)j*�-||��}||v�r�i}zHt.|��*}t/t0|j1dd �|D���}Wd�n1�s�0YWn t2�y$t3d!�g}Yn0|D]^}|�4d"��rJ|�5d#|�}�q*t6|�\}}}||v�rt||�7||�nt8||||�||<�q*|||<|||
_9q�|d$k�r�t|�|
_:q�|d%k�r�|�r�|
�;|j��s�|
j<�!|�t=|�}q�|d&k�r|�>t|��q�|d'k�r|�?t|��q�|d(kr�|�@|�q�|�|
|�d}
d}dS))NrzAPT::Architecturez^#LOC:(.+)$zS^(#LOC:.+)|(((http)|(ftp)|(rsync)|(file)|(mirror)|(https))://[A-Za-z0-9/\.:\-_@]+)$)Zlsb_releasez-iz-sT)Zuniversal_newlines�stdoutrz#lsb_release failed, using defaults:ZDebianz
%s/%s.infoz/usr/share/distro-info/{}.csv�:�rjZChangelogURIZMetaReleaseURIrz^%s$Z	MatchNameZParentSuiteZ	AvailableZOfficialZRepositoryTypeZBaseURIz
BaseURI-%sZMatchURIzMatchURI-%sZMirrorsFilezMirrorsFile-%scSsg|]}|���qSr)�strip)r�xrrrr_Ar:z%DistInfo.__init__.<locals>.<listcomp>z#WARNING: Failed to read mirror filez#LOC:z\1ZDescriptionrGZCompDescriptionZCompDescriptionLongZParentComponent)AZmetarelease_uri�	templatesrZconfig�findZarchrl�compilerrZcommunicaters�OSError�IOError�errnoZENOENT�loggingZwarning�distr!�lowerr$rrm�_�changelogs_uri�finish_templater%r'r2r*r(r)rYr/Zstring_to_boolr3r4r-r,r0�os�path�isabs�abspath�joinrr�filter�match�	Exception�printr
�subr=rWrUr1r+r<r.rGrQrSrN)r6r|Zbase_dirrXZ	match_locZmatch_mirror_line�excZmap_mirror_setsZ
dist_fnameZ	csv_fnamer"�	componentr#�tokensr�valueZnannyr1Zvalue_fZmirror_datar@rArBrrrr7�s�
����









��

�*

�


�


zDistInfo.__init__cCs�|sdS|jdur6|jr6|jD]}|jr|j|_q6q|jikrd|jrd|jD]}|jrL|j|_qdqL|r�|�|j�s�|j�|�d}|jD]}|j|_q�|j	�|�dS)z finish the current tempalte N)
r0r(r)r1r<r'r.rYr4ru)r6r"r��trrrr�bs$



zDistInfo.finish_template)Nro)rDrErFr7r�rrrrrn�s
trn�__main__ZUbunturoz

Suite: %szDesc: %szBaseURI: %szMatchURI: %szMirrors: %sz %s -%s -%sz  %s)'Z
__future__rrrzr{r��
subprocessrrrlrrr~r$�objectr%rGrUrZr=rnrD�d�inforrur"r'r+r,r0r1r�keysr.r;rHr/r(rrrr�<module>sBQ !





�