%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core/17212/usr/share/python3/__pycache__/
Upload File :
Create Path :
Current File : //snap/core/17212/usr/share/python3/__pycache__/py3versions.cpython-35.pyc



Ww�V�-�@s7ddlZddlZddlZdadadadd�ejjdd�jd�D�a	da
ddd�Zd	d
�Zddd
�Z
ddd�Zddd�Zddd�Zddd�Zddd�ZGdd�de�ZGdd�de�Zdd�Zdd�Zed kr3e�dS)!�NcCs,g|]"}|j�rd|j��qS)zpython%s)�strip)�.0Zver�r�!/usr/share/python3/py3versions.py�
<listcomp>
s	rZDEBPYTHON3_SUPPORTED��,cCs�ddlm}m}ts`tjjd�r`|�}td�}|j|�|j	�|atr�|r�ytj
d|�}Wn|k
r�t�YnX|SdS)Nr)�ConfigParser�
NoOptionErrorz"/usr/share/python3/debian_defaultsZDEFAULT)Zconfigparserr	r
�	_defaults�os�path�exists�openZ	read_file�close�get�
ValueError)�namer	r
�configZdefaultsfile�valuerrr�read_defaults	


rc
st|jd��dkr'td��ddl}d|jd|jd|jd|jd|ji}i}t�}tt	d	d
��}d}x:|jd�D])}|j
�}|dkr�q�|dkr�q�|jdt��tj
d�}|j|�}	y�|	std��|	jd�|	jd�}
��jd�\}}t|�dkr_w�|
dkr{|j��n,d
}||
���fdd�|D�}Wq�tk
r�td��Yq�Xq�Wd|kr�||d<|r�|j|�|d<|S)Nr�zDtoo many arguments provided for X-Python3-Version: min and max only.r�=z>=z<=z<<�version_onlyTF�all�current�current_ext�versionsz(>=|<=|<<|=)? *(\d\.\d)$z'error parsing Python3-Version attribute��.�cs%g|]}�|��r|�qSrr)r�av)�filtop�vrrrGs	z"parse_versions.<locals>.<listcomp>)rr)Nr)�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�opZvmajZvminr)r"r#r�parse_versions'sL	
 

r:FcCsltsMy,td�}dd�|jd�D�aWntk
rLgaYnX|rddd�tD�StSdS)Nzold-versionscSsg|]}|j��qSr)r)r�srrrrVs	z old_versions.<locals>.<listcomp>rcSs g|]}|dd��qS)�Nr)rr#rrrrZs	)�
_old_versionsrr%r)rrrrr�old_versionsQs 
r>cCsltsMy,td�}dd�|jd�D�aWntk
rLgaYnX|rddd�tD�StSdS)Nzunsupported-versionscSsg|]}|j��qSr)r)rr;rrrrds	z(unsupported_versions.<locals>.<listcomp>rcSs g|]}|dd��qS)r<Nr)rr#rrrrhs	)�_unsupported_versionsrr%r)rrrrr�unsupported_versions_s 
r@c	Cs�t�ts8y,td�}dd�|jd�D�aWn�tk
r7ddddg}y=d	dl}|j|d
ddd
d|j�}|j}Wn*t	k
r�t
jdj|��}YnXd}xB|D]:}|j
d�r�|jdd�dj�jd�}q�W|j�dd�|D�}|aYnXtjtjt��}tj�tj|�|r~dd�tD�StSdS)Nzsupported-versionscSsg|]}|j��qSr)r)rr;rrrrss	z&supported_versions.<locals>.<listcomp>rz/usr/bin/apt-cachez--no-all-versionsZshowzpython3-allr�bufsizer�shellF�stdout� zDepends:�:cSs%g|]}tjdd|��qS)z\s*(\S+)[ (]?.*z\1)r.�sub)rr;rrrr�s	cSs g|]}|dd��qS)r<Nr)rr#rrrr�s	)�default_version�_supported_versionsrr%r�
subprocess�Popen�PIPErC�ImportErrorr�popen�join�
startswithrr�pop�index�_default_version�sort�append)	rr�cmdrI�p�fdZdepends�line�defaultrrrr,ms8 



)


r,cCsttstjd�atd�}t|tjjd|�fkrRtd|��|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<)rRr�readlinkrr
rNr)rZdebian_defaultrrrrG�s!
rGcCst�d}t|�}tdd�}t|�dkr�|dj|�}g}x|D]}|j|�qZWy&|j|jtdd���}Wnd}YnX|j	�|r�|j|�nt
d��|s�t
d��|r�|Sd	d
�|D�SdS)NrTrrr<rz/No supported python3 versions in version stringzempty set of versionscSsg|]}d|�qS)zpython%sr)rr#rrrr�s	z&requested_versions.<locals>.<listcomp>)rGr:r,r$�intersectionrTrPrQrRrSr)r6rrr7�	supportedZvl�versionrYrrr�requested_versions�s,
&
r^cs`ddl}t���fdd�|jd�D�}|j�|rXdd�|D�S|SdS)Nrcs:g|]0}tjj|��krtjj|��qSr)rr
�basename)rr;)r\rrr�s	z&installed_versions.<locals>.<listcomp>z/usr/bin/python3.[0-9]cSs g|]}|dd��qS)r<Nr)rr#rrrr�s	)�globr,rS)rr`rr)r\r�installed_versions�s	
rac@seZdZdS)�ControlFileValueErrorN)�__name__�
__module__�__qualname__rrrrrb�srbc@seZdZdS)�MissingVersionValueErrorN)rcrdrerrrrrf�srfcCsAd}d}d}t|dd��}dd�|D�}WdQRXx�|D]�}|dkr||dkr||dkrsPd}qH|jd�r�d}qH|jd	|�r�|}qH|j�jd
�rH|dkr�td��|jdd
�d
j�}qHW|dkrtd��|dkr=|dkr9td��|S|S)zFread the debian/control file, extract the X-Python3-Version
    field.N�encodingzutf-8cSsg|]}|j��qSr)r)rrXrrrr�s	z/extract_pyversion_attribute.<locals>.<listcomp>r�SourcezSource:z	Package: zx-python3-version:z1attribute X-Python3-Version not in Source sectionrErznot a control filez$no X-Python3-Version in control file)rrO�lowerrr%rrbrf)�fn�pkgr]ZsversionZsectionZcontrolfile�linesrXrrr�extract_pyversion_attribute�s2
			 rmcCs�ddlm}d}|d|�}|jddddd	d
dd�|jd
dddd	d
dd�|jddddd	d
dd�|jddddd	d
dd�|jddddddd	d
dd�|j�\}}tjjtjd�}|j	r{t
|�dkr{ytt|j
��Wq�tk
rw}z#td||�tjd�WYdd}~Xq�Xn|jr�t
|�dkr�td jt|j
���n�|jr�t
|�dkr�td jt|j
���n�|jrZt
|�dkrZt
|�dkr%d!}n
|d}y�tjj|�r�|}y%t|d"�}	t|	|j
�}
Wq�tk
r�tjjd#||f�tjd�Yq�tk
r�tjjd$|�t|j
�}
Yq�Xnt||j
�}
td j|
��Wq�tk
rV}z,tjjd%||f�tjd�WYdd}~Xq�Xn'tjjd&||f�tjd�dS)'Nr)�OptionParserz;[-v] [-h] [-d|--default] [-s|--supported] [-i|--installed] �usagez-dz	--default�helpz!print the default python3 version�action�
store_true�destrYz-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)Frz%s:rrDzdebian/controlrhz%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
)ZoptparsernZ
add_option�
parse_argsrr
r_�sys�argvrYr$�printrGrr�exitr\rNr,rurart�isfilermr^rb�stderr�writerf)rnro�parserZopts�argsZprogram�msgrrjr6Zvsrrr�mainsn



#	


#r��__main__)rr.rwrr=r?�environrr%rHrRrr:r>r@r,rGr^rarrbrfrmr�rcrrrr�<module>s,	"*!
=A

Zerion Mini Shell 1.0