Ë
     åhiQ  ã                   ó¬   — d 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m	Z	 ddl
mZmZmZ ddlmZmZmZ  G d„ d«      Z G d„ d	«      Z G d
„ d«      Zy)zl
Utilities to create data structures for embedding Python modules and additional files into the executable.
é    N)Úget_code_objectÚreplace_filename_in_code_object)ÚBYTECODE_MAGICÚis_winÚstrict_collect_mode)ÚPYZ_ITEM_MODULEÚPYZ_ITEM_NSPKGÚPYZ_ITEM_PKGc                   ó4   — e Zd ZdZdZdZdZdd„Zed„ «       Z	y)	ÚZlibArchiveWriterzª
    Writer for PyInstaller's PYZ (ZlibArchive) archive. The archive is used to store collected byte-compiled Python
    modules, as individually-compressed entries.
    s   PYZ é   é   Nc                 ó>  — |xs i }t        |d«      5 }|j                  d| j                  z  «       g }|D ]&  }| j                  |||«      }|j	                  |«       Œ( |j                  «       }t        j                  |«      }	|j                  |	«       |j                  dt        j                  «       |j                  | j                  «       |j                  t        «       |j                  t        j                  d|«      «       ddd«       y# 1 sw Y   yxY w)a*  
        filename
            Target filename of the archive.
        entries
            An iterable containing entries in the form of tuples: (name, src_path, typecode), where `name` is the name
            under which the resource is stored (e.g., python module name, without suffix), `src_path` is name of the
            file from which the resource is read, and `typecode` is the Analysis-level TOC typecode (`PYMODULE`).
        code_dict
            Optional code dictionary containing code objects for analyzed/collected python modules.
        Úwbó    r   z!iN)ÚopenÚwriteÚ_HEADER_LENGTHÚ_write_entryÚappendÚtellÚmarshalÚdumpsÚseekÚosÚSEEK_SETÚ_PYZ_MAGIC_PATTERNr   ÚstructÚpack)
ÚselfÚfilenameÚentriesÚ	code_dictÚfpÚtocÚentryÚ	toc_entryÚ
toc_offsetÚtoc_datas
             úGC:\des-py\Monitor\venv\Lib\site-packages\PyInstaller/archive/writers.pyÚ__init__zZlibArchiveWriter.__init__$   së   € ð ’O ˆ	ä�(˜DÓ!ð 	4 Rà�H‰H�U˜T×0Ñ0Ñ0Ô1ð ˆCØ ò &�Ø ×-Ñ-¨b°%¸ÓC�	Ø—
‘
˜9Õ%ð&ð
 Ÿ™›ˆJÜ—}‘} SÓ)ˆHØ�H‰H�XÔð �G‰G�A”r—{‘{Ô#à�H‰H�T×,Ñ,Ô-Ø�H‰H”^Ô$Ø�H‰H”V—[‘[  zÓ2Ô3÷1	4÷ 	4ñ 	4ús   “C7DÄDc                 ó   — |\  }}}|dv sJ ‚|dv r|t         |j                  «       dffS ||   }t        j                  j	                  t        j                  j                  |«      «      \  }}	|dk(  r7t        }t        j                  j                  g |j                  d«      ¢d‘­Ž }
n4t        }t        j                  j                  |j                  d«      Ž dz   }
t        ||
«      }t        j                  |«      }t        j                  || j                  «      }|||j                  «       t!        |«      ff}|j#                  |«       |S )N>   ú
PYMODULE-1ú
PYMODULE-2ÚPYMODULE>   Nú-r   r+   ú.z__init__.pyú.py)r	   r   r   ÚpathÚsplitextÚbasenamer
   ÚjoinÚsplitr   r   r   r   ÚzlibÚcompressÚ_COMPRESSION_LEVELÚlenr   )Úclsr$   r&   r#   ÚnameÚsrc_pathÚtypecodeÚcode_objectÚsrc_basenameÚ_Úco_filenameÚdataÚobjr'   s                 r*   r   zZlibArchiveWriter._write_entryK   s(  € à#(Ñ ˆˆh˜ØÐCÑCÐCÐCà�{Ñ"ð œ>¨2¯7©7«9°aÐ8Ð9Ð9à ‘oˆäŸ'™'×*Ñ*¬2¯7©7×+;Ñ+;¸HÓ+EÓF‰ˆ�aØ˜:Ò%Ü#ˆHÜŸ'™'Ÿ,™,ÐG¨¯
©
°3«ÐG¸ÒG‰Kä&ˆHÜŸ'™'Ÿ,™,¨¯
©
°3«Ð8¸5Ñ@ˆKô 6°kÀ;ÓOˆô �}‰}˜[Ó)ˆô �m‰m˜D #×"8Ñ"8Ó9ˆð ˜H b§g¡g£i´°S³Ð:Ð;ˆ	ð 	�‰�ŒàÐó    )N)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r:   r+   Úclassmethodr   © rF   r*   r   r      s4   „ ñð "ÐØ€NØÐó%4ðN ñ#ó ñ#rF   r   c                   óš   — e Zd ZdZdZdZ ej                  e«      ZdZ	 ej                  e	«      Z
dZd„ Zd„ Zddefd	„Zdd
„Zed„ «       Zy)ÚCArchiveWriterah  
    Writer for PyInstaller's CArchive (PKG) archive.

    This archive contains all files that are bundled within an executable; a PYZ (ZlibArchive), DLLs, Python C
    extensions, and other data files that are bundled in onefile mode.

    The archive can be read from either C (bootloader code at application's run-time) or Python (for debug purposes).
    s   MEI
z
!8sIIII64sz!IIIIBcé	   c                 óL  — t        «       | _        t        |d«      5 }g }|D ]%  }| j                  ||«      }|j	                  |«       Œ' |j                  «       }| j                  |«      }	t        |	«      }
|j                  |	«       ||
z   | j                  z   }t        j                  d   dz  t        j                  d   z   }t        j                  | j                  | j                  |||
||j!                  d«      «      }|j                  |«       ddd«       y# 1 sw Y   yxY w)aH  
        filename
            Target filename of the archive.
        entries
            An iterable containing entries in the form of tuples: (dest_name, src_name, compress, typecode), where
            `dest_name` is the name under which the resource is stored in the archive (and name under which it is
            extracted at runtime), `src_name` is name of the file from which the resouce is read, `compress` is a
            boolean compression flag, and `typecode` is the Analysis-level TOC typecode.
        pylib_name
            Name of the python shared library.
        r   r   éd   é   ÚasciiN)ÚsetÚ_collected_namesr   r   r   r   Ú_serialize_tocr;   r   Ú_COOKIE_LENGTHÚsysÚversion_infor   r   Ú_COOKIE_FORMATÚ_COOKIE_MAGIC_PATTERNÚencode)r    r!   r"   Ú
pylib_namer$   r%   r&   r'   r(   r)   Ú
toc_lengthÚarchive_lengthÚpyversÚcookie_datas                 r*   r+   zCArchiveWriter.__init__†   s  € ô !$£ˆÔä�(˜DÓ!ð 	" RàˆCØ ò &�Ø ×-Ñ-¨b°%Ó8�	Ø—
‘
˜9Õ%ð&ð
 Ÿ™›ˆJØ×*Ñ*¨3Ó/ˆHÜ˜X›ˆJà�H‰H�XÔð (¨*Ñ4°t×7JÑ7JÑJˆNÜ×%Ñ% aÑ(¨3Ñ.´×1AÑ1AÀ!Ñ1DÑDˆFÜ Ÿ+™+Ø×#Ñ#Ø×*Ñ*ØØØØØ×!Ñ! 'Ó*óˆKð �H‰H�[Ô!÷7	"÷ 	"ñ 	"ús   œC5DÄD#c                 óx  — |\  }}}}|dk(  r| j                  |d||«      S t        j                  j                  |«      }t        rvt        j                  j
                  dk(  rY|j                  t        j                  j
                  d«      }|dk(  r*|j                  t        j                  j
                  d«      }t        rcd }|dv rnt        j                  j                  |«      }|r;|| j                  v rt        d|› d|› d	�«      ‚| j                  j                  |«       |d
k(  r| j                  |d|› d|› �|«      S |dv r›ddddœ|   }t        |||¬«      }	t        j                  j                  |«      d   t        j                  j                  |	j                  «      d   z   }
t        |	|
«      }	| j                  |t!        j"                  |	«      |d|¬«      S |dv r…t%        |d«      5 }|j'                  «       }d d d «       d d t(        k(  sJ ‚t!        j*                  |dd  «      }	|dz   }
t        |	|
«      }	| j                  |t!        j"                  |	«      |||¬«      S |dk(  r*|j-                  d«      dz   }| j                  |||||¬«      S | j/                  |||||¬«      S # 1 sw Y   Œ®xY w)NÚorF   ú/ú\Ún>   ÚMÚmÚsÚs1Ús2z7Attempting to collect a duplicated file into CArchive: z (type: ú)Údú:>   ri   rj   rk   r   rR   é   )ri   rj   rk   )Úoptimizeri   )r9   )rh   rg   Úrbé   é   r2   úutf-8r   )Ú_write_blobr   r3   Únormpathr   ÚsepÚreplacer   ÚnormcaserU   Ú
ValueErrorÚaddr   r4   rC   r   r   r   r   Úreadr   Úloadsr\   Ú_write_file)r    r$   r&   Ú	dest_nameÚsrc_namer9   r?   Únormalized_destÚoptim_levelÚcoderC   Úin_fprD   s                r*   r   zCArchiveWriter._write_entry±   sÀ  € Ø27Ñ/ˆ	�8˜X xð �sŠ?Ø×#Ñ# B¨¨Y¸ÓAÐAô —G‘G×$Ñ$ YÓ/ˆ	Ý”b—g‘g—k‘k SÒ(ð "×)Ñ)¬"¯'©'¯+©+°tÓ<ˆIð ˜3ŠØ#×+Ñ+¬B¯G©G¯K©K¸Ó>�õ Ø"ˆOØÐ6Ñ6àô #%§'¡'×"2Ñ"2°9Ó"=�áØ" d×&;Ñ&;Ñ;Ü$ØQÐRaÐQbÐbjÐksÐjtÐtuÐvóð ð ×%Ñ%×)Ñ)¨/Ô:à�sŠ?ð ×#Ñ# B¨°¨z¸¸9¸+Ð-FÈÓQÐQØÐ*Ñ*ð !"¨°!Ñ4°XÑ>ˆKÜ" 9¨hÀÔMˆDô Ÿ'™'×*Ñ*¨9Ó5°aÑ8¼2¿7¹7×;KÑ;KÈD×L\ÑL\Ó;]Ð^_Ñ;`Ñ`ˆKÜ2°4¸ÓEˆDØ×#Ñ# B¬¯©°dÓ(;¸YÈÐV^Ð#Ó_Ð_Ø˜Ñ#ô �h Ó%ð $¨Ø—z‘z“|�÷$à˜˜�8œ~Ò-Ð-Ð-ä—=‘=  b c Ó+ˆDØ# eÑ+ˆKÜ2°4¸ÓEˆDð ×#Ñ# B¬¯©°dÓ(;¸YÈÐ[cÐ#ÓdÐdØ˜Š_à—?‘? 7Ó+¨gÑ5ˆDØ×#Ñ# B¨¨i¸ÈHÐ#ÓUÐUà×#Ñ# B¨°)¸XÐPXÐ#ÓYÐY÷$ð $ús   Ç2J0Ê0J9Úblobc                 óÔ   — |j                  «       }t        |«      }|r!t        j                  || j                  ¬«      }|j                  |«       |t        |«      |t        |«      ||fS )zŽ
        Write the binary contents (**blob**) of a small file to the archive and return the corresponding CArchive TOC
        entry.
        )Úlevel)r   r;   r8   r9   r:   r   Úint)r    Úout_fpr…   r   r?   r9   Údata_offsetÚdata_lengths           r*   ru   zCArchiveWriter._write_blob  sX   € ð
 —k‘k“mˆÜ˜$“iˆÙÜ—=‘= ¨T×-DÑ-DÔEˆDØ�‰�TÔàœS ›Y¨´S¸³]ÀHÈiÐXÐXrF   c                 ó  — |j                  «       }t        j                  |«      j                  }t	        |d«      5 }|rƒt        d«      }	t        j                  | j                  «      }
	 |j                  |	«      }|sn$|j                  |
j                  |	d| «      «       Œ8|j                  |
j                  «       «       nt        j                  ||«       ddd«       ||j                  «       |z
  |t        |«      ||fS # 1 sw Y   Œ+xY w)zl
        Stream copy a large file into the archive and return the corresponding CArchive TOC entry.
        rq   i @  N)r   r   ÚstatÚst_sizer   Ú	bytearrayr8   Úcompressobjr:   Úreadintor   r9   ÚflushÚshutilÚcopyfileobjrˆ   )r    r‰   r€   r   r?   r9   rŠ   r‹   r„   Ú
tmp_bufferÚ
compressorÚnum_reads               r*   r~   zCArchiveWriter._write_file  sî   € ð —k‘k“mˆÜ—g‘g˜hÓ'×/Ñ/ˆÜ�(˜DÓ!ð 	2 UÙÜ& yÓ1�
Ü!×-Ñ-¨d×.EÑ.EÓF�
ØØ$Ÿ~™~¨jÓ9�HÙ#ØØ—L‘L ×!4Ñ!4°ZÀ	ÀÐ5JÓ!KÔLð	 ð
 —‘˜Z×-Ñ-Ó/Õ0ä×"Ñ" 5¨&Ô1÷	2ð ˜VŸ[™[›]¨[Ñ8¸+ÄsÈ8Ã}ÐV^Ð`iÐjÐj÷	2ð 	2ús   ¼BDÄDc                 ó€  — g }|D ]§  }|\  }}}}}}	|	j                  d«      }	t        |	«      dz   }
| j                  |
z   }|dz  dk7  rd|dz  z
  }|
|z  }
t        j                  | j
                  |
› d�z   | j                  |
z   |||||j                  d«      |	«      }|j                  |«       Œ© dj                  |«      S )Nrt   rR   rs   r   ri   rS   rF   )r\   r;   Ú_TOC_ENTRY_LENGTHr   r   Ú_TOC_ENTRY_FORMATr   r6   )r<   r%   Úserialized_tocr'   rŠ   Úcompressed_lengthr‹   r9   r?   r=   Úname_lengthÚentry_lengthÚpadding_lengthÚserialized_entrys                 r*   rV   zCArchiveWriter._serialize_toc#  sï   € àˆØò 	4ˆIØT]ÑQˆKÐ*¨K¸À8ÈTð —;‘;˜wÓ'ˆDÜ˜d›) a™-ˆKð
 ×0Ñ0°;Ñ>ˆLØ˜bÑ  AÒ%Ø!# |°bÑ'8Ñ!9�Ø˜~Ñ-�ô  &Ÿ{™{Ø×%Ñ%¨;¨-°qÐ(9Ñ9Ø×%Ñ%¨Ñ3ØØ!ØØØ—‘ Ó(Øó	 Ðð ×!Ñ!Ð"2Õ3ð7	4ð: �x‰x˜Ó'Ð'rF   N)F)rG   rH   rI   rJ   r[   rZ   r   ÚcalcsizerW   rš   r™   r:   r+   r   Úbytesru   r~   rK   rV   rL   rF   r*   rN   rN   r   sz   „ ñð 7Ðð "€NØ$�V—_‘_ ^Ó4€Nà!ÐØ'˜Ÿ™Ð(9Ó:ÐàÐò)"òVNZñ`Y¨ó Yókð* ñ(ó ñ(rF   rN   c                   ó>   — e Zd ZdZdZ ej                  e«      Zd„ Zy)ÚSplashWriterzž
    Writer for the splash screen resources archive.

    The resulting archive is added as an entry into the CArchive with the typecode PKG_ITEM_SPLASH.
    z!32s 32s 16s 16s II II IIc	                 óÚ  — d„ }	|D �
cg c]
  }
 |	|
«      ‘Œ }}
t        |d«      5 }|j                  d| j                  z  «       d}|j                  «       }|D ]5  }
|
j	                  d«      dz   }
|j                  |
«       |t        |
«      z  }Œ7 |j                  «       }t        |«      }|j                  |j	                  d«      «       |j                  «       }t        |t        «      rt        |«      }|j                  |«       nBt        |d«      5 }|j                  «       }ddd«       t        «      }|j                  |«       ~d„ }t        j                  | j                   ||d	d
«       ||dd
«       ||dd«       ||dd«      ||||||«      }|j                  dt        j                  «       |j                  |«       ddd«       yc c}
w # 1 sw Y   Œ±xY w# 1 sw Y   yxY w)aâ  
        Writer for splash screen resources that are bundled into the CArchive as a single archive/entry.

        :param filename: The filename of the archive to create
        :param requirements_list: List of filenames for the requirements array
        :param str tcl_shared_library_name: Basename of the Tcl shared library
        :param str tk_shared_library_name: Basename of the Tk shared library
        :param str tcl_module_directory_name: Basename of the Tcl module directory (e.g., tcl/)
        :param str tk_module_directory_name: Basename of the Tk module directory (e.g., tk/)
        :param Union[str, bytes] image: Image like object
        :param str script: The tcl/tk script to execute to create the screen.
        c                 óÞ   — t         j                  j                  | «      } t        rGt         j                  j                  dk(  r*| j                  t         j                  j                  d«      } | S )Nrd   re   )r   r3   rv   r   rw   rx   )r!   s    r*   Ú_normalize_filenamez2SplashWriter.__init__.<locals>._normalize_filename�  sI   € Ü—w‘w×'Ñ'¨Ó1ˆHÝœ"Ÿ'™'Ÿ+™+¨Ò,ð $×+Ñ+¬B¯G©G¯K©K¸Ó>�ØˆOrF   r   r   r   rt   rq   Nc           	      ó€   — | j                  d«      }t        |«      |k\  rt        d|›dt        |«      › d|› d�«      ‚|S )Nrt   zLength of the encoded field z (z&) is greater or equal to the limit of z characters!)r\   r;   rz   )ÚvalueÚ
field_nameÚlimitÚ	enc_values       r*   Ú_encode_strz*SplashWriter.__init__.<locals>._encode_str°  sU   € Ø!ŸL™L¨Ó1�	Ü�y“> UÒ*Ü$Ø6°z°nÀBÄsÈ9Ã~ÐFVð W$Ø$) 7¨,ð8óð ð
 !Ð rF   Útcl_shared_library_nameé    Útk_shared_library_nameÚtcl_module_directory_namers   Útk_module_directory_name)r   r   r   r   r\   r;   Ú
isinstancer¢   r|   r   r   Ú_HEADER_FORMATr   r   r   )r    r!   Úrequirements_listr®   r°   r±   r²   ÚimageÚscriptr§   r=   r$   Úrequirements_lenÚrequirements_offsetÚscript_offsetÚ
script_lenÚimage_offsetÚ	image_lenÚimage_fpÚ
image_datar­   Úheader_datas                         r*   r+   zSplashWriter.__init__g  sà  € ò4	ð DUÖU¸4Ñ0°Õ6ÐUÐÐUä�(˜DÓ!ð ?	" Rà�H‰H�U˜T×0Ñ0Ñ0Ô1ð
  !ÐØ"$§'¡'£)ÐØ)ò .�Ø—{‘{ 7Ó+¨eÑ3�Ø—‘˜”Ø ¤C¨£IÑ-Ñ ð.ð ŸG™G›IˆMÜ˜V›ˆJØ�H‰H�V—]‘] 7Ó+Ô,ð Ÿ7™7›9ˆLÜ˜%¤Ô'ä ›J�	Ø—‘˜•ô ˜% Ó&ð 1¨(Ø!)§¡£�J÷1ä 
›O�	Ø—‘˜Ô$Øò
!ô !Ÿ+™+Ø×#Ñ#ÙÐ3Ð5NÐPRÓSÙÐ2Ð4LÈbÓQÙÐ5Ð7RÐTVÓWÙÐ4Ð6PÐRTÓUØØØØØ Ø#óˆKð �G‰G�A”r—{‘{Ô#Ø�H‰H�[Ô!÷?	"ð ?	"ùò V÷<1ð 1ú÷9?	"ð ?	"ús*   ˆG¥C/G!ÄGÄ%B"G!ÇG	ÇG!Ç!G*N)	rG   rH   rI   rJ   r´   r   r¡   r   r+   rL   rF   r*   r¤   r¤   F  s$   „ ñð6 1€NØ$�V—_‘_ ^Ó4€Nóc"rF   r¤   )rJ   r   r   r“   r   rX   r8   ÚPyInstaller.building.utilsr   r   ÚPyInstaller.compatr   r   r   Ú#PyInstaller.loader.pyimod01_archiver   r	   r
   r   rN   r¤   rL   rF   r*   ú<module>rÄ      sS   ðñó Û 	Û Û Û 
Û ç Wß JÑ Jß ]Ñ ]÷Tñ T÷nQ(ñ Q(÷hD"ò D"rF   