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: //lib/python3/dist-packages/debian/__pycache__/debian_support.cpython-38.pyc
U

&]�^�[�@s`dZddlmZmZddlZddlZddlZz,ddlmZm	Z	m
Z
mZmZm
Z
mZmZWnek
rlYnXddlmZzddlZe��dZWnek
r�dZYnXzddlZejZWnFek
�rzddlZejZWnek
r�dd	�ZYnXYnXGd
d�de�ZGdd
�d
e�ZGdd�de�ZGdd�de�Z e�r^Gdd�de�Z!nGdd�de �Z!dd�Z"Gdd�d�Z#Gdd�d�Z$Gdd�de$�Z%dd�Z&ee&�Z'e&�Z(d2dd �Z)ee)�Z*['[&d!d"�Z+ee+�Z,e�-d#�Z.d3d$d%�Z/ee/�Z0d&d'�Z1ee1�Z2d(d)�Z3ee3�Z4d*d+�Z5ee5�Z6d,d-�Z7ee7�Z8d4d.d/�Z9ee9�Z:d0d1�Z;ee;�Z<dS)5z2 Facilities to deal with Debian-specific metadata �)�absolute_import�print_functionN)�Any�Dict�Iterator�List�Optional�Pattern�Text�Union)�function_deprecated_byTFcGstd��dS)Nz�Built-in sha1 implementation not found; cannot use hashlib implementation because it depends on OpenSSL, which may not be linked with this library due to license incompatibilities��NotImplementedError)�args�r�7/usr/lib/python3/dist-packages/debian/debian_support.py�new_sha1?s�rcs@eZdZdZ�fdd�Zdd�Zdd�Zdd	�Zee�Z	�Z
S)
�
ParseErrorz�An exception which is used to signal a parse failure.

    Attributes:

    filename - name of the file
    lineno - line number in the file
    msg - error message

    cs4tt|�st�||_||_||_tt|��|�dS�N)	�
isinstance�int�AssertionError�filename�lineno�msg�superr�__init__)�selfrrr��	__class__rrrRs
zParseError.__init__cCs|jSr)r�rrrr�__str__YszParseError.__str__cCsd|j|j|jfS)NzParseError(%r, %d, %r))rrrr rrr�__repr__\s�zParseError.__repr__cCs&|�d|j|j|jf�|��dS)z0Writes a machine-parsable error message to file.z
%s:%d: %s
N)�writerrr�flush)r�filerrr�	print_outaszParseError.print_out)�__name__�
__module__�__qualname__�__doc__rr!r"r&rZprintOut�
__classcell__rrrrrGs
rcs�eZdZdZe�d�ZdZdd�Zdd�Z	�fdd	�Z
�fd
d�Zdd
�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Z�ZS)"�BaseVersiona�Base class for classes representing Debian versions

    It doesn't implement any comparison, but it does check for valid versions
    according to Section 5.6.12 in the Debian Policy Manual.  Since splitting
    the version into epoch, upstream_version, and debian_revision components is
    pretty much free with the validation, it sets those fields as properties of
    the object, and sets the raw version to the full_version property.  A
    missing epoch or debian_revision results in the respective property set to
    None.  Setting any of the properties results in the full_version being
    recomputed and the rest of the properties set from that.

    It also implements __str__, just returning the raw version given to the
    initializer.
    zd^((?P<epoch>\d+):)?(?P<upstream_version>[A-Za-z0-9.+:~-]+?)(-(?P<debian_revision>[A-Za-z0-9+.~]+))?$)�full_version�epoch�upstream_version�debian_revision�debian_versioncCst|t�rt|�}||_dSr)rr,�strr-�r�versionrrrr�s
zBaseVersion.__init__cCsr|j�|�}|std|��|�d�dkrDd|�d�krDtd|��||_|�d�|_|�d�|_|�d�|_dS)NzInvalid version string %rr.�:r/r0)�re_valid_version�match�
ValueError�groupZ_BaseVersion__full_version�_BaseVersion__epoch�_BaseVersion__upstream_version�_BaseVersion__debian_revision)rr4�mrrr�_set_full_version�szBaseVersion._set_full_versioncs�||jkr tt|��||�dS|dkr,d}|dkrD|�t|��nt|dk	rTt|�}d|}t||�}t|||�z|��Wn8t	k
r�t|||�|��t	d||f��YnXdS)Nr1r0r-�_BaseVersion__%sz+Setting %s to %r results in invalid version)
�magic_attrsrr,�__setattr__r>r2�getattr�setattr�_update_full_versionr8)r�attr�value�private�	old_valuerrrrA�s(

�zBaseVersion.__setattr__cs8||jkrtt|��|�S|dkr&d}d|}t||�S)Nr1r0r?)r@rr,�__getattribute__rB)rrErGrrr�__getattr__�s
zBaseVersion.__getattr__cCsDd}|jdk	r||jd7}||j7}|jr:|d|j7}||_dS)N�r5�-)r:r;r<r-r3rrrrD�s

z BaseVersion._update_full_versioncCs|jSr)r-r rrrr!�szBaseVersion.__str__cCsd|jj|fS)Nz%s('%s'))rr'r rrrr"�szBaseVersion.__repr__cCst�dSrr
�r�otherrrr�_compare�szBaseVersion._comparecCs|�|�dkS�Nr�rOrMrrr�__lt__�szBaseVersion.__lt__cCs|�|�dkSrPrQrMrrr�__le__�szBaseVersion.__le__cCs|�|�dkSrPrQrMrrr�__eq__�szBaseVersion.__eq__cCs|�|�dkSrPrQrMrrr�__ne__�szBaseVersion.__ne__cCs|�|�dkSrPrQrMrrr�__ge__�szBaseVersion.__ge__cCs|�|�dkSrPrQrMrrr�__gt__�szBaseVersion.__gt__cCstt|��Sr)�hashr2r rrr�__hash__�szBaseVersion.__hash__)r'r(r)r*�re�compiler6r@rr>rArJrDr!r"rOrRrSrTrUrVrWrYr+rrrrr,is(�
r,cs(eZdZdZ�fdd�Zdd�Z�ZS)�
AptPkgVersionzARepresents a Debian package version, using apt_pkg.VersionComparecs tstd��tt|��|�dS)Nz5apt_pkg not available; install the python-apt package)�
_have_apt_pkgrrr\rr3rrrr�szAptPkgVersion.__init__cCst�t|�t|��Sr)�apt_pkg�version_comparer2rMrrrrO�szAptPkgVersion._compare)r'r(r)r*rrOr+rrrrr\�sr\c@sdeZdZdZe�d�Ze�d�Ze�d�Ze�d�Z	dd�Z
edd	��Zed
d��Z
edd
��ZdS)�
NativeVersionzBRepresents a Debian package version, with native Python comparisonz\d+|\D+z\d+z\dz[A-Za-z]c
Cs�|dkrdSt|t�sZztt|��}Wn2tk
rX}ztd||f��W5d}~XYnXt|jpdd�}t|jprd�}||kr�dS||kr�dS|�|jp�d|jp�d�}|dkr�|S|�|jp�d|jp�d�S)N�z&Couldn't convert %r to BaseVersion: %s�0���r)	rr,r2r8rr.�_version_cmp_partr/r0)rrN�eZlepochZrepoch�resrrrrOs.
���zNativeVersion._comparecCsD|dkrdS|j�|�r$t|�dS|j�|�r8t|�St|�dS)z'Return an integer value for character x�~rcra�)�re_digitr7r�re_alpha�ord)�cls�xrrr�_order*szNativeVersion._ordercsn�fdd�|D�}�fdd�|D�}|s,|rjd}d}|rB|�d�}|rP|�d�}||kr\dS||kr$dSq$dS)Ncsg|]}��|��qSr�rn��.0rm�rlrr�
<listcomp>9sz5NativeVersion._version_cmp_string.<locals>.<listcomp>csg|]}��|��qSrrorprrrrrs:srrcra)�pop)rl�va�vb�la�lb�a�brrrr�_version_cmp_string6s

z!NativeVersion._version_cmp_stringc
Cs�|j�|�}|j�|�}|s |r�d}d}|r6|�d�}|rD|�d�}|j�|�r�|j�|�r�t|�}t|�}||krxdS||kr�dSq|�||�}	|	dkr|	SqdS)Nrbrrcra)�re_all_digits_or_not�findallrt�	re_digitsr7rr{)
rlrurvrwrxryrzZavalZbvalrfrrrrdHs(

zNativeVersion._version_cmp_partN)r'r(r)r*rZr[r|r~rirjrO�classmethodrnr{rdrrrrr`s





r`c@seZdZdS��VersionN�r'r(r)rrrrr�csr�c@seZdZdSr�r�rrrrr�fscCs,t|�}t|�}||krdS||kr(dSdS)Nrcrar)r�)ryrzrurvrrrr_jsr_c@sHeZdZdZe�d�Ze�d�Zddd�Zdd	�Z	d
d
d�Z
ee
�ZdS)�PackageFilezmA Debian package file.

    Objects of this class can be used to read Debian's Source and
    Packages files.z+^([A-Za-z][A-Za-z0-9-_]+):(?:\s*(.*?))?\s*$z^\s+(?:\.|(\S.*?)\s*)$N�utf-8cCs.|dkrt|d�}||_||_d|_||_dS)z�Creates a new package file object.

        name - the name of the file the data comes from
        file_obj - an alternate data source; the default is to open the
                  file with the indicated name.
        N�rbr)�open�namer%r�encoding)rr�Zfile_objr�rrrr~s
zPackageFile.__init__ccs|j���|j�}|jd7_g}|�r|�d�dkrr|sF|�d�|Vg}|j���|j�}|jd7_q$|j�|�}|s�|�d�|�	�\}}|p�d}|j���|j�}|jd7_|j
�|�}|r�|�	�\}|dkr�d}d||f}q�q�q�|�||f�q$|�r|VdS)Nraz 	�
zexpected package recordzexpected package fieldrKz%s
%s)r%�readline�decoder�r�strip�raise_syntax_error�re_fieldr7�groups�re_continuation�append)r�line�pkgr7r��contentsZ	ncontentsrrr�__iter__�s:


zPackageFile.__iter__cCs |dkr|j}t|j||��dSr)rrr�)rrrrrrr��szPackageFile.raise_syntax_error)Nr�)N)
r'r(r)r*rZr[r�r�rr�r�rZraiseSyntaxErrorrrrrr�us


#
r�c@s`eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�
PseudoEnumz8A base class for types which resemble enumeration types.cCs||_||_dSr)�_namern)rr��orderrrrr�szPseudoEnum.__init__cCsd|jj|jfS)Nz%s(%r))rr'r�r rrrr"�szPseudoEnum.__repr__cCs|jSr)r�r rrrr!�szPseudoEnum.__str__cCs|j|jkSrrorMrrrrR�szPseudoEnum.__lt__cCs|j|jkSrrorMrrrrS�szPseudoEnum.__le__cCs|j|jkSrrorMrrrrT�szPseudoEnum.__eq__cCs|j|jkSrrorMrrrrU�szPseudoEnum.__ne__cCs|j|jkSrrorMrrrrV�szPseudoEnum.__ge__cCs|j|jkSrrorMrrrrW�szPseudoEnum.__gt__cCs
t|j�Sr)rXrnr rrrrY�szPseudoEnum.__hash__N)r'r(r)r*rr"r!rRrSrTrUrVrWrYrrrrr��sr�c@seZdZdS)�ReleaseNr�rrrrr��sr�cCs2i}d}t|�D]\}}t||�||<q|t_|S)N)ZbuzzZrexZboZhammZslinkZpotatoZwoodyZsargeZetchZlennyZsqueezeZwheezyZjessieZstretchZbusterZbullseyeZsid)�	enumerater��releases)r�Zrels�idxZrelrrr�
list_releases�sr�cCs|dkrt}|�|�Sr)�
_release_list�get)r�r�rrr�intern_release�sr�cCs>t�}|D]*}t|t�r$|�|�q
|�|�d��q
|��S)N�UTF-8)rr�bytes�update�encodeZ	hexdigest)�linesr=�lrrr�read_lines_sha1s
r�z^(\d+)(?:,(\d+))?([acd])$c
cst|�}|dkrt}|D]�}|�|�}|dkr:td|��|��\}}}t|�}|dk	r`t|�}|dkr�|d}|dkr�|d}||gfVq|dkr�|dk	r�td|��|}n|d}|dkr�|d}g}|D]0}	|	dkr�td|��|	d	kr��q|�|	�q�|||fVqdS)
a1Converts source to a stream of patches.

    Patches are triples of line indexes:

    - number of the first line to be replaced
    - one plus the number of the last line to be replaced
    - list of line replacements

    This is enough to model arbitrary additions, deletions and
    replacements.
    Nzinvalid patch command: %r�draryzinvalid patch argument: %rrKzend of stream in command: %r)z.
�.)�iter�	_patch_rer7r8r�rr�)
�sourceZre_cmd�ir�r7�first�last�cmdr��crrr�patches_from_ed_scripts@
r�cCs |D]\}}}||||�<qdS)z2Applies patches to lines.  Updates lines in place.Nr)r�Zpatchesr�r�rrrr�patch_linesXsr�c	Cs\|d}t|d�}z,|D]}|�|�q|��t�||�W5tj�|�rVt�|�XdS)Nz.newzw+)r��os�path�exists�unlinkr#�close�rename)r��localZ	local_newZnew_filer�rrr�replace_filebs
r�c
	Cspddl}ddl}ddlm}|��\}}z6t�|�|||�\}}|�|�}|�	�}	|��W5t�|�X|	S)z[Downloads a file from a remote location and gunzips it.

    Returns the lines in the file.rN)�urlretrieve)
�gzip�tempfile�six.moves.urllib.requestr�Zmkstempr�r�r�ZGzipFile�	readlines)
�remoter�r�r�Zhandle�fnamer�_Zgfiler�rrr�download_gunzip_linests	

r�cCst|d�}t||�|S)z�Copies a gzipped remote file to the local system.

    remote - URL, without the .gz suffix
    local - name of the local file
    �.gz)r�r�)r�r�r�rrr�
download_file�s
r�cCs�zt|�}Wn*tk
r6|r(td�t||�YSX|��}|��t|�}g}i}ddlm}|d}	t	�
d�}
z||	�}tt|	|��}WnRt
k
r�|r�td�t||�YStk
r�|r�td�t||�YSX|D]�}
|
D]�\}}|dk�r4|
�|�\}}||kr�|�r&td	�|Sq�|d
k�r�|��D]>}|dk�rX�qF|
�|�\}}}|�sx||k�rF|�|��qFq�|dk�r�|��D],}|dk�r��q�|
�|�\}}}|||<�q�q�|r�td
|�q�q�|�s�|�r�td|�t||�S|D]f}|�rtd|�t|d|d�}t|�||k�rJtd|��dd�|D�}t|t|���qt|�}||k�r�td||f��t||�|S)zjUpdates the local file by downloading a remote patch.

    Returns a list of lines in the local file.
    z1update_file: no local copy, downloading full filer)�urlopenz.diff/Indexz\s+z1update_file: could not interpret patch index filez0update_file: could not download patch index filezSHA1-Currentz%update_file: local file is up-to-datezSHA1-HistoryrKzSHA1-Patcheszupdate_file: field %r ignoredz*update_file: could not find historic entryz!update_file: downloading patch %rz.diff/r�zpatch %r was garbledcSsg|]}|�d��qS)r�)r�)rq�prrrrs�szupdate_file.<locals>.<listcomp>z"patch failed, got %s instead of %s)r��IOError�printr�r�r�r�r�r�rZr[�listr�r�split�
splitlinesr�r�r8r�r�r�)r�r��verboseZ
local_filer�Z
local_hashZpatches_to_applyZpatch_hashesr�Z
index_nameZ
re_whitespaceZ	index_urlZindex_fieldsZfieldsZfieldrFZremote_hashr��entryZ	hist_hashZ
patch_nameZ
patch_hashZpatch_contentsZpatch_contents_unicodeZnew_hashrrr�update_file�s�







�
�
r�cGs(i}|D]}|D]}d||<qqt|�S)zdCreate an order set (represented as a list) of the objects in
    the sequences passed as arguments.T)�sorted)r�srm�yrrr�
merge_as_setss
r�)N)N)N)=r*Z
__future__rrr��os.pathrZ�typingrrrrrr	r
r�ImportErrorZdebian.deprecationrr^Zinitr]Z_sha�newrZ_sha1Zsha1�	Exceptionr�objectr,r\r`r�r_r�r�r�r�ZlistReleasesr�r�Z
internReleaser�Z
readLinesSHA1r[r�r�ZpatchesFromEdScriptr�Z
patchLinesr�ZreplaceFiler�ZdownloadGunzipLinesr�ZdownloadFiler�Z
updateFiler�ZmergeAsSetsrrrr�<module>sx,



"
_B%


8
c