Skip to content

Commit 2d2ea6e

Browse files
author
PyCompiler ARK++ Team
committed
docs: fix Quick Navigation anchors by adding explicit IDs and headings; unify cleaner plugin i18n and add languages (en, fr, es, de)
1 parent 8c5b228 commit 2d2ea6e

9 files changed

Lines changed: 153 additions & 68 deletions

File tree

API/cleaner/__init__.py

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ def _is_excluded(path_str: str) -> bool:
6060

6161
# Demande de confirmation avant une opération potentiellement destructive
6262
if not sctx.msg_question(
63-
tr.get("title", "Nettoyeur"),
64-
tr.get("confirm_delete", "Supprimer tous les fichiers .pyc et les dossiers __pycache__ du workspace ?"),
63+
tr.get("title", "Cleaner"),
64+
tr.get("confirm_delete", "Delete all .pyc files and __pycache__ folders from the workspace?"),
6565
default_yes=False,
6666
):
67-
sctx.log_warn("Nettoyage annulé par l'utilisateur")
67+
sctx.log_warn(tr.get("cleanup_cancelled", "Cleanup cancelled by user"))
6868
return
6969

7070
# 1) Analyse (comptage des éléments à supprimer) avec progression indéterminée
@@ -89,8 +89,8 @@ def _is_excluded(path_str: str) -> bool:
8989
total += 1
9090

9191
if total == 0:
92-
ph.update(text="Rien à supprimer")
93-
sctx.log_info("Aucun fichier .pyc ou dossier __pycache__ à supprimer.")
92+
ph.update(text=tr.get("nothing_to_delete", "Nothing to delete"))
93+
sctx.log_info(tr.get("no_files_to_delete", "No .pyc files or __pycache__ folders to delete."))
9494
return
9595

9696
# 2) Suppression avec progression déterminée
@@ -107,16 +107,23 @@ def _is_excluded(path_str: str) -> bool:
107107
if _is_excluded(path):
108108
continue
109109
if ph.canceled:
110-
sctx.log_warn("Nettoyage annulé par l'utilisateur")
110+
sctx.log_warn(tr.get("cleanup_cancelled", "Cleanup cancelled by user"))
111111
return
112112
try:
113113
os.remove(path)
114114
pyc_count += 1
115115
except Exception as e:
116-
sctx.log_warn(f"Erreur suppression {file}: {e}")
116+
sctx.log_warn(
117+
tr.get("delete_error", "Error deleting {file}: {error}").format(file=file, error=e)
118+
)
117119
finally:
118120
current += 1
119-
ph.update(current, f"Suppression .pyc ({current}/{total})")
121+
ph.update(
122+
current,
123+
tr.get("deleting_pyc", "Deleting .pyc ({current}/{total})").format(
124+
current=current, total=total
125+
),
126+
)
120127

121128
# Supprimer les dossiers __pycache__
122129
for d in dirs:
@@ -125,20 +132,30 @@ def _is_excluded(path_str: str) -> bool:
125132
if _is_excluded(path):
126133
continue
127134
if ph.canceled:
128-
sctx.log_warn("Nettoyage annulé par l'utilisateur")
135+
sctx.log_warn(tr.get("cleanup_cancelled", "Cleanup cancelled by user"))
129136
return
130137
try:
131138
shutil.rmtree(path)
132139
pycache_count += 1
133140
except Exception as e:
134-
sctx.log_warn(f"Erreur suppression {d}: {e}")
141+
sctx.log_warn(
142+
tr.get("delete_error", "Error deleting {file}: {error}").format(file=d, error=e)
143+
)
135144
finally:
136145
current += 1
137-
ph.update(current, f"Suppression __pycache__ ({current}/{total})")
146+
ph.update(
147+
current,
148+
tr.get("deleting_pycache", "Deleting __pycache__ ({current}/{total})").format(
149+
current=current, total=total
150+
),
151+
)
138152

139153
# 3) Logs UI
140154
sctx.log_info(
141-
f"🗑️ Nettoyage terminé : {pyc_count} fichier(s) .pyc et {pycache_count} dossier(s) __pycache__ supprimés."
155+
tr.get(
156+
"cleanup_completed",
157+
"🗑️ Cleanup completed: {pyc_count} .pyc file(s) and {pycache_count} __pycache__ folder(s) deleted.",
158+
).format(pyc_count=pyc_count, pycache_count=pycache_count)
142159
)
143160
finally:
144161
ph.close()

API/cleaner/languages/de.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"_meta": {
3+
"code": "de",
4+
"name": "Deutsch"
5+
},
6+
"title": "Bereiniger",
7+
"confirm_delete": "Alle .pyc-Dateien und __pycache__-Ordner aus dem Workspace löschen?",
8+
"progress_title": "Workspace-Bereinigung",
9+
"analysis_text": "Analysiere zu löschende Elemente...",
10+
"cleanup_cancelled": "Bereinigung vom Benutzer abgebrochen",
11+
"nothing_to_delete": "Nichts zu löschen",
12+
"no_files_to_delete": "Keine .pyc-Dateien oder __pycache__-Ordner zu löschen.",
13+
"delete_error": "Fehler beim Löschen von {file}: {error}",
14+
"deleting_pyc": "Lösche .pyc ({current}/{total})",
15+
"deleting_pycache": "Lösche __pycache__ ({current}/{total})",
16+
"cleanup_completed": "🗑️ Bereinigung abgeschlossen: {pyc_count} .pyc-Datei(en) und {pycache_count} __pycache__-Ordner gelöscht."
17+
}

API/cleaner/languages/en.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"_meta": {
3+
"code": "en",
4+
"name": "English"
5+
},
6+
"title": "Cleaner",
7+
"confirm_delete": "Delete all .pyc files and __pycache__ folders from the workspace?",
8+
"progress_title": "Workspace Cleanup",
9+
"analysis_text": "Analyzing items to delete...",
10+
"cleanup_cancelled": "Cleanup cancelled by user",
11+
"nothing_to_delete": "Nothing to delete",
12+
"no_files_to_delete": "No .pyc files or __pycache__ folders to delete.",
13+
"delete_error": "Error deleting {file}: {error}",
14+
"deleting_pyc": "Deleting .pyc ({current}/{total})",
15+
"deleting_pycache": "Deleting __pycache__ ({current}/{total})",
16+
"cleanup_completed": "🗑️ Cleanup completed: {pyc_count} .pyc file(s) and {pycache_count} __pycache__ folder(s) deleted."
17+
}

API/cleaner/languages/es.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"_meta": {
3+
"code": "es",
4+
"name": "Español"
5+
},
6+
"title": "Limpiador",
7+
"confirm_delete": "¿Eliminar todos los archivos .pyc y carpetas __pycache__ del workspace?",
8+
"progress_title": "Limpieza del workspace",
9+
"analysis_text": "Analizando elementos a eliminar...",
10+
"cleanup_cancelled": "Limpieza cancelada por el usuario",
11+
"nothing_to_delete": "Nada que eliminar",
12+
"no_files_to_delete": "No hay archivos .pyc o carpetas __pycache__ para eliminar.",
13+
"delete_error": "Error al eliminar {file}: {error}",
14+
"deleting_pyc": "Eliminando .pyc ({current}/{total})",
15+
"deleting_pycache": "Eliminando __pycache__ ({current}/{total})",
16+
"cleanup_completed": "🗑️ Limpieza completada: {pyc_count} archivo(s) .pyc y {pycache_count} carpeta(s) __pycache__ eliminadas."
17+
}

API/cleaner/languages/fr.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"_meta": {
3+
"code": "fr",
4+
"name": "Français"
5+
},
6+
"title": "Nettoyeur",
7+
"confirm_delete": "Supprimer tous les fichiers .pyc et les dossiers __pycache__ du workspace ?",
8+
"progress_title": "Nettoyage du workspace",
9+
"analysis_text": "Analyse des éléments à supprimer...",
10+
"cleanup_cancelled": "Nettoyage annulé par l'utilisateur",
11+
"nothing_to_delete": "Rien à supprimer",
12+
"no_files_to_delete": "Aucun fichier .pyc ou dossier __pycache__ à supprimer.",
13+
"delete_error": "Erreur lors de la suppression de {file} : {error}",
14+
"deleting_pyc": "Suppression .pyc ({current}/{total})",
15+
"deleting_pycache": "Suppression __pycache__ ({current}/{total})",
16+
"cleanup_completed": "🗑️ Nettoyage terminé : {pyc_count} fichier(s) .pyc et {pycache_count} dossier(s) __pycache__ supprimés."
17+
}

docs/how_to_create_a_bcasl_API.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Table of contents
6868

6969
---
7070

71-
0) TL;DR (copy‑paste template)
71+
## 0) TL;DR (copy‑paste template) {#0-tldr-copy-paste-template}
7272

7373
```python
7474
# API/my_plugin/__init__.py
@@ -116,7 +116,7 @@ def bcasl_register(manager):
116116

117117
---
118118

119-
1) Quick checklist
119+
## 1) Quick checklist {#1-quick-checklist}
120120
- [ ] Package under API/<plugin_id>/ with __init__.py
121121
- [ ] BCASL signature: BCASL_PLUGIN=True, BCASL_ID, BCASL_DESCRIPTION
122122
- [ ] Extended metadata (recommended): NAME, VERSION, AUTHOR, CREATED, LICENSE, COMPATIBILITY, TAGS
@@ -129,7 +129,7 @@ def bcasl_register(manager):
129129

130130
---
131131

132-
2) Folder layout
132+
## 2) Folder layout {#2-folder-layout}
133133

134134
Place plugins exclusively under API/<plugin_id>/ (never under acasl/ or bcasl/):
135135
```
@@ -141,7 +141,7 @@ Place plugins exclusively under API/<plugin_id>/ (never under acasl/ or bcasl/):
141141

142142
---
143143

144-
3) Minimal plugin (with metadata)
144+
## 3) Minimal plugin (with metadata) {#3-minimal-plugin-with-metadata}
145145

146146
```python
147147
from __future__ import annotations
@@ -183,7 +183,7 @@ def bcasl_register(manager):
183183

184184
---
185185

186-
4) Tag taxonomy and default ordering (minify before obfuscation)
186+
## 4) Tag taxonomy and default ordering (minify before obfuscation) {#4-tag-taxonomy-and-default-ordering-minify-before-obfuscation}
187187

188188
The host computes a default order from BCASL_TAGS (no IDs are hard‑coded):
189189
- clean, cleanup, sanitize, prune, tidy → earliest
@@ -221,7 +221,7 @@ Recommended baseline tags by stage:
221221

222222
---
223223

224-
5) Progress and non‑interactive considerations
224+
## 5) Progress and non‑interactive considerations {#5-progress-and-non-interactive-considerations}
225225

226226
- Always use progress(...) for long operations; it is non‑blocking and UI‑safe.
227227
- Ask confirmation only when interactive. Detect non‑interactive mode (best‑effort):
@@ -245,7 +245,7 @@ if ask and not sctx.msg_question("Proceed?", "Run heavy step now?", default_yes=
245245

246246
---
247247

248-
6) Configuration patterns
248+
## 6) Configuration patterns {#6-configuration-patterns}
249249

250250
- Workspace config (bcasl.*) can be JSON/YAML/TOML/INI/CFG; the UI can create and edit it.
251251
- Per‑plugin settings: use ensure_settings_file(...) to materialize a user‑editable file under the workspace.
@@ -257,7 +257,7 @@ settings = ensure_settings_file(sctx, subdir="config", basename="my_plugin", fmt
257257

258258
---
259259

260-
6.1) System install helpers (pip global + package managers)
260+
## 6.1) System install helpers (pip global + package managers) {#61-system-install-helpers-pip-global--package-managers}
261261

262262
- Use the standardized helpers to request consent and install dependencies system‑wide.
263263
- In non‑interactive mode these helpers return False and skip installation safely.
@@ -294,7 +294,7 @@ if not ok:
294294

295295
---
296296

297-
7) Context essentials
297+
## 7) Context essentials {#7-context-essentials}
298298

299299
- Safe paths: sctx.safe_path(rel_or_abs) and sctx.is_within_workspace(Path)
300300
- Scans: sctx.iter_files(patterns=[...], exclude=[...], enforce_workspace=True)
@@ -303,7 +303,7 @@ if not ok:
303303

304304
---
305305

306-
8) i18n (async)
306+
## 8) i18n (async) {#8-i18n-async}
307307

308308
- Place a languages/ folder in your package; load with API_SDK helpers:
309309
```python
@@ -314,7 +314,7 @@ tr = asyncio.run(load_plugin_translations(__file__, "System"))
314314

315315
---
316316

317-
9) Workspace switching (safe)
317+
## 9) Workspace switching (safe) {#9-workspace-switching-safe}
318318

319319
```python
320320
from API_SDK import set_selected_workspace
@@ -325,7 +325,7 @@ if ok:
325325

326326
---
327327

328-
10) Examples
328+
## 10) Examples {#10-examples}
329329

330330
A) Minifier (minify before obfuscation via tags)
331331
```python
@@ -472,7 +472,7 @@ def bcasl_register(manager):
472472

473473
---
474474

475-
11) Troubleshooting
475+
## 11) Troubleshooting {#11-troubleshooting}
476476
- Plugin not visible → ensure BCASL_PLUGIN/ID/DESCRIPTION exist; it's under API/<plugin_id>/ (not under acasl/ or bcasl/); use @plugin; register via bcasl_register; open API Loader; check logs
477477
- Config invalid → use UI raw editor; validate formats; fall back to JSON
478478
- Long operations → use progress; split work; no modal blocking in background

0 commit comments

Comments
 (0)