• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

SystemRDL / PeakRDL / 4497728222

pending completion
4497728222

push

github

Alex Mykyta
Add link to community plugins

207 of 214 branches covered (96.73%)

Branch coverage included in aggregate %.

545 of 549 relevant lines covered (99.27%)

5.89 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/peakrdl/plugins/entry_points.py
1
import sys
6✔
2
from typing import List, Tuple, TYPE_CHECKING
6✔
3

4
if TYPE_CHECKING:
5
    from importlib.metadata import EntryPoint, Distribution
6

7
if sys.version_info >= (3,10,0):
6✔
8
    from importlib import metadata
2✔
9

10
    def _get_entry_points(group_name: str) -> List[Tuple['EntryPoint', 'Distribution']]:
2✔
11
        eps = []
2✔
12
        for ep in metadata.entry_points().select(group=group_name):
2✔
13
            eps.append((ep, ep.dist))
2✔
14
        return eps
2✔
15

16
    def _get_name_from_dist(dist: 'Distribution') -> str:
2✔
17
        return dist.name
2✔
18

19
elif sys.version_info >= (3,8,0): # pragma: no cover
20
    from importlib import metadata
21

22
    def _get_entry_points(group_name: str) -> List[Tuple['EntryPoint', 'Distribution']]:
23
        eps = []
24
        dist_names = set()
25
        for dist in metadata.distributions():
26
            # Due to a bug in importlib.metadata's distributions iterator, in
27
            # some cases editable installs will cause duplicate dist entries.
28
            # Filter this out.
29
            dist_name = get_name_from_dist(dist)
30
            if dist_name in dist_names:
31
                continue
32
            dist_names.add(dist_name)
33

34
            for ep in dist.entry_points:
35
                if ep.group == group_name:
36
                    eps.append((ep, dist))
37
        return eps
38

39
    def _get_name_from_dist(dist: 'Distribution') -> str:
40
        return dist.metadata["Name"]
41

42
else: # pragma: no cover
43
    import pkg_resources # type: ignore
44

45
    def _get_entry_points(group_name: str) -> List[Tuple['EntryPoint', 'Distribution']]:
46
        eps = []
47
        for ep in pkg_resources.iter_entry_points(group_name):
48
            eps.append((ep, ep.dist))
49
        return eps
50

51
    def _get_name_from_dist(dist: 'Distribution') -> str:
52
        return dist.project_name # type: ignore
53

54

55
def get_entry_points(group_name: str) -> List[Tuple['EntryPoint', 'Distribution']]:
6✔
56
    return _get_entry_points(group_name)
6✔
57

58
def get_name_from_dist(dist: 'Distribution') -> str:
6✔
59
    return _get_name_from_dist(dist)
6✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc