version_file_utils
appimage_updater.utils.version_file_utils
¶
Utilities for handling version files and version selection.
This module provides shared functionality for extracting and selecting versions from files, reducing duplication between LocalVersionService and VersionChecker.
extract_versions_from_files(app_files, version_extractor)
¶
Extract version information from a list of files.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
app_files
|
list[Path]
|
List of file paths to process |
required |
version_extractor
|
Callable[[str], str | None]
|
Function that extracts version from filename |
required |
Returns:
Type | Description |
---|---|
list[tuple[str, float, Path]]
|
List of tuples (version_str, mtime, path) for files with extractable versions |
Source code in src/appimage_updater/utils/version_file_utils.py
select_newest_version(version_files, version_normalizer)
¶
Select the newest version from a list of version files.
Sorts by semantic version (descending) then by modification time (newest first). Falls back to modification time only if version parsing fails.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
version_files
|
list[tuple[str, float, Path]]
|
List of tuples (version_str, mtime, path) |
required |
version_normalizer
|
Callable[[str], str]
|
Function to normalize version strings |
required |
Returns:
Type | Description |
---|---|
str
|
Normalized version string of the newest version |
Raises:
Type | Description |
---|---|
IndexError
|
If version_files list is empty |