diff options
author | Cristian Maureira-Fredes <Cristian.Maureira-Fredes@qt.io> | 2021-04-23 13:31:31 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-04-26 11:37:48 +0000 |
commit | d9437d7c4935febe28f26557f0785d559dd537a2 (patch) | |
tree | 8499938880859473e810dd16a3a03ef54538e4d3 /tools/snippets_translate/parse_utils.py | |
parent | 1513d87904ad53d80d0b95866ce5692d2c96a8bd (diff) |
doc: fatal error when snippet conversion fails
When the snippets_translate tool fails, the build process
continues normally, falling back to use the original C++
snippets.
This problem can be dangerous, since we will not notice if
something is wrong without checking the full log.
This patch make the build process to fail when the tool
doesn't exit normally.
For builds where the documentation generation is skipped,
this change will have no effect.
Complementary to this, the patch includes a new Python file
to determine if the C++ include have an import
counterpart in Python.
Fixes: PYSIDE-1527
Change-Id: I725b623f60dbc540a6e7834502300c39cd22b5a3
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
(cherry picked from commit 3dc9ee1b1bea5b39b2997b214c99f5cc9b827ab7)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tools/snippets_translate/parse_utils.py')
-rw-r--r-- | tools/snippets_translate/parse_utils.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/tools/snippets_translate/parse_utils.py b/tools/snippets_translate/parse_utils.py index c4ba91409..d82108355 100644 --- a/tools/snippets_translate/parse_utils.py +++ b/tools/snippets_translate/parse_utils.py @@ -38,10 +38,7 @@ ############################################################################# import re - -# Bring all the PySide modules to find classes for the imports -import PySide6 -from PySide6 import * +from module_classes import module_classes def get_qt_module_class(x): @@ -56,11 +53,13 @@ def get_qt_module_class(x): In case it doesn't find the class or the module, it will return None. """ - for imodule in (m for m in dir(PySide6) if m.startswith("Qt")): + if "/" in x: + x = x.split("/")[-1] + + for imodule, iclasses in module_classes.items(): if imodule == x: return True, x - # we use eval() to transform 'QtModule' into QtModule - for iclass in (c for c in dir(eval(f"PySide6.{imodule}")) if c.startswith("Q")): + for iclass in iclasses: if iclass == x: return False, imodule return None |