
    !hiv                        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ZddlZddl	m
Z ddlmZ  ej                  e      Zd Zd ZddZd Zd	 Zd
 Zd Zd Zd Zd Zej6                  ej8                  ej:                  ej<                  ej>                  ej@                  ejB                  ejD                  ejF                  ejH                  ejJ                  ejL                  ejN                  ejP                  iZ) ejT                  ddjW                   e,ejZ                  e)            z  ej\                        Z/de0fdZ1d Z2d Z3y)zM
This module contains miscellaneous functions that do not fit anywhere else.
    N)log)is_winc                 z    g }t        j                  |       D ]   \  }}}|j                  t        |             " |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filess        BC:\des-py\Monitor\venv\Lib\site-packages\PyInstaller/utils/misc.pydlls_in_subdirsr      s>     HWWY/ +dED)*+O    c                     t        | g d      S )zH
    Returns a list of *.dll, *.so, *.dylib in the given directory.
    )z*.soz*.dllz*.dylib)files_in_dir)r
   s    r   r	   r	   (   s     	#?@@r   c           	          |xs g }g }|D ]D  }|j                  t        j                  t        j                  j	                  | |                   F |S )zV
    Returns a list of files in the given directory that match the given pattern.
    )r   globr   pathjoin)r
   file_patternsr   file_patterns       r   r   r   /   sM    
 "'RME% GTYYrww||I|DEFGLr   c                 L   t         j                  j                  t         j                  j                  |             }d}	 t	        d      D ]G  }t        t        j                  |            }||v r t         j                  j                  |      }E|c S  	 y# t        $ r Y yw xY w)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)r   r   dirnameabspathrangesetlistdirIOError)filenamecurr_dirpatternir   s        r   get_path_to_toplevel_modulesr&   <   s     wwrwwx89HG
r 	 A

8,-E%77??84  	    s    AB B 	B#"B#c                 R    	 t        j                  |       d   S # t        $ r Y yw xY w)N   r   )r   stat	Exception)fnms    r   mtimer,   X   s-     wws|A s    	&&c                    t         j                  j                  |       }t         j                  j                  |      st        j                  |       t        | dd      5 }t        j                  ||       ddd       y# 1 sw Y   yxY w)zo
    Save data into text file as Python data structure.
    :param filename:
    :param data:
    :return:
    wutf-8encodingN)r   r   r   existsmakedirsopenpprint)r"   datar   fs       r   save_py_data_structr8   a   sc     ggooh'G77>>'"
G	hg	. !dA  s   "BBc                     t        | dd      5 }t        rddlm} t	        |j                               cddd       S # 1 sw Y   yxY w)zc
    Load data saved as python code and interpret that code.
    :param filename:
    :return:
    rr/   r0   r   )versioninfoN)r4   r   PyInstaller.utils.win32r;   evalread)r"   r7   r;   s      r   load_py_data_structr?   o   s:     
hg	. !;AFFH~  s	   %>Ac                 z    t         j                  j                  t         j                  j                  |             S N)r   r   r   normpath)apaths    r   absnormpathrD   }   s$    77??277++E233r   c                 z    d}g }| j                  d      dd D ]  }||rd|z   n|z  }|j                  |       ! |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   )splitappend)full_modnameprefixparentspkgs       r   module_parent_packagesrO      sT     FG!!#&q, v#)3.v Nr   c                    t        | d      5 }|j                  dt        j                         |j	                         }d}d}d}|t        |      k\  rt        ||z
  d      }||z
  }|t        |      k  rnm|j                  |t        j                         |j                  |      }|j                  |      }	|	dk7  r||	z   }n |t        |      z   dz
  }|t        |      k\  r|dk(  r
	 ddd       y	 ddd       y	# 1 sw Y   yxY w)
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.
    rbr   i    s   QTMETADATA rH      NFT)
r4   seekr   SEEK_ENDtelllenmaxSEEK_SETr>   rfind)
r"   fpend_posSEARCH_CHUNK_SIZEQTMETADATA_MAGICmagic_offset	start_pos
chunk_sizebufposs
             r   is_file_qt_pluginrc      s    
h	 
2;;'') )-..G&77;I 9,JC 011GGIr{{+''*%C)),-Cby(3#&6"77!;G -.. 21 4 5  s   CC;"C;1C;;Ds   \A(%s)?(.*)   |rawc                     t         j                  |       j                         \  }} |rt        |   |       d   S t	        j
                  t        j                  |       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_REmatchgroupsBOM_MARKERS_TO_DECODERStokenizedetect_encodingioBytesIOreadlinedecode)re   bomr1   _s       r   rp   rp      sh    
 ||C '')HC
&s+C033**2::c?+C+CDKHa::hr   c                 :    	 t        |        y# t        $ r Y yw xY w)z7
    Check if the passed argument is an iterable."
    FT)iter	TypeError)args    r   is_iterablerw      s'    S	   s    	c                 t    t        j                  |       j                  D ]  }|j                         s|c S  y)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)pathlibPathrM   is_file)r"   parents     r   path_to_parent_archiver}      s6     ,,x(00 >>M r   rA   )4__doc__r   r   r5   codecsrerk   rm   ry   PyInstallerr   loggingPyInstaller.compatr   	getLogger__name__loggerr   r	   r   r&   r,   r8   r?   rD   rO   rc   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_decoderj   compiler   mapescapeDOTALLrg   bytesrp   rw   r}    r   r   <module>r      s:    	   	  	  & %			8	$A
84"#N 00
00
f**
00
00
f**
OOV((  
OdiiBII?V0W&XXZ\ZcZc	d
  
 	r   