[apps/code] properly display the importation source

- It sould be nameOfScript.py, not just nameOfScript, when the source is
a script
- Fix the source for script name variables. For instance, "from
script1 import *" should display the node "script1" with the source "script1.py"
- If a script has the same name as a module, the module will be imported
and not the script, so do not load its variables (even if the module is
not in the toolbox).
This commit is contained in:
Léa Saviot
2020-04-28 17:04:42 +02:00
committed by Émilie Feral
parent f49bf76b19
commit 4fb0a7e467
4 changed files with 111 additions and 59 deletions

View File

@@ -438,11 +438,13 @@ PythonToolbox::PythonToolbox() :
}
const ToolboxMessageTree * PythonToolbox::moduleChildren(const char * name, int * numberOfNodes) const {
assert(numberOfNodes != nullptr);
for (ToolboxMessageTree t : modulesChildren) {
if (strcmp(I18n::translate(t.label()), name) == 0) {
*numberOfNodes = t.numberOfChildren();
assert(*numberOfNodes > 0);
const int childrenCount = t.numberOfChildren();
if (numberOfNodes != nullptr) {
*numberOfNodes = childrenCount;
}
assert(childrenCount > 0);
return static_cast<const ToolboxMessageTree *>(t.children(0));
}
}