mafw.tools.recent_files
Reusable recent-file history and storage abstractions.
Added in version v2.4.
- Author:
Bulgheroni Antonio (antonio.bulgheroni@ec.europa.eu)
- Description:
Maintain bounded recent-file history independently of any graphical interface.
Classes
|
Keep recent-file data in memory for applications without persistent storage. |
|
Persist recent-file history as a UTF-8 JSON array at a configured path. |
|
Maintain configurable, normalized, duplicate-free recent-file history. |
|
Define the replaceable persistence interface used by recent-file histories. |
- class mafw.tools.recent_files.InMemoryRecentFileStorage(paths: Iterable[str] = ())[source]
Bases:
objectKeep recent-file data in memory for applications without persistent storage.
Added in version v2.4.
- class mafw.tools.recent_files.JsonRecentFileStorage(path: Path | str)[source]
Bases:
objectPersist recent-file history as a UTF-8 JSON array at a configured path.
Added in version v2.4.
- class mafw.tools.recent_files.RecentFileService(storage: ~mafw.tools.recent_files.RecentFileStorage, *, max_entries: int = 10, exists: ~collections.abc.Callable[[~pathlib.Path], bool] = <function Path.is_file>)[source]
Bases:
objectMaintain configurable, normalized, duplicate-free recent-file history.
Storage and path-existence checks are injectable so the service can be shared by independent MAFw applications and tested without constructing GUI widgets.
Added in version v2.4.
- _is_file(path: Path) bool[source]
Check file availability while treating filesystem errors as stale entries.
- _normalize(path: Path | str) Path[source]
Resolve a path to a stable absolute representation without requiring it to exist.
- _persist() None[source]
Persist history without allowing storage failures to break file operations.