Skip to content

Add file_assoc: resolve the app registered for a file type#428

Merged
JE-Chen merged 1 commit into
devfrom
feat/file-assoc-batch
Jun 25, 2026
Merged

Add file_assoc: resolve the app registered for a file type#428
JE-Chen merged 1 commit into
devfrom
feat/file-assoc-batch

Conversation

@JE-Chen

@JE-Chen JE-Chen commented Jun 25, 2026

Copy link
Copy Markdown
Member

Why

open_path (shell_open) opens a file with whatever app is registered for it; this answers the inverse, read-only question — which app is that? Useful to assert "PDFs open in Acrobat, not the browser" before driving an open. Third feature of the ROUND-15 cross-app OS lane (after shell_open and idle_keepawake).

What

A headless utils/file_assoc/ module:

  • normalize_ext(target) — pure helper: path / .ext / bare ext → lowercased .ext (takes the last extension; rejects empty / extensionless).
  • file_association(target, *, resolver=None) — returns {ext, command, exe, friendly, content_type} for the file type, via the Windows AssocQueryStringW shell API. The app fields are None when nothing is registered.

The assembly logic is unit-testable without Windows through an injectable resolver seam; the live lookup is Windows-only (raises elsewhere directing to pass resolver=, mirroring idle_keepawake's probe). AssocQueryStringW is a single documented two-pass ctypes call (size query → buffer), no COM.

Five-layer coverage

  • Headless core: je_auto_control/utils/file_assoc/ (no PySide6).
  • Facade: re-exported from je_auto_control/__init__.py + __all__.
  • Executor: AC_normalize_ext (pure), AC_file_association.
  • MCP: matching ac_* tools (both read-only).
  • Script Builder: commands under Shell.

Docs: EN/Zh v205_features_doc.rst + WHATS_NEW. Headless test test_file_assoc_batch.py (10 tests, injected resolver). Verified the real Win32 AssocQueryStringW path end-to-end on Windows (.txt→Notepad, .html→Edge). ruff / pylint 10.00 / bandit / radon clean.

shell_open opens a file with whatever app is registered for it; file_assoc
answers the inverse, read-only question - which app is that? Given a path,
.ext or bare ext it returns the registered executable, friendly app name,
open command line and MIME content type via the Windows AssocQueryStringW
shell API. normalize_ext is the pure path/.ext/bare-ext to .ext helper.
The assembly logic is unit-testable without Windows through an injectable
resolver seam. The natural companion to open_path: one tells you what would
open a file, the other opens it.
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 34 complexity · 0 duplication

Metric Results
Complexity 34
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@JE-Chen JE-Chen merged commit b6e2185 into dev Jun 25, 2026
22 of 23 checks passed
@JE-Chen JE-Chen deleted the feat/file-assoc-batch branch June 25, 2026 00:24
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant