HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3/dist-packages/aptsources/__pycache__/sourceslist.cpython-38.pyc
U

&��c1J�@s"ddlmZmZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZddddd	gZ
d
d�Zdd�ZGd
d�de�ZGdd�de�ZGdd�de�ZGdd	�d	e�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}Wntk
rVYdSXd|kr~||�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

�cCs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|_||_	|dkr\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"�piecesZtmpZp_foundZspace_found�irrr�mysplitts6




zSourceEntry.mysplitc	Cs�||_|��}|dks|dkr(d|_dS|ddkrpd|_|dd�����}|ddkrdd|_dS|dd�}|�d�}|dkr�||dd�|_|d|�}|�|�}t|�dkr�d|_dS|d��|_	|j	d	kr�d|_dS|d��dd
k�r�|�
d��d���}|D]n}z|�dd�\}}Wntk
�rDd|_Yn8X|d
k�r^|�d�|_n|dk�rvt
�|�|_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!r9r4r�pop�	Exceptionrr#Zstring_to_boolrrrr )r+r"r7r8ZoptionsZoption�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|jdk	rX|dd�|j�|jrLdndf7}n<|jdk	rz|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]rAZyesZnoz
 [trusted=%s]z
 [arch=%s]z %s %sr� z #�
)rr"rrrr�joinrrr4r r!)r+r"rrrrI�s,

�


zSourceEntry.str)N)�__name__�
__module__�__qualname__�__doc__r,r/r9r(rHrJrIrrrrrVs
%@c@seZdZdZdd�ZdS)rz a Matcher that does nothing cCsdS)NTr)r+rrrr�matchszNullMatcher.matchN)rNrOrPrQrRrrrrrsc@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%�globrrUrR)r+r'�partsdir�sourcerrrrVs

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�|��|kVqdSrT)�getattr)�.0rE��attrsrarr�	<genexpr>1sz%SourcesList.__find.<locals>.<genexpr>c3s|]}|��VqdSrTr)reZ	predicate)rarrrh2s)rCrrr�all)r+Z
predicatesrgrrrfrZ__find,s
�zSourcesList.__findr���Nc	s�|��}|�d�}	|	r&|dd���}t���|dd�}
|j�fdd�|	d|||d�}|D]<}|
D]2}
|
|jkrd|
|
�|
�=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
|�}|dk	�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��kSrT�rrr�rrr�<lambda>E�z!SourcesList.add.<locals>.<lambda>F)rrrrrrcst|j��kSrTrkrrlrrrmRrn)rrrrrz	[arch=%s]rArKcss|]}|r|VqdSrTr)re�partrrrrhksz"SourcesList.add.<locals>.<genexpr>rL)r2�
startswithrGr�_SourcesList__findr rr4rrrM�extendr5rr'rUrRr�insert)r+rrrZ
orig_compsr!�posr'rrr �sourcesraZnew_comp�partsr"Z	new_entryrrlr�add5sh
�
�


�


zSourcesList.addcCs|j�|�dS)z2 remove the specified entry from the sources.list N)r�remove)r+Zsource_entryrrrrxwszSourcesList.removecCs|tj�d�}tj�||�r8tj�|�r8t�|||�tj�d�}t	�	d|�D]$}tj�||�rRt�|||�qRdS)z: restore sources.list files based on the backup extension rrXrYN)
r#r$rZr[r\r]�shutil�copyr%r_)r+�
backup_extr'r`rrr�restore_backup{szSourcesList.restore_backupcCsXt�}|dkrt�d�}|jD]4}|j|krtj�|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]ryrz)r+r{Zalready_backupedrarrr�backup�s


�zSourcesList.backupc	Csbz:t|d��&}|D]}t||�}|j�|�qW5QRXWn"tk
r\t�d|�YnXdS)z (re)load the current sources �rzcould not open file '%s'
N)�openrrr5rD�loggingZwarning)r+r'�fr"rarrrr^�s
zSourcesList.loadc	Cs�i}t|j�dkrFtj�d�}d}t|d��}|�|�W5QRXdSz@|jD]4}|j|krnt|jd�||j<||j�|�	��qNW5|D]}||��q�XdS)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$rZr��write�closer'rI)r+�filesr\�headerr�rarrr�save�s�

zSourcesList.savecCsrg}i}|D]\}|jdkrq|jjrN|j}||kr:g||<||}|�|�qt|jj�dkr|�|�q||fS)z5get all parent and child channels in the sources listNr)r)Zchildr5r4r*)r+Zsources_list�parentsZused_child_templatesrarEZtemprrr�check_for_relations�s
zSourcesList.check_for_relations)TrS)N)rNrOrPrQr,rVrcrqrwrxr|rr^r�r�rrrrr		s �

	�
B

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]}|jdk	rP|j�|�qPqdS)Nz	%s/*.infoz.infor)Zbase_dir)	�	templatesr_r[r\�basenamer&r�	match_urir5)r+rWZ
spec_filesr�r8rr)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�rrRZ
match_namerrr)r)r+ra�foundr)rrrrR�s&
�
���zSourceEntryMatcher.matchN)rNrOrPrQr,rRrrrrr
�s�__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�ryr}r#Zdistinfor�__all__rr�objectrrr	r
rNZinit_configrurb�inforIZmirrorrrrr�<module>sD�
-E(
���