
    wi                     D    S /r  " S S\5      rSSKrS r " S S \5      rg)AutoFinalizedObjectc                   D   ^  \ rS rSrSrS rU 4S jrS rS rS r	Sr
U =r$ )	_AutoFinalizedObjectBase$   zO
Base class for objects that get automatically
finalized on delete or at exit.
c                     g)zwActually finalizes the object (frees allocated resources etc.).

Returns: None

Derived classes should implement this.
N selfs    K/home/james-whalen/.local/lib/python3.13/site-packages/usb/_objfinalizer.py_finalize_object)_AutoFinalizedObjectBase._finalize_object*   s     	    c                 <   > [         [        U ]  U 5      nSUl        U$ )zCreates a new object instance and adds the private finalizer
attributes to it.

Returns: new object instance

Arguments:
* *args, **kwargs -- ignored
F)superr   __new___finalize_calledclsargskwargsinstance	__class__s       r
   r    _AutoFinalizedObjectBase.__new__3   s$     13?D$)!r   c                 V    U R                   (       d  SU l         U R                  5         gg)zLHelper method that finalizes the object if not already done.

Returns: None
TN)r   r   r   s    r
   _do_finalize_object,_AutoFinalizedObjectBase._do_finalize_object@   s&    
 $$$(D!!!# %r   c                     [        S5      e)z9Finalizes the object if not already done.

Returns: None
z6finalize() must be implemented by AutoFinalizedObject.)NotImplementedErrorr   s    r
   finalize!_AutoFinalizedObjectBase.finalizeI   s     "D
 	
r   c                 $    U R                  5         g )N)r   r   s    r
   __del__ _AutoFinalizedObjectBase.__del__S   s    r   )r   )__name__
__module____qualname____firstlineno____doc__r   r   r   r   r!   __static_attributes____classcell__r   s   @r
   r   r   $   s&    
$
 r   r       Nc                 :    U " 5       nUb  UR                  5         gg)zHelper function for weakref.finalize() that dereferences a weakref
to an object and calls its _do_finalize_object() method if the object
is still alive. Does nothing otherwise.

Returns: None (implicit)

Arguments:
* obj_ref -- weakref to an object
N)r   )obj_refobjs     r
   _do_finalize_object_refr/   Y   s!     )C
! r   c                   .   ^  \ rS rSrU 4S jrS rSrU =r$ )r   i   c                    > [         [        U ]
  " U /UQ70 UD6n[        R                  " U[
        [        R                  " U5      5      Ul        U$ )zCreates a new object instance and adds the private finalizer
attributes to it.

Returns: new object instance

Arguments:
* *args, **kwargs -- passed to the parent instance creator
                     (which ignores them)
)r   r   r   weakrefr   r/   ref
_finalizerr   s       r
   r   AutoFinalizedObject.__new__k   sW    . ,c:

 
 &..-w{{8/D
 r   c                 $    U R                  5         g)z)Finalizes the object if not already done.N)r5   r   s    r
   r   AutoFinalizedObject.finalize   s    r   r   )r#   r$   r%   r&   r   r   r(   r)   r*   s   @r
   r   r   i   s    B r   )__all__objectr   r3   r/   r   r   r   r
   <module>r;      s4   B !
!0v 0f " %2 %r   