newplugin.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:USTC-Software-2017 作者: igemsoftware2017 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号