Python pkg_resources.EntryPoint 模块,parse_map() 实例源码

我们从Python开源项目中,提取了以下1个代码示例,用于说明如何使用pkg_resources.EntryPoint.parse_map()

项目:click-man    作者:click-contrib    | 项目源码 | 文件源码
def run(self):
        """
        Generate man pages for the scripts defined in distutils setup().

        The cli application is gathered from the setuptools setup()
        function in setup.py.

        The generated man pages are written to files in the directory given
        by ``--target``.
        """
        eps = EntryPoint.parse_map(self.distribution.entry_points or '')

        if 'console_scripts' not in eps or not eps['console_scripts']:
            raise DistutilsSetupError('No entry points defined in setup()')

        console_scripts = [(k, v) for k, v in eps['console_scripts'].items()]
        # Only generate man pages for first console script
        # FIXME: create own setup() attribute for CLI script configuration
        name, entry_point = console_scripts[0]

        self.announce('Load entry point {0}'.format(name), level=2)
        cli = entry_point.resolve()
        self.announce('Generate man pages for {0}'.format(name), level=2)
        write_man_pages(name, cli, version=self.version, target_dir=self.target)