MCPcopy Index your code
hub / github.com/RustPython/RustPython / from_name

Method from_name

Lib/importlib/metadata/__init__.py:394–409  ·  view source on GitHub ↗

Return the Distribution for the given package name. :param name: The name of the distribution package to search for. :return: The Distribution instance (or subclass thereof) for the named package, if found. :raises PackageNotFoundError: When the named package's d

(cls, name: str)

Source from the content-addressed store, hash-verified

392
393 @classmethod
394 def from_name(cls, name: str) -> Distribution:
395 """Return the Distribution for the given package name.
396
397 :param name: The name of the distribution package to search for.
398 :return: The Distribution instance (or subclass thereof) for the named
399 package, if found.
400 :raises PackageNotFoundError: When the named package's distribution
401 metadata cannot be found.
402 :raises ValueError: When an invalid value is supplied for name.
403 """
404 if not name:
405 raise ValueError("A distribution name is required.")
406 try:
407 return next(iter(cls.discover(name=name)))
408 except StopIteration:
409 raise PackageNotFoundError(name)
410
411 @classmethod
412 def discover(

Calls 4

nextFunction · 0.85
iterFunction · 0.85
discoverMethod · 0.45