loaders – Load modules, get and execute functions¶
Deal with python path and dynamic module and function load
-
libvhc.loaders.load_recipes(log, entry_point_group='vhc.recipes')[source]¶ Load the recipes advertised under the entry point group and fill the
recipe_matchanddefault_driversdictionariesParameters: - log :
logging.LoggerAdapterorlogging.Loggerinstance logger
- entry_point_group : string, optional
name of the entry point group
Returns: - recipe_names : list of strings
name of the loaded recipes
- log :
-
libvhc.loaders.load_drivers(log, entry_point_group='vhc.drivers')[source]¶ Load the drivers advertised under the entry point group
Parameters: - log :
logging.LoggerAdapterorlogging.Loggerinstance logger
- entry_point_group : string, optional
name of the entry point group
Returns: - ddrivers : dict
dictionary mapping the driver names with the functions implementing them
- log :
-
libvhc.loaders.load_reference_file_parsers(log, entry_point_group='vhc.file_parsers')[source]¶ Load the classes implementing file parsers
Parameters: - group : string
name of the group to load
- name : string, optional
name of the entry points to load
Returns: - names : list of strings
name of the loaded parsers
-
libvhc.loaders.load_entrypoints(group, name=None, log=None)[source]¶ Get all the entry points for the
groupand load them.Parameters: - group : string
name of the group to load
- name : string, optional
name of the entry points to load
- log :
logging.LoggerAdapterorlogging.Logger, optional if given, exception when loading entry points are logged as errors, with the full traceback; if
Nonethe exception is re-raised
Returns: - entry_points : list
yields the entry points as a list of [name,
pkg_resources.EntryPoint, loaded]
-
libvhc.loaders._print(name, doc, n_lines=3)[source]¶ Print the name and n_lines of the documentation
-
class
libvhc.loaders.ListStream[source]¶ Bases:
listWrap a list into a class with a
write()andflush(), so that it’s possible to use it as stream handler
-
libvhc.loaders._report(args, what, name, load_func)[source]¶ Load the entry points and print the report
Parameters: - args : Namespace
parsed command line
- what : string
name of the group to report
- name : string
name of the entry point group
- load_func : callable
function used to do the loading and the checking
-
libvhc.loaders._print_exception(stream, full_exception=False, old_log=None)[source]¶ Get the value from the stream and print it
If
full_exceptionis False, print only the error message.Parameters: - stream :
ListStream stream containing the information to print
- full_exception : bool, optional
whether to print the whole stream, or only the lines containing
[ERROR]- old_log : string, optional
if given, don’t report thing already contained in old_log
- stream :