Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_parse_bad():
with pytest.raises(entrypoints.BadEntryPoint):
entrypoints.EntryPoint.from_string("this won't work", 'foo')
extensions = json.load(infile)
ComponentRegistry._frozen_extensions = {}
for group in extensions:
ComponentRegistry._frozen_extensions[group] = []
for ext_info in extensions.get(group, []):
name = ext_info['name']
obj_path = ext_info['object']
distro_info = ext_info['distribution']
distro = None
if distro_info is not None:
distro = entrypoints.Distribution(*distro_info)
entry = entrypoints.EntryPoint.from_string(obj_path, name, distro=distro)
ComponentRegistry._frozen_extensions[group].append(entry)
def get_single(group, name, path=None):
"""Find a single entry point.
Returns an :class:`EntryPoint` object, or raises :exc:`NoSuchEntryPoint`
if no match is found.
"""
for config, distro in iter_files_distros(path=path):
if (group in config) and (name in config[group]):
epstr = config[group][name]
with BadEntryPoint.err_to_warnings():
return EntryPoint.from_string(epstr, name, distro)
raise NoSuchEntryPoint(group, name)
def get_group_all(group, path=None):
"""Find all entry points in a group.
Returns a list of :class:`EntryPoint` objects.
"""
result = []
for config, distro in iter_files_distros(path=path):
if group in config:
for name, epstr in config[group].items():
with BadEntryPoint.err_to_warnings():
result.append(EntryPoint.from_string(epstr, name, distro))
return result