An immutable collection of selectable EntryPoint objects.
| 315 | |
| 316 | |
| 317 | class EntryPoints(tuple): |
| 318 | """ |
| 319 | An immutable collection of selectable EntryPoint objects. |
| 320 | """ |
| 321 | |
| 322 | __slots__ = () |
| 323 | |
| 324 | def __getitem__(self, name: str) -> EntryPoint: # type: ignore[override] # Work with str instead of int |
| 325 | """ |
| 326 | Get the EntryPoint in self matching name. |
| 327 | """ |
| 328 | try: |
| 329 | return next(iter(self.select(name=name))) |
| 330 | except StopIteration: |
| 331 | raise KeyError(name) |
| 332 | |
| 333 | def __repr__(self): |
| 334 | """ |
| 335 | Repr with classname and tuple constructor to |
| 336 | signal that we deviate from regular tuple behavior. |
| 337 | """ |
| 338 | return '%s(%r)' % (self.__class__.__name__, tuple(self)) |
| 339 | |
| 340 | def select(self, **params) -> EntryPoints: |
| 341 | """ |
| 342 | Select entry points from self that match the |
| 343 | given parameters (typically group and/or name). |
| 344 | """ |
| 345 | return EntryPoints(ep for ep in self if ep.matches(**params)) |
| 346 | |
| 347 | @property |
| 348 | def names(self) -> set[str]: |
| 349 | """ |
| 350 | Return the set of all names of all entry points. |
| 351 | """ |
| 352 | return {ep.name for ep in self} |
| 353 | |
| 354 | @property |
| 355 | def groups(self) -> set[str]: |
| 356 | """ |
| 357 | Return the set of all groups of all entry points. |
| 358 | """ |
| 359 | return {ep.group for ep in self} |
| 360 | |
| 361 | @classmethod |
| 362 | def _from_text_for(cls, text, dist): |
| 363 | return cls(ep._for(dist) for ep in cls._from_text(text)) |
| 364 | |
| 365 | @staticmethod |
| 366 | def _from_text(text): |
| 367 | return ( |
| 368 | EntryPoint(name=item.value.name, value=item.value.value, group=item.name) |
| 369 | for item in Sectioned.section_pairs(text or '') |
| 370 | ) |
| 371 | |
| 372 | |
| 373 | class PackagePath(pathlib.PurePosixPath): |
no outgoing calls
no test coverage detected
searching dependent graphs…