
    SOgXF                     b    S SK Jr  S SKJr  S SKJr  S SKJr  S SKJ	r	  S SK
Jr   " S S\5      rg	)
   )DirectoryManager)FileManager)ModuleManager)EntryPointManager)PluginManager)IPluginc                   ~   \ rS rSrS rS rS2S jrS2S jrS2S jr  S3S jr	    S4S	 jr
S
 rS rS rS2S jrS5S jrS rS rS5S jrS rS rS rS rS5S jrS rS rS5S jrS rS r\4S jrS rS2S jr S r!S  r"S! r#S2S" jr$S# r%S$ r& S5S% jr'S& r( S5S' jr)S( r*S5S) jr+S* r,S5S+ jr-S, r.S- r/S. r0S/ r1S0 r2S1r3g)6PluginInterface	   c                 :   UR                  S[        5       5      U l        UR                  S[        5       5      U l        UR                  S[        5       5      U l        UR                  S[        5       5      U l        UR                  S[        5       5      U l
        g )Ndirectory_managerfile_managermodule_managerentry_point_managerplugin_manager)getr   r   r   r   r   r   r   r   r   r   )selfkwargss     c/Users/admin/workspace/ai/Jarvis/env/lib/python3.13/site-packages/pluginmanager/plugin_interface.py__init__PluginInterface.__init__
   s}    !',?,<,>"@ #JJ~{}E$jj)9=?K#)::.C.?.A$C  %jj)9=?K    c                 6    U R                   R                  5       $ )ar  
A helper method to add all of the site packages tracked by python
to the set of plugin directories.

NOTE that if using a virtualenv, there is an outstanding bug with the
method used here. While there is a workaround implemented, when using a
virutalenv this method WILL NOT track every single path tracked by
python. See: https://github.com/pypa/virtualenv/issues/355
)r   add_site_packages_pathsr   s    r   track_site_package_paths(PluginInterface.track_site_package_paths   s     %%==??r   Nc                 f    Uc  U R                  5       nU R                  nUR                  U5      nU$ N)get_plugin_directoriesr   collect_directories)r   directories
dir_manageplugin_directoriess       r   collect_plugin_directories*PluginInterface.collect_plugin_directories"   s8    557K++
';;KH!!r   c                 b    Uc  U R                  5       nU R                  R                  U5      nU$ r   )r%   r   collect_filepaths)r   r"   plugin_filepathss      r   collect_plugin_filepaths(PluginInterface.collect_plugin_filepaths*   s3    99;K,,>>{Kr   c                 b    Uc  U R                  5       nU R                  R                  U5      nU$ r   )r*   r   load_modules)r   	filepathsloaded_moduless      r   r-   PluginInterface.load_modules0   s2    557I,,99)Dr   c                     Uc  U R                  5       nU R                  R                  U5      nU(       a  U R                  U5        U$ r   )r-   r   collect_pluginsadd_plugins)r   modulesstore_collected_pluginspluginss       r   r2   PluginInterface.collect_plugins6   sC     ?'')G%%55g>"W%r   c                    U R                   R                  nU" UUU5      nU(       aa  U(       a5  U R                  R                  R	                  UR                  5       5        U$ U R                  R                  R	                  U5        U$ r   )r   r2   r   r6   extendvalues)r   entry_point_namesverify_requirementsr5   return_dictr2   r6   s          r   collect_entry_point_plugins+PluginInterface.collect_entry_point_pluginsA   sy     22BB!"3"5"-/ ###++227>>3CD  ##++227;r   c                 :    U R                   R                  U5        g)au  
sets plugins to the internal state.
If the instance member `instantiate_classes` in the underlying
member `plugin_manager` is True and the plugins
have class instances in them, attempts to instatiate the classes.
The default is `True`

This can be checked/changed by:

    `plugin_interface.plugin_manager.instantiate_classes`

If the instance member `unique_instances` in the underlying member
`plugin_manager` is True and duplicate instances are passed in,
this method will not track the new instances internally.
The default is `True`

This can be checked/changed by:

    `plugin_interface.plugin_manager.unique_instances`

N)r   set_pluginsr   r6   s     r   rA   PluginInterface.set_pluginsT   s    , 	''0r   c                 :    U R                   R                  U5        g)a  
Adds plugins to the internal state. `plugins` may be a single
object or an iterable.

If the instance member `instantiate_classes` in the underlying
member `plugin_manager` is True and the plugins
have class instances in them, attempts to instatiate the classes.
Default is `True`

This can be checked/changed by:

    `plugin_interface.plugin_manager.instantiate_classes`

If the instance member `unique_instances` in the underlying member
`plugin_manager` is True and duplicate instances are passed in,
this method will not track the new instances internally.
Default is `True`

This can be checked/changed by:

    `plugin_interface.plugin_manager.unique_instances`

N)r   r3   rB   s     r   r3   PluginInterface.add_pluginsl   s    0 	''0r   c                 :    U R                   R                  U5        g)z]
removes `plugins` from the internal state

`plugins` may be a single object or an iterable.
N)r   remove_pluginsrB   s     r   rG   PluginInterface.remove_plugins   s     	**73r   c                 8    U R                   R                  U5      $ )z
Gets out the plugins from the internal state. Returns a list
object.

If the optional filter_function is supplied, applies the filter
function to the arguments before returning them. Filters should
be callable and take a list argument of plugins.
)r   get_pluginsr   filter_functions     r   rJ   PluginInterface.get_plugins   s     ""..??r   c                 :    U R                   R                  X5        g)aG  
Adds `directories` to the set of plugin directories.

`directories` may be either a single object or a iterable.

`directories` can be relative paths, but will be converted into
absolute paths based on the current working directory.

if `except_blacklisted` is `True` all `directories` in
that are blacklisted will be removed
N)r   add_directoriesr   pathsexcept_blacklisteds      r   add_plugin_directories&PluginInterface.add_plugin_directories   s     	..uIr   c                 6    U R                   R                  5       $ )z2
Returns the plugin directories in a `set` object
)r   get_directoriesr   s    r   r    &PluginInterface.get_plugin_directories   s     %%5577r   c                 :    U R                   R                  U5        g)a   
Removes any `directories` from the set of plugin directories.

`directories` may be a single object or an iterable.

Recommend passing in all paths as absolute, but the method will
attemmpt to convert all paths to absolute if they are not already
based on the current working directory.
N)r   remove_directories)r   rQ   s     r   remove_plugin_directories)PluginInterface.remove_plugin_directories   s     	11%8r   c                 :    U R                   R                  X5        g)a  
Sets the plugin directories to `directories`. This will delete
the previous state stored in `self.plugin_directories` in favor
of the `directories` passed in.

`directories` may be either a single object or an iterable.

`directories` can contain relative paths but will be
converted into absolute paths based on the current working
directory.

if `except_blacklisted` is `True` all `directories` in
blacklisted that are blacklisted will be removed
N)r   set_directoriesrP   s      r   set_plugin_directories&PluginInterface.set_plugin_directories   s     	..uIr   c                 :    U R                   R                  U5        g r   )r   add_entry_pointsr   namess     r   ra    PluginInterface.add_entry_points         11%8r   c                 :    U R                   R                  U5        g r   )r   remove_entry_pointsrb   s     r   rg   #PluginInterface.remove_entry_points   s      44U;r   c                 :    U R                   R                  U5        g r   )r   set_entry_pointsrb   s     r   rj    PluginInterface.set_entry_points   re   r   c                 6    U R                   R                  5       $ r   )r   get_entry_pointsr   s    r   rm    PluginInterface.get_entry_points   s    ''88::r   c                 <    U R                   R                  UU5        g)a-  
Adds `filepaths` to internal state. Recommend passing
in absolute filepaths. Method will attempt to convert to
absolute paths if they are not already.

`filepaths` can be a single object or an iterable

If `except_blacklisted` is `True`, all `filepaths` that
have been blacklisted will not be added.
N)r   add_plugin_filepathsr   r.   rR   s      r   rp   $PluginInterface.add_plugin_filepaths        	..y/A	Cr   c                 6    U R                   R                  5       $ )zD
returns the plugin filepaths tracked internally as a `set` object.
)r   get_plugin_filepathsr   s    r   ru   $PluginInterface.get_plugin_filepaths   s       5577r   c                 :    U R                   R                  U5        g)z
Removes `filepaths` from internal state.
Recommend passing in absolute filepaths. Method will
attempt to convert to absolute paths if not passed in.

`filepaths` can be a single object or an iterable.
N)r   remove_plugin_filepathsr   r.   s     r   rx   'PluginInterface.remove_plugin_filepaths   s     	11)<r   c                 <    U R                   R                  UU5        g)a,  
Sets internal state to `filepaths`. Recommend passing
in absolute filepaths. Method will attempt to convert to
absolute paths if they are not already.

`filepaths` can be a single object or an iterable.

If `except_blacklisted` is `True`, all `filepaths` that
have been blacklisted will not be set.
N)r   set_plugin_filepathsrq   s      r   r|   $PluginInterface.set_plugin_filepaths   rs   r   c                 :    U R                   R                  U5        g)zr
Manually add in `modules` to be tracked by the module manager.

`modules` may be a single object or an iterable.
N)r   add_to_loaded_modules)r   r4   s     r   r   %PluginInterface.add_to_loaded_modules  s     	11':r   c                 6    U R                   R                  5       $ )z.
Returns all modules loaded by this instance.
)r   get_loaded_modulesr   s    r   r   "PluginInterface.get_loaded_modules
  s     ""5577r   c                 8    U R                   R                  U5      $ )ak  
Gets instances out of the internal state using
the default filter supplied in filter_function.
By default, it is the class IPlugin.

Can optionally pass in a list or tuple of classes
in for `filter_function` which will accomplish
the same goal.

lastly, a callable can be passed in, however
it is up to the user to determine if the
objects are instances or not.
)r   get_instancesrK   s     r   r   PluginInterface.get_instances  s     ""00AAr   c                 :    U R                   R                  U5        g)zd
Adds `file_filters` to the internal file filters.
`file_filters` can be single object or iterable.
N)r   add_file_filtersr   file_filterss     r   r    PluginInterface.add_file_filters       
 	**<8r   c                 8    U R                   R                  U5      $ )zo
Gets the file filters.
`filter_function`, can be a user defined filter. Should be callable
and return a list.
)r   get_file_filtersrK   s     r   r    PluginInterface.get_file_filters'  s       11/BBr   c                 :    U R                   R                  U5        g)zk
Removes the `file_filters` from the internal state.
`file_filters` can be a single object or an iterable.
N)r   remove_file_filtersr   s     r   r   #PluginInterface.remove_file_filters/  s    
 	--l;r   c                 :    U R                   R                  U5        g)zu
Sets internal file filters to `file_filters` by tossing old state.
`file_filters` can be single object or iterable.
N)r   set_file_filtersr   s     r   r    PluginInterface.set_file_filters6  r   r   c                 :    U R                   R                  U5        g)z
Adds `module_plugin_filters` to the internal module filters.
May be a single object or an iterable.

Every module filters must be a callable and take in
a list of plugins and their associated names.
N)r   add_module_plugin_filtersr   module_plugin_filterss     r   r   )PluginInterface.add_module_plugin_filters=       	556KLr   c                 8    U R                   R                  U5      $ )z
Gets the internal module filters. Returns a list object.

If supplied, the `filter_function` should take in a single
list argument and return back a list. `filter_function` is
designed to given the option for a custom filter on the module filters.
)r   get_module_plugin_filtersrK   s     r   r   )PluginInterface.get_module_plugin_filtersG  s     ""<<_MMr   c                 :    U R                   R                  U5        g)z
Removes `module_plugin_filters` from the internal module filters.
If the filters are not found in the internal representation,
the function passes on silently.

`module_plugin_filters` may be a single object or an iterable.
N)r   remove_module_plugin_filtersr   s     r   r   ,PluginInterface.remove_module_plugin_filtersQ  s     	889NOr   c                 :    U R                   R                  U5        g)z
Sets the internal module filters to `module_plugin_filters`
`module_plugin_filters` may be a single object or an iterable.

Every module filters must be a callable and take in
a list of plugins and their associated names.
N)r   set_module_plugin_filtersr   s     r   r   )PluginInterface.set_module_plugin_filters[  r   r   c                 @    U R                   R                  nU" X5        g)a  
Adds `directories` to be blacklisted. Blacklisted directories will not
be returned or searched recursively when calling the
`collect_directories` method.

`directories` may be a single instance or an iterable. Recommend
passing in absolute paths, but method will try to convert to absolute
paths based on the current working directory.

If `remove_from_stored_directories` is true, all `directories`
will be removed from internal state.
N)r   add_blacklisted_directories)r   r"   rm_black_dirs_from_stored_dirsadd_black_dirss       r   r   +PluginInterface.add_blacklisted_directoriese       //KK{Cr   c                 6    U R                   R                  5       $ )z1
Returns the set of the blacklisted directories.
)r   get_blacklisted_directoriesr   s    r   r   +PluginInterface.get_blacklisted_directoriesw  s     %%AACCr   c                 @    U R                   R                  nU" X5        g)a  
Sets the `directories` to be blacklisted. Blacklisted directories will
not be returned or searched recursively when calling
`collect_directories`.

This will replace the previously stored set of blacklisted
paths.

`directories` may be a single instance or an iterable. Recommend
passing in absolute paths. Method will try to convert to absolute path
based on current working directory.
N)r   set_blacklisted_directories)r   r"   r   set_black_dirss       r   r   +PluginInterface.set_blacklisted_directories}  r   r   c                 :    U R                   R                  U5        g)ay  
Attempts to remove the `directories` from the set of blacklisted
directories. If a particular directory is not found in the set of
blacklisted, method will continue on silently.

`directories` may be a single instance or an iterable. Recommend
passing in absolute paths. Method will try to convert to an absolute
path if it is not already using the current working directory.
N)r   remove_blacklisted_directories)r   r"   s     r   r   .PluginInterface.remove_blacklisted_directories  s     	==kJr   c                 <    U R                   R                  UU5        g)z
Add `filepaths` to blacklisted filepaths.
If `remove_from_stored` is `True`, any `filepaths` in
internal state will be automatically removed.
N)r   add_blacklisted_filepathsr   r.   remove_from_storeds      r   r   )PluginInterface.add_blacklisted_filepaths  s     	33I4F	Hr   c                 6    U R                   R                  5       $ )z4
Returns the blacklisted filepaths as a set object.
)r   get_blacklisted_filepathsr   s    r   r   )PluginInterface.get_blacklisted_filepaths  s       ::<<r   c                 :    U R                   R                  U5        g)z
Sets internal blacklisted filepaths to filepaths.
If `remove_from_stored` is `True`, any `filepaths` in
internal state will be automatically removed.
N)r   set_blacklisted_filepathsr   s      r   r   )PluginInterface.set_blacklisted_filepaths  s     	33I>r   c                 :    U R                   R                  U5        g)z
Removes `filepaths` from blacklisted filepaths.
`filepaths` may be a single filepath or iterable of filepaths.
recommend passing in absolute filepaths but method will attempt
to convert to absolute filepaths based on current working directory.
N)r   remove_blacklisted_filepathsry   s     r   r   ,PluginInterface.remove_blacklisted_filepaths  s     	66yAr   c                 :    U R                   R                  U5        g)zH
add blacklisted plugins.
`plugins` may be a single object or iterable.
N)r   add_blacklisted_pluginsrB   s     r   r   'PluginInterface.add_blacklisted_plugins      
 	33G<r   c                 6    U R                   R                  5       $ )zO
gets blacklisted plugins tracked in the internal state
Returns a list object.
)r   get_blacklisted_pluginsr   s    r   r   'PluginInterface.get_blacklisted_plugins  s    
 ""::<<r   c                 :    U R                   R                  U5        g)zI
sets blacklisted plugins.
`plugins` may be a single object or iterable.
N)r   set_blacklisted_pluginsrB   s     r   r   'PluginInterface.set_blacklisted_plugins  r   r   c                 :    U R                   R                  U5        g)z_
removes `plugins` from the blacklisted plugins.
`plugins` may be a single object or iterable.
N)r   remove_blacklisted_pluginsrB   s     r   r   *PluginInterface.remove_blacklisted_plugins  s    
 	66w?r   )r   r   r   r   r   r   )NT)NFTF)T)4__name__
__module____qualname____firstlineno__r   r   r%   r*   r-   r2   r>   rA   r3   rG   rJ   rS   r    rZ   r^   ra   rg   rj   rm   rp   ru   rx   r|   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   __static_attributes__ r   r   r
   r
   	   s%   
L
@"  !%04	 7;8=<@05	&10144	@J8
9J"9<9;C8=C;8 -4 B 9C<9MNPM DHD$D DHD$
KH=?B===@r   r
   N)r   r   r   r   r   r   r   r   r   r   ipluginr   objectr
   r   r   r   <module>r      s'    / % ) 2 ) L@f L@r   