
    Efi                         d 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dZ	 	 	 	 d	dZd ZdS )
aw  
    lml.loader
    ~~~~~~~~~~~~~~~~~~~

    Plugin discovery module. It supports plugins installed via pip tools
    and pyinstaller. :func:`~lml.loader.scan_plugins` is expected to be
    called in the main package of yours at an earliest time of convenience.

    :copyright: (c) 2017-2020 by Onni Software Ltd.
    :license: New BSD License, see LICENSE for more details
    N)chain)	do_importc                 ^    d| z  }t          j        d           t          ||||           dS )a  
    Implicitly discover plugins via pkgutil and pyinstaller path

    Parameters
    -----------------

    prefix:string
      module prefix. This prefix should become the prefix of the module name
      of all plugins.

      In the tutorial, robotchef-britishcuisine is a plugin package
      of robotchef and its module name is 'robotchef_britishcuisine'. When
      robotchef call scan_plugins to load its cuisine plugins, it specifies
      its prefix as "robotchef_". All modules that starts with 'robotchef_'
      will be auto-loaded: robotchef_britishcuisine, robotchef_chinesecuisine,
      etc.

    pyinstaller_path:string
       used in pyinstaller only. When your end developer would package
       your main library and its plugins using pyinstaller, this path
       helps pyinstaller to find the plugins.

    black_list:list
       a list of module names that should be skipped.

    white_list:list
       a list of modules that comes with your main module. If you have a
       built-in module, the module name should be inserted into the list.

       For example, robot_cuisine is a built-in module inside robotchef. It
       is listed in white_list.
    z^%s.+$z?Deprecated! since version 0.0.3. Please use scan_plugins_regex!)plugin_name_patternspyinstaller_path
black_list
white_listN)warningswarnscan_plugins_regex)prefixr   r   r	   r   __plugin_name_patternss         L/var/www/ffwdstore.be/apps/py-env/lib/python3.11/site-packages/lml/loader.pyscan_pluginsr      sV    N &.MI   3)	         c                     t                               d           |g }|g } fdt          j                    D             }t	           |          }t          |||          }|D ]}||v rt                               d|z              $	 t          |           5# t          $ r>}t                               |           t                               |           Y d}~xd}~ww xY wt                               d           dS )ak  
    Implicitly discover plugins via pkgutil and pyinstaller path using
    regular expression

    Parameters
    -----------------

    plugin_name_patterns: python regular expression
       it is used to match all your plugins, either it is a prefix,
       a suffix, some text in the middle or all.

    pyinstaller_path:string
       used in pyinstaller only. When your end developer would package
       your main library and its plugins using pyinstaller, this path
       helps pyinstaller to find the plugins.

    black_list:list
       a list of module names that should be skipped.

    white_list:list
       a list of modules that comes with your main module. If you have a
       built-in module, the module name should be inserted into the list.

       For example, robot_cuisine is a built-in module inside robotchef. It
       is listed in white_list.
    zscanning for plugins...Nc              3   n   K   | ]/}|d          
t          j        |d                   %|d         V  0dS )      N)rematch).0module_infor   s     r   	<genexpr>z%scan_plugins_regex.<locals>.<genexpr>s   s`        q> !h';[^LLA     r   zignored zscanning done)logdebugpkgutiliter_modulesscan_from_pyinstallerr   r   ImportError)	r   r   r   r	   module_namesmodule_names_from_pyinstallerall_modulesmodule_namees	   `        r   r   r   J   sB   B II'(((

   "/11  L %:.% %! 3Z K #  *$$IIj;.///	k"""" 	 	 	IIk"""IIaLLLHHHH	 IIos   B
C#%4CC#c              #      K   t                      }d t          t          j        |          D             D ]}||z  }|D ] }d|v rt	          j        | |          r|V  !dS )z+
    Discover plugins from pyinstaller
    c              3   D   K   | ]}t          |d           |j        V  dS )tocN)hasattrr(   )r   importers     r   r   z(scan_from_pyinstaller.<locals>.<genexpr>   sH        8U##     r   .N)setmapr   get_importerr   r   )r   pathtable_of_contenta_tocr$   s        r   r   r      s       uu G0$77   " "
 	E!'  +8(+66 		 r   )NNN)NNNN)__doc__r   loggingr   r
   	itertoolsr   	lml.utilsr   	getLogger__name__r   r   r   r    r   r   <module>r9      s   
 
 
			               g!! 0 0 0 0h 	D D D DX    r   