
    $g                     ^    d dl Z d dlZd dlZd dlZddlmZmZmZmZ ddl	m
Z
 d ZddZd	dZy)
    N   )generate_class_filegenerate_importsgenerate_classes_filesgenerate_class)ComponentRegistryc                     t        | d      5 }|j                         }t        j                  t        j
                        j                  |      }d d d        |S # 1 sw Y   S xY w)Nzutf-8)encoding)object_pairs_hook)openreadjsonJSONDecodercollectionsOrderedDictdecode)metadata_path	data_filejson_stringdatas       ^/var/www/dash_apps/app1/venv/lib/python3.12/site-packages/dash/development/component_loader.py_get_metadatar      s\    	mg	. 
)nn&+2I2IJQQ


 K

 Ks   AAA&c                 h   t        j                  t        d| d             t        j                  j                  |       g }t        |       }|D ]^  }||   }|j                  d      j                         j                  d      d   }t        ||d   |d   |d      }|j                  |       ` |S )	a  Load React component metadata into a format Dash can parse.

    Usage: load_components('../../component-suites/lib/metadata.json')

    Keyword arguments:
    metadata_path -- a path to a JSON file created by
    [`react-docgen`](https://github.com/reactjs/react-docgen).

    Returns:
    components -- a list of component objects with keys
    `type`, `valid_kwargs`, and `setup`.
    zWDynamic components loading has been deprecated and will be removed in dash 3.0.
Update z5 to generate components with dash-generate-components/.r   propsdescriptionN)warningswarnDeprecationWarningr   registryaddr   splitpopr   append)r   	namespace
componentsr   componentPathcomponentDataname	components           r   load_componentsr,      s     MM[ UW	
 ""9-J'D  %]+ ""3'++-33C8;"-(-*F	SW
	 	)$%     c                     t        |      }t        j                  j                  | d      }t        j                  j	                  |      rt        j
                  |       t        | |t              }t        | |       y)ag  Load React component metadata into a format Dash can parse, then create
    Python class files.

    Usage: generate_classes()

    Keyword arguments:
    namespace -- name of the generated Python package (also output dir)

    metadata_path -- a path to a JSON file created by
    [`react-docgen`](https://github.com/reactjs/react-docgen).

    Returns:
    z_imports_.pyN)	r   ospathjoinexistsremover   r   r   )r&   r   r   imports_pathr'   s        r   generate_classesr5   G   s[     'D77<<	>:L 
ww~~l#
		,'	49LMJ Y
+r-   )default_namespace)zlib/metadata.json)r   r   r/   r   _py_components_generationr   r   r   r   base_componentr   r   r,   r5    r-   r   <module>r:      s0      	   .*Z,r-   