zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
U
X±dã@s.dZddlZddlZddlZddlZddlZddlZddlZddlm    Z
ddl m Z e
  e¡Zdd„Zdd„Zd"d    d
„Zd d „Zd d„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zejejejejejej ej!ej"ej#ej$ej%ej&ej'ej(iZ)e *dd +e,ej-e)ƒ¡ej.¡Z/e0dœdd„Z1d d!„Z2dS)#zM
This module contains miscellaneous functions that do not fit anywhere else.
éN)Úlog)Úis_wincCs,g}t |¡D]\}}}| t|ƒ¡q|S)z\
    Returns a list *.dll, *.so, *.dylib in the given directory and its subdirectories.
    )ÚosÚwalkÚextendÚ dlls_in_dir)Ú    directoryÚfilelistÚrootÚdirsÚfiles©r úMd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\PyInstaller/utils/misc.pyÚdlls_in_subdirssrcCst|dddgƒS)zH
    Returns a list of *.dll, *.so, *.dylib in the given directory.
    z*.soz*.dllz*.dylib)Ú files_in_dir)rr r rr'src    Cs4|pg}g}|D]}| t tj ||¡¡¡q|S)zV
    Returns a list of files in the given directory that match the given pattern.
    )rÚglobrÚpathÚjoin)rZ file_patternsr Z file_patternr r rr.s
rcCs>g}zddl}| d¡Wntk
r8t d¡YnX|S)zW
    Try importing modules required for unicode support in the frozen application.
    rNÚcodecszCannot detect modules 'codecs'.)rÚappendÚ ImportErrorÚloggerÚerror)Úmodulesrr r rÚget_unicode_modules;srcCsrtj tj |¡¡}d}z@tdƒD]2}tt |¡ƒ}||krJtj |¡}q"|WSq"Wntk
rlYnXdS)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)rrÚdirnameÚabspathÚrangeÚsetÚlistdirÚIOError)ÚfilenameZcurr_dirÚpatternÚir r r rÚget_path_to_toplevel_modulesJs     r%cCs,zt |¡dWStk
r&YdSXdS)Nér)rÚstatÚ    Exception)Zfnmr r rÚmtimefsr)c    CsLtj |¡}tj |¡s"t |¡t|ddd}t ||¡W5QRXdS)zo
    Save data into text file as Python data structure.
    :param filename:
    :param data:
    :return:
    Úwúutf-8©ÚencodingN)rrrÚexistsÚmakedirsÚopenÚpprint)r"ÚdatarÚfr r rÚsave_py_data_structos
 
r4c
CsNt|ddd6}ddlm}tr,ddlm}t| ¡ƒW5QR£SQRXdS)zc
    Load data saved as python code and interpret that code.
    :param filename:
    :return:
    Úrr+r,r)ÚBindingRedirect)Ú versioninfoN)r0ZPyInstaller.depend.bindependr6rZPyInstaller.utils.win32r7ÚevalÚread)r"r3r6r7r r rÚload_py_data_struct}s
  r:cCstj tj |¡¡S)N)rrrÚnormpath)Zapathr r rÚ absnormpathŽsr<cCsBd}g}| d¡dd…D]"}||r,d|n|7}| |¡q|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éÿÿÿÿ)Úsplitr)Z full_modnameÚprefixÚparentsÚpkgr r rÚmodule_parent_packages’s  rDc
    CsÒt|dƒ¾}| dtj¡| ¡}d}d}d}|t|ƒkr¤t||dƒ}||}|t|ƒkr^q¤| |tj¡| |¡}|     |¡}    |    dkr’||    }q¤|t|ƒd}q.|dkrºW5QR£dSW5QR£dSQRXd    S)
    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 r?éFTN)
r0ÚseekrÚSEEK_ENDÚtellÚlenÚmaxÚSEEK_SETr9Úrfind)
r"ÚfpZend_posZSEARCH_CHUNK_SIZEZQTMETADATA_MAGICZ magic_offsetZ    start_posÚ
chunk_sizeÚbufÚposr r rÚis_file_qt_plugin£s*       
 
rRs \A(%s)?(.*)ó|)ÚrawcCsFt |¡ ¡\}}|r&t||ƒdSt t |¡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_REÚmatchÚgroupsÚBOM_MARKERS_TO_DECODERSÚtokenizeÚdetect_encodingÚioÚBytesIOÚreadlineÚdecode)rTÚbomr-Ú_r r rr^Õs
r^cCs(z t|ƒWntk
r"YdSXdS)z7
    Check if the passed argument is an iterable."
    FT)ÚiterÚ    TypeError)Úargr r rÚ is_iterableâs
 rd)N)3Ú__doc__rrr1rÚrerYr[Z PyInstallerrÚloggingZPyInstaller.compatrÚ    getLoggerÚ__name__rrrrrr%r)r4r:r<rDrRÚ BOM_UTF32_LEÚutf_32_le_decodeÚ BOM_UTF32_BEÚutf_32_be_decodeÚ    BOM_UTF32Ú utf_32_decodeÚ BOM_UTF16_LEÚutf_16_le_decodeÚ BOM_UTF16_BEÚutf_16_be_decodeÚ    BOM_UTF16Ú utf_16_decodeÚBOM_UTF8Ú utf_8_decoderXÚcompilerÚmapÚescapeÚDOTALLrUÚbytesr^rdr r r rÚ<module> sN  
 
 
    'ù