mirror of
https://github.com/miurahr/aqtinstall.git
synced 2025-12-18 13:14:37 +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):
|
def _check_qt_arg_version_offline(self, version):
|
||||||
return version in Settings.available_offline_installer_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):
|
def _set_sevenzip(self, external):
|
||||||
sevenzip = external
|
sevenzip = external
|
||||||
if sevenzip is None:
|
if sevenzip is None:
|
||||||
@@ -389,23 +404,14 @@ class Cli:
|
|||||||
auto_desktop_archives: List[QtPackage] = get_auto_desktop_archives()
|
auto_desktop_archives: List[QtPackage] = get_auto_desktop_archives()
|
||||||
|
|
||||||
if not self._check_qt_arg_versions(qt_version):
|
if not self._check_qt_arg_versions(qt_version):
|
||||||
self.logger.warning(
|
self.logger.warning(self._warning_unknown_qt_version(qt_version))
|
||||||
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."
|
|
||||||
)
|
|
||||||
if not self._check_qt_arg_combination(qt_version, os_name, target, arch):
|
if not self._check_qt_arg_combination(qt_version, os_name, target, arch):
|
||||||
self.logger.warning(
|
self.logger.warning(self._warning_unknown_target_arch_combo([os_name, target, arch]))
|
||||||
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."
|
|
||||||
)
|
|
||||||
all_extra = True if modules is not None and "all" in modules else False
|
all_extra = True if modules is not None and "all" in modules else False
|
||||||
if not all_extra:
|
if not all_extra:
|
||||||
unexpected_modules = self._select_unexpected_modules(qt_version, modules)
|
unexpected_modules = self._select_unexpected_modules(qt_version, modules)
|
||||||
if unexpected_modules:
|
if unexpected_modules:
|
||||||
self.logger.warning(
|
self.logger.warning(self._warning_unexpected_modules(unexpected_modules))
|
||||||
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."
|
|
||||||
)
|
|
||||||
|
|
||||||
qt_archives: QtArchives = retry_on_bad_connection(
|
qt_archives: QtArchives = retry_on_bad_connection(
|
||||||
lambda base_url: QtArchives(
|
lambda base_url: QtArchives(
|
||||||
@@ -475,10 +481,7 @@ class Cli:
|
|||||||
archives = args.archives
|
archives = args.archives
|
||||||
all_extra = True if modules is not None and "all" in modules else False
|
all_extra = True if modules is not None and "all" in modules else False
|
||||||
if not self._check_qt_arg_versions(qt_version):
|
if not self._check_qt_arg_versions(qt_version):
|
||||||
self.logger.warning(
|
self.logger.warning(self._warning_unknown_qt_version(qt_version))
|
||||||
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."
|
|
||||||
)
|
|
||||||
|
|
||||||
srcdocexamples_archives: SrcDocExamplesArchives = retry_on_bad_connection(
|
srcdocexamples_archives: SrcDocExamplesArchives = retry_on_bad_connection(
|
||||||
lambda base_url: SrcDocExamplesArchives(
|
lambda base_url: SrcDocExamplesArchives(
|
||||||
@@ -575,10 +578,7 @@ class Cli:
|
|||||||
|
|
||||||
for arch in archs:
|
for arch in archs:
|
||||||
if not self._check_tools_arg_combination(os_name, tool_name, arch):
|
if not self._check_tools_arg_combination(os_name, tool_name, arch):
|
||||||
self.logger.warning(
|
self.logger.warning(self._warning_unknown_target_arch_combo([os_name, tool_name, arch]))
|
||||||
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."
|
|
||||||
)
|
|
||||||
|
|
||||||
tool_archives: ToolArchives = retry_on_bad_connection(
|
tool_archives: ToolArchives = retry_on_bad_connection(
|
||||||
lambda base_url: ToolArchives(
|
lambda base_url: ToolArchives(
|
||||||
|
|||||||
Reference in New Issue
Block a user