Skip to content

Commit 7b9d008

Browse files
committed
retirement du engine loder connetion avec ark config
1 parent 508f86b commit 7b9d008

10 files changed

Lines changed: 16 additions & 734 deletions

File tree

Core/ark_config_loader.py

Lines changed: 0 additions & 200 deletions
Original file line numberDiff line numberDiff line change
@@ -54,32 +54,6 @@
5454
"compile_only_main": False,
5555
"main_file_names": ["main.py", "app.py"],
5656
"auto_detect_entry_points": True,
57-
# PyInstaller options
58-
"pyinstaller": {
59-
"onefile": True,
60-
"windowed": False,
61-
"noconfirm": True,
62-
"clean": False,
63-
"noupx": False,
64-
"icon": None,
65-
"debug": False,
66-
"additional_options": [],
67-
},
68-
# Nuitka options
69-
"nuitka": {
70-
"onefile": True,
71-
"standalone": True,
72-
"disable_console": False,
73-
"show_progress": True,
74-
"output_dir": None,
75-
"icon": None,
76-
"additional_options": [],
77-
},
78-
# Output configuration
79-
"output": {
80-
"directory": "dist",
81-
"clean_before_build": False,
82-
},
8357
# Dependencies
8458
"dependencies": {
8559
"requirements_files": [
@@ -108,11 +82,6 @@
10882
"bcasl_enabled": True,
10983
"plugin_timeout": 0.0,
11084
},
111-
# Engines UI state (persisted widget states per engine)
112-
"engines": {
113-
"pyinstaller": {"ui": {"widgets": {}}},
114-
"nuitka": {"ui": {"widgets": {}}},
115-
},
11685
}
11786

11887

@@ -321,27 +290,6 @@ def create_default_ark_config(workspace_dir: str) -> bool:
321290
- "app.py"
322291
auto_detect_entry_points: true
323292
324-
# PYINSTALLER OPTIONS
325-
pyinstaller:
326-
onefile: true
327-
windowed: false
328-
noconfirm: true
329-
clean: false
330-
noupx: false
331-
icon: null
332-
debug: false
333-
additional_options: []
334-
335-
# NUITKA OPTIONS
336-
nuitka:
337-
onefile: true
338-
standalone: true
339-
disable_console: false
340-
show_progress: true
341-
output_dir: null
342-
icon: null
343-
additional_options: []
344-
345293
# OUTPUT CONFIGURATION
346294
output:
347295
directory: "dist"
@@ -362,15 +310,6 @@ def create_default_ark_config(workspace_dir: str) -> bool:
362310
- "pip"
363311
auto_detect: true
364312
fallback_to_pip: true
365-
366-
# ENGINES (UI state persistence)
367-
engines:
368-
pyinstaller:
369-
ui:
370-
widgets: {}
371-
nuitka:
372-
ui:
373-
widgets: {}
374313
"""
375314

376315
with open(config_file, "w", encoding="utf-8") as f:
@@ -383,142 +322,3 @@ def create_default_ark_config(workspace_dir: str) -> bool:
383322
return False
384323

385324

386-
# --- Simple Engine UI state helpers (for non-dev friendly persistence) ---
387-
388-
389-
def _read_yaml(path: Path) -> dict:
390-
try:
391-
if path.exists():
392-
with open(path, "r", encoding="utf-8") as f:
393-
data = yaml.safe_load(f) or {}
394-
return data if isinstance(data, dict) else {}
395-
except Exception:
396-
pass
397-
return {}
398-
399-
400-
def _write_yaml_atomic(path: Path, data: dict) -> bool:
401-
try:
402-
path.parent.mkdir(parents=True, exist_ok=True)
403-
tmp = path.with_suffix(path.suffix + ".tmp")
404-
with open(tmp, "w", encoding="utf-8") as f:
405-
yaml.safe_dump(data, f, allow_unicode=True, sort_keys=False)
406-
os.replace(tmp, path)
407-
return True
408-
except Exception:
409-
return False
410-
411-
412-
essential_props = ("checked", "text", "enabled", "visible", "currentIndex")
413-
414-
415-
def load_engine_ui_state(workspace_dir: str, engine_id: str) -> dict:
416-
"""Load saved UI state for an engine from ARK_Main_Config.yml (YAML ONLY).
417-
Cherche les fichiers dans cet ordre:
418-
1. ARK_Main_Config.yaml
419-
2. ARK_Main_Config.yml
420-
3. .ARK_Main_Config.yaml
421-
4. .ARK_Main_Config.yml
422-
423-
Returns a mapping {widgetName: {prop: value}} or {}.
424-
"""
425-
try:
426-
if not workspace_dir:
427-
return {}
428-
429-
workspace_path = Path(workspace_dir)
430-
431-
# Chercher les fichiers YAML dans l'ordre de priorité
432-
config_candidates = [
433-
workspace_path / "ARK_Main_Config.yaml",
434-
workspace_path / "ARK_Main_Config.yml",
435-
workspace_path / ".ARK_Main_Config.yaml",
436-
workspace_path / ".ARK_Main_Config.yml",
437-
]
438-
439-
cfg = {}
440-
for candidate in config_candidates:
441-
if candidate.exists() and candidate.is_file():
442-
cfg = _read_yaml(candidate)
443-
break
444-
445-
engines = cfg.get("engines", {}) if isinstance(cfg, dict) else {}
446-
e = engines.get(str(engine_id), {}) if isinstance(engines, dict) else {}
447-
ui = e.get("ui", {}) if isinstance(e, dict) else {}
448-
widgets = ui.get("widgets", {}) if isinstance(ui, dict) else {}
449-
return widgets if isinstance(widgets, dict) else {}
450-
except Exception:
451-
return {}
452-
453-
454-
def save_engine_ui_state(workspace_dir: str, engine_id: str, updates: dict) -> bool:
455-
"""Save UI state for an engine into ARK_Main_Config.yml (YAML ONLY).
456-
Cherche les fichiers existants dans cet ordre:
457-
1. ARK_Main_Config.yaml
458-
2. ARK_Main_Config.yml
459-
3. .ARK_Main_Config.yaml
460-
4. .ARK_Main_Config.yml
461-
462-
Si aucun fichier n'existe, crée ARK_Main_Config.yml par défaut.
463-
464-
- workspace_dir: project workspace path
465-
- engine_id: id string (e.g. 'pyinstaller')
466-
- updates: {widgetName: {prop: value}}
467-
Returns True on success, False otherwise.
468-
"""
469-
if not workspace_dir:
470-
return False
471-
try:
472-
workspace_path = Path(workspace_dir)
473-
474-
# Chercher les fichiers YAML existants dans l'ordre de priorité
475-
config_candidates = [
476-
workspace_path / "ARK_Main_Config.yaml",
477-
workspace_path / "ARK_Main_Config.yml",
478-
workspace_path / ".ARK_Main_Config.yaml",
479-
workspace_path / ".ARK_Main_Config.yml",
480-
]
481-
482-
cfg_path = None
483-
for candidate in config_candidates:
484-
if candidate.exists() and candidate.is_file():
485-
cfg_path = candidate
486-
break
487-
488-
# Si aucun fichier n'existe, utiliser ARK_Main_Config.yml par défaut
489-
if cfg_path is None:
490-
cfg_path = workspace_path / "ARK_Main_Config.yml"
491-
492-
cfg = _read_yaml(cfg_path)
493-
if not isinstance(cfg, dict):
494-
cfg = {}
495-
engines = cfg.get("engines")
496-
if not isinstance(engines, dict):
497-
engines = {}
498-
cfg["engines"] = engines
499-
e = engines.get(str(engine_id))
500-
if not isinstance(e, dict):
501-
e = {}
502-
engines[str(engine_id)] = e
503-
ui = e.get("ui")
504-
if not isinstance(ui, dict):
505-
ui = {}
506-
e["ui"] = ui
507-
widgets = ui.get("widgets")
508-
if not isinstance(widgets, dict):
509-
widgets = {}
510-
ui["widgets"] = widgets
511-
# Merge per widget
512-
for wname, props in (updates or {}).items():
513-
if not isinstance(wname, str) or not isinstance(props, dict):
514-
continue
515-
cur = widgets.get(wname)
516-
if not isinstance(cur, dict):
517-
cur = {}
518-
widgets[wname] = cur
519-
for k, v in props.items():
520-
if k in essential_props:
521-
cur[k] = v
522-
return _write_yaml_atomic(cfg_path, cfg)
523-
except Exception:
524-
return False

Core/engines_loader/registry.py

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
from typing import Optional, Any
1919

2020
from .base import CompilerEngine
21-
from Core.ark_config_loader import load_engine_ui_state, save_engine_ui_state
2221

2322
_REGISTRY: dict[str, type[CompilerEngine]] = {}
2423
_ORDER: list[str] = []
@@ -64,49 +63,6 @@ def register(engine_cls: type[CompilerEngine]):
6463
return engine_cls
6564

6665

67-
def _apply_widgets_state(container, widgets_state: dict) -> None:
68-
"""Apply basic properties to child widgets given a simple state mapping.
69-
Supported props: checked, text, enabled, visible, currentIndex.
70-
"""
71-
try:
72-
for wname, props in widgets_state.items():
73-
try:
74-
w = container.findChild(object, wname)
75-
if w is None:
76-
continue
77-
for k, v in (props or {}).items():
78-
try:
79-
if k == "checked" and hasattr(w, "setChecked"):
80-
w.setChecked(bool(v))
81-
elif k == "text" and hasattr(w, "setText"):
82-
w.setText(str(v))
83-
elif k == "enabled" and hasattr(w, "setEnabled"):
84-
w.setEnabled(bool(v))
85-
elif k == "visible" and hasattr(w, "setVisible"):
86-
w.setVisible(bool(v))
87-
elif k == "currentIndex" and hasattr(w, "setCurrentIndex"):
88-
w.setCurrentIndex(int(v))
89-
except Exception:
90-
continue
91-
except Exception:
92-
continue
93-
except Exception:
94-
pass
95-
96-
97-
def save_engine_ui(gui, engine_id: str, updates: dict[str, dict[str, Any]]) -> bool:
98-
"""Public helper for engines to persist UI state into ARK_Main_Config.yml.
99-
Engines pass a mapping {widgetName: {prop: value}}. Returns True on success.
100-
"""
101-
try:
102-
ws = getattr(gui, "workspace_dir", None)
103-
if not ws:
104-
return False
105-
return save_engine_ui_state(ws, engine_id, updates)
106-
except Exception:
107-
return False
108-
109-
11066
def get_engine(eid: str) -> Optional[type[CompilerEngine]]:
11167
try:
11268
return _REGISTRY.get(eid)
@@ -141,15 +97,6 @@ def bind_tabs(gui) -> None:
14197
if not pair:
14298
continue
14399
widget, label = pair
144-
# Apply saved UI state for this engine (simple mapping by objectName)
145-
try:
146-
ws = getattr(gui, "workspace_dir", None)
147-
if ws:
148-
widgets_state = load_engine_ui_state(ws, eid)
149-
if isinstance(widgets_state, dict) and widgets_state:
150-
_apply_widgets_state(widget, widgets_state)
151-
except Exception:
152-
pass
153100
try:
154101
existing = tabs.indexOf(widget)
155102
except Exception:

0 commit comments

Comments
 (0)