;ivdZddlZddlZddlZddlZddlZddlZddlZddlZddl m Z ddl m Z e jeZdZdZddZdZd Zd Zd Zd Zd ZdZejejejejejej ej!ej"ej#ej$ej%ej&ej'ej(iZ)ej*dd+e,ej-e)zej.Z/de0fdZ1dZ2dZ3dS)zM This module contains miscellaneous functions that do not fit anywhere else. N)log)is_wincg}tj|D](\}}}|t|)|S)z\ Returns a list *.dll, *.so, *.dylib in the given directory and its subdirectories. )oswalkextend dlls_in_dir) directoryfilelistrootdirsfiless JC:\PYTHON\MyICR_Workspace\venv\Lib\site-packages\PyInstaller/utils/misc.pydlls_in_subdirsrsKHWY//++dE D))**** Oc&t|gdS)zH Returns a list of *.dll, *.so, *.dylib in the given directory. )z*.soz*.dllz*.dylib) files_in_dir)r s rr r (s  #?#?#? @ @@rc |pg}g}|D]G}|tjtj||H|S)zV Returns a list of files in the given directory that match the given pattern. )rglobrpathjoin)r file_patternsr file_patterns rrr/sX "'RM E%GG  TYrw||I|DDEEFFFF LrcZtjtj|}d} t dD]J}t tj|}||vr tj|}G|cSn#t$rYnwxYwdS)a Return the path to top-level directory that contains Python modules. It will look in parent directories for __init__.py files. The first parent directory without __init__.py is the top-level directory. Returned directory might be used to extend the PYTHONPATH. z __init__.py N)rrdirnameabspathrangesetlistdirIOError)filenamecurr_dirpatternirs rget_path_to_toplevel_modulesr&<swrwx8899HG  r  A 8,,--E%7??844         4sAB B('B(cZ tj|dS#t$rYdSwxYw)Nr)rstat Exception)fnms rmtimer,Xs=ws||A qqs  **c*tj|}tj|stj|t |dd5}t j||ddddS#1swxYwYdS)zo Save data into text file as Python data structure. :param filename: :param data: :return: wutf-8encodingN)rrrexistsmakedirsopenpprint)r"datarfs rsave_py_data_structr8asgooh''G 7>>' " " G hg . . .! dAs%BB B ct|dd5}trddlm}t |cdddS#1swxYwYdS)zc Load data saved as python code and interpret that code. :param filename: :return: rr/r0r) versioninfoN)r4rPyInstaller.utils.win32r;evalread)r"r7r;s rload_py_data_structr?os hg . . .!  < ; ; ; ; ; ;AFFHH~~ s.AAAcztjtj|SN)rrrnormpath)apaths r absnormpathrD}s& 7??27++E22 3 33rcd}g}|dddD]#}||rd|zn|z }||$|S)z Return list of parent package names. 'aaa.bb.c.dddd' -> ['aaa', 'aaa.bb', 'aaa.bb.c'] :param full_modname: Full name of a module. :return: List of parent module names. .r)splitappend) full_modnameprefixparentspkgs rmodule_parent_packagesrOseFG!!#&&qt,v.#))3.v Nrcpt|d5}|dtj|}d}d}d}|t |krt ||z d}||z }|t |krn~||tj||}| |} | dkr|| z}n(|t |zdz }|t |k|dkr ddddS dddd S#1swxYwYdS) z Check if the given file is a Qt plugin file. :param filename: Full path to file to check. :return: True if given file is a Qt plugin file, False if not. rbri s QTMETADATA rHNFT) r4seekrSEEK_ENDtelllenmaxSEEK_SETr>rfind) r"fpend_posSEARCH_CHUNK_SIZEQTMETADATA_MAGIC magic_offset start_pos chunk_sizebufposs ris_file_qt_pluginrcs h   2;'')) ) -....G&77;;I 9,JC 01111 GGIr{ + + +''*%%C)),--Cbyy(3 #&6"7"77!;G-.... 2  145sC?D+D++D/2D/s \A(%s)?(.*)|rawc t|\}}|rt||dSt jt j|j\}}| |S)z Decode bytes to string, respecting and removing any byte-order marks if present, or respecting but not removing any PEP263 encoding comments (# encoding: cp1252). r) BOM_REmatchgroupsBOM_MARKERS_TO_DECODERStokenizedetect_encodingioBytesIOreadlinedecode)rebomr1_s rrprpsv ||C  ''))HC 4&s+C0033*2:c??+CDDKHa ::h  rcJ t|n#t$rYdSwxYwdS)z7 Check if the passed argument is an iterable." FT)iter TypeError)args r is_iterablerws; S uu 4s   cntj|jD]}|r|cSdS)z Check if the given file path points to a file inside an existing archive file. Returns first path from the set of parent paths that points to an existing file, or `None` if no such path exists (i.e., file is an actual stand-alone file). N)pathlibPathrMis_file)r"parents rpath_to_parent_archiver}sE ,x((0 >>   MMM  4rrA)4__doc__rrr5codecsrerkrmry PyInstallerrloggingPyInstaller.compatr getLogger__name__loggerrr rr&r,r8r?rDrOrc BOM_UTF32_LEutf_32_le_decode BOM_UTF32_BEutf_32_be_decode BOM_UTF32 utf_32_decode BOM_UTF16_LEutf_16_le_decode BOM_UTF16_BEutf_16_be_decode BOM_UTF16 utf_16_decodeBOM_UTF8 utf_8_decoderjcompilermapescapeDOTALLrgbytesrprwr}rrrs  &&&&&&%%%%%%  8 $ $AAA    8      444"###N 0 0 f* 0 0 f* OV( OdiiBI?V0W0W&X&XXZ\Zc d d            r