+
    oFj?.                     l    R t ^ RIt^ RIHt ^ RIt^ RIt ! R R]P                  P                  4      tR# )zISimple in-memory CrashDatabase implementation, mainly useful for testing.N)Anyc                   h  a  ] tR t^t o RtV 3R lR ltR)R ltR tR tR t	V 3R	 lR
 lt
V 3R lR ltV 3R lR ltR*R ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltR tV 3R lR ltR tV 3R lR ltR+V 3R lR lltV 3R  lR! ltV 3R" lR# ltV 3R$ lR% ltV 3R& lR' ltR(tV tR# ),CrashDatabasezSimple implementation of crash database interface which keeps everything
in memory.

This is mainly useful for testing and debugging.
c                N   < V ^8  d   QhRS[ R,          RS[S[ S[3,          RR/# )   	auth_fileNoptionsreturn)strdictr   )format__classdict__s   "</usr/lib/python3/dist-packages/apport/crashdb_impl/memory.py__annotate__CrashDatabase.__annotate__   s.     # ##* #tCH~ #$ #    c                    \         P                  P                  P                  WV4       . V n        \        4       V n        \        4       V n        RV n        RV n	        RV9   d   V P                  4        R# R# )zdInitialize crash database connection.

This class does not support bug patterns and authentication.
g        Nsample_data)apportcrashdbr   __init__reportsset
unretraceddup_uncheckedupload_delay
upload_msgadd_sample_data)selfr   r   s   &&&r   r   CrashDatabase.__init__   sb    
 	$$--dwG .0$'E'*u26G#  " $r   Nc           
     d   V P                  V4      '       g   Q hV'       d>   V P                  '       d,   V! V P                  ^ ,          V P                  ^,          4       V P                  P                  RVRRRRRR/4       \	        V P                  4      ^,
          pRV9   d   V P
                  P                  V4       MV P                  P                  V4       V P                  '       dC   V'       d
   V! ^ ^d4       \        P                  ! V P                  4       V'       d
   V! ^d^d4       V# )zuStore the report and return a handle number (starting from 0).

This does not support (nor need) progress callbacks.
reportfixed_versionNdup_ofcomment 	Traceback)acceptsr   r   appendlenr   addr   r   timesleep)r   r!   progress_callbackuser_message_callbackcrash_ids   &&&& r   uploadCrashDatabase.upload-   s    
 ||F#### T___!$//!"4dooa6HIvhiQST	
 t||$q(& ""8,OO)  !!S)JJt(() !#s+r   c                8    RV9   d   RVR,           RV 2# RV 2# )zReturn http://<sourcepackage>.bugs.example.com/<handle> for package
bugs or http://bugs.example.com/<handle> for reports without a
SourcePackage.
SourcePackagezhttp://z.bugs.example.com/zhttp://bugs.example.com/ )r   r!   handles   &&&r   get_comment_urlCrashDatabase.get_comment_urlJ   s3    
 f$VO455GxPP)&22r   c                $    V P                  W4      # )zReturn 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.
)r6   )r   r!   r/   s   &&&r   
get_id_urlCrashDatabase.get_id_urlS   s     ##F55r   c                6    V P                   V,          R,          # )z>Download the problem report from given ID and return a Report.r!   r   r   r/   s   &&r   downloadCrashDatabase.download]   s    ||H%h//r   c                6   < V ^8  d   QhRS[ RS[S[,          /# r   r/   r	   )intlistr
   )r   r   s   "r   r   r   a   s#     C Cc Cd3i Cr   c                F    V P                   V,          R,          R,          .# )z5Return list of affected source packages for given ID.r!   r3   r<   r=   s   &&r   get_affected_packages#CrashDatabase.get_affected_packagesa   s    X&x0ABBr   c                &   < V ^8  d   QhRS[ RS[/# rA   rB   bool)r   r   s   "r   r   r   e   s      C D r   c                    R# )z3Check whether the user is the reporter of given ID.Tr4   r=   s   &&r   is_reporterCrashDatabase.is_reportere   s    r   c                &   < V ^8  d   QhRS[ RS[/# rA   rH   )r   r   s   "r   r   r   i   s     * *3 *4 *r   c                $    V P                  V4      # )a  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.
)rK   r=   s   &&r   
can_updateCrashDatabase.can_updatei   s     ))r   c                    V P                   V,          pW7R&   V'       d&   V F  pW9   g   K  W(,          VR,          V&   K  	  R# VR,          P                  V4       R# )a  Update the given report ID with all data from report.

This creates a text comment with the "short" data (see
ProblemReport.write_mime()), and creates attachments for all the
bulk/binary data.

If change_description is True, and the crash db implementation supports
it, the short data will be put into the description instead (like in a
new bug).

comment will be added to the "short" data. If attachment_comment is
given, it will be added to the attachment uploads.

If key_filter is a list or set, then only those keys will be added.
r$   r!   N)r   update)	r   r/   r!   r$   change_descriptionattachment_comment
key_filterrfs	   &&&&&&&  r   rR   CrashDatabase.updatet   sN    0 LL");%+YAhKN   hKv&r   c                &   < V ^8  d   QhRS[ RS[/# rA   rB   r
   )r   r   s   "r   r   r      s     A A3 A3 Ar   c                D    V P                   V,          R,          R,          # )zFGet 'DistroRelease: <release>' from the given report ID and return
it.r!   DistroReleaser<   r=   s   &&r   get_distro_release CrashDatabase.get_distro_release   s     ||H%h/@@r   c                0   < V ^8  d   QhRS[ S[,          /# r   r	   r   rB   )r   r   s   "r   r   r      s      SX r   c                    \        4       p\        V P                  4       F0  w  r#VR,          e   K  VR,          e   K  VP                  V4       K2  	  V# )a0  Return an ID set of all crashes which are not yet fixed.

The list must not contain bugs which were rejected or duplicate.

This function should make sure that the returned list is correct. If
there are any errors with connecting to the crash database, it should
raise an exception (preferably OSError).
r#   r"   )r   	enumerater   r*   )r   resultir!   s   &   r   get_unfixedCrashDatabase.get_unfixed   sG     "4<<0IAh'F?,C,K

1 1 r   c                4   < V ^8  d   QhRS[ RS[R,          /# r   r/   r	   NrZ   )r   r   s   "r   r   r      s      # #* r   c                     V P                   V,          R,          e   R# V P                   V,          R,          #   \         d     R# i ; i)a  Return the package version that fixes a given crash.

Return None if the crash is not yet fixed, or an empty string if the
crash is fixed, but it cannot be determined by which version. Return
'invalid' if the crash report got invalidated, such as closed a
duplicate or rejected.

This function should make sure that the returned result is correct. If
there are any errors with connecting to the crash database, it should
raise an exception (preferably OSError).
r#   invalidr"   )r   
IndexErrorr=   s   &&r   get_fixed_versionCrashDatabase.get_fixed_version   sD    	||H%h/; <<)/:: 		s   : : A	A	c                4   < V ^8  d   QhRS[ RS[ R,          /# ri   rB   )r   r   s   "r   r   r      s     0 0S 0S4Z 0r   c                6    V P                   V,          R,          # )zSReturn master ID for a duplicate bug.

If the bug is not a duplicate, return None.
r#   r<   r=   s   &&r   duplicate_ofCrashDatabase.duplicate_of   s    
 ||H%h//r   c                0    W0P                   V,          R&   R# )z\Mark a crash id as duplicate of given master ID.

If master is None, id gets un-duplicated.
r#   Nr<   )r   r!   r/   	master_ids   &&&&r   close_duplicateCrashDatabase.close_duplicate   s    
 ,5Xx(r   c                *   < V ^8  d   QhRS[ RS[ RR/# )r   r/   masterr	   Nrp   )r   r   s   "r   r   r      s'     V V VS VT Vr   c                t    V P                   V,          R,          f   Q hRV 2V P                   V,          R&   R# )ziMark a crash id as reintroducing an earlier crash which is
already marked as fixed (having ID 'master').
r"   Nzregression, already fixed in #r$   r<   )r   r/   ry   s   &&&r   mark_regressionCrashDatabase.mark_regression   s8     ||F#O4@@@.LVH,UXy)r   c                b     V P                   P                  V4       R#   \         d     R# i ; i)z/Mark crash id as checked for being a duplicate.N)r   removeKeyError)r   r/   r!   s   &&&r   _mark_dup_checkedCrashDatabase._mark_dup_checked   s-    	%%h/ 		s    ..c                $   < V ^8  d   QhRS[ RR/# ri   rp   )r   r   s   "r   r   r      s     ) )c )d )r   c                <    V P                   P                  V4       R# )zMark crash id as retraced.N)r   r~   r=   s   &&r   mark_retracedCrashDatabase.mark_retraced   s    x(r   c                8   < V ^8  d   QhRS[ RS[R,          RR/# )r   r/   invalid_msgNr	   rZ   )r   r   s   "r   r   r      s)      *-*	r   c                    R# )zdMark crash id as 'failed to retrace'.

This is a no-op since this crash DB is not interested in it.
Nr4   )r   r/   r   s   &&&r   mark_retrace_failed!CrashDatabase.mark_retrace_failed   s    r   c                0   < V ^8  d   QhRS[ S[,          /# r`   ra   )r   r   s   "r   r   r      s      C r   c                    V P                   # )zuReturn an ID set of all crashes which have not been retraced yet and
which happened on the current host architecture.)r   r   s   &r   get_unretracedCrashDatabase.get_unretraced   s     r   c                0   < V ^8  d   QhRS[ S[,          /# r`   ra   )r   r   s   "r   r   r      s     " "3s8 "r   c                    V P                   # )a  Return an ID set of all crashes which have not been checked for
being a duplicate.

This is mainly useful for crashes of scripting languages such as
Python, since they do not need to be retraced. It should not return
bugs that are covered by get_unretraced().
)r   r   s   &r   get_dup_uncheckedCrashDatabase.get_dup_unchecked   s     !!!r   c                    < V ^8  d   QhRS[ /# r`   rp   )r   r   s   "r   r   r      s     % %3 %r   c                :    \        V P                  4      ^,
          # )z0Return the ID of the most recently filed report.)r)   r   r   s   &r   	latest_idCrashDatabase.latest_id   s    4<< 1$$r   c                   < V ^8  d   QhRR/# )r   r	   Nr4   )r   r   s   "r   r   r      s     R R Rr   c                   \         P                  P                  4       pRVR&   RVR&   RVR&   RVR&   R	VR
&   RVR&   V P                  V4       \         P                  P                  4       pRVR&   RVR&   RVR&   RVR&   R	VR
&   RVR&   V P                  V4       \         P                  P                  4       pRVR&   RVR&   RVR&   RVR&   RVR
&   RVR&   V P                  V4       \         P                  P                  4       pRVR&   RVR&   RVR&   RVR
&   RVR&   V P                  V4       \         P                  P                  4       pRVR&   RVR&   RVR&   RVR
&   RVR&   V P                  V4       R# )zGAdd some sample crash reports.

This is mostly useful for test suites.
zlibfoo1 1.2-3Packagefoor3   zFooLinux Pi/2r\   11Signalz
/bin/crashExecutablePathzfoo_bar (x=1) at crash.c:28
d01 (x=1) at crash.c:29
raise () from /lib/libpthread.so.0
<signal handler called>
__frob (x=1) at crash.c:30StacktraceTopzlibfoo1 1.2-4z
Testux 1.0zfoo_bar (x=2) at crash.c:28
d01 (x=3) at crash.c:29
raise () from /lib/libpthread.so.0
<signal handler called>
__frob (x=4) at crash.c:30zbar 42-4barz/usr/bin/brokenzuh (p=0x0) at crash.c:25
g (x=1, y=42) at crash.c:26
f (x=1) at crash.c:27
e (x=1) at crash.c:28
d (x=1) at crash.c:29zpython-goo 3epsilon1pygooz
Testux 2.2z/usr/bin/pygoozTraceback (most recent call last):
  File "test.py", line 7, in <module>
    print(_f(5))
  File "test.py", line 5, in _f
    return g_foo00(x+1)
  File "test.py", line 2, in g_foo00
    return x/0
ZeroDivisionError: integer division or modulo by zeror&   zpython-goo 5N)r   r!   Reportr0   )r   rV   s   & r   r   CrashDatabase.add_sample_data   s    MM  "&)"/,/(*
/
 	A MM  "&)"/)/(*
/
 	A MM  "!)"/)/(/
/
 	A MM  "-)$/)/.
9+ 	A MM  "%)$/)/.
9+ 	Ar   )r   r   r   r   r   )NN)FNN)N)__name__
__module____qualname____firstlineno____doc__r   r0   r6   r9   r>   rE   rK   rO   rR   r]   rf   rm   rr   rv   r{   r   r   r   r   r   r   r   __static_attributes____classdictcell__)r   s   @r   r   r      s     # #&:360C C * * 'DA A
   &0 05V V) )  
" "% %R Rr   r   )	r   r+   typingr   apport.crashdbr   apport.reportr   r   r4   r   r   <module>r      s.    O    xFNN00 xr   