HEX
Server: nginx/1.28.0
System: Linux server-one 5.15.0-153-generic #163-Ubuntu SMP Thu Aug 7 16:37:18 UTC 2025 x86_64
User: root (0)
PHP: 8.3.23
Disabled: NONE
Upload Files
File: //proc/2991266/root/usr/share/apt-listchanges/__pycache__/DebianFiles.cpython-310.pyc
o

Dc``O@�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
ddlmZdd�ZGdd�d�ZGdd	�d	�ZGd
d�d�ZGdd
�d
�ZGdd�d�ZGdd�d�ZGdd�d�Zd	dgZdS)�N)�_)�reducecCs dddddd�}|�|��d�S)N����)�critical�	emergency�high�medium�low�c)�get�lower)�u�urgency_map�r�)/usr/share/apt-listchanges/DebianFiles.py�_numeric_urgency-s�rc@s>eZdZe�d�Zgd�Zdd�Zdd�Zdd�Z	d	d
�Z
dS)�
ControlStanzaz^\S+ \((?P<version>.*)\).*)�Package�Source�Version�Architecture�StatuscCs~d}|�d�D]5}|sdS|ddvr$|r#t||t||�d|�q|�dd�\}}||jvr:t|||���qd}qdS)N�
r)� �	�:r)�split�setattr�getattr�fields_to_read�lstrip)�self�s�field�line�valuerrr�__init__;s�
�zControlStanza.__init__cCst|d|j��d�dS)Nrrr)r!rr�r$rrr�sourceLszControlStanza.sourcecCst|d�o|j�d�ddkS)Nrrr�	installed)�hasattrrrr*rrrr,OszControlStanza.installedcCs>|j}t|d�r|j�|j�}|r|�d�}|�|�s|S|S)a�
        This function returns the version of the package. One would like it to
        be the "binary" version, though we have the tough case of source
        package whose binary packages versioning scheme is different from the
        source one (see OOo, linux-source, ...).

        This code does the following, if the Source field is set with a
        specified version, then we use the binary version if and only if the
        source version is a prefix. We must do that because of binNMUs.
        r�version)rr-�source_version_re�matchr�group�
startswith)r$�vr0�svrrrr.Rs


zControlStanza.versionN)�__name__�
__module__�__qualname__�re�compiler/r"r)r+r,r.rrrrr7s
rc@�4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�
ControlParsercCsg|_i|_dS�N)�stanzas�indexr*rrrr)hs
zControlParser.__init__cCs.i|j|<|jD]}||j|t||�<qdSr<)r>r=r!)r$r&�stanzarrr�	makeindexls

�zControlParser.makeindexc
Cs�z-t|ddd��}|jdd�|���d�D�7_Wd�WdS1s&wYWdStyG}zttd�|t|�d��|�d}~ww)	N�utf-8�replace)�encoding�errorscSsg|]}|rt|��qSr)r��.0�xrrr�
<listcomp>tsz*ControlParser.readfile.<locals>.<listcomp>�

�'Error processing '%(what)s': %(errmsg)s��what�errmsg)�openr=�readr�	Exception�RuntimeErrorr�str)r$�file�f�exrrr�readfileqs$&�����zControlParser.readfilec
Csnzdd|gtj}t�|�}|j�t|�dd���WdSty6}ztt	d�|t
|�d��|�d}~ww)Nzdpkg-debz-frArBrJrK)rr"�
subprocess�check_outputr=�append�decoderPrQrrR)r$�deb�command�outputrUrrr�readdebys
����zControlParser.readdebcCsZ||jvr||j|vr|j||SdS|jD]}t||�r*t||�|kr*|SqdSr<)r>r=r-r!)r$r&r(r?rrr�find�s

�zControlParser.findN)r5r6r7r)r@rVr^r_rrrrr;gs	r;c@szeZdZddd�Zdd�Zdd�Zedd	��Zed
d��Zedd
��Z	edd��Z
edd��Zedd��Zdd�Z
e
ZdS)�ChangelogEntryFcCs0|��|_||_t|�|_d|_d|_||_dS)N�)�strip�_header�_versionr�_trailer�_content�_binnmu)r$�headerr.�urgency�binnmurrrr)�s


zChangelogEntry.__init__cCs|��|_dSr<)�rstripre)r$�trailerrrr�set_trailer�szChangelogEntry.set_trailercCs.|jr|j|7_dS|��s||_dSdSr<)rf�isspace)r$�contentrrr�add_content�s

�zChangelogEntry.add_contentcC�|jSr<)rdr*rrrr.��zChangelogEntry.versioncCrqr<�rr*rrr�numeric_urgency�rrzChangelogEntry.numeric_urgencycCrqr<)rgr*rrrrj�rrzChangelogEntry.binnmucCrqr<)rcr*rrrrh�rrzChangelogEntry.headercCrqr<)rer*rrrrl�rrzChangelogEntry.trailercCs
|j��Sr<)rfrkr*rrrro�s
zChangelogEntry.contentcCs2|jd|jd|j}|jr|jr|S|��S)NrI)rhrorlrb)r$�resultrrr�__str__�szChangelogEntry.__str__N)F)r5r6r7r)rmrp�propertyr.rtrjrhrlrorv�__repr__rrrrr`�s$






r`c@s`eZdZdd�Zedd��Zedd��Zedd��Zed	d
��Zedd��Z	d
d�Z
dd�ZdS)�ChangescCs ||_g|_g|_td�|_dS)Nr)�_package�_entries�_binnmusr)r$�packagerrrr)�szChanges.__init__cCrqr<)rzr*rrrr}�rrzChanges.packagecCrqr<rsr*rrrrt�rrzChanges.numeric_urgencycCrqr<)r{r*rrr�entries�rrzChanges.entriescCrqr<)r|r*rrr�binnmus�rrzChanges.binnmuscCs |jrd�tt|j��dSdS)NrIra)r{�join�maprRr*rrr�changes�szChanges.changescCs6|jr|j�|�dS|j�|�t|j|j�|_dSr<)rjr|rYr{�minrrt�r$�entryrrr�
save_entry�szChanges.save_entrycCs|j��|j��dSr<)r{�reverser|r*rrrr��s
zChanges.reverseN)r5r6r7r)rwr}rtr~rr�r�r�rrrrry�s




ryc@sTeZdZe�d�Ze�d�Ze�dej�Ze�d�Z	dZ
dd�Zdd	�Zd
d�Z
dS)
�ChangelogParserz8^\S+ \((?P<version>.*)\) .*;.*urgency=(?P<urgency>\w+).*zV^(\S+ \(?\d.*\)|Old Changelog:|Changes|ChangeLog begins|Mon|Tue|Wed|Thu|Fri|Sat|Sun).*z(;;\s*)?Local\s+variables.*z^\s--\s.*<.*@.*>.*$zbinary-only=yescCs
||_dSr<)�_changes)r$r�rrrr)�s
zChangelogParser.__init__c
Csld}d}d}|rt|�nd}|��D]�}|�dd�}|�d�r q|durA|�d�s-|dkrA|s;|j�|�r;|�|�q|�|�q|sI|j�|�nd}|r�d}|�	d	�}	|r`t
�|	|�d
kr`nO|�|�|duru|t
|jj�krud}n:t||	|�	d�|j|v�}q|j�|�r�|s�n"d}|�|�t|dd
d�}q|j�|�r�n|dur�|�|�q|�|�|S)z�Parse changelog or news from the given file descriptor.
        If since_version is specified, only save entries later
        than the specified version.
        If latest is specified, only the latest N versions.FNrArB�#rrTr.rrirar)�int�	readlinesrZr2�_changelog_trailerr0rmrp�_changelog_headerr1�apt_pkg�version_compare�_save_entry�lenr�r~r`�_binnmu_marker�_changelog_header_ancient�_changelog_header_emacs)
r$�fd�
since_version�latest�ancientr��is_debian_changelogr'r0r.rrr�parse�sT


��
�

zChangelogParser.parsecCs|dur|j�|�dSdSr<)r�r�r�rrrr�*s�zChangelogParser._save_entryN)r5r6r7r8r9r�r��
IGNORECASEr�r�r�r)r�r�rrrrr��s


9r�c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�ChangelogsReadercCs"||_||_||_||_||_dSr<)�_source_pkg_name�_rootdir�_since_version�_latest�_reverse)r$�source_pkg_name�rootdirr�r�r�rrrr)/s

zChangelogsReader.__init__csRt�j����fdd�}t||d�}|rt||d�p|}|s dS�jr'����S)Ncs|p
��tj��j|���Sr<)�_read_changelog�os�pathr�r�)�acc�fname�r�r$rr�<lambda>9s�z2ChangelogsReader.read_changelogs.<locals>.<lambda>F)ryr�rr�r�)r$�	filenames�binnmus_filenames�
find_firstrurr�r�read_changelogs6s
z ChangelogsReader.read_changelogscCsP|�|�}|s	dS|�t|��||j|j�Wd�S1s!wYdS)NF)�_open_changelog_filer�r�r�r�)r$�filenamer�r�rrrr�Hs
$�z ChangelogsReader._read_changelogcCs�t�|�}|D]I}z(tj�|�rt�td�|�WdS|�d�r*t�	|�WSt
|d�WStyP}z|jtj
krF|jtjkrF�WYd}~qd}~wwdS)Nz(Ignoring `%s' (seems to be a directory!)z.gz�rb)�globr�r��isdir�ALCLog�errorr�endswith�gzip�GzipFilerN�IOError�errno�ENOENT�ELOOP)r$r�r��errrr�Ps 

���z%ChangelogsReader._open_changelog_fileN)r5r6r7r)r�r�r�rrrrr�.s
r�c@r:)rcCsJ||_t�}|�|j�|jd}|j|_|��|_|��|_|j	|_
dS)Nr)r�r;r^r=r�binaryr+r.rr�arch)r$r��parser�pkgdatarrrr)bs


zPackage.__init__c
Cs�|�d�}|�d�}|�d|j�}|�d�}g}	|dks!|dkr&|	�|�|dks.|dkr=|	�|�|	�|�|	�|�|�|	�}
z"t|j|
|||�}|�|d�}|�|||�}
Wt�|
d	�||
fSt�|
d	�w)
aiExtract changelog and binnmu entries, news or both from the package.

        Unpacks changelog or news files from the binary package, and parses them.
        If since_version is specified, only return entries later than the specified version.
        If latest is specified, only the latest N versions.
        Returns a tuple of sequences of Changes objects.zNEWS.Debianzchangelog.Debianzchangelog.Debian.�	changelog�both�news�
changelogsNr)	�_changelog_variationsr��extend�_extract_contentsr�r+r��shutil�rmtree)r$�whichr�r�r��news_filenames�changelog_filenames�changelog_filenames_binnmu�changelog_filenames_nativer��tempdir�readerr�r�rrr�extract_changesns*








��zPackage.extract_changesc	Cs�tjdd�}tj�||jd�}t|d�}z�z&dddd|j|jfg}t�	t
d	�d
t|�i�tj
||tjddd
�WnLtjyh}zt�t
d�|j|jrV|j�dd�nt|�d��WYd}~n>d}~wty�}zt�t
d�|jt|�d��WYd}~n+d}~wwt|jd|||��|gd�W|��t�|d�SW|��t�|d�dSW|��t�|d�dS|��t�|d�w)a�Run apt-get changelog and parse the downloaded changelog.

        Retrieve changelog using the "apt-get changelog" command, and parse it.
        If since_version is specified, only return entries later than the specified version.
        If latest is specified, only the latest N versions.
        Returns a single sequence of Changes objects or None on downloading or parsing failure.�apt-listchanges��prefixz
.changelog�wzapt-getz-qqr�z%s=%sz%Calling %(cmd)s to retrieve changelog�cmd�xT)�stdout�stderr�timeout�checkz]Unable to retrieve changelog for package %(pkg)s; 'apt-get changelog' failed with: %(errmsg)srArB)�pkgrMNz_Unable to retrieve changelog for package %(pkg)s; could not run 'apt-get changelog': %(errmsg)srar)�tempfile�mkdtempr�r�r�r�rNrr��debugrrRrW�run�PIPE�CalledProcessErrorr�r�rZrPr�r+r��closer�r�)	r$r�r�r�r��changelog_file�changelog_fdr\rUrrr�extract_changes_via_apt�sN	

���
�����
���
�zPackage.extract_changes_via_aptcCsptjdd�}dt�|j�t�|�d�dd�|D��f}t�|�}t�|�r6t�	|�t
jkr6t�
|d�t�|S)Nr�r�zFdpkg-deb --fsys-tarfile %s | tar xf - --wildcards -C %s %s 2>/dev/nullrcSsg|]}t�|��qSr)�shlex�quoterErrrrH�sz-Package._extract_contents.<locals>.<listcomp>r)r�r�r�r�r�r�r��system�WIFSIGNALED�WTERMSIG�signal�SIGINTr�r��KeyboardInterrupt)r$r�r��extract_command�statusrrrr��s�
zPackage._extract_contentscsddg}�fdd�|D�S)Nz./usr/share/doc/*/%s.gzz./usr/share/doc/*/%scsg|]}|��qSrrrE�r�rrrH�sz1Package._changelog_variations.<locals>.<listcomp>r)r$r��formatsrr�rr��s�zPackage._changelog_variationsN)r5r6r7r)r�r�r�r�rrrrras#*r)r8r�r�r�r�r�r�r�r�rWr�r��ALChacksr�	functoolsrrrr;r`ryr�r�r�__all__rrrr�<module>s.
0'1(G3s