mirror of
https://github.com/miurahr/aqtinstall.git
synced 2025-12-18 13:14:37 +03:00
Implementation for aqt list-qt --long-modules
This commit is contained in:
@@ -34,6 +34,7 @@ from typing import Callable, Dict, Generator, List, Optional, Tuple
|
|||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
from xml.etree.ElementTree import Element
|
from xml.etree.ElementTree import Element
|
||||||
|
|
||||||
|
import humanize
|
||||||
import requests
|
import requests
|
||||||
import requests.adapters
|
import requests.adapters
|
||||||
from defusedxml import ElementTree
|
from defusedxml import ElementTree
|
||||||
@@ -290,6 +291,12 @@ def xml_to_modules(
|
|||||||
name = packageupdate.find("Name").text
|
name = packageupdate.find("Name").text
|
||||||
packages[name] = {}
|
packages[name] = {}
|
||||||
for child in packageupdate:
|
for child in packageupdate:
|
||||||
|
if child.tag == "UpdateFile":
|
||||||
|
for attr in "CompressedSize", "UncompressedSize":
|
||||||
|
if attr not in child.attrib:
|
||||||
|
continue
|
||||||
|
packages[name][attr] = humanize.naturalsize(child.attrib[attr], gnu=True)
|
||||||
|
else:
|
||||||
packages[name][child.tag] = child.text
|
packages[name][child.tag] = child.text
|
||||||
return packages
|
return packages
|
||||||
|
|
||||||
|
|||||||
@@ -493,9 +493,11 @@ class Cli:
|
|||||||
if args.target not in ArchiveId.TARGETS_FOR_HOST[args.host]:
|
if args.target not in ArchiveId.TARGETS_FOR_HOST[args.host]:
|
||||||
raise CliInputError("'{0.target}' is not a valid target for host '{0.host}'".format(args))
|
raise CliInputError("'{0.target}' is not a valid target for host '{0.host}'".format(args))
|
||||||
if args.modules:
|
if args.modules:
|
||||||
modules_ver, modules_query = args.modules[0], tuple(args.modules)
|
modules_ver, modules_query, is_long = args.modules[0], tuple(args.modules), False
|
||||||
|
elif args.long_modules:
|
||||||
|
modules_ver, modules_query, is_long = args.long_modules[0], tuple(args.long_modules), True
|
||||||
else:
|
else:
|
||||||
modules_ver, modules_query = None, None
|
modules_ver, modules_query, is_long = None, None, False
|
||||||
|
|
||||||
for version_str in (modules_ver, args.extensions, args.arch, args.archives[0] if args.archives else None):
|
for version_str in (modules_ver, args.extensions, args.arch, args.archives[0] if args.archives else None):
|
||||||
Cli._validate_version_str(version_str, allow_latest=True, allow_empty=True)
|
Cli._validate_version_str(version_str, allow_latest=True, allow_empty=True)
|
||||||
@@ -517,6 +519,7 @@ class Cli:
|
|||||||
spec=spec,
|
spec=spec,
|
||||||
is_latest_version=args.latest_version,
|
is_latest_version=args.latest_version,
|
||||||
modules_query=modules_query,
|
modules_query=modules_query,
|
||||||
|
is_long_listing=is_long,
|
||||||
extensions_ver=args.extensions,
|
extensions_ver=args.extensions,
|
||||||
architectures_ver=args.arch,
|
architectures_ver=args.arch,
|
||||||
archives_query=args.archives,
|
archives_query=args.archives,
|
||||||
@@ -736,6 +739,16 @@ class Cli:
|
|||||||
'Second arg: an architecture, which may be printed with the "--arch" flag. '
|
'Second arg: an architecture, which may be printed with the "--arch" flag. '
|
||||||
"When set, this prints all the modules available for either Qt 5.X.Y or the latest version of Qt.",
|
"When set, this prints all the modules available for either Qt 5.X.Y or the latest version of Qt.",
|
||||||
)
|
)
|
||||||
|
output_modifier_exclusive_group.add_argument(
|
||||||
|
"--long-modules",
|
||||||
|
type=str,
|
||||||
|
nargs=2,
|
||||||
|
metavar=("(VERSION | latest)", "ARCHITECTURE"),
|
||||||
|
help='First arg: Qt version in the format of "5.X.Y", or the keyword "latest". '
|
||||||
|
'Second arg: an architecture, which may be printed with the "--arch" flag. '
|
||||||
|
"When set, this prints a table that describes all the modules available "
|
||||||
|
"for either Qt 5.X.Y or the latest version of Qt.",
|
||||||
|
)
|
||||||
output_modifier_exclusive_group.add_argument(
|
output_modifier_exclusive_group.add_argument(
|
||||||
"--extensions",
|
"--extensions",
|
||||||
type=str,
|
type=str,
|
||||||
|
|||||||
@@ -448,6 +448,11 @@ class MetadataFactory:
|
|||||||
self.request_type = "latest version"
|
self.request_type = "latest version"
|
||||||
self._action = lambda: Versions(self.fetch_latest_version())
|
self._action = lambda: Versions(self.fetch_latest_version())
|
||||||
elif modules_query:
|
elif modules_query:
|
||||||
|
if is_long_listing:
|
||||||
|
self.request_type = "long modules"
|
||||||
|
version, arch = modules_query
|
||||||
|
self._action = lambda: self.fetch_long_modules(self._to_version(version), arch)
|
||||||
|
else:
|
||||||
self.request_type = "modules"
|
self.request_type = "modules"
|
||||||
version, arch = modules_query
|
version, arch = modules_query
|
||||||
self._action = lambda: self.fetch_modules(self._to_version(version), arch)
|
self._action = lambda: self.fetch_modules(self._to_version(version), arch)
|
||||||
@@ -731,6 +736,30 @@ class MetadataFactory:
|
|||||||
modules.add(module)
|
modules.add(module)
|
||||||
return sorted(modules)
|
return sorted(modules)
|
||||||
|
|
||||||
|
def fetch_long_modules(self, version: Version, arch: str) -> ModuleData:
|
||||||
|
"""Returns long listing of modules"""
|
||||||
|
self.validate_extension(version)
|
||||||
|
qt_ver_str = self._get_qt_version_str(version)
|
||||||
|
# Example: re.compile(r"^(preview\.)?qt\.(qt5\.)?590(\.addons)?\.(?P<module>[^.]+)\.gcc_64$")
|
||||||
|
pattern = re.compile(
|
||||||
|
r"^(preview\.)?qt\.(qt"
|
||||||
|
+ str(version.major)
|
||||||
|
+ r"\.)?"
|
||||||
|
+ qt_ver_str
|
||||||
|
+ r"(\.addons)?\.(?P<module>[^.]+)\."
|
||||||
|
+ arch
|
||||||
|
+ r"$"
|
||||||
|
)
|
||||||
|
|
||||||
|
def matches_arch(element: Element) -> bool:
|
||||||
|
name_node = element.find("Name")
|
||||||
|
return bool(name_node is not None) and bool(pattern.match(str(name_node.text)))
|
||||||
|
|
||||||
|
modules_meta = self._fetch_module_metadata(self.archive_id.to_folder(qt_ver_str), matches_arch)
|
||||||
|
m = {pattern.match(key).group("module"): value for key, value in modules_meta.items()}
|
||||||
|
|
||||||
|
return ModuleData(m)
|
||||||
|
|
||||||
def fetch_modules_sde(self, cmd_type: str, version: Version) -> List[str]:
|
def fetch_modules_sde(self, cmd_type: str, version: Version) -> List[str]:
|
||||||
"""Returns list of modules for src/doc/examples"""
|
"""Returns list of modules for src/doc/examples"""
|
||||||
assert (
|
assert (
|
||||||
|
|||||||
@@ -23,14 +23,15 @@ classifiers = [
|
|||||||
]
|
]
|
||||||
requires-python = ">=3.6"
|
requires-python = ">=3.6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"requests",
|
|
||||||
"semantic_version",
|
|
||||||
"patch>=1.16",
|
|
||||||
"py7zr>=0.18.3",
|
|
||||||
"texttable",
|
|
||||||
"bs4",
|
"bs4",
|
||||||
"dataclasses;python_version<'3.7'",
|
"dataclasses;python_version<'3.7'",
|
||||||
"defusedxml",
|
"defusedxml",
|
||||||
|
"humanize",
|
||||||
|
"patch>=1.16",
|
||||||
|
"py7zr>=0.18.3",
|
||||||
|
"requests",
|
||||||
|
"semantic_version",
|
||||||
|
"texttable",
|
||||||
]
|
]
|
||||||
dynamic = ["version", "entry-points"]
|
dynamic = ["version", "entry-points"]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user