MCPcopy
hub / github.com/pex-tool/pex / CallableEntryPoint

Class CallableEntryPoint

pex/dist_metadata.py:1258–1281  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1256
1257@attr.s(frozen=True)
1258class CallableEntryPoint(object):
1259 module = attr.ib() # type: str
1260 attrs = attr.ib() # type: Tuple[str, ...]
1261
1262 @attrs.validator
1263 def _validate_attrs(self, _, value):
1264 if not value:
1265 raise ValueError("A callable entry point must select a callable item from the module.")
1266
1267 def resolve(self):
1268 # type: () -> Callable[[], Any]
1269 module = importlib.import_module(self.module)
1270 try:
1271 return cast("Callable[[], Any]", functools.reduce(getattr, self.attrs, module))
1272 except AttributeError as e:
1273 raise ImportError(
1274 "Could not resolve {attrs} in {module}: {err}".format(
1275 attrs=".".join(self.attrs), module=module, err=e
1276 )
1277 )
1278
1279 def __str__(self):
1280 # type: () -> str
1281 return "{module}:{attrs}".format(module=self.module, attrs=".".join(self.attrs))
1282
1283
1284def parse_entry_point(value):

Callers 3

parse_entry_pointFunction · 0.85

Calls

no outgoing calls