
    +j&                     b   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ej        Z	n#  ej
        Z	Y nxY wd Zd Zd Zedk    rf eej                  dk     r ed           dS ej        d         Z ee            eej                  d	k    r eeej        d                    dS dS dS )
    Nc                 0   t           j                            |           rd S d| z  }t          j        |d          }	 t          j        |           D ]k\  }}}|D ]b}t           j                            ||          }dt           j                            ||           z  }|                    ||t                     cl	 |
                                 n# |
                                 w xY wt          j        |            t          j        ||            d S )N%s.zipwmodez%sarcnamecompress_type)ospathisfilezipfileZipFilewalkjoinrelpathwritecompressioncloseshutilrmtreemove)	directoryPathzipFilePathzfdirName
subdirListfileListfnamefullPathrelPaths	            U/DATA/AppData/hermes/venv/lib/python3.11/site-packages/vtkmodules/web/vtkjs_helper.pyconvertDirectoryToZipFiler#      s   	w~~m$$ ]*K	3	/	/	/B-/W]-C-C 	O 	O)GZ! O O7<<77"'//(M"J"JK7+NNNNO	O 	








M-   
K]+++++s   B C C*c           	      L   t           j                            |           rt           j                            |          rt           j                            |           }t           j                            |dt           j                            |           d d         z            }t          | d          5 }|                                }t          j
        |          }|                                                    dd          }d d d            n# 1 swxY w Y   t          |dd          5 }t          |d	d          5 }|D ]}	d
|	v r|                    d           |                    d|z             |                    dt           j                            |           z             |                    d           |                    d           |                    |	           	 d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S d S d S )Nz%s.htmlirb
 rzutf-8)r   encodingr   z</body>z	<script>
zvar contentToLoad = "%s";

zOGlance.importBase64Dataset("%s" , contentToLoad, glanceInstance.proxyManager);
zglanceInstance.showApp();
z
</script>
)r   r   r   existsdirnamer   basenameopenreadbase64	b64encodedecodereplacer   )
dataPathsrcHtmlPathdstDirdstHtmlPathdatadataContentbase64ContentsrcHtmldstHtmllines
             r"   addDataToViewerr=   *   s   	w~~h (BGNN;$?$? (**gll69rw7G7G7Q7QRUSURU7V+VWW (D!! 	ET))++K",[99M)0022::4DDM	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E +C'::: 	(gkg>>> ('# ( (D D((l333&E&UVVVn g..x889    &CDDDm444MM$''''(( ( ( ( ( ( ( ( ( ( ( ( ( ( (	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	(( ( ( (sJ   8ADDD2HB+G=1H=H	HH	HHHc           	      l   t           j                            |           rd S  G fddt                    }d }d fd}d| z  }t           j                            t           j                            | t           j                            }t           j                            |d          }t          |d          }t          j	        |
                                          }t          j        |d	
          }		 d}
t                      }t          j        dt           j                            |           z   dz             }i }g |d<   d}|d         d         D ]d}|d                             i            t%          |          |d         |         d<   t'          |d                   |d         |         d<   |dz   }e |            d}t)          t          j        |                    D ]}t           j                            ||          }t           j                            |          rl|                    |          rW|
s, |t           j                            |d          |           d}
 |||	|||           t1          j        |           |dz   }D ]W}|	                    t           j                            |         d          t          j        |d          t8                     X|d         D ].}|d         |d<   d|d<   i |d<   |d                  |d         d<   /|	                    dt          j        |d          t8                     t          j        |           |	                                 n# |	                                 w xY wt1          j        ||            d S )Nc                       e Zd ZdZ fdZdS )'zipAllTimeSteps.<locals>.UrlCounterDictr   c                     ||                                  vr&t          j                  | |<   | j        dz   | _        | |         S )N   )keysstrCounter)selfnameobjNameToUrlss     r"   
GetUrlNamez2zipAllTimeSteps.<locals>.UrlCounterDict.GetUrlNameP   sB    499;;&& !677T
#|a/:    N)__name__
__module____qualname__rE   rI   )rH   s   r"   UrlCounterDictr@   M   s3        	 	 	 	 	 	 	rJ   rN   c                 @   t          | d          5 }|                                }t          j        |          }|D ]}||         ||<   |d         D ]2}|                    |d                    |                    d           3	 d d d            d S # 1 swxY w Y   d S )Nr(   scenetype)r-   r.   jsonloadspop)
sourcePathdestObj
sourceFile
sourceData	sourceObjkeyobjs          r"   	InitIndexz"zipAllTimeSteps.<locals>.InitIndexV   s    *c"" 	 j#**J
:..I  . .(~w'    F$$$ 	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	 s   A4BBBc                 Z    i }| d         D ]}|d         |||d                  d         <    |S )NrP   rG   rQ   url )indexObjurlsr[   s      r"   getUrlToNameDictionaryz/zipAllTimeSteps.<locals>.getUrlToNameDictionarya   s?    G$ 	8 	8C,/KDS[!%())rJ   c                 p   t          t          j                            | d          d          5 }t	          j        |                                          } |          }|d         d         |         }	|D ]}
|
dk    s|
dk    r||
         |	|
<   |d         D ]S}|d         }i |	|<   |d         |	|         d<   |d	         |	|         d	<   |d
         |	|         d
<   |d         |	|         d<   T	 d d d            n# 1 swxY w Y   t          t          j        |                     D ]}t          j                            | |          }t          j        	                    |          du rEt          j        t          j                            |d                    D ]}t          j                            |d|          }t          j        
                    |          rV||vrR|                    |           t          j                            d|          }|                    ||t                     t          j                            | |d          }t          |d          5 }t	          j        |                                          }d d d            n# 1 swxY w Y   |                                D ]~}	 d||                                         v rd||         d         d<   d||                                         v r"||         d         D ]}d|d         d         d<   o# t          $ r Y {w xY w||         }t          j                            |                    |          t#          |          d          }|                    |t	          j        |d          t                     d S )N
index.jsonr(   	animation	timeStepsrP   versionrG   actoractorRotationmapperpropertyFr7   r   refz
../../databasepatharrays   indentr
   )r-   r   r   r   rR   rS   r.   sortedlistdirisdirr   addr   r   rC   AttributeErrorrI   rD   writestrdumps)r+   zipobj
storedDatarootIdxtimeSteprH   currentIdxFile
currentIdx	urlToNamerootTimeStepSectionrZ   r[   objNamefoldercurrentItemfilenamefullpathr!   objIndexFilePathobjIndexFileobjIndexObjDataelmarraycurrentObjNameobjIndexRelPathrb   s                            r"   addDirectoryToZipz*zipAllTimeSteps.<locals>.addDirectoryToZipg   s]    "',,w55s;; 	K~N$7$7$9$9::J..z::I")+"6{"CH"M! ; ;'>>SI%5%5+5c?#C((!'* K Kf+/1#G,8;G#G,W5@CO@T#G,_=9<X#G,X6;>z?#G,Z88K	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K" RZ0011 !	 !	F',,w77Kw}}[))U22Jrw||K'H'HII W W7<<VXFF7>>(++ W
0J0JNN8,,, gll68<<GLL7+LVVV  "w||GV\JJ&,, B"&*\->->-@-@"A"AB B B B B B B B B B B B B B B&++--   4 9 9 ; ;;;BN,U3J??3#7#<#<#>#>>>%4S%9(%C L LE?KE&M%0<<%   H&v.N gll((88#h-- O OO
?1555)     ;!	 !	s7   B?C<<D D )'JJ 	#J 	>A+L**
L76L7r   rd   r(   r   r   F^z	\.[0-9]+$seriesr   re   rf   r^   timer}   rB   Tro   rp   rr   rP   rG   idvtkHttpDataSetSeriesReaderrQ   ) r   r   r   dictabspathr   pardirr-   rR   rS   r.   r   r   setrecompiler,   appendrD   floatrs   rt   ru   matchr   r   rx   ry   r   remover   r   )r   rN   r\   r   r   currentDirectoryrootIndexPathrootIndexFilerootIndexObjr   isSceneInitializedcurrentlyAddedDatareggenericIndexObjr}   itemr   r    rG   r[   rb   rH   s                       @@r"   zipAllTimeStepsr   I   s   	w~~m$$          	  	  	   6 6 6 6 6t ]*Kwrw||M29'M'MNNGLL!1<@@M,,M:m002233L	3	/	/	/B< # !UUj 0 0 ? ??,NOO$&! -k: 	$ 	$DH%,,R0009<XOH%h/6>CDL>Q>QOH%h/
;!|HH&((RZ(899:: 	( 	(Fw||$4f==Hw}}X&& (399V+<+< () .Ibgll8\BBLQQQ)-&!!& !   h'''#a< " 	 	DKK]40,??
?1555)       ( 	R 	RCFCI6CK02C,-7DS[7QC,-e44
$*\!<<<K 	 	
 	
 	
 		-    	








K]+++++s   =I4N N__main__ro   zNUsage: directoryToFile /path/to/directory.vtkjs [/path/to/ParaViewGlance.html]rB      )r/   rR   r   r   r   sysr   zlibZIP_DEFLATEDr   
ZIP_STOREDr#   r=   r   rK   lenargvprintfileNamer_   rJ   r"   <module>r      sF     				 				  



 %KKK&KK%$KKK
, , ,.( ( (>], ], ],H z
s38}}q\	
 	
 	
 	
 	
 8A;!!(+++3sx==AOHchqk22222  s   * 	5