本文整理汇总了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)
示例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'
示例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'
示例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
示例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
示例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'