
    9ic                         S SK r S SKrS SKrS SKrS SKJr  S SKJr  S SKr	SSK
Jr  SSKJrJr   " S S	\R                  5      r " S
 S\5      r " S S\\\5      rg)    N)UserList)Path   )logging   )	JsonMixinStrMixinc                   $    \ rS rSrSrS rS rSrg)CopyableWeakMethod   z(
A weak method that can be deep copied.
c                     U $ N )selfs    k/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/paddlex/inference/common/result/base_result.py__copy__CopyableWeakMethod.__copy__!   s        c                 "    U R                  5       $ r   )r   )r   memos     r   __deepcopy__CopyableWeakMethod.__deepcopy__$   s    }}r   r   N)__name__
__module____qualname____firstlineno____doc__r   r   __static_attributes__r   r   r   r   r      s    r   r   c                   >   ^  \ rS rSrSrU 4S jrS rU 4S jrSrU =r	$ )AutoWeakList(   z=
A list that automatically removes weak references to items.
c                    > [         R                  " U5      (       a  [        TU ]  [	        U5      5        g[        TU ]  U5        g)z{
Append item to list.
If item is a bound method, append a weak reference to the method.
Otherwise, append the item itself.
N)inspectismethodsuperappendr   )r   item	__class__s     r   r&   AutoWeakList.append-   s4     D!!GN-d34GN4 r   c              #      #    U R                    H.  n[        U[        5      (       a  U" 5       nUb  Uv   M(  M*  Uv   M0     g7f)zIterate over items in the list.N)data
isinstancer   )r   r'   funcs      r   __iter__AutoWeakList.__iter__8   s?     IID$ 233v#J $ 
 s   A Ac                 b   > [         TU ]  U5      n[        U[        5      (       a	  U" 5       nU$ U$ )zGet item at index.)r%   __getitem__r,   r   )r   indexr'   r-   r(   s       r   r1   AutoWeakList.__getitem__B   s1    w"5)d.//6DKr   r   )
r   r   r   r   r   r&   r.   r1   r   __classcell__r(   s   @r   r    r    (   s    	! r   r    c                   P   ^  \ rS rSrSrS\SS4U 4S jjrS\SS4S jrS	 r	S
r
U =r$ )
BaseResultK   zBase class for result objects that can save themselves.

This class inherits from dict and provides properties and methods for handling result.
r+   returnNc                    > [         TU ]  U5        [        5       U l        [        R                  " U 5        [
        R                  " U 5        [        R                  " SSS9  SU l        g)zZInitializes the BaseResult with the given data.

Args:
    data (dict): The initial data.
r   )	threshold	edgeitemsN)	r%   __init__r    _save_funcsr	   r   npset_printoptions_rand_fn)r   r+   r(   s     r   r=   BaseResult.__init__Q   sO     	'>$4 
a15r   	save_pathc                     U R                    H8  n[        R                  " U5      nSUR                  ;   a  U" US9  M1  U" 5         M:     g)zxCalls all registered save methods with the given save path.

Args:
    save_path (str): The path to save the result to.
rC   )rC   N)r>   r#   	signature
parameters)r   rC   r-   rE   s       r   save_allBaseResult.save_all^   s?     $$D))$/Ii222y) %r   c                    U R                  SS 5      c  U R                  (       a  U R                  $ [        [        R                  " 5       5      n[        R
                  " SS5      nU SU 3n[        R                  " SU S35        [        U5      R                  U l        U R                  $ U S   n[        U5      R                  $ )N
input_pathi  i'  _zThere is not input file name as reference for name of saved result file. So the saved result file would be named with timestamp and random number: `z`.)
getrA   inttimerandomrandintr   warningr   name)r   	timestamprandom_numberfps       r   _get_input_fnBaseResult._get_input_fnk   s    88L$'/}}}}$DIIK(I"NN46M;a/BOO g  hj  gk  km  n !HMMDM== ,Bx}}r   )rA   r>   )r   r   r   r   r   dictr=   strrG   rV   r   r4   r5   s   @r   r7   r7   K   s8    
T d # $  r   r7   )r#   rO   rN   weakrefcollectionsr   pathlibr   numpyr?   utilsr   mixinr   r	   
WeakMethodr   r    rX   r7   r   r   r   <module>ra      sQ             &	++ 	 8  F.y( .r   