Add file_assoc: resolve the app registered for a file type#428
Merged
Conversation
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.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 34 |
| Duplication | 0 |
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.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



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 (aftershell_openandidle_keepawake).What
A headless
utils/file_assoc/module:normalize_ext(target)— pure helper: path /.ext/ bareext→ 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 WindowsAssocQueryStringWshell API. The app fields areNonewhen nothing is registered.The assembly logic is unit-testable without Windows through an injectable
resolverseam; the live lookup is Windows-only (raises elsewhere directing to passresolver=, mirroringidle_keepawake's probe).AssocQueryStringWis a single documented two-pass ctypes call (size query → buffer), no COM.Five-layer coverage
je_auto_control/utils/file_assoc/(noPySide6).je_auto_control/__init__.py+__all__.AC_normalize_ext(pure),AC_file_association.ac_*tools (both read-only).Docs: EN/Zh
v205_features_doc.rst+ WHATS_NEW. Headless testtest_file_assoc_batch.py(10 tests, injected resolver). Verified the real Win32AssocQueryStringWpath end-to-end on Windows (.txt→Notepad,.html→Edge). ruff / pylint 10.00 / bandit / radon clean.