mirror of
https://github.com/miurahr/aqtinstall.git
synced 2025-12-18 21:24:38 +03:00
Refactor warning messages into reusable functions
This will reduce code duplication and make the warning messages easier to improve in the future, since they will only need to be changed in one location.
This commit is contained in:
@@ -213,6 +213,21 @@ class Cli:
|
||||
def _check_qt_arg_version_offline(self, version):
|
||||
return version in Settings.available_offline_installer_version
|
||||
|
||||
def _warning_unknown_qt_version(self, qt_version: str) -> str:
|
||||
return self._warning_on_bad_combination(f'Qt version "{qt_version}"')
|
||||
|
||||
def _warning_unknown_target_arch_combo(self, args: List[str]) -> str:
|
||||
return self._warning_on_bad_combination(f"target combination \"{' '.join(args)}\"")
|
||||
|
||||
def _warning_unexpected_modules(self, unexpected_modules: List[str]) -> str:
|
||||
return self._warning_on_bad_combination(f"modules {unexpected_modules}")
|
||||
|
||||
def _warning_on_bad_combination(self, combo_message: str) -> str:
|
||||
return (
|
||||
f"Specified {combo_message} did not exist when this version of aqtinstall was released. "
|
||||
"This may not install properly, but we will try our best."
|
||||
)
|
||||
|
||||
def _set_sevenzip(self, external):
|
||||
sevenzip = external
|
||||
if sevenzip is None:
|
||||
@@ -389,23 +404,14 @@ class Cli:
|
||||
auto_desktop_archives: List[QtPackage] = get_auto_desktop_archives()
|
||||
|
||||
if not self._check_qt_arg_versions(qt_version):
|
||||
self.logger.warning(
|
||||
f'Specified Qt version "{qt_version}" did not exist when this version of aqtinstall was released. '
|
||||
"This may not install properly, but we will try our best."
|
||||
)
|
||||
self.logger.warning(self._warning_unknown_qt_version(qt_version))
|
||||
if not self._check_qt_arg_combination(qt_version, os_name, target, arch):
|
||||
self.logger.warning(
|
||||
f'Specified target combination "{os_name} {target} {arch}" did not exist when this version of '
|
||||
"aqtinstall was released. This may not install properly, but we will try our best."
|
||||
)
|
||||
self.logger.warning(self._warning_unknown_target_arch_combo([os_name, target, arch]))
|
||||
all_extra = True if modules is not None and "all" in modules else False
|
||||
if not all_extra:
|
||||
unexpected_modules = self._select_unexpected_modules(qt_version, modules)
|
||||
if unexpected_modules:
|
||||
self.logger.warning(
|
||||
f"Specified modules {unexpected_modules} did not exist when this version of aqtinstall was released. "
|
||||
"This may not install properly, but we will try our best."
|
||||
)
|
||||
self.logger.warning(self._warning_unexpected_modules(unexpected_modules))
|
||||
|
||||
qt_archives: QtArchives = retry_on_bad_connection(
|
||||
lambda base_url: QtArchives(
|
||||
@@ -475,10 +481,7 @@ class Cli:
|
||||
archives = args.archives
|
||||
all_extra = True if modules is not None and "all" in modules else False
|
||||
if not self._check_qt_arg_versions(qt_version):
|
||||
self.logger.warning(
|
||||
f'Specified Qt version "{qt_version}" did not exist when this version of aqtinstall was released. '
|
||||
"This may not install properly, but we will try our best."
|
||||
)
|
||||
self.logger.warning(self._warning_unknown_qt_version(qt_version))
|
||||
|
||||
srcdocexamples_archives: SrcDocExamplesArchives = retry_on_bad_connection(
|
||||
lambda base_url: SrcDocExamplesArchives(
|
||||
@@ -575,10 +578,7 @@ class Cli:
|
||||
|
||||
for arch in archs:
|
||||
if not self._check_tools_arg_combination(os_name, tool_name, arch):
|
||||
self.logger.warning(
|
||||
f'Specified target combination "{os_name} {tool_name} {arch}" did not exist when this version of '
|
||||
"aqtinstall was released. This may not install properly, but we will try our best."
|
||||
)
|
||||
self.logger.warning(self._warning_unknown_target_arch_combo([os_name, tool_name, arch]))
|
||||
|
||||
tool_archives: ToolArchives = retry_on_bad_connection(
|
||||
lambda base_url: ToolArchives(
|
||||
|
||||
Reference in New Issue
Block a user