import_tools
Functions for importing classes.
New in version 0.5.0.
Functions:
|
Returns a list of objects in the given package, optionally filtered by |
|
Returns a list of entry points in the given category, optionally filtered by |
|
Returns a mapping of entry point names to the entry points in the given category, optionally filtered by |
|
Returns a list of objects in the given module, optionally filtered by |
|
Returns an iterator over the names of the submodules and subpackages of the given module. |
-
discover
(package, match_func=None, exclude_side_effects=True)[source] Returns a list of objects in the given package, optionally filtered by
match_func
.- Parameters
package (
ModuleType
) – A Python packagematch_func (
Optional
[Callable
[[Any
],bool
]]) – Function taking an object and returningTrue
if the object is to be included in the output. DefaultNone
, which includes all objects.exclude_side_effects (
bool
) – Don’t include objects that are only there because of an import side effect. DefaultTrue
.
- Return type
- Overloads
Changed in version 1.0.0: Added the
exclude_side_effects
parameter.
-
discover_entry_points
(group_name, match_func=None)[source] Returns a list of entry points in the given category, optionally filtered by
match_func
.New in version 1.1.0.
- Parameters
- Return type
- Returns
List of matching objects.
-
discover_entry_points_by_name
(group_name, name_match_func=None, object_match_func=None)[source] Returns a mapping of entry point names to the entry points in the given category, optionally filtered by
name_match_func
andobject_match_func
.New in version 2.5.0.
- Parameters
group_name (
str
) – The entry point group name, e.g.'entry_points'
.name_match_func (
Optional
[Callable
[[Any
],bool
]]) – Function taking the entry point name and returningTrue
if the entry point is to be included in the output. DefaultNone
, which includes all entry points.object_match_func (
Optional
[Callable
[[Any
],bool
]]) – Function taking an object and returningTrue
if the object is to be included in the output. DefaultNone
, which includes all objects.
- Return type
-
discover_in_module
(module, match_func=None, exclude_side_effects=True)[source] Returns a list of objects in the given module, optionally filtered by
match_func
.New in version 2.6.0.
- Parameters
module (
ModuleType
) – A Python module.match_func (
Optional
[Callable
[[Any
],bool
]]) – Function taking an object and returningTrue
if the object is to be included in the output. DefaultNone
, which includes all objects.exclude_side_effects (
bool
) – Don’t include objects that are only there because of an import side effect. DefaultTrue
.
- Return type