_։2 d Z ddlZddlZddlZddlZddlmZ ddlmZm Z m Z ej e Z dede eef ddfd Zd e e eef ded fdZddeddfdZddeddfdZd Zd Z G d d ZdS )z> Provides utilities for dynamically loading packages/modules. N)Path) GeneratorListUnionmodule_name file_pathreturnmodulec t j | | }t j | }|j | |S )z4 Execute and return module from *file_path* ) importlibutilspec_from_file_locationmodule_from_specloaderexec_module)r r specr s S/opt/imunify360/venv/lib/python3.11/site-packages/defence360agent/utils/importer.pyget_module_by_pathr sK >11+yIID ^ , ,T 2 2FKF###M paths)r NNc # K t j | D ]D}|j s;t |j j |j dz }t |j | V EdS )z) Yields all modules from *paths* z.pyN)pkgutiliter_modulesispkgr module_finderpathnamer )r r r s r r r sr &u-- 8 8| 8,1225H5H5HHD$V[$777778 8r Fr c R t j | }n# t $ r |s Y dS w xY wt j | |j |j r<| }t j |j D ]"}t j | d|j !dS dS )z Import *name* module, if *name* is a package import all submodules. If *name* module/package is not found: - raise ModuleNotFoundError if *missing_ok* is False - ignore it if *missing_ok* is True N.)r r find_specModuleNotFoundError import_moduler is_packager r r submodule_search_locations)r missing_okr packager s r loadr' ' s ~''-- D!!!{di(( @*4+JKK @ @F#w$>$>$>$>????@ @ @ @s " 33packagesc 2 | D ]}t || d S )N)r% )r' )r( r% r&