File: //lib/python3/dist-packages/apport/crashdb_impl/__pycache__/memory.cpython-310.pyc
o
Z�8d�( � @ s, d Z ddlZddlZG dd� dejj�ZdS )zISimple in-memory CrashDatabase implementation, mainly useful for testing.� Nc @ s� e Zd ZdZdd� Zd.dd�Zdd� Zd d
� Zdd� Zd
d� Z dd� Z
dd� Z d/dd�Zdd� Z
dd� Zdd� Zdd� Zdd� Zd d!� Zd"d#� Zd$d%� Zd&d'� Zd(d)� Zd*d+� Zd,d-� ZdS )0�
CrashDatabasez�Simple implementation of crash database interface which keeps everything
in memory.
This is mainly useful for testing and debugging.c C s@ t jj�| ||� g | _t� | _t� | _d|v r| �� dS dS )zkInitialize crash database connection.
This class does not support bug patterns and authentication.�
dummy_dataN) �apport�crashdbr �__init__�reports�set�
unretraced�
dup_unchecked�add_dummy_data)�self� auth_file�options� r �</usr/lib/python3/dist-packages/apport/crashdb_impl/memory.pyr s �zCrashDatabase.__init__Nc C sZ | � |�sJ �| j�|dddd�� t| j�d }d|v r%| j�|� |S | j�|� |S )z�Store the report and return a handle number (starting from 0).
This does not support (nor need) progress callbacks.
N� )�report�
fixed_version�dup_of�comment� � Traceback)�acceptsr �append�lenr
�addr )r r �progress_callback�idr r r �upload$ s
��zCrashDatabase.uploadc C s d|v rd|d |f S d| S )z�Return http://<sourcepackage>.bugs.example.com/<handle> for package bugs
or http://bugs.example.com/<handle> for reports without a SourcePackage.�
SourcePackagezhttp://%s.bugs.example.com/%izhttp://bugs.example.com/%ir )r r �handler r r �get_comment_url4 s zCrashDatabase.get_comment_urlc C s | � ||�S )z�Return URL for a given report ID.
The report is passed in case building the URL needs additional
information from it, such as the SourcePackage name.
Return None if URL is not available or cannot be determined.
)r! )r r r r r r �
get_id_url= s zCrashDatabase.get_id_urlc C � | j | d S )z>Download the problem report from given ID and return a Report.r �r �r r r r r �downloadG � zCrashDatabase.downloadc C s | j | d d gS )z5Return list of affected source packages for given ID.r r r$ r% r r r �get_affected_packagesL s z#CrashDatabase.get_affected_packagesc C s dS )z3Check whether the user is the reporter of given ID.Tr r% r r r �is_reporterQ s zCrashDatabase.is_reporterc C s
| � |�S )aB Check whether the user is eligible to update a report.
A user should add additional information to an existing ID if (s)he is
the reporter or subscribed, the bug is open, not a duplicate, etc. The
exact policy and checks should be done according to the particular
implementation.
)r) r% r r r �
can_updateV s
zCrashDatabase.can_updateFc C sN | j | }||d<