
    Mf!                     H   d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
Z
d dlZ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 dd	lmZ dd
lmZ g dZ G d dej        ej                  Z	 	 	 	 	 	 	 	 	 	 ddZd Zd Zd Zd Zedk    r e             dS dS )    )OrderedDictN   )write_class_file)generate_exports)generate_class_file)generate_imports)generate_classes_files)generate_struct_file)generate_module)	UNDEFINEDREQUIREDto_plotly_jsonavailable_propertiesavailable_wildcard_propertiesz_.*c                       e Zd ZdS )_CombinedFormatterN)__name__
__module____qualname__     c/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/dash/development/component_generator.pyr   r       s         	Dr   r   package.json^_ c                    |                     dd                              d          }t          j        dk    }t	          j        dd          }d                    d t          D                       }d	t          j	        d
<   t          j        dt          j                            ||                     |	sDt          j	                                        }t          j                            d          |d<   t          j        d| d| d| d|  |           }t#          j        |t"          j        t"          j        ||          }|                                \  }}|                                }|r-t-          |                                t          j                   |s6t-          d| d| dt          j                   t          j        d           t5          |                    d                    }	i }|
$d |
                    d          D             }
|
|d<   |r||d<   t7          j        t:          fi |g}||Kt=          ddd          5 }t5          |                                          }d d d            n# 1 swxY w Y   |t          j                             d           st          j!        d            t          j                             d!          st          j!        d!           t          j        "                    d"          r>t=          d"d          5 }tG          j$        |          }d d d            n# 1 swxY w Y   nd }|%                    t7          j        tL          ||#                     |.|%                    t7          j        tN          |$                     tQ          ||	g|R  }t=          t          j                            |d%          d&d          5 }tS          j*        |	|d'(           d d d            n# 1 swxY w Y   tW          ||           |tY          |||	||||||	  	         |t[          |||	||           d S d S ))N-_z/\win32dashzextract-meta.js|c              3   "   K   | ]
}d | dV  dS )^$Nr   ).0ps     r   	<genexpr>z&generate_components.<locals>.<genexpr><   s*       B BaQ B B B B B Br   node_modules	NODE_PATHr   z./node_modulesMODULES_PATHznode z "z" "z" )posix)stdoutstderrshellenv)filezError generating metadata in z	 (status=)r   utf-8c                 8    g | ]}|                     d           S ) )strip)r%   	components     r   
<listcomp>z'generate_components.<locals>.<listcomp>g   s1     
 
 
%.IOOC  
 
 
r   ,prop_reorder_exceptions	max_propsr)encodingmanRzdash-info.yaml)prefix	rpkg_data)r?   zmetadata.jsonw   )indent).replacerstripsysplatformpkg_resourcesresource_filenamejoinreserved_wordsosenvironshutilcopyfilepathcopyabspathshlexsplit
subprocessPopenPIPEcommunicatepollprintdecoder-   exitsafe_json_loads	functoolspartialr   openreadexistsmakedirsisfileyaml	safe_loadappendr   r
   r	   jsondumpr   r   r   )components_sourceproject_shortnamepackage_info_filenameignorerprefixrdependsrimports	rsuggestsjlprefixmetadatakeep_prop_orderr:   
is_windowsextract_pathreserved_patternsr/   cmdprocouterrstatuspy_generator_kwargsgenerator_methodsfpkg_datayamldatar@   
componentss                               r   generate_componentsr   '   s[    *11#s;;BB5II(J 26;LMML B B> B B BBB,BJ{
O%68MNN    8joo !goo.>??NkWLWWFWW/@WWDUWW .
 
 

 ??
 
 
 ##%%S 	1#**,,SZ0000 	U0AUUFUUUZ    HQKKK"3::g#6#677"
 
2A2G2G2L2L
 
 
 :I56 5+4K("*+>VVBUVVWh2.#888 	1A&qvvxx00H	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 w~~e$$ 	Kw~~c"" 	K7>>*++ 	&999 5X N844	5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 I  .w)TTT	
 	
 	
   28DDD	
 	
 	
 ((98XFWXXXJ	
&88#
 
 
 )	
	(Aa(((() ) ) ) ) ) ) ) ) ) ) ) ) ) )
 &
333
	
 
	
 
	
 ):x8TTTTT s6   "JJJ*MMM6PP!Pc                     t          j        | t                    }t          j        d         dk    r|S t          |          S )N)object_pairs_hookr      )rh   loadsr   rF   version_infobyteify)sjsondata_unicodes     r   r]   r]      s?    z!{CCC
a#$$$r   c                  X   t          j        dt          d          } |                     dd           |                     dd           |                     d	d
dd           |                     dddd           |                     dd           |                     ddd           |                     ddd           |                     ddd           |                     dd           |                     ddd d           |                     dt          d d!"           | S )#Nzdash-generate-componentszpGenerate dash components by extracting the metadata using react-docgen. Then map the metadata to Python classes.)progformatter_classdescriptionrj   z"React components source directory.)helprk   z0Name of the project to export the classes files.z-pz--package-info-filenamer   z@The filename of the copied `package.json` to `project_shortname`)defaultr   z-iz--ignorer   z6Files/directories matching the pattern will be ignoredz
--r-prefixz]Specify a prefix for Dash for R component names, write components to R dir, create R package.z--r-dependsr   zkSpecify a comma-separated list of R packages to be inserted into the Depends field of the DESCRIPTION file.z--r-importszkSpecify a comma-separated list of R packages to be inserted into the Imports field of the DESCRIPTION file.z--r-suggestszlSpecify a comma-separated list of R packages to be inserted into the Suggests field of the DESCRIPTION file.z--jl-prefixz-kz--keep-prop-orderzSpecify a comma-separated list of components which will use the prop order described in the component proptypes instead of alphabetically reordered props. Pass the 'ALL' keyword to have every component retain its original prop order.z--max-props   aj  Specify the max number of props to list in the component signature. More props will still be shown in the docstring, and will still work when provided as kwargs to the component. Python <3.7 only supports 255 args, but you may also want to reduce further for improved readability at the expense of auto-completion for the later props. Use 0 to include all props.)typer   r   )argparseArgumentParserr   add_argumentint)parsers    r   component_build_arg_parserr      s   $'*G  F +2VWWW
"T     !O	     E	     1    
 C     C     D     1    
 #	     V	  	 	 	 Mr   c                      t                                                      } t          | j        | j        | j        | j        | j        | j        | j	        | j
        | j        | j        | j                   d S )N)	rl   rm   rn   ro   rp   rq   rr   rt   r:   )r   
parse_argsr   rj   rk   rl   rm   r_prefix	r_depends	r_imports
r_suggests	jl_prefixrt   r:   )argss    r   clir      su    %''2244D"8{/,.     r   c                    t          | t                    r+t          d |                                 D                       S t          | t                    rd | D             S t          | t
                    r|                     d          S | S )Nc                 P    g | ]#\  }}t          |          t          |          f$S r   r   )r%   keyvalues      r   r7   zbyteify.<locals>.<listcomp>  s-    WWW
UgcllGENN+WWWr   c                 ,    g | ]}t          |          S r   r   )r%   elements     r   r7   zbyteify.<locals>.<listcomp>
  s     ===W  ===r   r2   )
isinstancedictr   	iteritemslistunicodeencode)input_objects    r   r   r     s    ,%% 
WWl>T>T>V>VWWW
 
 	
 ,%% >======,(( ,""7+++r   __main__)
r   r   Nr   r   r   NNNN) collectionsr   rh   rF   rU   rS   rL   r   rN   r^   rH   re   _r_components_generationr   r   _py_components_generationr   r   r	   _jl_components_generationr
   r   rK   ArgumentDefaultsHelpFormatterRawDescriptionHelpFormatterr   r   r]   r   r   r   r   r   r   r   <module>r      s   # # # # # #  



      				            6 6 6 6 6 6 6 6 6 6 6 6 : : : : : : 7 7 7 7 7 7 = = = = = = ; ; ; ; ; ; 6 6 6 6 6 6  	 	 	 	 	*H,P	 	 	 )xU xU xU xUv% % %F F FR  $	 	 	 zCEEEEE r   