def _validate_plugin_name(self, plugin_name):
"""
To validate the given `plugin_name`.
A `plugin_name` is considered valid if:
+ it's not empty.
+ it does not exist currently.
Afterwards the attributes `self.plugin_name` and `self.label` will be
set.
"""
if not plugin_name:
raise CommandError("You must provide a plugin_name.")
try:
importlib.import_module(plugin_name)
raise CommandError(
"The plugin_name %r is conflicted with another module, "
"please specify a new one." % plugin_name)
except ImportError:
pass
self.label = plugin_name.rsplit('.', 1)[-1]
self.plugin_name = plugin_name
评论列表
文章目录