Besides moving the existing one out of system.py, a new one should be created with a behaviour like system.
Specifically it should allow for the addition of rules like:
PreferDirectory(directory, filter=identity, reverse=False) -- Where directory is a PluginDirectory object and filter is a callable which takes the list of all plugin directories and returns the ones to which the rule applies. Reverse causes the result of filter to be prefer over this one.
PreferImplementation(implementation_name, filter=idetity, plugin_filter=identity, reverse=False) -- Prefers a specific implementation over all others. Filter filters implementation names that this rule applies to. plugin_filter filters plugin_ids that this rule applies too. (Note that filter and plugin_filter should probably return similar values). reverse again reverses the preference.
PreferVersion(version, filter=identity, plugin_filter=identity, reverse=False) -- Like above but with versions
OrderImplementations(order_function, plugin_filter=identity) -- Gives order_function the list of implementations and asks it to order them by preference. Plugin filter, as always, filters which plugins this applies to.
OrderVersions(order_function, plugin_filter=identity) -- Gives order_function the list of versions and asks it to order them by preference. Plugin filter, as always, filters which plugins this applies to.
Ignore(function) -- Ignores any plugins matching function.
Alias(aliased_name, original_name) -- Creates an alias for an existing namespace. For example: Alias("thing.current", "thing.bird") would alias an lookup of "thing.current" to instead resolve as "thing.bird". All aliases are absolute.
Maybe more.
Some helper objects would be useful:
NamespaceFilter
VersionFilter
ImplementationFilter
DirectoryFilter
Also the plugin resolver should have a couple default rules in the following priority order:
"madz_prefer_internal": PreferDirectory()
"madz_order_semver": OrderVersions per semver
"madz_prefer_default": PreferImplementation("")
"madz_order_alphabetical": OrderImplementations per alphabetical
The PluginResolver should allow rules to be labled for ease of addition/insertion/removal. It will likely have to use some pruning mechanisms, and should follow rules sequentially. It's job is twofold given a plugin_id:
Complete missing information.
Choose a plugin that best fits the resolution order.
It may sometimes be asked for multiple plugins, or all matching plugins.
Besides moving the existing one out of system.py, a new one should be created with a behaviour like system.
Specifically it should allow for the addition of rules like:
Some helper objects would be useful:
Also the plugin resolver should have a couple default rules in the following priority order:
The PluginResolver should allow rules to be labled for ease of addition/insertion/removal. It will likely have to use some pruning mechanisms, and should follow rules sequentially. It's job is twofold given a plugin_id: