%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core20/current/usr/share/python3/__pycache__/
Upload File :
Create Path :
Current File : //snap/core20/current/usr/share/python3/__pycache__/py3versions.cpython-38.pyc

U

�zk^�-�@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�}|�|�|�	�|atrz|rzzt�
d|�}Wn|k
rtt�YnX|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
	sht|�d��dkrtd��ddl}|j|j|j|j|jd�}i}t�}tt	dd��}d}|�d�D]�}|�
�}|d	krxqb|d
kr�qb|�dt��t�
d�}|�|�}	zx|	s�td
��|	�d�|	�d�}
���d�\}}t|�dkr�Wqb|
dkr�|���n d}||
���fdd�|D�}Wqbtk
�r:td
��YqbXqbd|k�rd||d<|�rd|�|�|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�vrrrGs
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'sP�


r:FcCsXts>z td�}dd�|�d�D�aWntk
r<gaYnX|rPdd�tD�StSdS)Nzold-versionscSsg|]}|���qSrr�r�srrrrVsz old_versions.<locals>.<listcomp>r
cSsg|]}|dd��qS��Nr�rr#rrrrZs)�
_old_versionsrr%r�rrrrr�old_versionsQs
rBcCsXts>z td�}dd�|�d�D�aWntk
r<gaYnX|rPdd�tD�StSdS)Nzunsupported-versionscSsg|]}|���qSrrr;rrrrdsz(unsupported_versions.<locals>.<listcomp>r
cSsg|]}|dd��qSr=rr?rrrrhs)�_unsupported_versionsrr%rrArrr�unsupported_versions_s
rDc	Cs"t�ts�z td�}dd�|�d�D�aWn�tk
r�ddddg}z&d	dl}|j|d
d|jd�}|j}Wn$t	k
r�t
�d
�|��}YnXd}|D](}|�
d�r�|�dd
�d
���d�}q�|��dd�|D�}|aYnXt�t�t��}t��t�|�|�rdd�tD�StSdS)Nzsupported-versionscSsg|]}|���qSrrr;rrrrssz&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�scSsg|]}|dd��qSr=rr?rrrr�s)�default_version�_supported_versionsrr%r�
subprocess�Popen�PIPErG�ImportErrorr�popen�join�
startswithrr�pop�index�_default_version�sort�append)	rr�cmdrM�p�fdZdepends�line�defaultrrrr,ms@��



r,cCsTtst�d�atd�}t|tj�d|�fkr8td|��|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>)rVr�readlinkrrrRr)rZdebian_defaultrrrrK�s
�rKcCs�t�d}t|�}tdd�}t|�dkr�|d�|�}g}|D]}|�|�q>z|�|�tdd���}Wnd}YnX|�	�|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�sz&requested_versions.<locals>.<listcomp>)rKr:r,r$�intersectionrXrTrUrVrWr)r6rrr7�	supportedZvl�versionr]rrr�requested_versions�s,

rbcsHddl}t���fdd�|�d�D�}|��|r@dd�|D�S|SdS)Nrcs(g|] }tj�|��krtj�|��qSr)rr�basenamer;�r`rrr�s�z&installed_versions.<locals>.<listcomp>z/usr/bin/python3.[0-9]cSsg|]}|dd��qSr=rr?rrrr�s)�globr,rW)rrerrrdr�installed_versions�s
�rfc@seZdZdS)�ControlFileValueErrorN��__name__�
__module__�__qualname__rrrrrg�srgc@seZdZdS)�MissingVersionValueErrorNrhrrrrrl�srlc	Cs�d}d}d}t|dd��}dd�|D�}W5QRX|D]|}|dkr\|dkr\|dkrVq�d}q6|�d�rld}q6|�d	|�r�|}q6|���d
�r6|dkr�td��|�dd
�d
��}q6|dkr�td��|dkr�|dkr�td��|S|S)zFread the debian/control file, extract the X-Python3-Version
    field.Nzutf-8)�encodingcSsg|]}|���qSrr)rr\rrrr�sz/extract_pyversion_attribute.<locals>.<listcomp>r	�SourcezSource:z	Package: zx-python3-version:z1attribute X-Python3-Version not in Source sectionrIrznot a control filez$no X-Python3-Version in control file)rrS�lowerrr%rrgrl)�fn�pkgraZsversionZsectionZcontrolfile�linesr\rrr�extract_pyversion_attribute�s2
rsc
Cs�ddlm}d}||d�}|jddddd	d
�|jddd
ddd
�|jdddddd
�|jdddddd
�|jddddddd�|��\}}tj�tjd�}|j	�rt
|�dk�rztt|j
��Wn<tk
�r}ztd||�t�d�W5d}~XYnX�n�|j�r6t
|�dk�r6td�t|j
����nt|j�rdt
|�dk�rdtd�t|j
����nF|j�r�t
|�dk�r�t
|�dk�r�d }n|d}z�tj�|��r*|}zt|d!�}	t|	|j
�}
Wnbtk
�r�tj�d"||f�t�d�Yn0tk
�r&tj�d#|�t|j
�}
YnXnt||j
�}
td�|
��WnBtk
�r�}z"tj�d$||f�t�d�W5d}~XYnXntj�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 versionsr`z-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)rwr]rxryz%s:rrHzdebian/controlrnz%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
)ZoptparsertZ
add_option�
parse_argsrrrc�sys�argvr]r$�printrKrr�exitr`rRr,r{rfrz�isfilersrbrg�stderr�writerl)rtru�parserZopts�argsZprogram�msgrrpr6Zvsrrr�mains�
����� 
��r��__main__)N)F)F)F)F)F)F)rr.r}r
r@rC�environrr%rLrVrr:rBrDr,rKrbrfrrgrlrsr�rirrrr�<module>s.�
*


!



=A

Zerion Mini Shell 1.0