%PDF- %PDF-
Mini Shell

Mini Shell

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

3

Ĥ�[�-�@s�ddlZddlZddlZdadadadd�ejjdd�jd�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|]}|j�rd|j��qS)zpython%s)�strip)�.0Zver�r�!/usr/share/python3/py3versions.py�
<listcomp>
srZDEBPYTHON3_SUPPORTED��,cCs~ddlm}m}tsDtjjd�rD|�}td�}|j|�|j	�|atrz|rzytj
d|�}Wn|k
rtt�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
slt|jd��dkrtd��ddl}|j|j|j|j|jd�}i}t�}tt	dd��}d}x�|jd�D]�}|j
�}|d	krzqd|dkr�qd|jdt��tj
d
�}|j|�}	yx|	s�td��|	jd�|	jd�}
��jd�\}}t|�dkr�wd|
dk�r�|j��n d}||
���fdd�|D�}Wqdtk
�r<td��YqdXqdWd|k�rh||d<|�rh|j|�|d<|S)Nr�zDtoo many arguments provided for X-Python3-Version: min and max only.r)N�=z>=z<=z<<T)�version_onlyF�all�current�current_ext�versionsz(>=|<=|<<|=)? *(\d\.\d)$z'error parsing Python3-Version attribute��.�rcsg|]}�|��r|�qSrr)r�av)�filtop�vrrrGsz"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:FcCsXts>y td�}dd�|jd�D�aWntk
r<gaYnX|rPdd�tD�StSdS)Nzold-versionscSsg|]}|j��qSr)r)r�srrrrVsz old_versions.<locals>.<listcomp>rcSsg|]}|dd��qS)�Nr)rr#rrrrZs)�
_old_versionsrr%r)rrrrr�old_versionsQs
r>cCsXts>y td�}dd�|jd�D�aWntk
r<gaYnX|rPdd�tD�StSdS)Nzunsupported-versionscSsg|]}|j��qSr)r)rr;rrrrdsz(unsupported_versions.<locals>.<listcomp>rcSsg|]}|dd��qS)r<Nr)rr#rrrrhs)�_unsupported_versionsrr%r)rrrrr�unsupported_versions_s
r@c	Cs&t�ts�y td�}dd�|jd�D�aWn�tk
r�ddddg}y&d	dl}|j|d
d|jd�}|j}Wn$t	k
r�t
jd
j|��}YnXd}x0|D](}|j
d�r�|jdd
�d
j�jd�}q�W|j�dd�|D�}|aYnXtjtjt��}tj�tj|�|�rdd�tD�StSdS)Nzsupported-versionscSsg|]}|j��qSr)r)rr;rrrrssz&supported_versions.<locals>.<listcomp>rz/usr/bin/apt-cachez--no-all-versionsZshowzpython3-allrrF)�bufsize�shell�stdout� zDepends:�:cSsg|]}tjdd|��qS)z\s*(\S+)[ (]?.*z\1)r.�sub)rr;rrrr�scSsg|]}|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|�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<)rRr�readlinkrr
rNr)rZdebian_defaultrrrrG�s
rGcCs�t�d}t|�}tdd�}t|�dkr�|dj|�}g}x|D]}|j|�q@Wy|j|jtdd���}Wnd}YnX|j	�|r�|j|�nt
d��|s�t
d��|r�|Sd	d
�|D�SdS)NT)rrrr<rz/No supported python3 versions in version stringzempty set of versionscSsg|]}d|�qS)zpython%sr)rr#rrrr�sz&requested_versions.<locals>.<listcomp>)rGr:r,r$�intersectionrTrPrQrRrSr)r6rrr7�	supportedZvl�versionrYrrr�requested_versions�s,


r^csHddl}t���fdd�|jd�D�}|j�|r@dd�|D�S|SdS)Nrcs(g|] }tjj|��krtjj|��qSr)rr
�basename)rr;)r\rrr�sz&installed_versions.<locals>.<listcomp>z/usr/bin/python3.[0-9]cSsg|]}|dd��qS)r<Nr)rr#rrrr�s)�globr,rS)rr`rr)r\r�installed_versions�s
rac@seZdZdS)�ControlFileValueErrorN)�__name__�
__module__�__qualname__rrrrrb�srbc@seZdZdS)�MissingVersionValueErrorN)rcrdrerrrrrf�srfcCs�d}d}d}t|dd��}dd�|D�}WdQRXx�|D]z}|dkr\|dkr\|dkrVPd}q8|jd�rld}q8|jd	|�r�|}q8|j�jd
�r8|dkr�td��|jdd
�d
j�}q8W|dkr�td��|dkr�|dkr�td��|S|S)zFread the debian/control file, extract the X-Python3-Version
    field.Nzutf-8)�encodingcSsg|]}|j��qSr)r)rrXrrrr�sz/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
�|jddd
ddd
�|jdddddd
�|jdddddd
�|jddddddd�|j�\}}tjjtjd�}|j	o�t
|�dk�rytt|j
��Wn:tk
r�}ztd||�tjd�WYdd}~XnX�n�|j�r2t
|�dk�r2tdjt|j
����nt|j�r`t
|�dk�r`tdjt|j
����nF|j�r�t
|�dk�r�t
|�dk�r�d }n|d}y�tjj|��r&|}yt|d!�}	t|	|j
�}
Wnbtk
�r�tjjd"||f�tjd�Yn0tk
�r"tjjd#|�t|j
�}
YnXnt||j
�}
tdj|
��WnBtk
�r�}z$tjjd$||f�tjd�WYdd}~XnXntjjd%||f�tjd�dS)&Nr)�OptionParserz;[-v] [-h] [-d|--default] [-s|--supported] [-i|--installed] )�usagez-dz	--defaultz!print the default python3 version�
store_truerY)�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)rqrYrrrsz%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__)N)F)F)F)F)F)F)rr.rwrr=r?�environrr%rHrRrr:r>r@r,rGr^rarrbrfrmr�rcrrrr�<module>s,
*


!



=A

Zerion Mini Shell 1.0