
    ,j                     r    d Z ddlZddlZddlZddlmZ  G d d          Zd Zedk    r e             dS dS )z
From a list of trame modules name, gather and generate the required static
content that needs to be served for a trame application to work.
    N)Pathc                   4    e Zd Zd Zd Zd Zd Zd ZddZdS )	StaticContentGeneratorc                 >    d| _         d | _        i | _        d| _        d S )Nwww_generatorvue3)namewwwserveclient_type)selfs    I/DATA/AppData/hermes/venv/lib/python3.11/site-packages/trame/tools/www.py__init__zStaticContentGenerator.__init__   s%    #	
!    c                     dd l }t          j        d          } | j        d |                    |j                  D               d S )Nr   ztrame.modulesc                     g | ]	}|j         
S  )r	   ).0ms     r   
<listcomp>z5StaticContentGenerator.enable_all.<locals>.<listcomp>   s    RRRafRRRr   )pkgutil	importlibimport_moduleenable_modulesiter_modules__path__)r   r   roots      r   
enable_allz!StaticContentGenerator.enable_all   sP    &77RRg.B.B4=.Q.QRRRSSSSr   c                     dS )zFake serverNr   )r   argskwargss      r   add_protocol_to_configurez0StaticContentGenerator.add_protocol_to_configure   s    r   c                 `   t          |t                    r|n|j        }d}d|v r2	  |                    d          |            d}n# t          $ r Y nw xY wd}|rQd|v r-| j                            |                    d                     d|v r|                    d          | _        d S d S d S )NFsetupTr   r
   )
isinstancedict__dict__get	TypeErrorr   updater
   )r   moduler!   definitionsload_remainings        r   enable_modulez$StaticContentGenerator.enable_module   s     *64 8 8Mfffok!!(((...!%    "N 	2+%%
!!+//'":":;;;##&??511	2 	2 $#s    A 
AAc                 J   |D ]}d }	 t          j        d|           }nX# t          $ rK 	 t          d|           t          j        |          }n"# t          $ r t          d|            Y nw xY wY nw xY w|t          d|            |                     |           d S )Nztrame.modules.zmodule_name:z - Error: Skipping module zSkipping module: )r   r   ModuleNotFoundErrorprintr.   )r   namesmodule_namer+   s       r   r   z%StaticContentGenerator.enable_modules2   s      	' 	'KFF"01O+1O1OPP& F F FF.+666&4[AAFF* F F FD{DDEEEEEF	F ~7+77888v&&&&	' 	's2    
A5$AA5A/,A5.A//A54A5Nc                    |t          j                    }| j        rt          j        | j        |d           | j                                        D ].\  }}t          |          |z  }t          j        ||d           /d S )NT)dirs_exist_ok)r   cwdr
   shutilcopytreer   items)r   output_directorysub_pathsrc_dirdst_dirs        r   writezStaticContentGenerator.writeD   s    ##xzz8 	O "    "&!1!1!3!3 	B 	BHg+,,x7GOGWDAAAAA	B 	Br   )N)	__name__
__module____qualname__r   r   r"   r.   r   r>   r   r   r   r   r      s|        " " "T T T  2 2 2*' ' '$B B B B B Br   r   c                     t          j        d          } |                     dd           |                     ddd	           |                                 \  }}t	                      }|j        |_        t          |          r |j        |  n|                                 |	                    |j
                   d S )
Nz2Static Web Client generator for trame applications)descriptionz--outputz(Directory to fill with trame client code)helpz--client-typer   z"Type of client to use [vue2, vue3])defaultrD   )argparseArgumentParseradd_argumentparse_known_argsr   r   lenr   r   r>   output)parserr    module_names	generators       r   mainrO   T   s    $H  F 7    
 1      0022D,&((I ,I
<  	 ,///OODK     r   __main__)	__doc__rF   r   r7   pathlibr   r   rO   r?   r   r   r   <module>rS      s    
            EB EB EB EB EB EB EB EBP! ! !4 zDFFFFF r   