;ikdZddlZddlZddlZddlZddlZddlmZ ddl m Z ddl m Z ddlmZddlmZe jeZGdd eZd Zd Zee fee fedfedfd efeefeefd ZGddZGddZdS)z- Code related to processing of import hooks. N)log)format_binaries_and_datas)importlib_load_source) PostGraphAPI)ImportErrorWhenRunningHookc4eZdZdZdZ fdZdZdZxZS)ModuleHookCachea Cache of lazily loadable hook script objects. This cache is implemented as a `dict` subclass mapping from the fully-qualified names of all modules with at least one hook script to lists of `ModuleHook` instances encapsulating these scripts. As a `dict` subclass, all cached module names and hook scripts are accessible via standard dictionary operations. Attributes ---------- module_graph : ModuleGraph Current module graph. _hook_module_name_prefix : str String prefixing the names of all in-memory modules lazily loaded from cached hook scripts. See also the `hook_module_name_prefix` parameter passed to the `ModuleHook.__init__()` method. rcttj||_dt j|_t xjdz c_| |dS)a Cache all hook scripts in the passed directories. **Order of caching is significant** with respect to hooks for the same module, as the values of this dictionary are lists. Hooks for the same module will be run in the order in which they are cached. Previously cached hooks are always preserved rather than overridden. By default, official hooks are cached _before_ user-defined hooks. For modules with both official and user-defined hooks, this implies that the former take priority over and hence will be loaded _before_ the latter. Parameters ---------- module_graph : ModuleGraph Current module graph. hook_dirs : list List of the absolute or relative paths of all directories containing **hook scripts** (i.e., Python scripts with filenames matching `hook-{module_name}.py`, where `{module_name}` is the module hooked by that script) to be cached. z__PyInstaller_hooks_{}_N) super__init__weakrefproxy module_graphformatr _cache_id_next_hook_module_name_prefix_cache_hook_dirs)selfr hook_dirs __class__s NC:\PYTHON\MyICR_Workspace\venv\Lib\site-packages\PyInstaller/depend/imphook.pyr zModuleHookCache.__init__8s{*  $M,77)B(H(HIg(h(h%&&!+&& i(((((c |D] \}}tj|}tj|s"t d|t jtj|d}|D]r}tj|dd}t|j |||j |}| |g}| |s|D]G}||} t| dkr | d||<)t!| dd } | d||<Hd S) z Cache all hook scripts in the passed directories. Parameters ---------- hook_dirs : list List of the absolute or relative paths of all directories containing hook scripts to be cached. zHook directory "{}" not found.z hook-*.py)r module_name hook_filenamehook_module_name_prefixdefault_priorityr rc|jSN)priority)hooks rz2ModuleHookCache._cache_hook_dirs..sdmrT)keyreverseN)ospathabspathisdirFileNotFoundErrorrglobjoinbasename ModuleHookrr setdefaultappendkeyslensorted) rrhook_dirr hook_filenamesrr module_hook module_hookshooks sorted_hookss rrz ModuleHookCache._cache_hook_dirs\s+4 1 1 &H&wx00H7==** ['(H(O(OPX(Y(YZZZ"Yrw||Hk'J'JKKN!/ 1 1 !g..}==adC )!%!2 +"/,0,I%5   ${B?? ##K0000! 1( 99;; 4 4K%E5zzQ$)!H[!! &e1K1KUYZZZ $0O[!! 4 4rc|D]?}||d}|%tj|jd@dS)z Remove the passed modules and all hook scripts cached for these modules from this cache. Parameters ---------- module_names : list List of all fully-qualified module names to be removed. N)popsysmoduleshook_module_name)r module_namesrr8s rremove_moduleszModuleHookCache.remove_modulessV( D DK((;55K&