관리-도구
편집 파일: importer.cpython-311.opt-1.pyc
� IMg- � � � d Z ddlZddlZddlZddlZddlZddlZddlmZ ddl m Z mZmZ ej e� � Zdedeeef ddfd �Zd eeeef de d fd�Zddeddfd�Zddeddfd�Zd� Zd� ZdS )z> Provides utilities for dynamically loading packages/modules. � N)�Path)� Generator�List�Union�module_name� file_path�return�modulec � � t j � | |� � }t j � |� � }|j � |� � |S )z4 Execute and return module from *file_path* )� importlib�util�spec_from_file_location�module_from_spec�loader�exec_module)r r �specr s �S/opt/imunify360/venv/lib/python3.11/site-packages/defence360agent/utils/importer.py�get_module_by_pathr sK � � �>�1�1�+�y�I�I�D� �^� ,� ,�T� 2� 2�F��K���F�#�#�#��M� �paths)r NNc # � K � t j | � � D ]D}|j s;t |j j � � |j � d�z }t |j |� � V � �EdS )z) Yields all modules from *paths* z.pyN)�pkgutil�iter_modules�ispkgr � module_finder�path�namer )r r r s r r r sr � � � � �&�u�-�-� 8� 8���|� 8���,�1�2�2���5H�5H�5H�H�D�$�V�[�$�7�7�7�7�7��8� 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_spec�ModuleNotFoundError� import_moduler � is_packager r r �submodule_search_locations)r � missing_okr �packager s r �loadr'