
    {-j                         d dl Z d dlZd dlZd dlZd dlmZ d dlmZ d dlZ	ddl
mZ ddlmZmZ  G d d	ej                  Z G d
 de          Z G d deee          ZdS )    N)UserList)Path   )logging   )	JsonMixinStrMixinc                       e Zd ZdZd Zd ZdS )CopyableWeakMethodz0
    A weak method that can be deep copied.
    c                     | S N )selfs    k/var/www/html/banglarbhumi/venv/lib/python3.11/site-packages/paddlex/inference/common/result/base_result.py__copy__zCopyableWeakMethod.__copy__!   s        c                 *    |                                  S r   )r   )r   memos     r   __deepcopy__zCopyableWeakMethod.__deepcopy__$   s    }}r   N)__name__
__module____qualname____doc__r   r   r   r   r   r   r      s<               r   r   c                   2     e Zd ZdZ fdZd Z fdZ xZS )AutoWeakListzE
    A list that automatically removes weak references to items.
    c                     t          j        |          r0t                                          t	          |                     dS t                                          |           dS )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    zAutoWeakList.append-   sY     D!! 	!GGNN-d3344444GGNN4     r   c              #   r   K   | j         D ],}t          |t                    r |            }||V  (|V  -dS )zIterate over items in the list.N)data
isinstancer   )r   r!   funcs      r   __iter__zAutoWeakList.__iter__8   sZ      I 	 	D$ 233 tvv#JJJ



	 	r   c                     t                                          |          }t          |t                    r |            }|S |S )zGet item at index.)r   __getitem__r%   r   )r   indexr!   r&   r"   s       r   r)   zAutoWeakList.__getitem__B   sB    ww""5))d.// 	466DKr   )r   r   r   r   r    r'   r)   __classcell__r"   s   @r   r   r   (   sj         	! 	! 	! 	! 	!          r   r   c                   B     e Zd ZdZdeddf fdZdeddfdZd Z xZ	S )	
BaseResultzBase class for result objects that can save themselves.

    This class inherits from dict and provides properties and methods for handling result.
    r$   returnNc                     t                                          |           t                      | _        t	          j        |            t          j        |            t          j        dd           d| _        dS )zrInitializes 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   r3   zBaseResult.__init__Q   sl     	'>>$4   
a15555r   	save_pathc                     | j         D ]6}t          j        |          }d|j        v r ||           , |             7dS )zCalls all registered save methods with the given save path.

        Args:
            save_path (str): The path to save the result to.
        r8   )r8   N)r4   r   	signature
parameters)r   r8   r&   r:   s       r   save_allzBaseResult.save_all^   sa     $ 	 	D)$//Ii222y)))))	 	r   c                    |                      dd           | j        r| j        S t          t          j                              }t	          j        dd          }| d| }t          j        d| d           t          |          j	        | _        | j        S t          | d         t                    r| d         d         }n| d         }|}t          |          j	        S )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`.r   )getr7   inttimerandomrandintr   debugr   namer%   list)r   	timestamprandom_numberfpr>   s        r   _get_input_fnzBaseResult._get_input_fnk   s    88L$''/} %}$DIKK((I"N466M////BM n  hj  n  n  n   !HHMDM= d<($// 	,l+A.JJl+JBxx}r   )
r   r   r   r   dictr3   strr<   rK   r+   r,   s   @r   r.   r.   K   s         
T d      # $          r   r.   )r   rC   rB   weakrefcollectionsr   pathlibr   numpyr5   utilsr   mixinr   r	   
WeakMethodr   r   rL   r.   r   r   r   <module>rU      s                                   & & & & & & & &	 	 	 	 	+ 	 	 	         8      F2 2 2 2 2y( 2 2 2 2 2r   