Compare commits
1 Commits
main
...
default-sy
Author | SHA1 | Date | |
---|---|---|---|
1365fc48bf |
@ -6,6 +6,7 @@ import platform
|
|||||||
from collections.abc import Sequence
|
from collections.abc import Sequence
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
from itertools import product
|
||||||
from mimetypes import guess_type
|
from mimetypes import guess_type
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from subprocess import check_call
|
from subprocess import check_call
|
||||||
@ -47,6 +48,31 @@ def removesuffix(s: str, suf: str) -> str:
|
|||||||
return s[: -len(suf)] if s and s.endswith(suf) else s
|
return s[: -len(suf)] if s and s.endswith(suf) else s
|
||||||
|
|
||||||
|
|
||||||
|
SYSTEM_SYNONYMS: list[list[str]] = [
|
||||||
|
["Darwin", "darwin", "macos", "macOS"],
|
||||||
|
["Windows", "windows", "win", "win64"],
|
||||||
|
["Linux", "linux"],
|
||||||
|
]
|
||||||
|
|
||||||
|
ARCH_SYNONYMS: list[list[str]] = [
|
||||||
|
["arm"],
|
||||||
|
["x86_64", "amd64"],
|
||||||
|
["arm64", "aarch64", "armv8b", "armv8l"],
|
||||||
|
["i386", "x86"],
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def get_synonyms(value: str, thesaurus: list[list[str]]) -> list[str]:
|
||||||
|
"""Gets synonym list for a given value."""
|
||||||
|
results = [value]
|
||||||
|
|
||||||
|
for l in thesaurus:
|
||||||
|
if value in l:
|
||||||
|
results += l
|
||||||
|
|
||||||
|
return results
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class GitRemoteInfo:
|
class GitRemoteInfo:
|
||||||
"""Extracts information about a repository"""
|
"""Extracts information about a repository"""
|
||||||
@ -245,21 +271,29 @@ def match_asset(
|
|||||||
|
|
||||||
system = platform.system()
|
system = platform.system()
|
||||||
if system_mapping:
|
if system_mapping:
|
||||||
system = system_mapping.get(system, system)
|
systems = [system_mapping.get(system, system)]
|
||||||
|
else:
|
||||||
|
systems = get_synonyms(system, SYSTEM_SYNONYMS)
|
||||||
|
|
||||||
arch = platform.machine()
|
arch = platform.machine()
|
||||||
if arch_mapping:
|
if arch_mapping:
|
||||||
arch = arch_mapping.get(arch, arch)
|
archs = [arch_mapping.get(arch, arch)]
|
||||||
|
else:
|
||||||
|
archs = get_synonyms(arch, ARCH_SYNONYMS)
|
||||||
|
|
||||||
expected_names = {
|
expected_names = {
|
||||||
format.format(
|
format.format(
|
||||||
version=normalized_version,
|
version=version_opt,
|
||||||
system=system,
|
system=system_opt,
|
||||||
arch=arch,
|
arch=arch_opt,
|
||||||
)
|
)
|
||||||
for normalized_version in (
|
for version_opt, system_opt, arch_opt in product(
|
||||||
version.lstrip("v"),
|
(
|
||||||
"v" + version if not version.startswith("v") else version,
|
version.lstrip("v"),
|
||||||
|
"v" + version if not version.startswith("v") else version,
|
||||||
|
),
|
||||||
|
systems,
|
||||||
|
archs,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user