本文整理匯總了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'