
    Q/PhI                         d dl Z d dlmZ d dlmZmZmZ erd dlmZ d dl	m
Z
 d dlmZ d dlmZ d dlmZ  G d	 d
          ZdS )    N)Path)TYPE_CHECKINGOptionalUnion)ProfileReport)Settings)BaseDescription)Root)__version__c                       e Zd ZU dZdZdZdZee         e	d<   dZ
dZedee         fd            ZdefdZdeded         fd	Zd
eeef         ddfdZdeeef         ded         fdZdS )SerializeReportz6Extend the report to be able to dump and load reports.N_df_hashreturnc                     d S )N )selfs    `/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/ydata_profiling/serialize_report.pydf_hashzSerializeReport.df_hash   s    t    c                 d    ddl }|                    | j        | j        | j        | j        g          S )z
        Serialize ProfileReport and return bytes for reproducing ProfileReport or Caching.

        Returns:
            Bytes which contains hash of DataFrame, config, _description_set and _report
        r   N)pickledumpsr   config_description_set_report)r   r   s     r   r   zSerializeReport.dumps   s?     	 ||%	
 
 	
r   data)r   r   c           	         ddl }	 |                    |          \  }}}}n"# t          $ r}t          d          |d}~ww xY wt	          |du pt          |t                    t          |t                    |du pt          |t                    |du pt          |t                    f          st          d          || j
        k    s| j        | j        || _        nt          j        d           | j        || _        nt          j        d           || _        |A|j        d         t$          k    r+t          j        dt$           d	|j        d          d
           || _        nt          d          | S )a  
        Deserialize the serialized report

        Args:
            data: The bytes of a serialize ProfileReport object.

        Raises:
            ValueError: if ignore_config is set to False and the configs do not match.

        Returns:
            self
        r   NzFailed to load datazHFailed to load data: file may be damaged or from an incompatible versionzMThe description set of current ProfileReport is not None. It won't be loaded.zDThe report of current ProfileReport is not None. It won't be loaded.ydata_profiling_versionz}The package version specified in the loaded data is not equal to the version installed. Currently running on ydata-profiling z6 , while loaded data is generated by ydata_profiling, .z8DataFrame does not match with the current ProfileReport.)r   loads	Exception
ValueErrorall
isinstancestrr   r	   r
   r   dfr   warningswarnr   r   packager   r   )r   r   r   r   loaded_configloaded_description_setloaded_reportes           r   r    zSerializeReport.loads.   s    		; T""& 	; 	; 	;233:	; 4;:gs#;#;=(33&$. G4oFF%HM4)H)H
 
 	 Z   t|## $,(>%%c   |#,Z  
 (DK '2*23LM  |<G| | @V  @^  _x  @y| | |   $DMM WXXXs   ! 
A ;A output_filec                     t          |t                    st          t          |                    }|                    d          }|                    |                                            dS )z,
        Dump ProfileReport to file
        z.ppN)r$   r   r%   with_suffixwrite_bytesr   )r   r.   s     r   dumpzSerializeReport.dumpx   s`     +t,, 	1s;//00K!--e44

-----r   	load_filec                     t          |t                    st          t          |                    }|                     |                                           | S )z
        Load ProfileReport from file

        Raises:
             ValueError: if the DataFrame or Config do not match with the current ProfileReport
        )r$   r   r%   r    
read_bytes)r   r3   s     r   loadzSerializeReport.load   sL     )T** 	-S^^,,I

9''))***r   )__name__
__module____qualname____doc__r&   r   r   r   r%   __annotations__r   r   propertyr   bytesr   r   r    r   r2   r6   r   r   r   r   r      s        @@	BF"Hhsm"""G#    X
u 
 
 
 
&H% HE*L$M H H H HT.dCi 0 .T . . . .tSy)	1	2     r   r   )r'   pathlibr   typingr   r   r   ydata_profiling.profile_reportr   ydata_profiling.configr   ydata_profiling.modelr	   (ydata_profiling.report.presentation.corer
   ydata_profiling.versionr   r   r   r   r   <module>rE      s           1 1 1 1 1 1 1 1 1 1 =<<<<<< + + + + + + 1 1 1 1 1 1 9 9 9 9 9 9 / / / / / /A A A A A A A A A Ar   