當前位置: 首頁>>代碼示例>>Python>>正文


Python EntryPoint.parse_map方法代碼示例

本文整理匯總了Python中pkg_resources.EntryPoint.parse_map方法的典型用法代碼示例。如果您正苦於以下問題:Python EntryPoint.parse_map方法的具體用法?Python EntryPoint.parse_map怎麽用?Python EntryPoint.parse_map使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pkg_resources.EntryPoint的用法示例。


在下文中一共展示了EntryPoint.parse_map方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: run

# 需要導入模塊: from pkg_resources import EntryPoint [as 別名]
# 或者: from pkg_resources.EntryPoint import parse_map [as 別名]
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()]
        # FIXME: create own setup() attribute for CLI script configuration
        for name, entry_point in console_scripts:
            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) 
開發者ID:click-contrib,項目名稱:click-man,代碼行數:24,代碼來源:man_pages.py

示例2: gen_header

# 需要導入模塊: from pkg_resources import EntryPoint [as 別名]
# 或者: from pkg_resources.EntryPoint import parse_map [as 別名]
def gen_header(self):
        epm = EntryPoint.parse_map(self.distribution.entry_points or '')
        ep = epm.get('setuptools.installation', {}).get('eggsecutable')
        if ep is None:
            return 'w'  # not an eggsecutable, do it the usual way.

        if not ep.attrs or ep.extras:
            raise DistutilsSetupError(
                "eggsecutable entry point (%r) cannot have 'extras' "
                "or refer to a module" % (ep,)
            )

        pyver = sys.version[:3]
        pkg = ep.module_name
        full = '.'.join(ep.attrs)
        base = ep.attrs[0]
        basename = os.path.basename(self.egg_output)

        header = (
            "#!/bin/sh\n"
            'if [ `basename $0` = "%(basename)s" ]\n'
            'then exec python%(pyver)s -c "'
            "import sys, os; sys.path.insert(0, os.path.abspath('$0')); "
            "from %(pkg)s import %(base)s; sys.exit(%(full)s())"
            '" "$@"\n'
            'else\n'
            '  echo $0 is not the correct name for this egg file.\n'
            '  echo Please rename it back to %(basename)s and try again.\n'
            '  exec false\n'
            'fi\n'
        ) % locals()

        if not self.dry_run:
            mkpath(os.path.dirname(self.egg_output), dry_run=self.dry_run)
            f = open(self.egg_output, 'w')
            f.write(header)
            f.close()
        return 'a' 
開發者ID:jpush,項目名稱:jbox,代碼行數:40,代碼來源:bdist_egg.py

示例3: gen_header

# 需要導入模塊: from pkg_resources import EntryPoint [as 別名]
# 或者: from pkg_resources.EntryPoint import parse_map [as 別名]
def gen_header(self):
        epm = EntryPoint.parse_map(self.distribution.entry_points or '')
        ep = epm.get('setuptools.installation',{}).get('eggsecutable')
        if ep is None:
            return 'w'  # not an eggsecutable, do it the usual way.

        if not ep.attrs or ep.extras:
            raise DistutilsSetupError(
                "eggsecutable entry point (%r) cannot have 'extras' "
                "or refer to a module" % (ep,)
            )

        pyver = sys.version[:3]
        pkg = ep.module_name
        full = '.'.join(ep.attrs)
        base = ep.attrs[0]
        basename = os.path.basename(self.egg_output)

        header = (
            "#!/bin/sh\n"
            'if [ `basename $0` = "%(basename)s" ]\n'
            'then exec python%(pyver)s -c "'
            "import sys, os; sys.path.insert(0, os.path.abspath('$0')); "
            "from %(pkg)s import %(base)s; sys.exit(%(full)s())"
            '" "$@"\n'
            'else\n'
            '  echo $0 is not the correct name for this egg file.\n'
            '  echo Please rename it back to %(basename)s and try again.\n'
            '  exec false\n'
            'fi\n'

        ) % locals()

        if not self.dry_run:
            mkpath(os.path.dirname(self.egg_output), dry_run=self.dry_run)
            f = open(self.egg_output, 'w')
            f.write(header)
            f.close()
        return 'a' 
開發者ID:MayOneUS,項目名稱:pledgeservice,代碼行數:41,代碼來源:bdist_egg.py

示例4: _read_entry_points

# 需要導入模塊: from pkg_resources import EntryPoint [as 別名]
# 或者: from pkg_resources.EntryPoint import parse_map [as 別名]
def _read_entry_points(ep_contents):
    ep_map = EntryPoint.parse_map(ep_contents)

    for _, epgroup in ep_map.iteritems():
        for epname, ep in epgroup.iteritems():
            epgroup[epname] = str(ep)

    return ep_map 
開發者ID:PaloAltoNetworks,項目名稱:minemeld-core,代碼行數:10,代碼來源:manager.py

示例5: get_wex_entry_points_from_cwd

# 需要導入模塊: from pkg_resources import EntryPoint [as 別名]
# 或者: from pkg_resources.EntryPoint import parse_map [as 別名]
def get_wex_entry_points_from_cwd():
    try:
        with open(os.path.join(os.getcwd(), 'entry_points.txt')) as txt:
            entry_point_map = EntryPoint.parse_map(txt.read())
        entry_points = dict((str(ep), ep)
                            for ep in entry_point_map.get(GROUP, {}).values())
        if os.getcwd() not in sys.path:
            sys.path.insert(0, os.getcwd())
    except IOError as exc:
        if exc.errno != errno.ENOENT:
            raise
        entry_points = {}

    return entry_points 
開發者ID:eBay,項目名稱:wextracto,代碼行數:16,代碼來源:entrypoints.py

示例6: gen_header

# 需要導入模塊: from pkg_resources import EntryPoint [as 別名]
# 或者: from pkg_resources.EntryPoint import parse_map [as 別名]
def gen_header(self):
        epm = EntryPoint.parse_map(self.distribution.entry_points or '')
        ep = epm.get('setuptools.installation', {}).get('eggsecutable')
        if ep is None:
            return 'w'  # not an eggsecutable, do it the usual way.

        if not ep.attrs or ep.extras:
            raise DistutilsSetupError(
                "eggsecutable entry point (%r) cannot have 'extras' "
                "or refer to a module" % (ep,)
            )

        pyver = '{}.{}'.format(*sys.version_info)
        pkg = ep.module_name
        full = '.'.join(ep.attrs)
        base = ep.attrs[0]
        basename = os.path.basename(self.egg_output)

        header = (
            "#!/bin/sh\n"
            'if [ `basename $0` = "%(basename)s" ]\n'
            'then exec python%(pyver)s -c "'
            "import sys, os; sys.path.insert(0, os.path.abspath('$0')); "
            "from %(pkg)s import %(base)s; sys.exit(%(full)s())"
            '" "$@"\n'
            'else\n'
            '  echo $0 is not the correct name for this egg file.\n'
            '  echo Please rename it back to %(basename)s and try again.\n'
            '  exec false\n'
            'fi\n'
        ) % locals()

        if not self.dry_run:
            mkpath(os.path.dirname(self.egg_output), dry_run=self.dry_run)
            f = open(self.egg_output, 'w')
            f.write(header)
            f.close()
        return 'a' 
開發者ID:ali5h,項目名稱:rules_pip,代碼行數:40,代碼來源:bdist_egg.py


注:本文中的pkg_resources.EntryPoint.parse_map方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。