Skip to content

Commit 1b0d6a9

Browse files
committed
reformatting
1 parent 7822bfd commit 1b0d6a9

7 files changed

Lines changed: 378 additions & 180 deletions

File tree

Core/Api.py

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -66,37 +66,39 @@ def request_workspace_change_from_BcPlugin(folder: str) -> bool:
6666
if invoker is None or not isinstance(invoker, _UiInvoker):
6767
invoker = _UiInvoker(gui)
6868
setattr(gui, "_ui_invoker", invoker)
69-
result_holder = {"ok": False}
70-
loop = _QEventLoop()
69+
result_holder = {"ok": False}
70+
loop = _QEventLoop()
7171

72-
def _do():
73-
try:
74-
if not Api._confirm_workspace_change(gui, str(folder)):
75-
result_holder["ok"] = False
76-
return
77-
result_holder["ok"] = bool(
78-
gui.apply_workspace_selection(str(folder), source="plugin")
79-
)
80-
except Exception:
81-
result_holder["ok"] = False
82-
finally:
72+
def _do():
8373
try:
84-
loop.quit()
74+
if not Api._confirm_workspace_change(gui, str(folder)):
75+
result_holder["ok"] = False
76+
return
77+
result_holder["ok"] = bool(
78+
gui.apply_workspace_selection(str(folder), source="plugin")
79+
)
8580
except Exception:
86-
pass
81+
result_holder["ok"] = False
82+
finally:
83+
try:
84+
loop.quit()
85+
except Exception:
86+
pass
8787

88-
try:
89-
invoker.post(_do)
90-
except Exception:
91-
# Fallback: direct call in case invoker posting fails
9288
try:
93-
if not Api._confirm_workspace_change(gui, str(folder)):
94-
return False
95-
return bool(gui.apply_workspace_selection(str(folder), source="plugin"))
89+
invoker.post(_do)
9690
except Exception:
97-
return False
98-
loop.exec()
99-
return bool(result_holder.get("ok", False))
91+
# Fallback: direct call in case invoker posting fails
92+
try:
93+
if not Api._confirm_workspace_change(gui, str(folder)):
94+
return False
95+
return bool(
96+
gui.apply_workspace_selection(str(folder), source="plugin")
97+
)
98+
except Exception:
99+
return False
100+
loop.exec()
101+
return bool(result_holder.get("ok", False))
100102
except Exception:
101103
# Accept by contract even on unexpected errors
102104
return True

Core/WorkSpaceManager/SetupWorkspace.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,9 @@ def apply_workspace_selection(
172172
try:
173173
tr_map = getattr(gui_instance, "_tr", None)
174174
if isinstance(tr_map, dict):
175-
tmpl = tr_map.get("label_workspace_status") or "Workspace: {path}"
175+
tmpl = (
176+
tr_map.get("label_workspace_status") or "Workspace: {path}"
177+
)
176178
gui_instance.label_workspace_status.setText(
177179
str(tmpl).replace("{path}", str(folder))
178180
)

Core/WorkSpaceManager/WorkspaceAdvancedManipulation.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def select_files_manually(gui_instance):
7575
f"Le fichier {f} est en dehors du workspace et sera ignoré.",
7676
f"The file {f} is outside the workspace and will be ignored.",
7777
),
78-
)
78+
)
7979
if valid_files:
8080
gui_instance.selected_files = valid_files
8181
gui_instance.log_i18n(
@@ -269,12 +269,18 @@ def clear_workspace(gui_instance, keep_dir: bool = True) -> bool:
269269
tr_map = getattr(gui_instance, "_tr", None)
270270
if isinstance(tr_map, dict):
271271
if keep_dir and workspace_dir:
272-
tmpl = tr_map.get("label_workspace_status") or "Workspace: {path}"
272+
tmpl = (
273+
tr_map.get("label_workspace_status")
274+
or "Workspace: {path}"
275+
)
273276
gui_instance.label_workspace_status.setText(
274277
str(tmpl).replace("{path}", str(workspace_dir))
275278
)
276279
else:
277-
val = tr_map.get("label_workspace_status_none") or "Workspace: None"
280+
val = (
281+
tr_map.get("label_workspace_status_none")
282+
or "Workspace: None"
283+
)
278284
gui_instance.label_workspace_status.setText(str(val))
279285
else:
280286
if keep_dir and workspace_dir:

bcasl/Loader.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,9 @@ def _apply_plugins_config(
253253
for pid, val in pmap.items():
254254
try:
255255
enabled = (
256-
val if isinstance(val, bool) else bool((val or {}).get("enabled", True))
256+
val
257+
if isinstance(val, bool)
258+
else bool((val or {}).get("enabled", True))
257259
)
258260
if not enabled:
259261
manager.disable_plugin(pid)
@@ -294,9 +296,7 @@ def _run_bcasl_sync(
294296

295297
workspace_meta = _build_workspace_meta(workspace_root, cfg)
296298
return manager.run_pre_compile(
297-
PreCompileContext(
298-
workspace_root, config=cfg, workspace_metadata=workspace_meta
299-
)
299+
PreCompileContext(workspace_root, config=cfg, workspace_metadata=workspace_meta)
300300
)
301301

302302

bcasl/executor.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ def _record_timeout(
147147
_logger.error("Plugin %s timeout après %.1fs", plugin_id, timeout_s)
148148

149149

150-
def _resolve_exec_options(config: dict[str, Any], default_sandbox: bool) -> tuple[bool, int]:
150+
def _resolve_exec_options(
151+
config: dict[str, Any], default_sandbox: bool
152+
) -> tuple[bool, int]:
151153
try:
152154
opts = dict(config or {}).get("options", {}) if isinstance(config, dict) else {}
153155
except Exception:
@@ -179,7 +181,9 @@ def _build_dependency_graph(
179181
for pid, rec in active_items.items():
180182
for dep in rec.requires:
181183
if dep not in active_items:
182-
_logger.warning("Dépendance manquante pour %s: '%s' (ignorée)", pid, dep)
184+
_logger.warning(
185+
"Dépendance manquante pour %s: '%s' (ignorée)", pid, dep
186+
)
183187
continue
184188
indeg[pid] += 1
185189
children[dep].append(pid)
@@ -380,7 +384,9 @@ def _run_parallel_sandbox(
380384

381385
def _configure_worker_env(config: dict[str, Any]) -> None:
382386
try:
383-
_opts = dict(config or {}).get("options", {}) if isinstance(config, dict) else {}
387+
_opts = (
388+
dict(config or {}).get("options", {}) if isinstance(config, dict) else {}
389+
)
384390
_env_nonint = os.environ.get("PYCOMPILER_NONINTERACTIVE_PLUGINS")
385391
_env_offscreen = os.environ.get("PYCOMPILER_OFFSCREEN_PLUGINS")
386392
_noninteractive = (
@@ -413,7 +419,9 @@ def _configure_worker_env(config: dict[str, Any]) -> None:
413419

414420
def _maybe_init_qt_app(config: dict[str, Any]) -> None:
415421
try:
416-
_opts2 = dict(config or {}).get("options", {}) if isinstance(config, dict) else {}
422+
_opts2 = (
423+
dict(config or {}).get("options", {}) if isinstance(config, dict) else {}
424+
)
417425
_env_allow = os.environ.get("PYCOMPILER_SANDBOX_DIALOGS")
418426
_allow_dialogs = (
419427
(str(_env_allow).strip().lower() in ("1", "true", "yes"))
@@ -480,7 +488,9 @@ def __init__(self, *args, **kwargs) -> None:
480488

481489
def _apply_resource_limits(config: dict[str, Any]) -> None:
482490
try:
483-
_opts3 = dict(config or {}).get("options", {}) if isinstance(config, dict) else {}
491+
_opts3 = (
492+
dict(config or {}).get("options", {}) if isinstance(config, dict) else {}
493+
)
484494
_limits = _opts3.get("plugin_limits", {}) if isinstance(_opts3, dict) else {}
485495
_mem_mb = int(_limits.get("mem_mb", 0))
486496
_cpu_s = int(_limits.get("cpu_time_s", 0))
@@ -534,7 +544,9 @@ def _load_plugin_instance(
534544
if plg is None or getattr(getattr(plg, "meta", None), "id", None) != plugin_id:
535545
try:
536546
mgr = BCASL(_Path(project_root), config=config, sandbox=False)
537-
if hasattr(module, "bcasl_register") and callable(getattr(module, "bcasl_register")):
547+
if hasattr(module, "bcasl_register") and callable(
548+
getattr(module, "bcasl_register")
549+
):
538550
module.bcasl_register(mgr)
539551
rec = getattr(mgr, "_registry", {}).get(plugin_id)
540552
if rec is None:

pycompiler_ark.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ def onlymod_log(message: str, gui: Optional[object] = None) -> str:
122122

123123
return line
124124

125+
125126
IS_WINDOWS = os.name == "nt" or platform.system().lower().startswith("win")
126127
IS_DARWIN = platform.system().lower().startswith("darwin")
127128
IS_LINUX = platform.system().lower().startswith("linux")
@@ -564,7 +565,9 @@ def launch_bcasl_standalone(workspace_dir: Optional[str] = None) -> int:
564565
click.echo(
565566
f"❌ Error: Failed to import BCASL standalone module: {e}", err=True
566567
)
567-
click.echo("Make sure OnlyMod.BcaslOnlyMod is properly installed.", err=True)
568+
click.echo(
569+
"Make sure OnlyMod.BcaslOnlyMod is properly installed.", err=True
570+
)
568571
else:
569572
print(f"❌ Error: Failed to import BCASL standalone module: {e}")
570573
print("Make sure OnlyMod.BcaslOnlyMod is properly installed.")

0 commit comments

Comments
 (0)