
    j	                     @   d dl Z d dlmZmZmZmZ d dlmZmZ d dl	m
Z
mZmZ d dlmZmZmZ d dlmZ  e             ee
j                  	 	 	 	 	 	 ddee         d	eee                  d
ee         dedee         dee         dedee         fd                        ZdS )    N)IOAnyListOptional)Elementprocess_metadata)FileTypeadd_metadata_with_filetypeis_json_processable)exactly_oneget_last_modified_date get_last_modified_date_from_file)dict_to_elementsTfilenamefiletextinclude_metadatametadata_filenamemetadata_last_modifiedkwargsreturnc                    ||                                 dk    r|s| sg S t          | ||           d}| Mt          |           }t          | d          5 }|                                }	ddd           n# 1 swxY w Y   nw|dt          |          }|                                }
t          |
t                    r|
n|
                                }	|	                    d           n|t          |          }	t          |	          st          d          	 t          j        |	          }t          |          }n"# t          j        $ r t          d	          w xY w|D ]}|r|p||j        _        |S )
a  Partitions serialized Unstructured output into its constituent elements.

    Parameters
    ----------
    filename
        A string defining the target filename path.
    file
        A file-like object as bytes --> open(filename, "rb").
    text
        The string representation of the .json document.
    metadata_last_modified
        The last modified date for the document.
    N )r   r   r   utf8)encodingr   )	file_textzJJSON cannot be partitioned. Schema does not match the Unstructured schema.zNot a valid json)stripr   r   openreadr   
isinstancestrdecodeseekr   
ValueErrorjsonloadsr   JSONDecodeErrormetadatalast_modified)r   r   r   r   r   r   r   last_modification_datefr   file_contentdictelementselements                 e/lsinfo/ai/hellotax_ai/base_platform/venv/lib/python3.11/site-packages/unstructured/partition/json.pypartition_jsonr1      s   0 DJJLLB..t.H.	48888!!7!A!A(V,,, 	!I	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 
	!A$!G!Gyy{{$.|S$A$A\LL|GZGZG\G\			!		II	333 
X
 
 	
-z)$$#D)) - - -+,,,-  ^ ^ 	^-C-]G]G* Os   A88A<?A<#D? ?E)NNNTNN)r%   typingr   r   r   r   unstructured.documents.elementsr   r    unstructured.file_utils.filetyper	   r
   r   unstructured.partition.commonr   r   r   unstructured.staging.baser   JSONr!   bytesboolr1        r0   <module>r<      s    * * * * * * * * * * * * E E E E E E E E         
         
 7 6 6 6 6 6 HM**" $!'+,0< <sm<
2e9
< 3-< 	<
  }< %SM< < 
']< < < +* < < <r;   