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/aptsources/__pycache__/sourceslist.cpython-39.pyc
a

�?i1J�@sddlmZmZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZgd�Z
dd�Zdd	�ZGd
d�de�ZGdd
�d
e�ZGdd�de�ZGdd�de�Zedk�re
��e�ZeD]Ze�de���q�edd�Ze�de�e�edd��e�edd��dS)�)�absolute_import�print_functionN�)�DistInfo)�	is_mirror�SourceEntry�NullMatcher�SourcesList�SourceEntryMatchercCs�|�d�}|�d�}||kr dSz |�d�d}|�d�d}WntyTYdS0d|vr|||�d�dd�|kr|dSdS)z� check if the given add_url is idential or a mirror of orig_uri e.g.:
        master_uri = archive.ubuntu.com
        compare_uri = de.archive.ubuntu.com
        -> True
    z/ Tz//rF�.N)�rstrip�split�
IndexError�index)Z
master_uriZcompare_uriZcompare_srvZ
master_srv�r�8/usr/lib/python3/dist-packages/aptsources/sourceslist.pyr.s

�rcCstt|��S)a. simple and efficient way to return uniq collection

    This is not intended for use with a SourceList. It is provided
    for internal use only. It does not have a leading underscore to
    not break any old code that uses it; but it should not be used
    in new code (and is not listed in __all__).)�list�set��srrr�uniqLsrc@sJeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)rz single sources.list entry NcCs|d|_d|_d|_g|_d|_d|_d|_g|_d|_||_	|dur\t
j�d�t
j�
d�}||_|�|�d|_g|_dS)NF�zDir::Etc�Dir::Etc::sourcelist)�invalid�disabled�type�
architectures�trusted�uri�dist�comps�comment�line�apt_pkg�config�find_dir�find�file�parse�template�children)�selfr"r'rrr�__init__Ys(�
�
zSourceEntry.__init__cCsH|j|jkoF|j|jkoF|j�d�|j�d�koF|j|jkoF|j|jkS)z- equal operator for two sources.list entries �/)rrrrrr )r+�otherrrr�__eq__ls
��
�
�zSourceEntry.__eq__cCs�|��}g}d}d}d}tt|��D]�}||dkrf|rTd}d}|�|�||}q�d}|||7}q$||dkr�d}|||7}q$|r�||��s�d}|�|�||}q$||��r�|s�d}q$|||7}q$t|�dkr�|�|�|S)z� a split() implementation that understands the sources.list
            format better and takes [] into account (for e.g. cdroms) rF�[T�]r)�strip�range�len�append�isspace)r+r"�pieces�tmpZp_foundZspace_found�irrr�mysplitts6




zSourceEntry.mysplitc	Cs�||_|��}|dks|dkr(d|_dS|ddkrpd|_|dd�����}|ddvrdd|_dS|dd�}|�d�}|dkr�||dd�|_|d|�}|�|�}t|�dkr�d|_dS|d��|_	|j	d	vr�d|_dS|d��dd
k�r~|�
d��d���}|D]l}z|�dd�\}}Wnt�yBd|_Yn80|d
k�r\|�d�|_n|dk�rtt
�|�|_nd|_�q|d��|_t|j�dk�r�d|_|d��|_t|�dk�r�|dd�|_ng|_dS)z^ parse a given sources.list (textual) line and break it up
            into the field we have r�#TNrr)�rpm�rpm-src�deb�deb-src�)r>r?r<r=r0z[]�=Zarch�,r�)r"r2rrr
r&r!r:r4r�pop�	Exceptionrr#Zstring_to_boolrrrr )r+r"r7r9ZoptionsZoption�key�valuerrrr(�sV





zSourceEntry.parsecCsB||_|r |j���d�|_n|j��ddkr>d|j|_dS)z# set a line to enabled or disabled r;rN)rr"�lstripr2)r+Z	new_valuerrr�set_enabled�s
zSourceEntry.set_enabledcCs|����S)z debug helper )�strr2)r+rrr�__str__�szSourceEntry.__str__cCs�|jr|jSd}|jrd}||j7}|jrX|jdurX|dd�|j�|jrLdndf7}n<|jdurz|d|jrpdnd7}n|jr�|d	d�|j�7}|d
|j|jf7}t	|j
�dkr�|dd�|j
�7}|jdkr�|d
|j7}|d7}|S)z# return the current line as string rz# Nz [arch=%s trusted=%s]rBZyesZnoz
 [trusted=%s]z
 [arch=%s]z %s %sr� z #�
)rr"rrrr�joinrrr4r r!)r+r"rrrrJ�s*
�


zSourceEntry.str)N)�__name__�
__module__�__qualname__�__doc__r,r/r:r(rIrKrJrrrrrVs
%@rc@seZdZdZdd�ZdS)rz a Matcher that does nothing cCsdS)NTr)r+rrrr�matchszNullMatcher.matchN)rOrPrQrRrSrrrrrsrc@sveZdZdZddd�Zdd�Zdd	�Zd
d�Zdd
dgfdd�Zdd�Z	dd�Z
ddd�Zdd�Zdd�Z
dd�ZdS)r	z8 represents the full sources.list + sources.list.d file T� /usr/share/python-apt/templates/cCs*g|_|rt|�|_nt�|_|��dS�N)rr
�matcherr�refresh)r+ZwithMatcher�matcherPathrrrr,s
zSourcesList.__init__cCstg|_tj�d�}tj�|�r(|�|�tj�d�}t	�	d|�D]}|�|�qB|jD]}|j
sX|j�|�qXdS)z" update the list of known entries r�Dir::Etc::sourceparts�	%s/*.listN)
rr#r$�	find_file�os�path�exists�loadr%�globrrVrS)r+r'�partsdir�sourcerrrrWs

zSourcesList.refreshccs|jD]
}|VqdS)zM simple iterator to go over self.list, returns SourceEntry
            types N)r)r+�entryrrr�__iter__&s
zSourcesList.__iter__c/sl��dd�}|jD]T�|r2|�d��j�d�kr2qt��fdd��D��rt�fdd�|D��r�VqdS)Nrr-c3s |]}t�|��|kVqdSrU)�getattr)�.0rF��attrsrbrr�	<genexpr>1�z%SourcesList.__find.<locals>.<genexpr>c3s|]}|��VqdSrUr)rfZ	predicate)rbrrri2rj)rDrrr�all)r+Z
predicatesrhrrrgrZ__find,s
�zSourcesList.__findr���Nc	s�|��}|�d�}	|	r&|dd���}t���|dd�}
|j�fdd�|	d|||d�}|D]<}|
D]2}
|
|jvrd|
|
�|
�=t|
�dkrd|Sqdq\|j�fd	d�d|||d
�}|D]b}|j|	kr�t|j�t|
�kr�t	|j|
�|_|S|jr�|	s�t|j�t|
�kr�d|_|Sq�|	�r(dnd|��r@dd
�
��nd||g}|�|
�|�rh|�d|�d�
dd�|D��d}t
|�}|du�r�||_|j�|�|dk�r�|j�|�n|j�||�|S)z�
        Add a new source to the sources.list.
        The method will search for existing matching repos and will try to
        reuse them as far as possible
        r;rNcst|j��kSrU�rrr�rrr�<lambda>Erjz!SourcesList.add.<locals>.<lambda>F)rrrrrrcst|j��kSrUrmrrnrrroRrj)rrrrrz	[arch=%s]rBrLcss|]}|r|VqdSrUr)rf�partrrrrikrjz"SourcesList.add.<locals>.<genexpr>rM)r2�
startswithrHr�_SourcesList__findr rr4rrrN�extendr5rr'rVrSr�insert)r+rrrZ
orig_compsr!�posr'rrr �sourcesrbZnew_comp�partsr"Z	new_entryrrnr�add5s\
�
�


�


zSourcesList.addcCs|j�|�dS)z2 remove the specified entry from the sources.list N)r�remove)r+Zsource_entryrrrrywszSourcesList.removecCs|tj�d�}tj�||�r8tj�|�r8t�|||�tj�d�}t	�	d|�D]$}tj�||�rRt�|||�qRdS)z: restore sources.list files based on the backup extension rrYrZN)
r#r$r[r\r]r^�shutil�copyr%r`)r+�
backup_extr'rarrr�restore_backup{szSourcesList.restore_backupcCsXt�}|durt�d�}|jD]4}|j|vrtj�|j�rt�	|jd|j|f�q|S)z� make a backup of the current source files, if no backup extension
            is given, the current date/time is used (and returned) Nz%y%m%d.%H%Mz%s%s)
r�time�strftimerr'r\r]r^rzr{)r+r|Zalready_backupedrbrrr�backup�s


�zSourcesList.backupcCstzNt|d��0}|D]}t||�}|j�|�qWd�n1sB0YWn tynt�d|�Yn0dS)z (re)load the current sources �rNzcould not open file '%s'
)�openrrr5rE�loggingZwarning)r+r'�fr"rbrrrr_�s
0zSourcesList.loadc	Cs�i}t|j�dkrZtj�d�}d}t|d��}|�|�Wd�n1sL0YdSzV|jD]4}|j|vr�t|jd�||j<||j�|���qbW|D]}||�	�q�n|D]}||�	�q�0dS)z save the current sources rrz�## See sources.list(5) for more information, especialy
# Remember that you can only use http, ftp or file URIs
# CDROMs are managed through the apt-cdrom tool.
�wN)
r4rr#r$r[r��writer'rJ�close)r+�filesr]�headerr�rbrrr�save�s"�(

�zSourcesList.savecCsrg}i}|D]\}|jdurq|jjrN|j}||vr:g||<||}|�|�qt|jj�dkr|�|�q||fS)z5get all parent and child channels in the sources listNr)r)�childr5r4r*)r+Zsources_list�parentsZused_child_templatesrbrFZtemprrr�check_for_relations�s
zSourcesList.check_for_relations)TrT)N)rOrPrQrRr,rWrdrrrxryr}r�r_r�r�rrrrr		s �

	�
B

r	c@s eZdZdZdd�Zdd�ZdS)r
z} matcher class to make a source entry look nice
        lots of predefined matchers to make it i18n/gettext friendly
        cCsrg|_t�d|�}|D]T}tj�|�}|�d�}|d|�}t||d�}|jD]}|jdurP|j�|�qPqdS)Nz	%s/*.infoz.infor)Zbase_dir)	�	templatesr`r\r]�basenamer&r�	match_urir5)r+rXZ
spec_filesr�r9rr)rrrr,�s


zSourceEntryMatcher.__init__cCs�d}|jD]t}t�|j|j�rTt�|j|j�rT|j|jksD|jdkrTd}||_	q�q
|�
|j�r
t�|j|j�r
d}||_	q�q
|S)z%Add a matching template to the sourceFr>T)r��re�searchr�rrSZ
match_namerrr)r)r+rb�foundr)rrrrS�s&
�
���zSourceEntryMatcher.matchN)rOrPrQrRr,rSrrrrr
�sr
�__main__zentry %sz!http://archive.ubuntu.com/ubuntu/z$http://de.archive.ubuntu.com/ubuntu/zis_mirror(): %sz http://archive.ubuntu.com/ubuntuz#http://de.archive.ubuntu.com/ubuntu)Z
__future__rrr`r��os.pathr\r�rzr~r#Zdistinfor�__all__rr�objectrrr	r
rOZinit_configrvrc�inforJZmirrorrrrr�<module>s@
-E(
���