Skip to content

Commit cd3a26a

Browse files
committed
refactor: remove ensure_tools methods in bcasl and engine to use directly ensure_tools from utils.py
Signed-off-by: Samuel Amen Ague <ague.samuel27@gmail.com>
1 parent eb73d20 commit cd3a26a

6 files changed

Lines changed: 16 additions & 198 deletions

File tree

.gitignore

Lines changed: 6 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -1,185 +1,37 @@
1-
# Byte-compiled / optimized / DLL files
1+
# Byte-compiled
22
__pycache__/
3-
*.py[cod]
4-
*$py.class
5-
*.tar.gz
63
# C extensions
74
*.so
8-
.codex
95
# Swap/backup files
106
*.swp
117
*.bak
128
.codex
139
# Distribution / packaging
14-
.Python
1510
build/
1611
dist/
1712
*.egg-info/
1813
.eggs/
1914
*.egg
20-
MANIFEST
21-
.installed.cfg
22-
sdist/
23-
develop-eggs/
24-
downloads/
25-
eggs/
26-
lib/
27-
lib64/
28-
parts/
29-
var/
30-
wheels/
31-
pip-wheel-metadata/
32-
share/python-wheels/
33-
34-
# PyInstaller
35-
*.manifest
36-
*.spec
37-
38-
# Installer logs
39-
pip-log.txt
40-
pip-delete-this-directory.txt
41-
42-
# Unit test / coverage reports
43-
htmlcov/
44-
.tox/
45-
.nox/
46-
.coverage
47-
.coverage.*
48-
.cache
49-
nosetests.xml
50-
coverage.xml
51-
*.cover
52-
*.py,cover
53-
.hypothesis/
54-
.pytest_cache/
55-
56-
# Translations
57-
*.mo
58-
*.pot
59-
60-
# Django
61-
*.log
62-
local_settings.py
63-
db.sqlite3
64-
db.sqlite3-journal
65-
.codex
66-
# Flask
67-
instance/
68-
.webassets-cache
69-
70-
# Scrapy
71-
.scrapy
72-
73-
# Sphinx documentation
74-
docs/_build/
75-
76-
# PyBuilder
77-
target/
78-
79-
# Jupyter Notebook
80-
.ipynb_checkpoints
81-
82-
# IPython
83-
profile_default/
84-
ipython_config.py
85-
bcasl.yml
86-
# pyenv
87-
.python-version
88-
89-
# pipenv
90-
#Pipfile.lock
91-
92-
# PEP 582
93-
__pypackages__/
94-
95-
# Celery
96-
celerybeat-schedule
97-
celerybeat.pid
98-
99-
# SageMath
100-
*.sage.py
101-
10215
# Environments
10316
.env
10417
.venv
10518
env/
10619
venv/
10720
ENV/
108-
env.bak/
109-
venv.bak/
110-
11121
# mypy
11222
.mypy_cache/
11323
.dmypy.json
11424
dmypy.json
115-
11625
# Pyre
11726
.pyre/
118-
119-
# pytype
120-
.pytype/
121-
122-
# Cython debug symbols
123-
cython_debug/
124-
12527
# IDEs / Editors
126-
.directory
12728
.idea/
12829
.vscode/
129-
.spyderproject
130-
.spyproject
131-
.ropeproject
13230
.qtcreator/
133-
134-
# OS files
135-
.DS_Store
136-
Thumbs.db
137-
ehthumbs.db
138-
Desktop.ini
139-
140-
# mkdocs
141-
/site
142-
143-
# Security files
144-
*.p12
145-
*.pfx
146-
*.key
147-
*.pem
148-
certificates/
149-
150-
# PyCompiler ARK specific
151-
experimental_file/
152-
cloc
153-
error_logs/
154-
logs/
155-
crash_reports/
156-
work_notes.txt
157-
output/
158-
compiled/
159-
artifacts/
160-
*.exe
161-
*.app
162-
*.dmg
163-
*.pkg
164-
*.deb
165-
*.rpm
166-
config.json
167-
config.yaml
168-
config.toml
169-
user_preferences.json
170-
171-
clean_venv_duplicates.py
172-
force_clean_venv_files.py
173-
Licence_Injector.py
174-
sys
175-
.blackbox/
176-
.blackboxrules
177-
.kombai
178-
.pref/
179-
.qodo
180-
18131
# Temporary files
182-
temp/
18332
tmp/
184-
*.tmp
185-
prototype/
33+
#todo
34+
todo.md
35+
TODO.md
36+
todo/
37+
TODO/

pycompiler_ark/Core/Compiler/engine_runner.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
from pathlib import Path
3535
from typing import Any, Callable, Optional
3636

37+
from pycompiler_ark.Core.utils.ensure_tools import ensure_tools
3738
from pycompiler_ark.Ui import output
3839

3940
# BuildContext lives in engine_sdk; imported here so callers of this module
@@ -355,10 +356,10 @@ def sys_deps_manager(self):
355356
if on_stdout:
356357
on_stdout(f"⚙️ Environnement : {env_display}")
357358

358-
if hasattr(engine_instance, "ensure_tools_installed"):
359-
if not engine_instance.ensure_tools_installed(
360-
bridge, stop_signal=stop_signal
361-
):
359+
required_tools = getattr(engine_instance, "required_tools", {}) or {}
360+
if required_tools.get("python") or required_tools.get("system"):
361+
result = ensure_tools(required_tools, stop_signal=stop_signal, gui=bridge)
362+
if not result.ok:
362363
if stop_signal and stop_signal():
363364
return _failure("Compilation annulee par l'utilisateur.")
364365
return _failure(

pycompiler_ark/Core/engine/base.py

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
from dataclasses import dataclass
2020
from typing import TYPE_CHECKING, Callable, Optional
2121

22+
from pycompiler_ark.Ui import output
23+
2224
if TYPE_CHECKING:
2325
from pycompiler_ark.Core.engine.build_context import BuildContext
2426

@@ -92,12 +94,6 @@ def resolve_engine_meta(engine_or_cls: object) -> EngineMeta:
9294
author=str(getattr(engine_or_cls, "author", "") or ""),
9395
)
9496

95-
96-
def _tools_stage_message(stage: str, fr: str, en: str) -> tuple[str, str]:
97-
prefix = f"[tools:{stage}] "
98-
return prefix + fr, prefix + en
99-
100-
10197
class CompilerEngine:
10298
"""
10399
Base class for a pluggable compilation engine.
@@ -251,17 +247,6 @@ def required_tools(self) -> dict[str, list[str]]:
251247
"""
252248
return {"python": [], "system": []}
253249

254-
def ensure_tools_installed(
255-
self, gui, stop_signal: Optional[Callable[[], bool]] = None
256-
) -> bool:
257-
"""
258-
Check if all required tools are installed, and install missing ones.
259-
Delegates to the universal ensure_tools utility.
260-
"""
261-
from pycompiler_ark.Core.utils.ensure_tools import ensure_tools
262-
res = ensure_tools(self.required_tools, stop_signal=stop_signal, gui=gui)
263-
return res.ok
264-
265250
def get_log_prefix(self, file_basename: str) -> str:
266251
"""
267252
Return a log prefix string for the engine's compilation messages.

pycompiler_ark/bcasl/Base.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -108,26 +108,6 @@ def required_tools(self) -> dict[str, list[str]]:
108108
"""
109109
return {"python": [], "system": []}
110110

111-
def ensure_tools(
112-
self,
113-
stop_signal: Callable[[], bool] | None = None,
114-
log_cb: Callable[[str], None] | None = None,
115-
) -> bool:
116-
"""Vérifie et installe les outils requis déclarés dans required_tools.
117-
118-
Délègue vers l'utilitaire universel Core.utils.ensure_tools.
119-
Retourne True si tous les outils sont disponibles, False sinon.
120-
"""
121-
tools = self.required_tools
122-
if not tools.get("python") and not tools.get("system"):
123-
return True
124-
from pycompiler_ark.Core.utils.ensure_tools import (
125-
ensure_tools as _ensure_tools,
126-
)
127-
128-
result = _ensure_tools(tools, stop_signal=stop_signal, log_cb=log_cb)
129-
return result.ok
130-
131111
def on_pre_compile(self, ctx: PreCompileContext) -> None:
132112
"""Méthode à surcharger par le plugin."""
133113
raise NotImplementedError

pycompiler_ark/bcasl/executor.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
from pycompiler_ark.bcasl.PreCompileContext import PreCompileContext
2727

28+
from pycompiler_ark.Core.utils.ensure_tools import ensure_tools
2829
from pycompiler_ark.bcasl.Base import (
2930
BCASL_PLUGIN_REGISTER_FUNC,
3031
BcPluginBase,
@@ -310,7 +311,8 @@ def _run_plugin_sequential(
310311
tools = getattr(plg, "required_tools", {})
311312
if tools.get("python") or tools.get("system"):
312313
log_cb = getattr(ctx, "_log_cb", None)
313-
if not plg.ensure_tools(stop_signal=stop_requested, log_cb=log_cb):
314+
result = ensure_tools(tools, stop_signal=stop_requested, log_cb=log_cb)
315+
if not result.ok:
314316
_add_report_item(
315317
report,
316318
plugin_id=plg.meta.id,

todo.md

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)