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

uwefladrich / scriptengine / 6119250639

08 Sep 2023 08:03AM UTC coverage: 87.306% (-0.3%) from 87.565%
6119250639

Pull #95

github

uwefladrich
Autoformat setup.py
Pull Request #95: Improve packaging and CI

14 of 14 new or added lines in 1 file covered. (100.0%)

1685 of 1930 relevant lines covered (87.31%)

0.87 hits per line

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

67.86
/src/scriptengine/tasks/core/loader.py
1
import functools
1✔
2
import logging
1✔
3

4
try:
1✔
5
    from importlib.metadata import entry_points
1✔
6
except ModuleNotFoundError:  # Python prior to 3.8
×
7
    from importlib_metadata import entry_points
×
8

9
from scriptengine.exceptions import ScriptEngineTaskLoaderError
1✔
10

11

12
# The load function goes through entry points, searching for ScriptEngine
13
# tasks. Since the function can be called quite frequently and modules are
14
# *usually* not loaded while SE is run, the result is cached.
15
# Note that this means that dynamic module is *not supported* by the loading
16
# mechanism!
17
@functools.lru_cache(maxsize=None)
1✔
18
def load():
1✔
19
    loaded_tasks = dict()
1✔
20
    try:
1✔
21
        eps = entry_points(group="scriptengine.tasks")
1✔
22
    except TypeError:  # importlib.metadata prior to Python 3.10
×
23
        eps = set(entry_points().get("scriptengine.tasks", []))
×
24
    for ep in eps:
1✔
25
        if ep.name not in loaded_tasks:
1✔
26
            loaded_tasks[ep.name] = ep.load()
1✔
27
        else:
28
            existing_ep = next(cep for cep in eps if cep.name == ep.name)
×
29
            existing_mod = existing_ep.value.partition(":")[0]
×
30
            clashing_mod = ep.value.partition(":")[0]
×
31
            logging.getLogger("se.task.loader").error(
×
32
                f'Same task name "{ep.name}" defined in modules '
33
                f'"{existing_mod}" and "{clashing_mod}"'
34
            )
35
            raise ScriptEngineTaskLoaderError
×
36

37
    return loaded_tasks
1✔
38

39

40
def load_and_register():
1✔
41
    loaded_tasks = load()
1✔
42
    for name, task in loaded_tasks.items():
1✔
43
        task.register_name(name)
1✔
44
    return loaded_tasks
1✔
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

© 2026 Coveralls, Inc