
    i-                         d dl mZmZ ddlmZ ddlmZmZmZ ddl	m
Z
  G d de          Z G d	 d
e          Z G d de          ZdS )    )OptionalUnion   )BaseMetaClass)DbTypeDB_TYPE_BFILEDB_TYPE_BLOB)errorsc                   x    e Zd Zd Zd Zd Zd Zed             Zde	fdZ
ded	edd
fdZedefd            Zd
S )BaseLOBc                 8    | j                                          d S N)_implfree_lobselfs    \/var/www/html/Pagina-Ingenieria-Requisitos/venv/lib/python3.11/site-packages/oracledb/lob.py__del__zBaseLOB.__del__(   s    
    c                 l    | j         j        t          ur t          j        t          j                   d S d S r   )r   dbtyper   r
   
_raise_err%ERR_OPERATION_ONLY_SUPPORTED_ON_BFILEr   s    r   _check_is_bfilezBaseLOB._check_is_bfile+   s4    :M11fJKKKKK 21r   c                 l    | j         j        t          u r t          j        t          j                   d S d S r   )r   r   r   r
   r   $ERR_OPERATION_NOT_SUPPORTED_ON_BFILEr   s    r   _check_not_bfilezBaseLOB._check_not_bfile/   s4    :--fIJJJJJ .-r   c                 >   | j         t          u rAt          |t                    r|                                S t          |t
                    r|S n@t          |t                    r|S t          |t
                    r|                                S t          d          )a)  
        Checks the value to write and returns the actual value to write.
        Character LOBs must write strings but can accept UTF-8 encoded bytes
        (which will be decoded to strings). Binary LOBs must write bytes but
        can accept strings (which will be encoded in UTF-8).
        zexpecting string or bytes)typer	   
isinstancestrencodebytesdecode	TypeErrorr   values     r   _check_value_to_writezBaseLOB._check_value_to_write3   s     9$$%%% ||~~%E5))  %%% &E5)) &||~~%3444r   c                 l    t          |t                    r|S |                     |           }||_        |S r   )r    r   __new__r   )clsimpllobs      r   
_from_implzBaseLOB._from_implF   s6    dG$$ 	Kkk#	
r   returnc                 \    |                                   | j                                        S )zs
        Returns a two-tuple consisting of the directory alias and file name for
        a BFILE type LOB.
        )r   r   get_file_namer   s    r   getfilenamezBaseLOB.getfilenameN   s*    
 	z'')))r   	dir_aliasnameNc                 d    |                                   | j                            ||           dS )zH
        Sets the directory alias and name of a BFILE type LOB.
        N)r   r   set_file_name)r   r3   r4   s      r   setfilenamezBaseLOB.setfilenameV   s4     	
  D11111r   c                     | j         j        S )zu
        This read-only attribute returns the type of the LOB as one of the
        database type constants.
        )r   r   r   s    r   r   zBaseLOB.type]   s     z  r   )__name__
__module____qualname__r   r   r   r(   classmethodr.   tupler2   r!   r7   propertyr   r    r   r   r   r   &   s          L L LK K K5 5 5&   [*U * * * *2S 2 2 2 2 2 2 !f ! ! ! X! ! !r   r   )	metaclassc            	           e Zd Zd Zd ZddZdefdZdefdZ	defdZ
dd	Z	 ddedee         deeef         fdZdefdZ	 ddddedee         ddfdZddeeef         deddfdZdS )LOBc                 N    |                                  }t          |          |ffS r   )readr   r&   s     r   
__reduce__zLOB.__reduce__h   s"    		UeX&&r   c                 *    |                                  S r   )rD   r   s    r   __str__zLOB.__str__l   s    yy{{r   r/   Nc                 8    | j                                          dS u   
        Closes the LOB. Call this when writing is completed so that the indexes
        associated with the LOB can be updated -– but only if open() was called
        first.
        Nr   closer   s    r   rK   z	LOB.closeo   s     	
r   c                 \    |                                   | j                                        S )i
        Returns a boolean indicating if the file referenced by a BFILE type LOB
        exists.
        r   r   file_existsr   s    r   
fileexistszLOB.fileexistsw   s*    
 	z%%'''r   c                 \    |                                   | j                                        S )
        Returns the chunk size for the LOB. Reading and writing to the LOB in
        chunks of multiples of this size will improve performance.
        r   r   get_chunk_sizer   s    r   getchunksizezLOB.getchunksize   s*    
 	z((***r   c                 4    | j                                         S )j
        Returns a boolean indicating if the LOB has been opened using the
        method open().
        r   get_is_openr   s    r   isopenz
LOB.isopen   s    
 z%%'''r   c                 8    | j                                          dS aU  
        Opens the LOB for writing. This will improve performance when writing
        to the LOB in chunks and there are functional or extensible indexes
        associated with the LOB. If this method is not called, each write will
        perform an open internally followed by a close after the write has been
        completed.
        Nr   openr   s    r   r^   zLOB.open   s     	
r   r   offsetamountc                 "   |+| j                                         }||k    r	||z
  dz   }n'd}n$|dk    rt          j        t          j                   |dk    rt          j        t          j                   | j                             ||          S a  
        Returns a portion (or all) of the data in the LOB. Note that the amount
        and offset are in bytes for BLOB and BFILE type LOBs and in UCS-2 code
        points for CLOB and NCLOB type LOBs. UCS-2 code points are equivalent
        to characters for all but supplemental characters. If supplemental
        characters are in the LOB, the offset and amount will have to be chosen
        carefully to avoid splitting a character.
        Nr   r   )r   get_max_amountr
   r   ERR_INVALID_LOB_AMOUNTERR_INVALID_LOB_OFFSETrD   r   r_   r`   s      r   rD   zLOB.read   s     >Z..00F&1,q[[f;<<<Q;;f;<<<zvv...r   c                 4    | j                                         S )a(  
        Returns the size of the data in the LOB. For BLOB and BFILE type LOBs,
        this is the number of bytes. For CLOB and NCLOB type LOBs, this is the
        number of UCS-2 code points. UCS-2 code points are equivalent to
        characters for all but supplemental characters.
        r   get_sizer   s    r   sizezLOB.size   s     z""$$$r   r   newSizenew_sizerl   c                    |                                   |)|dk    r!t          j        t          j        dd           |}| j                            |           dS zt
        Trims the LOB to the new size (the second parameter is deprecated and
        should not be used).
        Nr   rl   rm   )deprecated_namenew_namer   r
   r   ERR_DUPLICATED_PARAMETERr   trimr   rm   rl   s      r   rt   zLOB.trim   sl     	1}}!3$-'   
 H
!!!!!r   datac                     |                                   | j                            |                     |          |           dS a  
        Writes the data to the LOB at the given offset. The offset is in bytes
        for BLOB type LOBs and in UCS-2 code points for CLOB and NCLOB type
        LOBs. UCS-2 code points are equivalent to characters for all but
        supplemental characters. If supplemental characters are in the LOB, the
        offset will have to be chosen carefully to avoid splitting a character.
        Note that if you want to make the LOB value smaller, you must use the
        trim() function.
        Nr   r   writer(   r   rv   r_   s      r   rz   z	LOB.write   sB     	
33D996BBBBBr   r/   Nr   Nr   r   )r9   r:   r;   rE   rG   rK   boolrP   intrU   rZ   r^   r   r   r!   r#   rD   rj   rt   rz   r?   r   r   rB   rB   f   s       ' ' '     (D ( ( ( (+c + + + +( ( ( ( (    8</ //'/}/	sEz	/ / / /.%c % % % %  "=A" " ""-5c]"	" " " "$C C%U
+ CS C C C C C C Cr   rB   c            	           e Zd ZddZdefdZdefdZdefdZddZ		 dd	ed
e
e         deeef         fdZdefdZ	 ddddede
e         ddfdZddeeef         d	eddfdZdS )AsyncLOBr/   Nc                 H   K   | j                                          d{V  dS rI   rJ   r   s    r   rK   zAsyncLOB.close   s4       j           r   c                 l   K   |                                   | j                                         d{V S )rM   NrN   r   s    r   rP   zAsyncLOB.fileexists   s@      
 	Z++---------r   c                 l   K   |                                   | j                                         d{V S )rR   NrS   r   s    r   rU   zAsyncLOB.getchunksize   s@      
 	Z..000000000r   c                 D   K   | j                                          d{V S )rW   NrX   r   s    r   rZ   zAsyncLOB.isopen   s.      
 Z++---------r   c                 H   K   | j                                          d{V  dS r\   r]   r   s    r   r^   zAsyncLOB.open   s2       joor   r   r_   r`   c                    K   |*| j                                         }||k    r	||z
  dz   }nd}|dk    rt          j        t          j                   | j                             ||           d{V S rb   )r   rc   r
   r   re   rD   rf   s      r   rD   zAsyncLOB.read  s       >Z..00F&1,Q;;f;<<<Z__VV444444444r   c                 D   K   | j                                          d{V S )a&  
        Returns the size of the data in the LOB. For BLOB and BFILE type LOBs
        this is the number of bytes. For CLOB and NCLOB type LOBs this is the
        number of UCS-2 code points. UCS-2 code points are equivalent to
        characters for all but supplemental characters.
        Nrh   r   s    r   rj   zAsyncLOB.size  s.       Z((*********r   r   rk   rm   rl   c                   K   |                                   |)|dk    r!t          j        t          j        dd           |}| j                            |           d{V  dS ro   rr   ru   s      r   rt   zAsyncLOB.trim!  s       	1}}!3$-'   
 Hjooh'''''''''''r   rv   c                    K   |                                   | j                            |                     |          |           d{V  dS rx   ry   r{   s      r   rz   zAsyncLOB.write3  sX       	jt99$??HHHHHHHHHHHr   r|   r}   r~   r   )r9   r:   r;   rK   r   rP   r   rU   rZ   r^   r   r   r!   r#   rD   rj   rt   rz   r?   r   r   r   r      ss       ! ! ! !.$ . . . .1C 1 1 1 1.d . . . .        8<5 55'/}5	sEz	5 5 5 5*+C + + + +  (=A( ( ((-5c](	( ( ( ($I Ic5j 1 I3 It I I I I I Ir   r   N)typingr   r   baser   	base_implr   r   r	    r
   r   rB   r   r?   r   r   <module>r      s  > # " " " " " " "       : : : : : : : : : :      =! =! =! =! =! =! =! =! =!@oC oC oC oC oC' oC oC oCdfI fI fI fI fIw fI fI fI fI fIr   