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/share/python3/__pycache__/py3versions.cpython-39.pyc
a

�j`�-�@s�ddlZddlZddlZdadadadd�ej�dd��d�D�a	da
d!dd�Zd	d
�Zd"dd
�Z
d#dd�Zd$dd�Zd%dd�Zd&dd�Zd'dd�ZGdd�de�ZGdd�de�Zdd�Zdd�Zed kr�e�dS)(�NcCs g|]}|��rd|���qS�zpython%s��strip)�.0Zver�r�!/usr/share/python3/py3versions.py�
<listcomp>
s�rZDEBPYTHON3_SUPPORTED��,cCs|ddlm}m}tsDtj�d�rD|�}td�}|�|�|�	�|atrx|rxzt�
d|�}Wn|yrt�Yn0|SdS)Nr)�ConfigParser�
NoOptionErrorz"/usr/share/python3/debian_defaultsZDEFAULT)Zconfigparserrr�	_defaults�os�path�exists�openZ	read_file�close�get�
ValueError)�namerrZconfigZdefaultsfile�valuerrr�read_defaults

rc
	sft|�d��dkrtd��ddl}|j|j|j|j|jd�}i}t�}tt	dd��}d}|�d�D]�}|�
�}|d	krxqb|d
vr�qb|�dt��t�
d�}|�|�}	zx|	s�td
��|	�d�|	�d�}
���d�\}}t|�dkr�Wqb|
dvr�|���n d}||
���fdd�|D�}Wqbt�y8td
��Yqb0qbd|v�rb||d<|�rb|�|�|d<|S)Nr
�zDtoo many arguments provided for X-Python3-Version: min and max only.r)N�=z>=z<=z<<T��version_onlyF�all)ZcurrentZcurrent_ext�versionsz(>=|<=|<<|=)? *(\d\.\d)$z'error parsing Python3-Version attribute��.�)Nrcsg|]}�|��r|�qSrr)r�av�Zfiltop�vrrrG�z"parse_versions.<locals>.<listcomp>)�len�splitr�operator�eq�ge�le�lt�set�supported_versionsr�
setdefault�re�compile�match�group�int�add�	Exception�union)
�vstringr'Z	operators�vinfoZexact_versionsZ
version_rangeZ
relop_seenZfieldZve�m�opZvmajZvminrr"r�parse_versions'sN�


r;FcCsVts<z td�}dd�|�d�D�aWnty:gaYn0|rNdd�tD�StSdS)Nzold-versionscSsg|]}|���qSrr�r�srrrrVr$z old_versions.<locals>.<listcomp>r
cSsg|]}|dd��qS��Nr�rr#rrrrZr$)�
_old_versionsrr&r�rrrrr�old_versionsQs
rCcCsVts<z td�}dd�|�d�D�aWnty:gaYn0|rNdd�tD�StSdS)Nzunsupported-versionscSsg|]}|���qSrrr<rrrrdr$z(unsupported_versions.<locals>.<listcomp>r
cSsg|]}|dd��qSr>rr@rrrrhr$)�_unsupported_versionsrr&rrBrrr�unsupported_versions_s
rEc	Cst�ts�z td�}dd�|�d�D�aWn�ty�gd�}z&ddl}|j|dd|jd	�}|j}Wn"t	y�t
�d
�|��}Yn0d}|D](}|�
d�r�|�dd�d���d�}q�|��d
d�|D�}|aYn0t�t�t��}t��t�|�|�rdd�tD�StSdS)Nzsupported-versionscSsg|]}|���qSrrr<rrrrsr$z&supported_versions.<locals>.<listcomp>r
)z/usr/bin/apt-cachez--no-all-versionsZshowzpython3-allrrF)�bufsize�shell�stdout� zDepends:�:cSsg|]}t�dd|��qS)z\s*(\S+)[ (]?.*z\1)r/�subr<rrrr�r$cSsg|]}|dd��qSr>rr@rrrr�r$)�default_version�_supported_versionsrr&r�
subprocess�Popen�PIPErH�ImportErrorr�popen�join�
startswithrr�pop�index�_default_version�sort�append)	rr�cmdrN�p�fdZdepends�line�defaultrrrr-ms8�



r-cCsTtst�d�atd�}t|tj�d|�fvr8td|��|a|rLtdd�StSdS)Nz/usr/bin/python3zdefault-versionz/usr/binzkthe symlink /usr/bin/python3 does not point to the python3 default version. It must be reset to point to %sr?)rWr�readlinkrrrSr)rZdebian_defaultrrrrL�s
�rLcCs�t�d}t|�}tdd�}t|�dkr�|d�|�}g}|D]}|�|�q>z|�|�tdd���}Wnd}Yn0|�	�|r�|�|�nt
d��|s�t
d��|r�|Sd	d
�|D�SdS)NTrrrr?r	z/No supported python3 versions in version stringzempty set of versionscSsg|]}d|�qSrrr@rrrr�r$z&requested_versions.<locals>.<listcomp>)rLr;r-r%�intersectionrYrUrVrWrXr)r7rrr8�	supportedZvl�versionr^rrr�requested_versions�s*

rccsHddl}t���fdd�|�d�D�}|��|r@dd�|D�S|SdS)Nrcs(g|] }tj�|��vrtj�|��qSr)rr�basenamer<�rarrr�s�z&installed_versions.<locals>.<listcomp>z/usr/bin/python3.[0-9]cSsg|]}|dd��qSr>rr@rrrr�r$)�globr-rX)rrfrrrer�installed_versions�s
�rgc@seZdZdS)�ControlFileValueErrorN��__name__�
__module__�__qualname__rrrrrh�srhc@seZdZdS)�MissingVersionValueErrorNrirrrrrm�srmcCs�d}d}d}t|dd��}dd�|D�}Wd�n1s<0Y|D]|}|dkrp|dkrp|dkrjq�d}qJ|�d�r�d}qJ|�d	|�r�|}qJ|���d
�rJ|dkr�td��|�dd
�d
��}qJ|dur�td��|dkr�|dur�td��|S|S)zFread the debian/control file, extract the X-Python3-Version
    field.Nzutf-8)�encodingcSsg|]}|���qSrr)rr]rrrr�r$z/extract_pyversion_attribute.<locals>.<listcomp>r	�SourcezSource:z	Package: zx-python3-version:z1attribute X-Python3-Version not in Source sectionrJrznot a control filez$no X-Python3-Version in control file)rrT�lowerrr&rrhrm)�fn�pkgrbZsversionZsectionZcontrolfile�linesr]rrr�extract_pyversion_attribute�s2,
rtc
Cs�ddlm}d}||d�}|jddddd	d
�|jddd
ddd
�|jdddddd
�|jdddddd
�|jddddddd�|��\}}tj�tjd�}|j	�r
t
|�dk�r
ztt|j
��Wn>t�y}z$td||�t�d�WYd}~n
d}~00�n�|j�r8t
|�dk�r8td�t|j
����nr|j�rft
|�dk�rftd�t|j
����nD|j�r�t
|�dk�r�t
|�dk�r�d }n|d}z�tj�|��r(|}zt|d!�}	t|	|j
�}
Wn^t�y�tj�d"||f�t�d�Yn.t�y$tj�d#|�t|j
�}
Yn0nt||j
�}
td�|
��WnDt�y�}z*tj�d$||f�t�d�WYd}~n
d}~00ntj�d%||f�t�d�dS)&Nr)�OptionParserz;[-v] [-h] [-d|--default] [-s|--supported] [-i|--installed] )�usagez-dz	--defaultz!print the default python3 version�
store_truer^)�help�action�destz-sz--supportedz$print the supported python3 versionsraz-rz--requestedz�print the python3 versions requested by a build; the argument is either the name of a control file or the value of the X-Python3-Version attribute�	requestedz-iz--installedz.print the installed supported python3 versions�	installedz-vz	--versionz print just the version number(s)Fr)rxr^ryrzz%s:rrIzdebian/controlroz%s: not a control file: %s, zC%s: no X-Python3-Version in control file, using supported versions
z%s: %s
z
usage: %s %s
)ZoptparseruZ
add_option�
parse_argsrrrd�sys�argvr^r%�printrLrr�exitrarSr-r|rgr{�isfilertrcrh�stderr�writerm)rurv�parserZopts�argsZprogram�msgrrqr7Zvsrrr�mains|
�����$
��"r��__main__)N)F)F)F)F)F)F)rr/r~r
rArD�environrr&rMrWrr;rCrEr-rLrcrgrrhrmrtr�rjrrrr�<module>s.�
*


!



=A